KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ws > jaxme > generator > sg > SimpleTypeSG


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;
18
19 import org.apache.ws.jaxme.js.DirectAccessible;
20 import org.apache.ws.jaxme.js.JavaMethod;
21 import org.apache.ws.jaxme.js.JavaQName;
22 import org.apache.ws.jaxme.js.JavaSource;
23 import org.apache.ws.jaxme.js.TypedValue;
24 import org.apache.ws.jaxme.generator.sg.AtomicTypeSG;
25 import org.apache.ws.jaxme.generator.sg.ListTypeSG;
26 import org.apache.ws.jaxme.generator.sg.UnionTypeSG;
27 import org.apache.ws.jaxme.generator.sg.Facet;
28 import org.apache.ws.jaxme.generator.sg.Facet.Type;
29 import org.apache.ws.jaxme.generator.sg.SGItem;
30 import org.apache.ws.jaxme.generator.sg.SGlet;
31 import org.xml.sax.SAXException JavaDoc;
32
33
34 /** <p>Interface of a source generator for complex types.</p>
35  *
36  * @author <a HREF="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
37  */

38 public interface SimpleTypeSG extends SGItem {
39   /** <p>Returns whether the simple type is atomic.</p>
40    */

41   public boolean isAtomic();
42
43   /** <p>Returns whether the simple type is a list.</p>
44    */

45   public boolean isList();
46
47   /** <p>Returns whether the simple type is a union.</p>
48    */

49   public boolean isUnion();
50
51   /** <p>Returns whether the simple type is nullable.</p>
52    */

53   public boolean isNullable();
54
55   /** <p>Sets whether the simple type is nullable.</p>
56    */

57   public void setNullable(boolean pNullable);
58
59   /** <p>If the simple type is atomic: Returns its atomic type details.</p>
60    */

61   public AtomicTypeSG getAtomicType();
62
63   /** <p>If the simple type is a list: Returns its item type details.</p>
64    * @throws IllegalStateException The type is no list.
65    */

66   public ListTypeSG getListType();
67
68   /** <p>If the simple type is a union: Returns its union type details.</p>
69    * @throws IllegalStateException The type is no union.
70    */

71   public UnionTypeSG getUnionType();
72
73   /** <p>Returns the data types runtime type.</p>
74    */

75   public JavaQName getRuntimeType();
76
77   /** Returns whether converting this type from a string can cause a
78    * {@link javax.xml.bind.ParseConversionEvent}.
79    */

80   public boolean isCausingParseConversionEvent();
81
82   /** <p>Returns a piece of Java code converting the string <code>pValue</code>
83    * into the runtime type. Conversion occurs at runtime, using the
84    * given instance of {@link org.apache.ws.jaxme.JMUnmarshallerHandler}.</p>
85    * @param pMethod The method performing the type convertion.
86    * @param pValue The value being casted
87    * @param pData A piece of Java code holding an instance of
88    * {@link org.apache.ws.jaxme.JMUnmarshallerHandler};
89    * may be used to support the conversion.
90    */

91   public TypedValue getCastFromString(JavaMethod pMethod, Object JavaDoc pValue, Object JavaDoc pData) throws SAXException JavaDoc;
92
93   /** <p>Returns a piece of Java code converting the runtime type
94    * <code>pValue</code> into a string. Conversion occurs at runtime, using the
95    * given instance of {@link org.apache.ws.jaxme.impl.JMUnmarshallerHandlerImpl}.</p>
96    */

97   public TypedValue getCastToString(JavaMethod pMethod, Object JavaDoc pValue, DirectAccessible pData) throws SAXException JavaDoc;
98
99   /** <p>Returns a piece of Java code converting the string <code>pValue</code>
100    * into the runtime type. Conversion occurs at compile time.</p>
101    */

102   public TypedValue getCastFromString(String JavaDoc pValue) throws SAXException JavaDoc;
103
104   /** <p>Returns whether the simple type does have a "set" method.</p>
105    */

106   public boolean hasSetMethod() throws SAXException JavaDoc;
107
108   /** <p>Returns the collection type, which is either of "indexed" (an array)
109    * or a list implementation, as specified by JAXB's property tag.</p>
110    */

111   public String JavaDoc getCollectionType();
112
113   /** <p>Returns all of the simple types facets.</p>
114    */

115   public Facet[] getFacets();
116
117   /** <p>Returns the simple types facets with the given type or null, if no
118    * such facet exists.</p>
119    */

120   public Facet getFacet(Type pType);
121
122   /** <p>Invokes the given {@link SGlet} on any value, assuming they
123    * are non null.</p>
124    */

125   public void forAllValues(JavaMethod pMethod, Object JavaDoc pValue, SGlet pSGlet) throws SAXException JavaDoc;
126
127   /** <p>Invokes the given {@link SGlet} on any non null value.</p>
128    */

129   public void forAllNonNullValues(JavaMethod pMethod, Object JavaDoc pValue, SGlet pSGlet) throws SAXException JavaDoc;
130
131   /** <p>Generates helper classes required by the simple type.</p>
132    */

133   public void generate() throws SAXException JavaDoc;
134
135   /** <p>Generates helper classes required by the simple type.
136    * The generated classes are inner classes of the given.</p>
137    */

138   public void generate(JavaSource pSource) throws SAXException JavaDoc;
139
140   /** <p>Returns code creating a boolean value indicating whether the given values
141    * are equal.</p>
142    */

143   public Object JavaDoc getEqualsCheck(JavaMethod pMethod, Object JavaDoc pValue1, Object JavaDoc pValue2) throws SAXException JavaDoc;
144
145   /** <p>Returns the types initial value, as created by the constructor.</p>
146    */

147   public Object JavaDoc getInitialValue(JavaSource pSource) throws SAXException JavaDoc;
148
149   /** <p>Generates a set method for the simple type.</p>
150    */

151   public JavaMethod getXMLSetMethod(JavaSource pSource, String JavaDoc pFieldName,
152                                     String JavaDoc pParamName, String JavaDoc pMethodName) throws SAXException JavaDoc;
153
154   /** <p>Adds code for validating the value <code>pValue</code> to the "add" or
155    * "set" method <code>pMethod</code>.</p>
156    */

157   public void addValidation(JavaMethod pMethod, DirectAccessible pValue) throws SAXException JavaDoc;
158 }
159
Popular Tags