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.AttributePSVI;
026: import org.apache.xerces.xs.*;
027:
028: /**
029: * Attribute namespace implementation; stores PSVI attribute items.
030: *
031: * @xerces.internal
032: *
033: * @author Sandy Gao, IBM
034: *
035: * @version $Id: PSVIAttrNSImpl.java 447266 2006-09-18 05:57:49Z mrglavas $
036: */
037: public class PSVIAttrNSImpl extends AttrNSImpl implements AttributePSVI {
038:
039: /** Serialization version. */
040: static final long serialVersionUID = -3241738699421018889L;
041:
042: /**
043: * Construct an attribute node.
044: */
045: public PSVIAttrNSImpl(CoreDocumentImpl ownerDocument,
046: String namespaceURI, String qualifiedName, String localName) {
047: super (ownerDocument, namespaceURI, qualifiedName, localName);
048: }
049:
050: /**
051: * Construct an attribute node.
052: */
053: public PSVIAttrNSImpl(CoreDocumentImpl ownerDocument,
054: String namespaceURI, String qualifiedName) {
055: super (ownerDocument, namespaceURI, qualifiedName);
056: }
057:
058: /** attribute declaration */
059: protected XSAttributeDeclaration fDeclaration = null;
060:
061: /** type of attribute, simpleType */
062: protected XSTypeDefinition fTypeDecl = null;
063:
064: /** If this attribute was explicitly given a
065: * value in the original document, this is true; otherwise, it is false */
066: protected boolean fSpecified = true;
067:
068: /** schema normalized value property */
069: protected String fNormalizedValue = null;
070:
071: /** schema actual value */
072: protected Object fActualValue = null;
073:
074: /** schema actual value type */
075: protected short fActualValueType = XSConstants.UNAVAILABLE_DT;
076:
077: /** actual value types if the value is a list */
078: protected ShortList fItemValueTypes = null;
079:
080: /** member type definition against which attribute was validated */
081: protected XSSimpleTypeDefinition fMemberType = null;
082:
083: /** validation attempted: none, partial, full */
084: protected short fValidationAttempted = AttributePSVI.VALIDATION_NONE;
085:
086: /** validity: valid, invalid, unknown */
087: protected short fValidity = AttributePSVI.VALIDITY_NOTKNOWN;
088:
089: /** error codes */
090: protected StringList fErrorCodes = null;
091:
092: /** validation context: could be QName or XPath expression*/
093: protected String fValidationContext = null;
094:
095: //
096: // AttributePSVI methods
097: //
098:
099: /**
100: * [schema default]
101: *
102: * @return The canonical lexical representation of the declaration's {value constraint} value.
103: * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_default>XML Schema Part 1: Structures [schema default]</a>
104: */
105: public String getSchemaDefault() {
106: return fDeclaration == null ? null : fDeclaration
107: .getConstraintValue();
108: }
109:
110: /**
111: * [schema normalized value]
112: *
113: *
114: * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_normalized_value>XML Schema Part 1: Structures [schema normalized value]</a>
115: * @return the normalized value of this item after validation
116: */
117: public String getSchemaNormalizedValue() {
118: return fNormalizedValue;
119: }
120:
121: /**
122: * [schema specified]
123: * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_specified">XML Schema Part 1: Structures [schema specified]</a>
124: * @return false value was specified in schema, true value comes from the infoset
125: */
126: public boolean getIsSchemaSpecified() {
127: return fSpecified;
128: }
129:
130: /**
131: * Determines the extent to which the document has been validated
132: *
133: * @return return the [validation attempted] property. The possible values are
134: * NO_VALIDATION, PARTIAL_VALIDATION and FULL_VALIDATION
135: */
136: public short getValidationAttempted() {
137: return fValidationAttempted;
138: }
139:
140: /**
141: * Determine the validity of the node with respect
142: * to the validation being attempted
143: *
144: * @return return the [validity] property. Possible values are:
145: * UNKNOWN_VALIDITY, INVALID_VALIDITY, VALID_VALIDITY
146: */
147: public short getValidity() {
148: return fValidity;
149: }
150:
151: /**
152: * A list of error codes generated from validation attempts.
153: * Need to find all the possible subclause reports that need reporting
154: *
155: * @return list of error codes
156: */
157: public StringList getErrorCodes() {
158: return fErrorCodes;
159: }
160:
161: // This is the only information we can provide in a pipeline.
162: public String getValidationContext() {
163: return fValidationContext;
164: }
165:
166: /**
167: * An item isomorphic to the type definition used to validate this element.
168: *
169: * @return a type declaration
170: */
171: public XSTypeDefinition getTypeDefinition() {
172: return fTypeDecl;
173: }
174:
175: /**
176: * If and only if that type definition is a simple type definition
177: * with {variety} union, or a complex type definition whose {content type}
178: * is a simple thype definition with {variety} union, then an item isomorphic
179: * to that member of the union's {member type definitions} which actually
180: * validated the element item's normalized value.
181: *
182: * @return a simple type declaration
183: */
184: public XSSimpleTypeDefinition getMemberTypeDefinition() {
185: return fMemberType;
186: }
187:
188: /**
189: * An item isomorphic to the attribute declaration used to validate
190: * this attribute.
191: *
192: * @return an attribute declaration
193: */
194: public XSAttributeDeclaration getAttributeDeclaration() {
195: return fDeclaration;
196: }
197:
198: /**
199: * Copy PSVI properties from another psvi item.
200: *
201: * @param attr the source of attribute PSVI items
202: */
203: public void setPSVI(AttributePSVI attr) {
204: this .fDeclaration = attr.getAttributeDeclaration();
205: this .fValidationContext = attr.getValidationContext();
206: this .fValidity = attr.getValidity();
207: this .fValidationAttempted = attr.getValidationAttempted();
208: this .fErrorCodes = attr.getErrorCodes();
209: this .fNormalizedValue = attr.getSchemaNormalizedValue();
210: this .fActualValue = attr.getActualNormalizedValue();
211: this .fActualValueType = attr.getActualNormalizedValueType();
212: this .fItemValueTypes = attr.getItemValueTypes();
213: this .fTypeDecl = attr.getTypeDefinition();
214: this .fMemberType = attr.getMemberTypeDefinition();
215: this .fSpecified = attr.getIsSchemaSpecified();
216: }
217:
218: /* (non-Javadoc)
219: * @see org.apache.xerces.xs.ItemPSVI#getActualNormalizedValue()
220: */
221: public Object getActualNormalizedValue() {
222: return this .fActualValue;
223: }
224:
225: /* (non-Javadoc)
226: * @see org.apache.xerces.xs.ItemPSVI#getActualNormalizedValueType()
227: */
228: public short getActualNormalizedValueType() {
229: return this .fActualValueType;
230: }
231:
232: /* (non-Javadoc)
233: * @see org.apache.xerces.xs.ItemPSVI#getItemValueTypes()
234: */
235: public ShortList getItemValueTypes() {
236: return this .fItemValueTypes;
237: }
238:
239: // REVISIT: Forbid serialization of PSVI DOM until
240: // we support object serialization of grammars -- mrglavas
241:
242: private void writeObject(ObjectOutputStream out) throws IOException {
243: throw new NotSerializableException(getClass().getName());
244: }
245:
246: private void readObject(ObjectInputStream in) throws IOException,
247: ClassNotFoundException {
248: throw new NotSerializableException(getClass().getName());
249: }
250: }
|