KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > search > QueryParameterRefImpl


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.search;
18
19 import org.alfresco.service.cmr.dictionary.DictionaryService;
20 import org.alfresco.service.cmr.search.NamedQueryParameterDefinition;
21 import org.alfresco.service.cmr.search.QueryParameterDefinition;
22 import org.alfresco.service.namespace.NamespaceService;
23 import org.alfresco.service.namespace.QName;
24 import org.dom4j.Element;
25 import org.dom4j.Namespace;
26
27 public class QueryParameterRefImpl implements NamedQueryParameterDefinition
28 {
29
30     private static final org.dom4j.QName ELEMENT_QNAME = new org.dom4j.QName("parameter-ref", new Namespace(NamespaceService.ALFRESCO_PREFIX, NamespaceService.ALFRESCO_URI));
31
32     private static final org.dom4j.QName DEF_QNAME = new org.dom4j.QName("qname", new Namespace(NamespaceService.ALFRESCO_PREFIX, NamespaceService.ALFRESCO_URI));
33     
34     private QName qName;
35     
36     private QueryCollection container;
37     
38     public QueryParameterRefImpl(QName qName, QueryCollection container)
39     {
40         super();
41         this.qName = qName;
42         this.container = container;
43     }
44  
45     public QName getQName()
46     {
47         return qName;
48     }
49     
50     public static NamedQueryParameterDefinition createParameterReference(Element element, DictionaryService dictionaryService, QueryCollection container)
51     {
52        
53         if (element.getQName().getName().equals(ELEMENT_QNAME.getName()))
54         {
55             QName qName = null;
56             Element qNameElement = element.element(DEF_QNAME.getName());
57             if(qNameElement != null)
58             {
59                qName = QName.createQName(qNameElement.getText(), container.getNamespacePrefixResolver());
60             }
61             
62             return new QueryParameterRefImpl(qName, container);
63         }
64         else
65         {
66             return null;
67         }
68     }
69
70     public static org.dom4j.QName getElementQName()
71     {
72         return ELEMENT_QNAME;
73     }
74
75     public QueryParameterDefinition getQueryParameterDefinition()
76     {
77         return container.getParameterDefinition(getQName());
78     }
79
80 }
81
Popular Tags