KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > org > apache > xerces > internal > impl > xs > ElementPSVImpl


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 2000-2002 The Apache Software Foundation.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Apache Software Foundation (http://www.apache.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "Xerces" and "Apache Software Foundation" must
28  * not be used to endorse or promote products derived from this
29  * software without prior written permission. For written
30  * permission, please contact apache@apache.org.
31  *
32  * 5. Products derived from this software may not be called "Apache",
33  * nor may "Apache" appear in their name, without prior written
34  * permission of the Apache Software Foundation.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47  * SUCH DAMAGE.
48  * ====================================================================
49  *
50  * This software consists of voluntary contributions made by many
51  * individuals on behalf of the Apache Software Foundation and was
52  * originally based on software copyright (c) 2001, International
53  * Business Machines, Inc., http://www.apache.org. For more
54  * information on the Apache Software Foundation, please see
55  * <http://www.apache.org/>.
56  */

57
58 package com.sun.org.apache.xerces.internal.impl.xs;
59
60 import com.sun.org.apache.xerces.internal.xs.ShortList;
61 import com.sun.org.apache.xerces.internal.xs.StringList;
62 import com.sun.org.apache.xerces.internal.xs.XSElementDeclaration;
63 import com.sun.org.apache.xerces.internal.xs.XSModel;
64 import com.sun.org.apache.xerces.internal.xs.XSNotationDeclaration;
65 import com.sun.org.apache.xerces.internal.xs.XSSimpleTypeDefinition;
66 import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition;
67 import com.sun.org.apache.xerces.internal.impl.xs.util.StringListImpl;
68 import com.sun.org.apache.xerces.internal.xs.ElementPSVI;
69 import com.sun.org.apache.xerces.internal.xs.XSConstants;
70
71 /**
72  * Element PSV infoset augmentations implementation.
73  * The following information will be available at the startElement call:
74  * name, namespace, type, notation, validation context
75  *
76  * The following information will be available at the endElement call:
77  * nil, specified, normalized value, member type, validity, error codes,
78  * default
79  *
80  * @author Elena Litani IBM
81  * @version $Id: ElementPSVImpl.java,v 1.24 2003/11/12 23:17:33 sandygao Exp $
82  */

83 public class ElementPSVImpl implements ElementPSVI {
84
85     /** element declaration */
86     protected XSElementDeclaration fDeclaration = null;
87
88     /** type of element, could be xsi:type */
89     protected XSTypeDefinition fTypeDecl = null;
90
91     /** true if clause 3.2 of Element Locally Valid (Element) (3.3.4)
92       * is satisfied, otherwise false
93       */

94     protected boolean fNil = false;
95
96     /** true if the element value was provided by the schema; false otherwise.
97      */

98     protected boolean fSpecified = false;
99
100     /** schema normalized value property */
101     protected String JavaDoc fNormalizedValue = null;
102
103     /** schema actual value */
104     protected Object JavaDoc fActualValue = null;
105
106     /** schema actual value type */
107     protected short fActualValueType = XSConstants.UNAVAILABLE_DT;
108
109     /** actual value types if the value is a list */
110     protected ShortList fItemValueTypes = null;
111
112     /** http://www.w3.org/TR/xmlschema-1/#e-notation*/
113     protected XSNotationDeclaration fNotation = null;
114
115     /** member type definition against which element was validated */
116     protected XSSimpleTypeDefinition fMemberType = null;
117
118     /** validation attempted: none, partial, full */
119     protected short fValidationAttempted = ElementPSVI.VALIDATION_NONE;
120
121     /** validity: valid, invalid, unknown */
122     protected short fValidity = ElementPSVI.VALIDITY_NOTKNOWN;
123
124     /** error codes */
125     protected String JavaDoc[] fErrorCodes = null;
126
127     /** validation context: could be QName or XPath expression*/
128     protected String JavaDoc fValidationContext = null;
129
130     /** the schema information property */
131     protected XSModel fSchemaInformation = null;
132     
133     //
134
// ElementPSVI methods
135
//
136

137     /**
138      * [schema default]
139      *
140      * @return The canonical lexical representation of the declaration's {value constraint} value.
141      * @see <a HREF="http://www.w3.org/TR/xmlschema-1/#e-schema_default>XML Schema Part 1: Structures [schema default]</a>
142      */

143     public String JavaDoc getSchemaDefault() {
144         return fDeclaration == null ? null : fDeclaration.getConstraintValue();
145     }
146
147     /**
148      * [schema normalized value]
149      *
150      *
151      * @see <a HREF="http://www.w3.org/TR/xmlschema-1/#e-schema_normalized_value>XML Schema Part 1: Structures [schema normalized value]</a>
152      * @return the normalized value of this item after validation
153      */

154     public String JavaDoc getSchemaNormalizedValue() {
155         return fNormalizedValue;
156     }
157
158     /**
159      * [schema specified]
160      * @see <a HREF="http://www.w3.org/TR/xmlschema-1/#e-schema_specified">XML Schema Part 1: Structures [schema specified]</a>
161      * @return true - value was specified in schema, false - value comes from the infoset
162      */

163     public boolean getIsSchemaSpecified() {
164         return fSpecified;
165     }
166
167     /**
168      * Determines the extent to which the document has been validated
169      *
170      * @return return the [validation attempted] property. The possible values are
171      * NO_VALIDATION, PARTIAL_VALIDATION and FULL_VALIDATION
172      */

173     public short getValidationAttempted() {
174         return fValidationAttempted;
175     }
176
177     /**
178      * Determine the validity of the node with respect
179      * to the validation being attempted
180      *
181      * @return return the [validity] property. Possible values are:
182      * UNKNOWN_VALIDITY, INVALID_VALIDITY, VALID_VALIDITY
183      */

184     public short getValidity() {
185         return fValidity;
186     }
187
188     /**
189      * A list of error codes generated from validation attempts.
190      * Need to find all the possible subclause reports that need reporting
191      *
192      * @return Array of error codes
193      */

194     public StringList getErrorCodes() {
195         if (fErrorCodes == null)
196             return null;
197         return new StringListImpl(fErrorCodes, fErrorCodes.length);
198     }
199
200
201     // This is the only information we can provide in a pipeline.
202
public String JavaDoc getValidationContext() {
203         return fValidationContext;
204     }
205
206     /**
207      * [nil]
208      * @see <a HREF="http://www.w3.org/TR/xmlschema-1/#e-nil>XML Schema Part 1: Structures [nil]</a>
209      * @return true if clause 3.2 of Element Locally Valid (Element) (3.3.4) above is satisfied, otherwise false
210      */

211     public boolean getNil() {
212         return fNil;
213     }
214
215     /**
216      * [notation]
217      * @see <a HREF="http://www.w3.org/TR/xmlschema-1/#e-notation>XML Schema Part 1: Structures [notation]</a>
218      * @return The notation declaration.
219      */

220     public XSNotationDeclaration getNotation() {
221         return fNotation;
222     }
223
224     /**
225      * An item isomorphic to the type definition used to validate this element.
226      *
227      * @return a type declaration
228      */

229     public XSTypeDefinition getTypeDefinition() {
230         return fTypeDecl;
231     }
232     
233     /**
234      * If and only if that type definition is a simple type definition
235      * with {variety} union, or a complex type definition whose {content type}
236      * is a simple thype definition with {variety} union, then an item isomorphic
237      * to that member of the union's {member type definitions} which actually
238      * validated the element item's normalized value.
239      *
240      * @return a simple type declaration
241      */

242     public XSSimpleTypeDefinition getMemberTypeDefinition() {
243         return fMemberType;
244     }
245
246     /**
247      * An item isomorphic to the element declaration used to validate
248      * this element.
249      *
250      * @return an element declaration
251      */

252     public XSElementDeclaration getElementDeclaration() {
253         return fDeclaration;
254     }
255
256     /**
257      * [schema information]
258      * @see <a HREF="http://www.w3.org/TR/xmlschema-1/#e-schema_information">XML Schema Part 1: Structures [schema information]</a>
259      * @return The schema information property if it's the validation root,
260      * null otherwise.
261      */

262     public XSModel getSchemaInformation() {
263         return fSchemaInformation;
264     }
265     
266     /* (non-Javadoc)
267      * @see com.sun.org.apache.xerces.internal.xs.ItemPSVI#getActualNormalizedValue()
268      */

269     public Object JavaDoc getActualNormalizedValue() {
270         return this.fActualValue;
271     }
272
273     /* (non-Javadoc)
274      * @see com.sun.org.apache.xerces.internal.xs.ItemPSVI#getActualNormalizedValueType()
275      */

276     public short getActualNormalizedValueType() {
277         return this.fActualValueType;
278     }
279
280     /* (non-Javadoc)
281      * @see com.sun.org.apache.xerces.internal.xs.ItemPSVI#getItemValueTypes()
282      */

283     public ShortList getItemValueTypes() {
284         return this.fItemValueTypes;
285     }
286
287     /**
288      * Reset() should be called in validator startElement(..) method.
289      */

290     public void reset() {
291         fDeclaration = null;
292         fTypeDecl = null;
293         fNil = false;
294         fSpecified = false;
295         fNotation = null;
296         fMemberType = null;
297         fValidationAttempted = ElementPSVI.VALIDATION_NONE;
298         fValidity = ElementPSVI.VALIDITY_NOTKNOWN;
299         fErrorCodes = null;
300         fValidationContext = null;
301         fNormalizedValue = null;
302         fActualValue = null;
303         fActualValueType = XSConstants.UNAVAILABLE_DT;
304         fItemValueTypes = null;
305     }
306
307 }
308
Popular Tags