1 /* 2 * reserved comment block 3 * DO NOT REMOVE OR ALTER! 4 */ 5 /* 6 * Copyright 2000-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.impl.xs; 22 23 import com.sun.org.apache.xerces.internal.xs.ShortList; 24 import com.sun.org.apache.xerces.internal.xs.StringList; 25 import com.sun.org.apache.xerces.internal.xs.XSAttributeDeclaration; 26 import com.sun.org.apache.xerces.internal.xs.XSSimpleTypeDefinition; 27 import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition; 28 import com.sun.org.apache.xerces.internal.impl.xs.util.StringListImpl; 29 import com.sun.org.apache.xerces.internal.xs.AttributePSVI; 30 import com.sun.org.apache.xerces.internal.xs.XSConstants; 31 32 /** 33 * Attribute PSV infoset augmentations implementation. 34 * The PSVI information for attributes will be available at the startElement call. 35 * 36 * @xerces.internal 37 * 38 * @author Elena Litani IBM 39 */ 40 public class AttributePSVImpl implements AttributePSVI { 41 42 /** attribute declaration */ 43 protected XSAttributeDeclaration fDeclaration = null; 44 45 /** type of attribute, simpleType */ 46 protected XSTypeDefinition fTypeDecl = null; 47 48 /** If this attribute was explicitly given a 49 * value in the original document, this is false; otherwise, it is true */ 50 protected boolean fSpecified = false; 51 52 /** schema normalized value property */ 53 protected String fNormalizedValue = null; 54 55 /** schema actual value */ 56 protected Object fActualValue = null; 57 58 /** schema actual value type */ 59 protected short fActualValueType = XSConstants.UNAVAILABLE_DT; 60 61 /** actual value types if the value is a list */ 62 protected ShortList fItemValueTypes = null; 63 64 /** member type definition against which attribute was validated */ 65 protected XSSimpleTypeDefinition fMemberType = null; 66 67 /** validation attempted: none, partial, full */ 68 protected short fValidationAttempted = AttributePSVI.VALIDATION_NONE; 69 70 /** validity: valid, invalid, unknown */ 71 protected short fValidity = AttributePSVI.VALIDITY_NOTKNOWN; 72 73 /** error codes */ 74 protected String[] fErrorCodes = null; 75 76 /** validation context: could be QName or XPath expression*/ 77 protected String fValidationContext = null; 78 79 // 80 // AttributePSVI methods 81 // 82 83 /** 84 * [schema default] 85 * 86 * @return The canonical lexical representation of the declaration's {value constraint} value. 87 * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_default>XML Schema Part 1: Structures [schema default]</a> 88 */ getSchemaDefault()89 public String getSchemaDefault() { 90 return fDeclaration == null ? null : fDeclaration.getConstraintValue(); 91 } 92 93 /** 94 * [schema normalized value] 95 * 96 * 97 * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_normalized_value>XML Schema Part 1: Structures [schema normalized value]</a> 98 * @return the normalized value of this item after validation 99 */ getSchemaNormalizedValue()100 public String getSchemaNormalizedValue() { 101 return fNormalizedValue; 102 } 103 104 /** 105 * [schema specified] 106 * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_specified">XML Schema Part 1: Structures [schema specified]</a> 107 * @return true - value was specified in schema, false - value comes from the infoset 108 */ getIsSchemaSpecified()109 public boolean getIsSchemaSpecified() { 110 return fSpecified; 111 } 112 113 114 /** 115 * Determines the extent to which the document has been validated 116 * 117 * @return return the [validation attempted] property. The possible values are 118 * NO_VALIDATION, PARTIAL_VALIDATION and FULL_VALIDATION 119 */ getValidationAttempted()120 public short getValidationAttempted() { 121 return fValidationAttempted; 122 } 123 124 /** 125 * Determine the validity of the node with respect 126 * to the validation being attempted 127 * 128 * @return return the [validity] property. Possible values are: 129 * UNKNOWN_VALIDITY, INVALID_VALIDITY, VALID_VALIDITY 130 */ getValidity()131 public short getValidity() { 132 return fValidity; 133 } 134 135 /** 136 * A list of error codes generated from validation attempts. 137 * Need to find all the possible subclause reports that need reporting 138 * 139 * @return list of error codes 140 */ getErrorCodes()141 public StringList getErrorCodes() { 142 if (fErrorCodes == null) 143 return null; 144 return new StringListImpl(fErrorCodes, fErrorCodes.length); 145 } 146 147 // This is the only information we can provide in a pipeline. getValidationContext()148 public String getValidationContext() { 149 return fValidationContext; 150 } 151 152 /** 153 * An item isomorphic to the type definition used to validate this element. 154 * 155 * @return a type declaration 156 */ getTypeDefinition()157 public XSTypeDefinition getTypeDefinition() { 158 return fTypeDecl; 159 } 160 161 /** 162 * If and only if that type definition is a simple type definition 163 * with {variety} union, or a complex type definition whose {content type} 164 * is a simple thype definition with {variety} union, then an item isomorphic 165 * to that member of the union's {member type definitions} which actually 166 * validated the element item's normalized value. 167 * 168 * @return a simple type declaration 169 */ getMemberTypeDefinition()170 public XSSimpleTypeDefinition getMemberTypeDefinition() { 171 return fMemberType; 172 } 173 174 /** 175 * An item isomorphic to the attribute declaration used to validate 176 * this attribute. 177 * 178 * @return an attribute declaration 179 */ getAttributeDeclaration()180 public XSAttributeDeclaration getAttributeDeclaration() { 181 return fDeclaration; 182 } 183 184 /* (non-Javadoc) 185 * @see com.sun.org.apache.xerces.internal.xs.ItemPSVI#getActualNormalizedValue() 186 */ getActualNormalizedValue()187 public Object getActualNormalizedValue() { 188 return this.fActualValue; 189 } 190 191 /* (non-Javadoc) 192 * @see com.sun.org.apache.xerces.internal.xs.ItemPSVI#getActualNormalizedValueType() 193 */ getActualNormalizedValueType()194 public short getActualNormalizedValueType() { 195 return this.fActualValueType; 196 } 197 198 /* (non-Javadoc) 199 * @see com.sun.org.apache.xerces.internal.xs.ItemPSVI#getItemValueTypes() 200 */ getItemValueTypes()201 public ShortList getItemValueTypes() { 202 return this.fItemValueTypes; 203 } 204 205 /** 206 * Reset() 207 */ reset()208 public void reset() { 209 fNormalizedValue = null; 210 fActualValue = null; 211 fActualValueType = XSConstants.UNAVAILABLE_DT; 212 fItemValueTypes = null; 213 fDeclaration = null; 214 fTypeDecl = null; 215 fSpecified = false; 216 fMemberType = null; 217 fValidationAttempted = AttributePSVI.VALIDATION_NONE; 218 fValidity = AttributePSVI.VALIDITY_NOTKNOWN; 219 fErrorCodes = null; 220 fValidationContext = null; 221 } 222 } 223