KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > org > apache > xerces > internal > dom > PSVIElementNSImpl


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 2002-2004 The Apache Software Foundation. All rights
6  * 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) 1999, 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.dom;
59
60 import java.io.IOException JavaDoc;
61 import java.io.NotSerializableException JavaDoc;
62 import java.io.ObjectInputStream JavaDoc;
63 import java.io.ObjectOutputStream JavaDoc;
64
65 import com.sun.org.apache.xerces.internal.xs.ElementPSVI;
66 import com.sun.org.apache.xerces.internal.xs.*;
67
68 /**
69  * Element namespace implementation; stores PSVI element items.
70  *
71  * @author Sandy Gao, IBM
72  *
73  * @version $Id: PSVIElementNSImpl.java,v 1.7 2004/02/05 18:26:31 mrglavas Exp $
74  */

75 public class PSVIElementNSImpl extends ElementNSImpl implements ElementPSVI {
76
77     /** Serialization version. */
78     static final long serialVersionUID = 6815489624636016068L;
79     
80     /**
81      * Construct an element node.
82      */

83     public PSVIElementNSImpl(CoreDocumentImpl ownerDocument, String JavaDoc namespaceURI,
84                              String JavaDoc qualifiedName, String JavaDoc localName) {
85         super(ownerDocument, namespaceURI, qualifiedName, localName);
86     }
87     
88     /**
89      * Construct an element node.
90      */

91     public PSVIElementNSImpl(CoreDocumentImpl ownerDocument, String JavaDoc namespaceURI,
92                              String JavaDoc qualifiedName) {
93         super(ownerDocument, namespaceURI, qualifiedName);
94     }
95     
96     /** element declaration */
97     protected XSElementDeclaration fDeclaration = null;
98
99     /** type of element, could be xsi:type */
100     protected XSTypeDefinition fTypeDecl = null;
101
102     /** true if clause 3.2 of Element Locally Valid (Element) (3.3.4)
103       * is satisfied, otherwise false
104       */

105     protected boolean fNil = false;
106
107     /** false if the element value was provided by the schema; true otherwise.
108      */

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

148     /**
149      * [schema default]
150      *
151      * @return The canonical lexical representation of the declaration's {value constraint} value.
152      * @see <a HREF="http://www.w3.org/TR/xmlschema-1/#e-schema_default>XML Schema Part 1: Structures [schema default]</a>
153      */

154     public String JavaDoc getSchemaDefault() {
155         return fDeclaration == null ? null : fDeclaration.getConstraintValue();
156     }
157
158     /**
159      * [schema normalized value]
160      *
161      *
162      * @see <a HREF="http://www.w3.org/TR/xmlschema-1/#e-schema_normalized_value>XML Schema Part 1: Structures [schema normalized value]</a>
163      * @return the normalized value of this item after validation
164      */

165     public String JavaDoc getSchemaNormalizedValue() {
166         return fNormalizedValue;
167     }
168
169     /**
170      * [schema specified]
171      * @see <a HREF="http://www.w3.org/TR/xmlschema-1/#e-schema_specified">XML Schema Part 1: Structures [schema specified]</a>
172      * @return false value was specified in schema, true value comes from the infoset
173      */

174     public boolean getIsSchemaSpecified() {
175         return fSpecified;
176     }
177
178     /**
179      * Determines the extent to which the document has been validated
180      *
181      * @return return the [validation attempted] property. The possible values are
182      * NO_VALIDATION, PARTIAL_VALIDATION and FULL_VALIDATION
183      */

184     public short getValidationAttempted() {
185         return fValidationAttempted;
186     }
187
188     /**
189      * Determine the validity of the node with respect
190      * to the validation being attempted
191      *
192      * @return return the [validity] property. Possible values are:
193      * UNKNOWN_VALIDITY, INVALID_VALIDITY, VALID_VALIDITY
194      */

195     public short getValidity() {
196         return fValidity;
197     }
198
199     /**
200      * A list of error codes generated from validation attempts.
201      * Need to find all the possible subclause reports that need reporting
202      *
203      * @return Array of error codes
204      */

205     public StringList getErrorCodes() {
206         return fErrorCodes;
207     }
208
209
210     // This is the only information we can provide in a pipeline.
211
public String JavaDoc getValidationContext() {
212         return fValidationContext;
213     }
214
215     /**
216      * [nil]
217      * @see <a HREF="http://www.w3.org/TR/xmlschema-1/#e-nil>XML Schema Part 1: Structures [nil]</a>
218      * @return true if clause 3.2 of Element Locally Valid (Element) (3.3.4) above is satisfied, otherwise false
219      */

220     public boolean getNil() {
221         return fNil;
222     }
223
224     /**
225      * [notation]
226      * @see <a HREF="http://www.w3.org/TR/xmlschema-1/#e-notation>XML Schema Part 1: Structures [notation]</a>
227      * @return The notation declaration.
228      */

229     public XSNotationDeclaration getNotation() {
230         return fNotation;
231     }
232
233     /**
234      * An item isomorphic to the type definition used to validate this element.
235      *
236      * @return a type declaration
237      */

238     public XSTypeDefinition getTypeDefinition() {
239         return fTypeDecl;
240     }
241     
242     /**
243      * If and only if that type definition is a simple type definition
244      * with {variety} union, or a complex type definition whose {content type}
245      * is a simple thype definition with {variety} union, then an item isomorphic
246      * to that member of the union's {member type definitions} which actually
247      * validated the element item's normalized value.
248      *
249      * @return a simple type declaration
250      */

251     public XSSimpleTypeDefinition getMemberTypeDefinition() {
252         return fMemberType;
253     }
254
255     /**
256      * An item isomorphic to the element declaration used to validate
257      * this element.
258      *
259      * @return an element declaration
260      */

261     public XSElementDeclaration getElementDeclaration() {
262         return fDeclaration;
263     }
264
265     /**
266      * [schema information]
267      * @see <a HREF="http://www.w3.org/TR/xmlschema-1/#e-schema_information">XML Schema Part 1: Structures [schema information]</a>
268      * @return The schema information property if it's the validation root,
269      * null otherwise.
270      */

271     public XSModel getSchemaInformation() {
272         return fSchemaInformation;
273     }
274     
275     /**
276      * Copy PSVI properties from another psvi item.
277      *
278      * @param attr the source of attribute PSVI items
279      */

280     public void setPSVI(ElementPSVI elem) {
281         this.fDeclaration = elem.getElementDeclaration();
282         this.fNotation = elem.getNotation();
283         this.fValidationContext = elem.getValidationContext();
284         this.fTypeDecl = elem.getTypeDefinition();
285         this.fSchemaInformation = elem.getSchemaInformation();
286         this.fValidity = elem.getValidity();
287         this.fValidationAttempted = elem.getValidationAttempted();
288         this.fErrorCodes = elem.getErrorCodes();
289         this.fNormalizedValue = elem.getSchemaNormalizedValue();
290         this.fActualValue = elem.getActualNormalizedValue();
291         this.fActualValueType = elem.getActualNormalizedValueType();
292         this.fItemValueTypes = elem.getItemValueTypes();
293         this.fMemberType = elem.getMemberTypeDefinition();
294         this.fSpecified = elem.getIsSchemaSpecified();
295     }
296
297     /* (non-Javadoc)
298      * @see com.sun.org.apache.xerces.internal.xs.ItemPSVI#getActualNormalizedValue()
299      */

300     public Object JavaDoc getActualNormalizedValue() {
301         return this.fActualValue;
302     }
303
304     /* (non-Javadoc)
305      * @see com.sun.org.apache.xerces.internal.xs.ItemPSVI#getActualNormalizedValueType()
306      */

307     public short getActualNormalizedValueType() {
308         return this.fActualValueType;
309     }
310
311     /* (non-Javadoc)
312      * @see com.sun.org.apache.xerces.internal.xs.ItemPSVI#getItemValueTypes()
313      */

314     public ShortList getItemValueTypes() {
315         return this.fItemValueTypes;
316     }
317     
318     // REVISIT: Forbid serialization of PSVI DOM until
319
// we support object serialization of grammars -- mrglavas
320

321     private void writeObject(ObjectOutputStream JavaDoc out)
322         throws IOException JavaDoc {
323         throw new NotSerializableException JavaDoc(getClass().getName());
324     }
325
326     private void readObject(ObjectInputStream JavaDoc in)
327         throws IOException JavaDoc, ClassNotFoundException JavaDoc {
328         throw new NotSerializableException JavaDoc(getClass().getName());
329     }
330 }
331
Popular Tags