KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xerces > dom > PSVIElementNSImpl


1 /*
2  * Copyright 2002-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.xerces.dom;
18
19 import java.io.IOException JavaDoc;
20 import java.io.NotSerializableException JavaDoc;
21 import java.io.ObjectInputStream JavaDoc;
22 import java.io.ObjectOutputStream JavaDoc;
23
24 import org.apache.xerces.xs.ElementPSVI;
25 import org.apache.xerces.xs.*;
26
27 /**
28  * Element namespace implementation; stores PSVI element items.
29  *
30  * @xerces.internal
31  *
32  * @author Sandy Gao, IBM
33  *
34  * @version $Id: PSVIElementNSImpl.java,v 1.9 2004/10/05 17:12:49 mrglavas Exp $
35  */

36 public class PSVIElementNSImpl extends ElementNSImpl implements ElementPSVI {
37
38     /** Serialization version. */
39     static final long serialVersionUID = 6815489624636016068L;
40     
41     /**
42      * Construct an element node.
43      */

44     public PSVIElementNSImpl(CoreDocumentImpl ownerDocument, String JavaDoc namespaceURI,
45                              String JavaDoc qualifiedName, String JavaDoc localName) {
46         super(ownerDocument, namespaceURI, qualifiedName, localName);
47     }
48     
49     /**
50      * Construct an element node.
51      */

52     public PSVIElementNSImpl(CoreDocumentImpl ownerDocument, String JavaDoc namespaceURI,
53                              String JavaDoc qualifiedName) {
54         super(ownerDocument, namespaceURI, qualifiedName);
55     }
56     
57     /** element declaration */
58     protected XSElementDeclaration fDeclaration = null;
59
60     /** type of element, could be xsi:type */
61     protected XSTypeDefinition fTypeDecl = null;
62
63     /** true if clause 3.2 of Element Locally Valid (Element) (3.3.4)
64       * is satisfied, otherwise false
65       */

66     protected boolean fNil = false;
67
68     /** false if the element value was provided by the schema; true otherwise.
69      */

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

109     /**
110      * [schema default]
111      *
112      * @return The canonical lexical representation of the declaration's {value constraint} value.
113      * @see <a HREF="http://www.w3.org/TR/xmlschema-1/#e-schema_default>XML Schema Part 1: Structures [schema default]</a>
114      */

115     public String JavaDoc getSchemaDefault() {
116         return fDeclaration == null ? null : fDeclaration.getConstraintValue();
117     }
118
119     /**
120      * [schema normalized value]
121      *
122      *
123      * @see <a HREF="http://www.w3.org/TR/xmlschema-1/#e-schema_normalized_value>XML Schema Part 1: Structures [schema normalized value]</a>
124      * @return the normalized value of this item after validation
125      */

126     public String JavaDoc getSchemaNormalizedValue() {
127         return fNormalizedValue;
128     }
129
130     /**
131      * [schema specified]
132      * @see <a HREF="http://www.w3.org/TR/xmlschema-1/#e-schema_specified">XML Schema Part 1: Structures [schema specified]</a>
133      * @return false value was specified in schema, true value comes from the infoset
134      */

135     public boolean getIsSchemaSpecified() {
136         return fSpecified;
137     }
138
139     /**
140      * Determines the extent to which the document has been validated
141      *
142      * @return return the [validation attempted] property. The possible values are
143      * NO_VALIDATION, PARTIAL_VALIDATION and FULL_VALIDATION
144      */

145     public short getValidationAttempted() {
146         return fValidationAttempted;
147     }
148
149     /**
150      * Determine the validity of the node with respect
151      * to the validation being attempted
152      *
153      * @return return the [validity] property. Possible values are:
154      * UNKNOWN_VALIDITY, INVALID_VALIDITY, VALID_VALIDITY
155      */

156     public short getValidity() {
157         return fValidity;
158     }
159
160     /**
161      * A list of error codes generated from validation attempts.
162      * Need to find all the possible subclause reports that need reporting
163      *
164      * @return Array of error codes
165      */

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

181     public boolean getNil() {
182         return fNil;
183     }
184
185     /**
186      * [notation]
187      * @see <a HREF="http://www.w3.org/TR/xmlschema-1/#e-notation>XML Schema Part 1: Structures [notation]</a>
188      * @return The notation declaration.
189      */

190     public XSNotationDeclaration getNotation() {
191         return fNotation;
192     }
193
194     /**
195      * An item isomorphic to the type definition used to validate this element.
196      *
197      * @return a type declaration
198      */

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

212     public XSSimpleTypeDefinition getMemberTypeDefinition() {
213         return fMemberType;
214     }
215
216     /**
217      * An item isomorphic to the element declaration used to validate
218      * this element.
219      *
220      * @return an element declaration
221      */

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

232     public XSModel getSchemaInformation() {
233         return fSchemaInformation;
234     }
235     
236     /**
237      * Copy PSVI properties from another psvi item.
238      *
239      * @param attr the source of attribute PSVI items
240      */

241     public void setPSVI(ElementPSVI elem) {
242         this.fDeclaration = elem.getElementDeclaration();
243         this.fNotation = elem.getNotation();
244         this.fValidationContext = elem.getValidationContext();
245         this.fTypeDecl = elem.getTypeDefinition();
246         this.fSchemaInformation = elem.getSchemaInformation();
247         this.fValidity = elem.getValidity();
248         this.fValidationAttempted = elem.getValidationAttempted();
249         this.fErrorCodes = elem.getErrorCodes();
250         this.fNormalizedValue = elem.getSchemaNormalizedValue();
251         this.fActualValue = elem.getActualNormalizedValue();
252         this.fActualValueType = elem.getActualNormalizedValueType();
253         this.fItemValueTypes = elem.getItemValueTypes();
254         this.fMemberType = elem.getMemberTypeDefinition();
255         this.fSpecified = elem.getIsSchemaSpecified();
256     }
257
258     /* (non-Javadoc)
259      * @see org.apache.xerces.xs.ItemPSVI#getActualNormalizedValue()
260      */

261     public Object JavaDoc getActualNormalizedValue() {
262         return this.fActualValue;
263     }
264
265     /* (non-Javadoc)
266      * @see org.apache.xerces.xs.ItemPSVI#getActualNormalizedValueType()
267      */

268     public short getActualNormalizedValueType() {
269         return this.fActualValueType;
270     }
271
272     /* (non-Javadoc)
273      * @see org.apache.xerces.xs.ItemPSVI#getItemValueTypes()
274      */

275     public ShortList getItemValueTypes() {
276         return this.fItemValueTypes;
277     }
278     
279     // REVISIT: Forbid serialization of PSVI DOM until
280
// we support object serialization of grammars -- mrglavas
281

282     private void writeObject(ObjectOutputStream JavaDoc out)
283         throws IOException JavaDoc {
284         throw new NotSerializableException JavaDoc(getClass().getName());
285     }
286
287     private void readObject(ObjectInputStream JavaDoc in)
288         throws IOException JavaDoc, ClassNotFoundException JavaDoc {
289         throw new NotSerializableException JavaDoc(getClass().getName());
290     }
291 }
292
Popular Tags