286N/A/*
286N/A * reserved comment block
286N/A * DO NOT REMOVE OR ALTER!
286N/A */
286N/A/*
286N/A * Copyright 2002-2004 The Apache Software Foundation.
286N/A *
286N/A * Licensed under the Apache License, Version 2.0 (the "License");
286N/A * you may not use this file except in compliance with the License.
286N/A * You may obtain a copy of the License at
286N/A *
286N/A * http://www.apache.org/licenses/LICENSE-2.0
286N/A *
286N/A * Unless required by applicable law or agreed to in writing, software
286N/A * distributed under the License is distributed on an "AS IS" BASIS,
286N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
286N/A * See the License for the specific language governing permissions and
286N/A * limitations under the License.
286N/A */
286N/A
286N/Apackage com.sun.org.apache.xerces.internal.dom;
286N/A
286N/Aimport java.io.IOException;
286N/Aimport java.io.NotSerializableException;
286N/Aimport java.io.ObjectInputStream;
286N/Aimport java.io.ObjectOutputStream;
286N/A
286N/Aimport com.sun.org.apache.xerces.internal.xs.AttributePSVI;
286N/Aimport com.sun.org.apache.xerces.internal.xs.*;
286N/A
286N/A/**
286N/A * Attribute namespace implementation; stores PSVI attribute items.
286N/A *
286N/A * @xerces.internal
286N/A *
286N/A * @author Sandy Gao, IBM
286N/A *
286N/A */
286N/Apublic class PSVIAttrNSImpl extends AttrNSImpl implements AttributePSVI {
286N/A
286N/A /** Serialization version. */
286N/A static final long serialVersionUID = -3241738699421018889L;
286N/A
286N/A /**
286N/A * Construct an attribute node.
286N/A */
286N/A public PSVIAttrNSImpl(CoreDocumentImpl ownerDocument, String namespaceURI,
286N/A String qualifiedName, String localName) {
286N/A super(ownerDocument, namespaceURI, qualifiedName, localName);
286N/A }
286N/A
286N/A /**
286N/A * Construct an attribute node.
286N/A */
286N/A public PSVIAttrNSImpl(CoreDocumentImpl ownerDocument, String namespaceURI,
286N/A String qualifiedName) {
286N/A super(ownerDocument, namespaceURI, qualifiedName);
286N/A }
286N/A
286N/A /** attribute declaration */
286N/A protected XSAttributeDeclaration fDeclaration = null;
286N/A
286N/A /** type of attribute, simpleType */
286N/A protected XSTypeDefinition fTypeDecl = null;
286N/A
286N/A /** If this attribute was explicitly given a
286N/A * value in the original document, this is true; otherwise, it is false */
286N/A protected boolean fSpecified = true;
286N/A
286N/A /** schema normalized value property */
286N/A protected String fNormalizedValue = null;
286N/A
286N/A /** schema actual value */
286N/A protected Object fActualValue = null;
286N/A
286N/A /** schema actual value type */
286N/A protected short fActualValueType = XSConstants.UNAVAILABLE_DT;
286N/A
286N/A /** actual value types if the value is a list */
286N/A protected ShortList fItemValueTypes = null;
286N/A
286N/A /** member type definition against which attribute was validated */
286N/A protected XSSimpleTypeDefinition fMemberType = null;
286N/A
286N/A /** validation attempted: none, partial, full */
286N/A protected short fValidationAttempted = AttributePSVI.VALIDATION_NONE;
286N/A
286N/A /** validity: valid, invalid, unknown */
286N/A protected short fValidity = AttributePSVI.VALIDITY_NOTKNOWN;
286N/A
286N/A /** error codes */
286N/A protected StringList fErrorCodes = null;
286N/A
286N/A /** validation context: could be QName or XPath expression*/
286N/A protected String fValidationContext = null;
286N/A
286N/A //
286N/A // AttributePSVI methods
286N/A //
286N/A
286N/A /**
286N/A * [schema default]
286N/A *
286N/A * @return The canonical lexical representation of the declaration's {value constraint} value.
286N/A * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_default>XML Schema Part 1: Structures [schema default]</a>
286N/A */
286N/A public String getSchemaDefault() {
286N/A return fDeclaration == null ? null : fDeclaration.getConstraintValue();
286N/A }
286N/A
286N/A /**
286N/A * [schema normalized value]
286N/A *
286N/A *
286N/A * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_normalized_value>XML Schema Part 1: Structures [schema normalized value]</a>
286N/A * @return the normalized value of this item after validation
286N/A */
286N/A public String getSchemaNormalizedValue() {
286N/A return fNormalizedValue;
286N/A }
286N/A
286N/A /**
286N/A * [schema specified]
286N/A * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_specified">XML Schema Part 1: Structures [schema specified]</a>
286N/A * @return false value was specified in schema, true value comes from the infoset
286N/A */
286N/A public boolean getIsSchemaSpecified() {
286N/A return fSpecified;
286N/A }
286N/A
286N/A
286N/A /**
286N/A * Determines the extent to which the document has been validated
286N/A *
286N/A * @return return the [validation attempted] property. The possible values are
286N/A * NO_VALIDATION, PARTIAL_VALIDATION and FULL_VALIDATION
286N/A */
286N/A public short getValidationAttempted() {
286N/A return fValidationAttempted;
286N/A }
286N/A
286N/A /**
286N/A * Determine the validity of the node with respect
286N/A * to the validation being attempted
286N/A *
286N/A * @return return the [validity] property. Possible values are:
286N/A * UNKNOWN_VALIDITY, INVALID_VALIDITY, VALID_VALIDITY
286N/A */
286N/A public short getValidity() {
286N/A return fValidity;
286N/A }
286N/A
286N/A /**
286N/A * A list of error codes generated from validation attempts.
286N/A * Need to find all the possible subclause reports that need reporting
286N/A *
286N/A * @return list of error codes
286N/A */
286N/A public StringList getErrorCodes() {
286N/A return fErrorCodes;
286N/A }
286N/A
286N/A // This is the only information we can provide in a pipeline.
286N/A public String getValidationContext() {
286N/A return fValidationContext;
286N/A }
286N/A
286N/A /**
286N/A * An item isomorphic to the type definition used to validate this element.
286N/A *
286N/A * @return a type declaration
286N/A */
286N/A public XSTypeDefinition getTypeDefinition() {
286N/A return fTypeDecl;
286N/A }
286N/A
286N/A /**
286N/A * If and only if that type definition is a simple type definition
286N/A * with {variety} union, or a complex type definition whose {content type}
286N/A * is a simple thype definition with {variety} union, then an item isomorphic
286N/A * to that member of the union's {member type definitions} which actually
286N/A * validated the element item's normalized value.
286N/A *
286N/A * @return a simple type declaration
286N/A */
286N/A public XSSimpleTypeDefinition getMemberTypeDefinition() {
286N/A return fMemberType;
286N/A }
286N/A
286N/A /**
286N/A * An item isomorphic to the attribute declaration used to validate
286N/A * this attribute.
286N/A *
286N/A * @return an attribute declaration
286N/A */
286N/A public XSAttributeDeclaration getAttributeDeclaration() {
286N/A return fDeclaration;
286N/A }
286N/A
286N/A /**
286N/A * Copy PSVI properties from another psvi item.
286N/A *
286N/A * @param attr the source of attribute PSVI items
286N/A */
286N/A public void setPSVI(AttributePSVI attr) {
286N/A this.fDeclaration = attr.getAttributeDeclaration();
286N/A this.fValidationContext = attr.getValidationContext();
286N/A this.fValidity = attr.getValidity();
286N/A this.fValidationAttempted = attr.getValidationAttempted();
286N/A this.fErrorCodes = attr.getErrorCodes();
286N/A this.fNormalizedValue = attr.getSchemaNormalizedValue();
286N/A this.fActualValue = attr.getActualNormalizedValue();
286N/A this.fActualValueType = attr.getActualNormalizedValueType();
286N/A this.fItemValueTypes = attr.getItemValueTypes();
286N/A this.fTypeDecl = attr.getTypeDefinition();
286N/A this.fMemberType = attr.getMemberTypeDefinition();
286N/A this.fSpecified = attr.getIsSchemaSpecified();
286N/A }
286N/A
286N/A /* (non-Javadoc)
286N/A * @see com.sun.org.apache.xerces.internal.xs.ItemPSVI#getActualNormalizedValue()
286N/A */
286N/A public Object getActualNormalizedValue() {
286N/A return this.fActualValue;
286N/A }
286N/A
286N/A /* (non-Javadoc)
286N/A * @see com.sun.org.apache.xerces.internal.xs.ItemPSVI#getActualNormalizedValueType()
286N/A */
286N/A public short getActualNormalizedValueType() {
286N/A return this.fActualValueType;
286N/A }
286N/A
286N/A /* (non-Javadoc)
286N/A * @see com.sun.org.apache.xerces.internal.xs.ItemPSVI#getItemValueTypes()
286N/A */
286N/A public ShortList getItemValueTypes() {
286N/A return this.fItemValueTypes;
286N/A }
286N/A
286N/A // REVISIT: Forbid serialization of PSVI DOM until
286N/A // we support object serialization of grammars -- mrglavas
286N/A
286N/A private void writeObject(ObjectOutputStream out)
286N/A throws IOException {
286N/A throw new NotSerializableException(getClass().getName());
286N/A }
286N/A
286N/A private void readObject(ObjectInputStream in)
286N/A throws IOException, ClassNotFoundException {
286N/A throw new NotSerializableException(getClass().getName());
286N/A }
286N/A}