Save This Page
Home » openjdk-7 » com.sun.org.apache.xerces.internal » dom » [javadoc | source]
    1   /*
    2    * reserved comment block
    3    * DO NOT REMOVE OR ALTER!
    4    */
    5   /*
    6    * Copyright 2002-2004 The Apache Software Foundation.
    7    *
    8    * Licensed under the Apache License, Version 2.0 (the "License");
    9    * you may not use this file except in compliance with the License.
   10    * You may obtain a copy of the License at
   11    *
   12    *      http://www.apache.org/licenses/LICENSE-2.0
   13    *
   14    * Unless required by applicable law or agreed to in writing, software
   15    * distributed under the License is distributed on an "AS IS" BASIS,
   16    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   17    * See the License for the specific language governing permissions and
   18    * limitations under the License.
   19    */
   20   
   21   package com.sun.org.apache.xerces.internal.dom;
   22   
   23   import java.io.IOException;
   24   import java.io.NotSerializableException;
   25   import java.io.ObjectInputStream;
   26   import java.io.ObjectOutputStream;
   27   
   28   import com.sun.org.apache.xerces.internal.xs.AttributePSVI;
   29   import com.sun.org.apache.xerces.internal.xs;
   30   
   31   /**
   32    * Attribute namespace implementation; stores PSVI attribute items.
   33    *
   34    * @xerces.internal
   35    *
   36    * @author Sandy Gao, IBM
   37    *
   38    */
   39   public class PSVIAttrNSImpl extends AttrNSImpl implements AttributePSVI {
   40   
   41       /** Serialization version. */
   42       static final long serialVersionUID = -3241738699421018889L;
   43   
   44       /**
   45        * Construct an attribute node.
   46        */
   47       public PSVIAttrNSImpl(CoreDocumentImpl ownerDocument, String namespaceURI,
   48                             String qualifiedName, String localName) {
   49           super(ownerDocument, namespaceURI, qualifiedName, localName);
   50       }
   51   
   52       /**
   53        * Construct an attribute node.
   54        */
   55       public PSVIAttrNSImpl(CoreDocumentImpl ownerDocument, String namespaceURI,
   56                             String qualifiedName) {
   57           super(ownerDocument, namespaceURI, qualifiedName);
   58       }
   59   
   60       /** attribute declaration */
   61       protected XSAttributeDeclaration fDeclaration = null;
   62   
   63       /** type of attribute, simpleType */
   64       protected XSTypeDefinition fTypeDecl = null;
   65   
   66       /** If this attribute was explicitly given a
   67        * value in the original document, this is true; otherwise, it is false  */
   68       protected boolean fSpecified = true;
   69   
   70       /** schema normalized value property */
   71       protected String fNormalizedValue = null;
   72   
   73       /** schema actual value */
   74       protected Object fActualValue = null;
   75   
   76       /** schema actual value type */
   77       protected short fActualValueType = XSConstants.UNAVAILABLE_DT;
   78   
   79       /** actual value types if the value is a list */
   80       protected ShortList fItemValueTypes = null;
   81   
   82       /** member type definition against which attribute was validated */
   83       protected XSSimpleTypeDefinition fMemberType = null;
   84   
   85       /** validation attempted: none, partial, full */
   86       protected short fValidationAttempted = AttributePSVI.VALIDATION_NONE;
   87   
   88       /** validity: valid, invalid, unknown */
   89       protected short fValidity = AttributePSVI.VALIDITY_NOTKNOWN;
   90   
   91       /** error codes */
   92       protected StringList fErrorCodes = null;
   93   
   94       /** validation context: could be QName or XPath expression*/
   95       protected String fValidationContext = null;
   96   
   97       //
   98       // AttributePSVI methods
   99       //
  100   
  101       /**
  102        * [schema default]
  103        *
  104        * @return The canonical lexical representation of the declaration's {value constraint} value.
  105        * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_default>XML Schema Part 1: Structures [schema default]</a>
  106        */
  107       public String getSchemaDefault() {
  108           return fDeclaration == null ? null : fDeclaration.getConstraintValue();
  109       }
  110   
  111       /**
  112        * [schema normalized value]
  113        *
  114        *
  115        * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_normalized_value>XML Schema Part 1: Structures [schema normalized value]</a>
  116        * @return the normalized value of this item after validation
  117        */
  118       public String getSchemaNormalizedValue() {
  119           return fNormalizedValue;
  120       }
  121   
  122       /**
  123        * [schema specified]
  124        * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_specified">XML Schema Part 1: Structures [schema specified]</a>
  125        * @return false value was specified in schema, true value comes from the infoset
  126        */
  127       public boolean getIsSchemaSpecified() {
  128           return fSpecified;
  129       }
  130   
  131   
  132       /**
  133        * Determines the extent to which the document has been validated
  134        *
  135        * @return return the [validation attempted] property. The possible values are
  136        *         NO_VALIDATION, PARTIAL_VALIDATION and FULL_VALIDATION
  137        */
  138       public short getValidationAttempted() {
  139           return fValidationAttempted;
  140       }
  141   
  142       /**
  143        * Determine the validity of the node with respect
  144        * to the validation being attempted
  145        *
  146        * @return return the [validity] property. Possible values are:
  147        *         UNKNOWN_VALIDITY, INVALID_VALIDITY, VALID_VALIDITY
  148        */
  149       public short getValidity() {
  150           return fValidity;
  151       }
  152   
  153       /**
  154        * A list of error codes generated from validation attempts.
  155        * Need to find all the possible subclause reports that need reporting
  156        *
  157        * @return list of error codes
  158        */
  159       public StringList getErrorCodes() {
  160           return fErrorCodes;
  161       }
  162   
  163       // This is the only information we can provide in a pipeline.
  164       public String getValidationContext() {
  165           return fValidationContext;
  166       }
  167   
  168       /**
  169        * An item isomorphic to the type definition used to validate this element.
  170        *
  171        * @return  a type declaration
  172        */
  173       public XSTypeDefinition getTypeDefinition() {
  174           return fTypeDecl;
  175       }
  176   
  177       /**
  178        * If and only if that type definition is a simple type definition
  179        * with {variety} union, or a complex type definition whose {content type}
  180        * is a simple thype definition with {variety} union, then an item isomorphic
  181        * to that member of the union's {member type definitions} which actually
  182        * validated the element item's normalized value.
  183        *
  184        * @return  a simple type declaration
  185        */
  186       public XSSimpleTypeDefinition getMemberTypeDefinition() {
  187           return fMemberType;
  188       }
  189   
  190       /**
  191        * An item isomorphic to the attribute declaration used to validate
  192        * this attribute.
  193        *
  194        * @return  an attribute declaration
  195        */
  196       public XSAttributeDeclaration getAttributeDeclaration() {
  197           return fDeclaration;
  198       }
  199   
  200       /**
  201        * Copy PSVI properties from another psvi item.
  202        *
  203        * @param attr  the source of attribute PSVI items
  204        */
  205       public void setPSVI(AttributePSVI attr) {
  206           this.fDeclaration = attr.getAttributeDeclaration();
  207           this.fValidationContext = attr.getValidationContext();
  208           this.fValidity = attr.getValidity();
  209           this.fValidationAttempted = attr.getValidationAttempted();
  210           this.fErrorCodes = attr.getErrorCodes();
  211           this.fNormalizedValue = attr.getSchemaNormalizedValue();
  212           this.fActualValue = attr.getActualNormalizedValue();
  213           this.fActualValueType = attr.getActualNormalizedValueType();
  214           this.fItemValueTypes = attr.getItemValueTypes();
  215           this.fTypeDecl = attr.getTypeDefinition();
  216           this.fMemberType = attr.getMemberTypeDefinition();
  217           this.fSpecified = attr.getIsSchemaSpecified();
  218       }
  219   
  220       /* (non-Javadoc)
  221        * @see com.sun.org.apache.xerces.internal.xs.ItemPSVI#getActualNormalizedValue()
  222        */
  223       public Object getActualNormalizedValue() {
  224           return this.fActualValue;
  225       }
  226   
  227       /* (non-Javadoc)
  228        * @see com.sun.org.apache.xerces.internal.xs.ItemPSVI#getActualNormalizedValueType()
  229        */
  230       public short getActualNormalizedValueType() {
  231           return this.fActualValueType;
  232       }
  233   
  234       /* (non-Javadoc)
  235        * @see com.sun.org.apache.xerces.internal.xs.ItemPSVI#getItemValueTypes()
  236        */
  237       public ShortList getItemValueTypes() {
  238           return this.fItemValueTypes;
  239       }
  240   
  241       // REVISIT: Forbid serialization of PSVI DOM until
  242       // we support object serialization of grammars -- mrglavas
  243   
  244       private void writeObject(ObjectOutputStream out)
  245           throws IOException {
  246           throw new NotSerializableException(getClass().getName());
  247       }
  248   
  249       private void readObject(ObjectInputStream in)
  250           throws IOException, ClassNotFoundException {
  251           throw new NotSerializableException(getClass().getName());
  252       }
  253   }

Save This Page
Home » openjdk-7 » com.sun.org.apache.xerces.internal » dom » [javadoc | source]