KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > dictionary > DelegateModelQuery


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.repo.dictionary;
18
19 import org.alfresco.service.cmr.dictionary.AspectDefinition;
20 import org.alfresco.service.cmr.dictionary.AssociationDefinition;
21 import org.alfresco.service.cmr.dictionary.ClassDefinition;
22 import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
23 import org.alfresco.service.cmr.dictionary.PropertyDefinition;
24 import org.alfresco.service.cmr.dictionary.TypeDefinition;
25 import org.alfresco.service.namespace.QName;
26
27 /**
28  * Model query that delegates its search if itself cannot find the model
29  * item required.
30  *
31  * @author David Caruana
32  *
33  */

34 /*package*/ class DelegateModelQuery implements ModelQuery
35 {
36
37     private ModelQuery query;
38     private ModelQuery delegate;
39     
40     
41     /**
42      * Construct
43      *
44      * @param query
45      * @param delegate
46      */

47     /*package*/ DelegateModelQuery(ModelQuery query, ModelQuery delegate)
48     {
49         this.query = query;
50         this.delegate = delegate;
51     }
52
53     
54     /* (non-Javadoc)
55      * @see org.alfresco.repo.dictionary.impl.ModelQuery#getPropertyType(org.alfresco.repo.ref.QName)
56      */

57     public DataTypeDefinition getDataType(QName name)
58     {
59         DataTypeDefinition def = query.getDataType(name);
60         if (def == null)
61         {
62             def = delegate.getDataType(name);
63         }
64         return def;
65     }
66
67     
68     /* (non-Javadoc)
69      * @see org.alfresco.repo.dictionary.ModelQuery#getDataType(java.lang.Class)
70      */

71     public DataTypeDefinition getDataType(Class JavaDoc javaClass)
72     {
73         DataTypeDefinition def = query.getDataType(javaClass);
74         if (def == null)
75         {
76             def = delegate.getDataType(javaClass);
77         }
78         return def;
79     }
80
81
82     /* (non-Javadoc)
83      * @see org.alfresco.repo.dictionary.impl.ModelQuery#getType(org.alfresco.repo.ref.QName)
84      */

85     public TypeDefinition getType(QName name)
86     {
87         TypeDefinition def = query.getType(name);
88         if (def == null)
89         {
90             def = delegate.getType(name);
91         }
92         return def;
93     }
94
95     
96     /* (non-Javadoc)
97      * @see org.alfresco.repo.dictionary.impl.ModelQuery#getAspect(org.alfresco.repo.ref.QName)
98      */

99     public AspectDefinition getAspect(QName name)
100     {
101         AspectDefinition def = query.getAspect(name);
102         if (def == null)
103         {
104             def = delegate.getAspect(name);
105         }
106         return def;
107     }
108
109     
110     /* (non-Javadoc)
111      * @see org.alfresco.repo.dictionary.impl.ModelQuery#getClass(org.alfresco.repo.ref.QName)
112      */

113     public ClassDefinition getClass(QName name)
114     {
115         ClassDefinition def = query.getClass(name);
116         if (def == null)
117         {
118             def = delegate.getClass(name);
119         }
120         return def;
121     }
122
123     
124     /* (non-Javadoc)
125      * @see org.alfresco.repo.dictionary.impl.ModelQuery#getProperty(org.alfresco.repo.ref.QName)
126      */

127     public PropertyDefinition getProperty(QName name)
128     {
129         PropertyDefinition def = query.getProperty(name);
130         if (def == null)
131         {
132             def = delegate.getProperty(name);
133         }
134         return def;
135     }
136
137
138     /* (non-Javadoc)
139      * @see org.alfresco.repo.dictionary.impl.ModelQuery#getAssociation(org.alfresco.repo.ref.QName)
140      */

141     public AssociationDefinition getAssociation(QName name)
142     {
143         AssociationDefinition def = query.getAssociation(name);
144         if (def == null)
145         {
146             def = delegate.getAssociation(name);
147         }
148         return def;
149     }
150     
151 }
152
Popular Tags