KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ws > jaxme > xs > impl > XSAtomicTypeRestrictionImpl


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.impl;
18
19 import org.apache.ws.jaxme.xs.XSAtomicType;
20 import org.apache.ws.jaxme.xs.XSType;
21 import org.apache.ws.jaxme.xs.xml.XsEFractionDigits;
22 import org.apache.ws.jaxme.xs.xml.XsELength;
23 import org.apache.ws.jaxme.xs.xml.XsEMaxExclusive;
24 import org.apache.ws.jaxme.xs.xml.XsEMaxInclusive;
25 import org.apache.ws.jaxme.xs.xml.XsEMaxLength;
26 import org.apache.ws.jaxme.xs.xml.XsEMinExclusive;
27 import org.apache.ws.jaxme.xs.xml.XsEMinInclusive;
28 import org.apache.ws.jaxme.xs.xml.XsEMinLength;
29 import org.apache.ws.jaxme.xs.xml.XsETotalDigits;
30 import org.apache.ws.jaxme.xs.xml.XsEWhiteSpace;
31 import org.apache.ws.jaxme.xs.xml.XsGSimpleRestrictionModel;
32 import org.xml.sax.SAXException JavaDoc;
33
34 /**
35  * @author <a HREF="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
36  */

37 public class XSAtomicTypeRestrictionImpl extends XSSimpleTypeRestrictionImpl implements XSAtomicType {
38   private final XSAtomicType atomicBaseType;
39
40   /** Creates a new atomic type restricting <code>pBaseType</code>
41    * with the constraints <code>pRestriction</code>.
42    */

43   public XSAtomicTypeRestrictionImpl(XSType pParent,
44                                      XSType pBaseType, XsGSimpleRestrictionModel pRestriction)
45       throws SAXException JavaDoc {
46     super(pParent, pBaseType, pRestriction);
47     atomicBaseType = pBaseType.getSimpleType().getAtomicType();
48   }
49
50   public boolean isAtomic() { return true; }
51
52   public XSAtomicType getAtomicType() {
53     return this;
54   }
55
56   public Long JavaDoc getFractionDigits() {
57     XsEFractionDigits fractionDigits = getRestriction().getFractionDigits();
58     if (fractionDigits == null) {
59       return atomicBaseType.getFractionDigits();
60     } else {
61       return new Long JavaDoc(fractionDigits.getValue());
62     }
63   }
64
65   public Long JavaDoc getLength() {
66     XsELength length = getRestriction().getLength();
67     if (length == null) {
68       return atomicBaseType.getLength();
69     } else {
70       return new Long JavaDoc(length.getValue());
71     }
72   }
73
74   public String JavaDoc getMaxExclusive() {
75     XsEMaxExclusive maxExclusive = getRestriction().getMaxExclusive();
76     if (maxExclusive == null) {
77       return atomicBaseType.getMaxExclusive();
78     } else {
79       return maxExclusive.getValue();
80     }
81   }
82
83   public String JavaDoc getMaxInclusive() {
84     XsEMaxInclusive maxInclusive = getRestriction().getMaxInclusive();
85     if (maxInclusive == null) {
86       return atomicBaseType.getMaxInclusive();
87     } else {
88       return maxInclusive.getValue();
89     }
90   }
91
92   public Long JavaDoc getMaxLength() {
93     XsEMaxLength length = getRestriction().getMaxLength();
94     if (length == null) {
95       return atomicBaseType.getMaxLength();
96     } else {
97       return new Long JavaDoc(length.getValue());
98     }
99   }
100
101   public String JavaDoc getMinExclusive() {
102     XsEMinExclusive minExclusive = getRestriction().getMinExclusive();
103     if (minExclusive == null) {
104       return atomicBaseType.getMinExclusive();
105     } else {
106       return minExclusive.getValue();
107     }
108   }
109
110   public String JavaDoc getMinInclusive() {
111     XsEMinInclusive minInclusive = getRestriction().getMinInclusive();
112     if (minInclusive == null) {
113       return atomicBaseType.getMinInclusive();
114     } else {
115       return minInclusive.getValue();
116     }
117   }
118
119   public Long JavaDoc getMinLength() {
120     XsEMinLength length = getRestriction().getMinLength();
121     if (length == null) {
122       return atomicBaseType.getMinLength();
123     } else {
124       return new Long JavaDoc(length.getValue());
125     }
126   }
127
128   public Long JavaDoc getTotalDigits() {
129     XsETotalDigits totalDigits = getRestriction().getTotalDigits();
130     if (totalDigits == null) {
131       return atomicBaseType.getTotalDigits();
132     } else {
133       return new Long JavaDoc(totalDigits.getValue());
134     }
135   }
136
137   public boolean isReplacing() {
138     XsEWhiteSpace whiteSpace = getRestriction().getWhiteSpace();
139     if (whiteSpace == null) {
140       return atomicBaseType.isReplacing();
141     } else {
142       return whiteSpace.isReplacing() || whiteSpace.isCollapsing();
143     }
144   }
145
146   public boolean isCollapsing() {
147     XsEWhiteSpace whiteSpace = getRestriction().getWhiteSpace();
148     if (whiteSpace == null) {
149       return atomicBaseType.isReplacing();
150     } else {
151       return whiteSpace.isCollapsing();
152     }
153   }
154 }
155
Popular Tags