KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ws > jaxme > generator > sg > impl > FacetImpl


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.generator.sg.impl;
18
19 import org.apache.ws.jaxme.generator.sg.Facet;
20 import org.apache.ws.jaxme.xs.XSEnumeration;
21 import org.apache.ws.jaxme.xs.XSType;
22
23 /**
24  * @author <a HREF="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
25  */

26 public class FacetImpl implements Facet {
27   private final Facet.Type type;
28   private final String JavaDoc[] values;
29   private final String JavaDoc value;
30   private final Long JavaDoc numValue;
31
32   /** <p>Creates a new enumeration facet.</p>
33    */

34   public FacetImpl(XSType pType, XSEnumeration[] pEnumerations) {
35     type = Facet.ENUMERATION;
36     values = new String JavaDoc[pEnumerations.length];
37     for (int i = 0; i < pEnumerations.length; i++) {
38       values[i] = pEnumerations[i].getValue();
39     }
40     value = null;
41     numValue = null;
42   }
43
44   public Type getType() { return type; }
45   public String JavaDoc[] getValues() {
46     if (values == null) {
47       throw new IllegalStateException JavaDoc("The facet type " + type + " doesn't support the getValues() method.");
48     }
49     return values;
50   }
51
52   public String JavaDoc getValue() {
53     if (value == null) {
54       throw new IllegalStateException JavaDoc("The facet type " + type + " doesn't support the getValue() method.");
55     }
56     return value;
57   }
58
59   public long getNumValue() {
60     if (numValue == null) {
61       throw new IllegalStateException JavaDoc("The facet type " + type + " doesn't support the getNumValue() method.");
62     }
63     return numValue.longValue();
64   }
65 }
66
Popular Tags