001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.xerces.dom;
019:
020: import java.io.IOException;
021: import java.io.NotSerializableException;
022: import java.io.ObjectInputStream;
023: import java.io.ObjectOutputStream;
024:
025: import org.apache.xerces.xs.ElementPSVI;
026: import org.apache.xerces.xs.*;
027:
028: /**
029: * Element namespace implementation; stores PSVI element items.
030: *
031: * @xerces.internal
032: *
033: * @author Sandy Gao, IBM
034: *
035: * @version $Id: PSVIElementNSImpl.java 449328 2006-09-23 22:58:23Z mrglavas $
036: */
037: public class PSVIElementNSImpl extends ElementNSImpl implements
038: ElementPSVI {
039:
040: /** Serialization version. */
041: static final long serialVersionUID = 6815489624636016068L;
042:
043: /**
044: * Construct an element node.
045: */
046: public PSVIElementNSImpl(CoreDocumentImpl ownerDocument,
047: String namespaceURI, String qualifiedName, String localName) {
048: super (ownerDocument, namespaceURI, qualifiedName, localName);
049: }
050:
051: /**
052: * Construct an element node.
053: */
054: public PSVIElementNSImpl(CoreDocumentImpl ownerDocument,
055: String namespaceURI, String qualifiedName) {
056: super (ownerDocument, namespaceURI, qualifiedName);
057: }
058:
059: /** element declaration */
060: protected XSElementDeclaration fDeclaration = null;
061:
062: /** type of element, could be xsi:type */
063: protected XSTypeDefinition fTypeDecl = null;
064:
065: /** true if clause 3.2 of Element Locally Valid (Element) (3.3.4)
066: * is satisfied, otherwise false
067: */
068: protected boolean fNil = false;
069:
070: /** false if the element value was provided by the schema; true otherwise.
071: */
072: protected boolean fSpecified = true;
073:
074: /** schema normalized value property */
075: protected String fNormalizedValue = null;
076:
077: /** schema actual value */
078: protected Object fActualValue = null;
079:
080: /** schema actual value type */
081: protected short fActualValueType = XSConstants.UNAVAILABLE_DT;
082:
083: /** actual value types if the value is a list */
084: protected ShortList fItemValueTypes = null;
085:
086: /** http://www.w3.org/TR/xmlschema-1/#e-notation*/
087: protected XSNotationDeclaration fNotation = null;
088:
089: /** member type definition against which element was validated */
090: protected XSSimpleTypeDefinition fMemberType = null;
091:
092: /** validation attempted: none, partial, full */
093: protected short fValidationAttempted = ElementPSVI.VALIDATION_NONE;
094:
095: /** validity: valid, invalid, unknown */
096: protected short fValidity = ElementPSVI.VALIDITY_NOTKNOWN;
097:
098: /** error codes */
099: protected StringList fErrorCodes = null;
100:
101: /** validation context: could be QName or XPath expression*/
102: protected String fValidationContext = null;
103:
104: /** the schema information property */
105: protected XSModel fSchemaInformation = null;
106:
107: //
108: // ElementPSVI methods
109: //
110:
111: /**
112: * [schema default]
113: *
114: * @return The canonical lexical representation of the declaration's {value constraint} value.
115: * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_default>XML Schema Part 1: Structures [schema default]</a>
116: */
117: public String getSchemaDefault() {
118: return fDeclaration == null ? null : fDeclaration
119: .getConstraintValue();
120: }
121:
122: /**
123: * [schema normalized value]
124: *
125: *
126: * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_normalized_value>XML Schema Part 1: Structures [schema normalized value]</a>
127: * @return the normalized value of this item after validation
128: */
129: public String getSchemaNormalizedValue() {
130: return fNormalizedValue;
131: }
132:
133: /**
134: * [schema specified]
135: * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_specified">XML Schema Part 1: Structures [schema specified]</a>
136: * @return false value was specified in schema, true value comes from the infoset
137: */
138: public boolean getIsSchemaSpecified() {
139: return fSpecified;
140: }
141:
142: /**
143: * Determines the extent to which the document has been validated
144: *
145: * @return return the [validation attempted] property. The possible values are
146: * NO_VALIDATION, PARTIAL_VALIDATION and FULL_VALIDATION
147: */
148: public short getValidationAttempted() {
149: return fValidationAttempted;
150: }
151:
152: /**
153: * Determine the validity of the node with respect
154: * to the validation being attempted
155: *
156: * @return return the [validity] property. Possible values are:
157: * UNKNOWN_VALIDITY, INVALID_VALIDITY, VALID_VALIDITY
158: */
159: public short getValidity() {
160: return fValidity;
161: }
162:
163: /**
164: * A list of error codes generated from validation attempts.
165: * Need to find all the possible subclause reports that need reporting
166: *
167: * @return Array of error codes
168: */
169: public StringList getErrorCodes() {
170: return fErrorCodes;
171: }
172:
173: // This is the only information we can provide in a pipeline.
174: public String getValidationContext() {
175: return fValidationContext;
176: }
177:
178: /**
179: * [nil]
180: * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-nil>XML Schema Part 1: Structures [nil]</a>
181: * @return true if clause 3.2 of Element Locally Valid (Element) (3.3.4) above is satisfied, otherwise false
182: */
183: public boolean getNil() {
184: return fNil;
185: }
186:
187: /**
188: * [notation]
189: * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-notation>XML Schema Part 1: Structures [notation]</a>
190: * @return The notation declaration.
191: */
192: public XSNotationDeclaration getNotation() {
193: return fNotation;
194: }
195:
196: /**
197: * An item isomorphic to the type definition used to validate this element.
198: *
199: * @return a type declaration
200: */
201: public XSTypeDefinition getTypeDefinition() {
202: return fTypeDecl;
203: }
204:
205: /**
206: * If and only if that type definition is a simple type definition
207: * with {variety} union, or a complex type definition whose {content type}
208: * is a simple thype definition with {variety} union, then an item isomorphic
209: * to that member of the union's {member type definitions} which actually
210: * validated the element item's normalized value.
211: *
212: * @return a simple type declaration
213: */
214: public XSSimpleTypeDefinition getMemberTypeDefinition() {
215: return fMemberType;
216: }
217:
218: /**
219: * An item isomorphic to the element declaration used to validate
220: * this element.
221: *
222: * @return an element declaration
223: */
224: public XSElementDeclaration getElementDeclaration() {
225: return fDeclaration;
226: }
227:
228: /**
229: * [schema information]
230: * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_information">XML Schema Part 1: Structures [schema information]</a>
231: * @return The schema information property if it's the validation root,
232: * null otherwise.
233: */
234: public XSModel getSchemaInformation() {
235: return fSchemaInformation;
236: }
237:
238: /**
239: * Copy PSVI properties from another psvi item.
240: *
241: * @param elem the source of element PSVI items
242: */
243: public void setPSVI(ElementPSVI elem) {
244: this .fDeclaration = elem.getElementDeclaration();
245: this .fNotation = elem.getNotation();
246: this .fValidationContext = elem.getValidationContext();
247: this .fTypeDecl = elem.getTypeDefinition();
248: this .fSchemaInformation = elem.getSchemaInformation();
249: this .fValidity = elem.getValidity();
250: this .fValidationAttempted = elem.getValidationAttempted();
251: this .fErrorCodes = elem.getErrorCodes();
252: this .fNormalizedValue = elem.getSchemaNormalizedValue();
253: this .fActualValue = elem.getActualNormalizedValue();
254: this .fActualValueType = elem.getActualNormalizedValueType();
255: this .fItemValueTypes = elem.getItemValueTypes();
256: this .fMemberType = elem.getMemberTypeDefinition();
257: this .fSpecified = elem.getIsSchemaSpecified();
258: this .fNil = elem.getNil();
259: }
260:
261: /* (non-Javadoc)
262: * @see org.apache.xerces.xs.ItemPSVI#getActualNormalizedValue()
263: */
264: public Object getActualNormalizedValue() {
265: return this .fActualValue;
266: }
267:
268: /* (non-Javadoc)
269: * @see org.apache.xerces.xs.ItemPSVI#getActualNormalizedValueType()
270: */
271: public short getActualNormalizedValueType() {
272: return this .fActualValueType;
273: }
274:
275: /* (non-Javadoc)
276: * @see org.apache.xerces.xs.ItemPSVI#getItemValueTypes()
277: */
278: public ShortList getItemValueTypes() {
279: return this .fItemValueTypes;
280: }
281:
282: // REVISIT: Forbid serialization of PSVI DOM until
283: // we support object serialization of grammars -- mrglavas
284:
285: private void writeObject(ObjectOutputStream out) throws IOException {
286: throw new NotSerializableException(getClass().getName());
287: }
288:
289: private void readObject(ObjectInputStream in) throws IOException,
290: ClassNotFoundException {
291: throw new NotSerializableException(getClass().getName());
292: }
293: }
|