KickJava   Java API By Example, From Geeks To Geeks.

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


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.XSListType;
21 import org.apache.ws.jaxme.xs.XSType;
22 import org.apache.ws.jaxme.xs.xml.XsELength;
23 import org.apache.ws.jaxme.xs.xml.XsEMaxLength;
24 import org.apache.ws.jaxme.xs.xml.XsEMinLength;
25 import org.apache.ws.jaxme.xs.xml.XsGSimpleRestrictionModel;
26 import org.xml.sax.SAXException JavaDoc;
27
28 /**
29  * @author <a HREF="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
30  */

31 public class XSListTypeRestrictionImpl extends XSSimpleTypeRestrictionImpl implements XSListType {
32   private final XSListType listBaseType;
33
34   public XSListTypeRestrictionImpl(XSType pParent,
35                                     XSType pRestrictedType, XsGSimpleRestrictionModel pRestriction)
36       throws SAXException JavaDoc {
37     super(pParent, pRestrictedType, pRestriction);
38     listBaseType = pRestrictedType.getSimpleType().getListType();
39   }
40
41   public boolean isList() { return true; }
42
43   public XSListType getListType() {
44     return this;
45   }
46
47   public XSType getItemType() {
48     return listBaseType.getItemType();
49   }
50
51   public Long JavaDoc getLength() {
52     XsELength length = getRestriction().getLength();
53     if (length == null) {
54       return listBaseType.getLength();
55     } else {
56       return new Long JavaDoc(length.getValue());
57     }
58   }
59
60   public Long JavaDoc getMinLength() {
61     XsEMinLength length = getRestriction().getMinLength();
62     if (length == null) {
63       return listBaseType.getMinLength();
64     } else {
65       return new Long JavaDoc(length.getValue());
66     }
67   }
68
69   public Long JavaDoc getMaxLength() {
70     XsEMaxLength length = getRestriction().getMaxLength();
71     if (length == null) {
72       return listBaseType.getMaxLength();
73     } else {
74       return new Long JavaDoc(length.getValue());
75     }
76   }
77 }
78
Popular Tags