KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xerces > impl > xs > ElementPSVImpl


1 /*
2  * Copyright 2000-2002,2004,2005 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.xerces.impl.xs;
18
19 import org.apache.xerces.xs.ShortList;
20 import org.apache.xerces.xs.StringList;
21 import org.apache.xerces.xs.XSElementDeclaration;
22 import org.apache.xerces.xs.XSModel;
23 import org.apache.xerces.xs.XSNotationDeclaration;
24 import org.apache.xerces.xs.XSSimpleTypeDefinition;
25 import org.apache.xerces.xs.XSTypeDefinition;
26 import org.apache.xerces.impl.xs.util.StringListImpl;
27 import org.apache.xerces.xs.ElementPSVI;
28 import org.apache.xerces.xs.XSConstants;
29
30 /**
31  * Element PSV infoset augmentations implementation.
32  * The following information will be available at the startElement call:
33  * name, namespace, type, notation, validation context
34  *
35  * The following information will be available at the endElement call:
36  * nil, specified, normalized value, member type, validity, error codes,
37  * default
38  *
39  * @xerces.internal
40  *
41  * @author Elena Litani IBM
42  * @version $Id: ElementPSVImpl.java,v 1.27 2005/05/25 04:33:07 mrglavas Exp $
43  */

44 public class ElementPSVImpl implements ElementPSVI {
45
46     /** element declaration */
47     protected XSElementDeclaration fDeclaration = null;
48
49     /** type of element, could be xsi:type */
50     protected XSTypeDefinition fTypeDecl = null;
51
52     /** true if clause 3.2 of Element Locally Valid (Element) (3.3.4)
53       * is satisfied, otherwise false
54       */

55     protected boolean fNil = false;
56
57     /** true if the element value was provided by the schema; false otherwise.
58      */

59     protected boolean fSpecified = false;
60
61     /** schema normalized value property */
62     protected String JavaDoc fNormalizedValue = null;
63
64     /** schema actual value */
65     protected Object JavaDoc fActualValue = null;
66
67     /** schema actual value type */
68     protected short fActualValueType = XSConstants.UNAVAILABLE_DT;
69
70     /** actual value types if the value is a list */
71     protected ShortList fItemValueTypes = null;
72
73     /** http://www.w3.org/TR/xmlschema-1/#e-notation*/
74     protected XSNotationDeclaration fNotation = null;
75
76     /** member type definition against which element was validated */
77     protected XSSimpleTypeDefinition fMemberType = null;
78
79     /** validation attempted: none, partial, full */
80     protected short fValidationAttempted = ElementPSVI.VALIDATION_NONE;
81
82     /** validity: valid, invalid, unknown */
83     protected short fValidity = ElementPSVI.VALIDITY_NOTKNOWN;
84
85     /** error codes */
86     protected String JavaDoc[] fErrorCodes = null;
87
88     /** validation context: could be QName or XPath expression*/
89     protected String JavaDoc fValidationContext = null;
90     
91     /** deferred XSModel **/
92     protected SchemaGrammar[] fGrammars = null;
93
94     /** the schema information property */
95     protected XSModel fSchemaInformation = null;
96     
97     //
98
// ElementPSVI methods
99
//
100

101     /**
102      * [schema default]
103      *
104      * @return The canonical lexical representation of the declaration's {value constraint} value.
105      * @see <a HREF="http://www.w3.org/TR/xmlschema-1/#e-schema_default>XML Schema Part 1: Structures [schema default]</a>
106      */

107     public String JavaDoc getSchemaDefault() {
108         return fDeclaration == null ? null : fDeclaration.getConstraintValue();
109     }
110
111     /**
112      * [schema normalized value]
113      *
114      *
115      * @see <a HREF="http://www.w3.org/TR/xmlschema-1/#e-schema_normalized_value>XML Schema Part 1: Structures [schema normalized value]</a>
116      * @return the normalized value of this item after validation
117      */

118     public String JavaDoc getSchemaNormalizedValue() {
119         return fNormalizedValue;
120     }
121
122     /**
123      * [schema specified]
124      * @see <a HREF="http://www.w3.org/TR/xmlschema-1/#e-schema_specified">XML Schema Part 1: Structures [schema specified]</a>
125      * @return true - value was specified in schema, false - value comes from the infoset
126      */

127     public boolean getIsSchemaSpecified() {
128         return fSpecified;
129     }
130
131     /**
132      * Determines the extent to which the document has been validated
133      *
134      * @return return the [validation attempted] property. The possible values are
135      * NO_VALIDATION, PARTIAL_VALIDATION and FULL_VALIDATION
136      */

137     public short getValidationAttempted() {
138         return fValidationAttempted;
139     }
140
141     /**
142      * Determine the validity of the node with respect
143      * to the validation being attempted
144      *
145      * @return return the [validity] property. Possible values are:
146      * UNKNOWN_VALIDITY, INVALID_VALIDITY, VALID_VALIDITY
147      */

148     public short getValidity() {
149         return fValidity;
150     }
151
152     /**
153      * A list of error codes generated from validation attempts.
154      * Need to find all the possible subclause reports that need reporting
155      *
156      * @return Array of error codes
157      */

158     public StringList getErrorCodes() {
159         if (fErrorCodes == null)
160             return null;
161         return new StringListImpl(fErrorCodes, fErrorCodes.length);
162     }
163
164
165     // This is the only information we can provide in a pipeline.
166
public String JavaDoc getValidationContext() {
167         return fValidationContext;
168     }
169
170     /**
171      * [nil]
172      * @see <a HREF="http://www.w3.org/TR/xmlschema-1/#e-nil>XML Schema Part 1: Structures [nil]</a>
173      * @return true if clause 3.2 of Element Locally Valid (Element) (3.3.4) above is satisfied, otherwise false
174      */

175     public boolean getNil() {
176         return fNil;
177     }
178
179     /**
180      * [notation]
181      * @see <a HREF="http://www.w3.org/TR/xmlschema-1/#e-notation>XML Schema Part 1: Structures [notation]</a>
182      * @return The notation declaration.
183      */

184     public XSNotationDeclaration getNotation() {
185         return fNotation;
186     }
187
188     /**
189      * An item isomorphic to the type definition used to validate this element.
190      *
191      * @return a type declaration
192      */

193     public XSTypeDefinition getTypeDefinition() {
194         return fTypeDecl;
195     }
196     
197     /**
198      * If and only if that type definition is a simple type definition
199      * with {variety} union, or a complex type definition whose {content type}
200      * is a simple thype definition with {variety} union, then an item isomorphic
201      * to that member of the union's {member type definitions} which actually
202      * validated the element item's normalized value.
203      *
204      * @return a simple type declaration
205      */

206     public XSSimpleTypeDefinition getMemberTypeDefinition() {
207         return fMemberType;
208     }
209
210     /**
211      * An item isomorphic to the element declaration used to validate
212      * this element.
213      *
214      * @return an element declaration
215      */

216     public XSElementDeclaration getElementDeclaration() {
217         return fDeclaration;
218     }
219
220     /**
221      * [schema information]
222      * @see <a HREF="http://www.w3.org/TR/xmlschema-1/#e-schema_information">XML Schema Part 1: Structures [schema information]</a>
223      * @return The schema information property if it's the validation root,
224      * null otherwise.
225      */

226     public synchronized XSModel getSchemaInformation() {
227         if (fSchemaInformation == null && fGrammars != null) {
228             fSchemaInformation = new XSModelImpl(fGrammars);
229         }
230         return fSchemaInformation;
231     }
232     
233     /* (non-Javadoc)
234      * @see org.apache.xerces.xs.ItemPSVI#getActualNormalizedValue()
235      */

236     public Object JavaDoc getActualNormalizedValue() {
237         return this.fActualValue;
238     }
239
240     /* (non-Javadoc)
241      * @see org.apache.xerces.xs.ItemPSVI#getActualNormalizedValueType()
242      */

243     public short getActualNormalizedValueType() {
244         return this.fActualValueType;
245     }
246
247     /* (non-Javadoc)
248      * @see org.apache.xerces.xs.ItemPSVI#getItemValueTypes()
249      */

250     public ShortList getItemValueTypes() {
251         return this.fItemValueTypes;
252     }
253
254     /**
255      * Reset() should be called in validator startElement(..) method.
256      */

257     public void reset() {
258         fDeclaration = null;
259         fTypeDecl = null;
260         fNil = false;
261         fSpecified = false;
262         fNotation = null;
263         fMemberType = null;
264         fValidationAttempted = ElementPSVI.VALIDATION_NONE;
265         fValidity = ElementPSVI.VALIDITY_NOTKNOWN;
266         fErrorCodes = null;
267         fValidationContext = null;
268         fNormalizedValue = null;
269         fActualValue = null;
270         fActualValueType = XSConstants.UNAVAILABLE_DT;
271         fItemValueTypes = null;
272     }
273
274 }
275
Popular Tags