KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ws > jaxme > xs > xml > impl > XsTWildcardImpl


1 /*
2  * Copyright 2003, 2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15
16  */

17 package org.apache.ws.jaxme.xs.xml.impl;
18
19 import org.apache.ws.jaxme.xs.xml.*;
20 import org.apache.ws.jaxme.xs.xml.XsNamespaceList.Basic;
21 import org.apache.ws.jaxme.xs.xml.XsNamespaceList.Other;
22
23
24 /** <p>Implementation of the <code>xs:wildcard</code> type, with the
25  * following specification:
26  * <pre>
27  * &lt;xs:complexType name="wildcard"&gt;
28  * &lt;xs:complexContent&gt;
29  * &lt;xs:extension base="xs:annotated"&gt;
30  * &lt;xs:attribute name="namespace" type="xs:namespaceList" use="optional" default="##any"/&gt;
31  * &lt;xs:attribute name="processContents" use="optional" default="strict"
32  * &lt;xs:simpleType&gt;
33  * &lt;xs:restriction base="xs:NMTOKEN"&gt;
34  * &lt;xs:enumeration value="skip"/&gt;
35  * &lt;xs:enumeration value="lax"/&gt;
36  * &lt;xs:enumeration value="strict"/&gt;
37  * &lt;/xs:restriction&gt;
38  * &lt;/xs:simpleType&gt;
39  * &lt;/xs:attribute&gt;
40  * &lt;/xs:extension&gt;
41  * &lt;/xs:complexContent&gt;
42  * &lt;/xs:complexType&gt;
43  * </pre></p>
44  *
45  * @author <a HREF="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
46  */

47 public class XsTWildcardImpl extends XsTAnnotatedImpl implements XsTWildcard {
48     private XsNamespaceList namespaceList = XsNamespaceList.ANY;
49     private ProcessContents processContents = STRICT;
50     
51     protected XsTWildcardImpl(XsObject pParent) {
52         super(pParent);
53     }
54     
55     public void setNamespace(final String JavaDoc pNamespaceList) {
56         if (getXsESchema().getTargetNamespace() == null) {
57             // The target can be changed, when importing this schema,
58
// thus we have to return a mutable object.
59
XsAnyURI pTargetNamespace = getXsESchema().getTargetNamespace();
60             if ("##any".equals(pNamespaceList)) {
61                 namespaceList = XsNamespaceList.ANY;
62             } else if ("##other".equals(pNamespaceList)) {
63                 namespaceList = new Other(pTargetNamespace){
64                     public XsAnyURI[] getUris() {
65                         XsAnyURI targetNamespace = getXsESchema().getTargetNamespace();
66                         if (targetNamespace == null) {
67                             return super.getUris();
68                         } else {
69                             return new XsAnyURI[]{targetNamespace};
70                         }
71                     }
72                 };
73             } else {
74                 namespaceList = new Basic(pNamespaceList, pTargetNamespace){
75                     public XsAnyURI[] getUris() {
76                         XsAnyURI targetNamespace = getXsESchema().getTargetNamespace();
77                         if (targetNamespace == null) {
78                             return super.getUris();
79                         } else {
80                             return XsNamespaceList.valueOf(pNamespaceList, targetNamespace).getUris();
81                         }
82                     }
83                 };
84             };
85         } else {
86             // The target cannot be changed, so we return an immutable object.
87
namespaceList = XsNamespaceList.valueOf(pNamespaceList, getXsESchema().getTargetNamespace());
88         }
89     }
90     
91     public XsNamespaceList getNamespace() {
92         return namespaceList;
93     }
94     
95     public void setProcessContents(ProcessContents pProcessContents) {
96         processContents = pProcessContents;
97     }
98     
99     public ProcessContents getProcessContents() {
100         return processContents;
101     }
102 }
103
Popular Tags