KickJava   Java API By Example, From Geeks To Geeks.

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


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.parser.impl.LocSAXException;
20 import org.apache.ws.jaxme.xs.xml.*;
21 import org.xml.sax.SAXException JavaDoc;
22
23 /** <p>Implementation of <code>xs:numFacet</code>, following
24  * this specification:
25  * <pre>
26  * &lt;xs:complexType name="numFacet"&gt;
27  * &lt;xs:complexContent&gt;
28  * &lt;xs:restriction base="xs:facet"&gt;
29  * &lt;xs:sequence&gt;
30  * &lt;xs:element ref="xs:annotation" minOccurs="0"/&gt;
31  * &lt;/xs:sequence&gt;
32  * &lt;xs:attribute name="value" type="xs:nonNegativeInteger" use="required"/&gt;
33  * &lt;/xs:restriction&gt;
34  * &lt;/xs:complexContent&gt;
35  * &lt;/xs:complexType&gt;
36  * </pre></p>
37  *
38  * @author <a HREF="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
39  */

40 public abstract class XsTNumFacetImpl extends XsTFixedFacetImpl
41     implements XsTNumFacet {
42   private long value = -1;
43
44   protected XsTNumFacetImpl(XsObject pParent) {
45     super(pParent);
46   }
47
48   public void setValue(long pValue) throws SAXException {
49     if (pValue < 0) {
50       throw new LocSAXException("The 'value' attribute must not be negative.", getLocator());
51     }
52     value = pValue;
53   }
54
55   public long getValue() {
56     return value;
57   }
58
59   public void validate() throws SAXException {
60     super.validate();
61     if (value == -1) {
62       throw new LocSAXException("Missing 'value' attribute.", getLocator());
63     }
64   }
65 }
66
Popular Tags