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.ElementPSVI; 29 import com.sun.org.apache.xerces.internal.xs.*; 30 31 /** 32 * Element namespace implementation; stores PSVI element items. 33 * 34 * @xerces.internal 35 * 36 * @author Sandy Gao, IBM 37 * 38 */ 39 public class PSVIElementNSImpl extends ElementNSImpl implements ElementPSVI { 40 41 /** Serialization version. */ 42 static final long serialVersionUID = 6815489624636016068L; 43 44 /** 45 * Construct an element node. 46 */ 47 public PSVIElementNSImpl(CoreDocumentImpl ownerDocument, String namespaceURI, 48 String qualifiedName, String localName) { 49 super(ownerDocument, namespaceURI, qualifiedName, localName); 50 } 51 52 /** 53 * Construct an element node. 54 */ 55 public PSVIElementNSImpl(CoreDocumentImpl ownerDocument, String namespaceURI, 56 String qualifiedName) { 57 super(ownerDocument, namespaceURI, qualifiedName); 58 } 59 60 /** element declaration */ 61 protected XSElementDeclaration fDeclaration = null; 62 63 /** type of element, could be xsi:type */ 64 protected XSTypeDefinition fTypeDecl = null; 65 66 /** true if clause 3.2 of Element Locally Valid (Element) (3.3.4) 67 * is satisfied, otherwise false 68 */ 69 protected boolean fNil = false; 70 71 /** false if the element value was provided by the schema; true otherwise. 72 */ 73 protected boolean fSpecified = true; 74 75 /** schema normalized value property */ 76 protected String fNormalizedValue = null; 77 78 /** schema actual value */ 79 protected Object fActualValue = null; 80 81 /** schema actual value type */ 82 protected short fActualValueType = XSConstants.UNAVAILABLE_DT; 83 84 /** actual value types if the value is a list */ 85 protected ShortList fItemValueTypes = null; 86 87 /** http://www.w3.org/TR/xmlschema-1/#e-notation*/ 88 protected XSNotationDeclaration fNotation = null; 89 90 /** member type definition against which element was validated */ 91 protected XSSimpleTypeDefinition fMemberType = null; 92 93 /** validation attempted: none, partial, full */ 94 protected short fValidationAttempted = ElementPSVI.VALIDATION_NONE; 95 96 /** validity: valid, invalid, unknown */ 97 protected short fValidity = ElementPSVI.VALIDITY_NOTKNOWN; 98 99 /** error codes */ 100 protected StringList fErrorCodes = null; 101 102 /** validation context: could be QName or XPath expression*/ 103 protected String fValidationContext = null; 104 105 /** the schema information property */ 106 protected XSModel fSchemaInformation = null; 107 108 // 109 // ElementPSVI methods 110 // 111 112 /** 113 * [schema default] 114 * 115 * @return The canonical lexical representation of the declaration's {value constraint} value. 116 * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_default>XML Schema Part 1: Structures [schema default]</a> 117 */ 118 public String getSchemaDefault() { 119 return fDeclaration == null ? null : fDeclaration.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 174 // This is the only information we can provide in a pipeline. 175 public String getValidationContext() { 176 return fValidationContext; 177 } 178 179 /** 180 * [nil] 181 * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-nil>XML Schema Part 1: Structures [nil]</a> 182 * @return true if clause 3.2 of Element Locally Valid (Element) (3.3.4) above is satisfied, otherwise false 183 */ 184 public boolean getNil() { 185 return fNil; 186 } 187 188 /** 189 * [notation] 190 * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-notation>XML Schema Part 1: Structures [notation]</a> 191 * @return The notation declaration. 192 */ 193 public XSNotationDeclaration getNotation() { 194 return fNotation; 195 } 196 197 /** 198 * An item isomorphic to the type definition used to validate this element. 199 * 200 * @return a type declaration 201 */ 202 public XSTypeDefinition getTypeDefinition() { 203 return fTypeDecl; 204 } 205 206 /** 207 * If and only if that type definition is a simple type definition 208 * with {variety} union, or a complex type definition whose {content type} 209 * is a simple thype definition with {variety} union, then an item isomorphic 210 * to that member of the union's {member type definitions} which actually 211 * validated the element item's normalized value. 212 * 213 * @return a simple type declaration 214 */ 215 public XSSimpleTypeDefinition getMemberTypeDefinition() { 216 return fMemberType; 217 } 218 219 /** 220 * An item isomorphic to the element declaration used to validate 221 * this element. 222 * 223 * @return an element declaration 224 */ 225 public XSElementDeclaration getElementDeclaration() { 226 return fDeclaration; 227 } 228 229 /** 230 * [schema information] 231 * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_information">XML Schema Part 1: Structures [schema information]</a> 232 * @return The schema information property if it's the validation root, 233 * null otherwise. 234 */ 235 public XSModel getSchemaInformation() { 236 return fSchemaInformation; 237 } 238 239 /** 240 * Copy PSVI properties from another psvi item. 241 * 242 * @param attr the source of attribute PSVI items 243 */ 244 public void setPSVI(ElementPSVI elem) { 245 this.fDeclaration = elem.getElementDeclaration(); 246 this.fNotation = elem.getNotation(); 247 this.fValidationContext = elem.getValidationContext(); 248 this.fTypeDecl = elem.getTypeDefinition(); 249 this.fSchemaInformation = elem.getSchemaInformation(); 250 this.fValidity = elem.getValidity(); 251 this.fValidationAttempted = elem.getValidationAttempted(); 252 this.fErrorCodes = elem.getErrorCodes(); 253 this.fNormalizedValue = elem.getSchemaNormalizedValue(); 254 this.fActualValue = elem.getActualNormalizedValue(); 255 this.fActualValueType = elem.getActualNormalizedValueType(); 256 this.fItemValueTypes = elem.getItemValueTypes(); 257 this.fMemberType = elem.getMemberTypeDefinition(); 258 this.fSpecified = elem.getIsSchemaSpecified(); 259 this.fNil = elem.getNil(); 260 } 261 262 /* (non-Javadoc) 263 * @see com.sun.org.apache.xerces.internal.xs.ItemPSVI#getActualNormalizedValue() 264 */ 265 public Object getActualNormalizedValue() { 266 return this.fActualValue; 267 } 268 269 /* (non-Javadoc) 270 * @see com.sun.org.apache.xerces.internal.xs.ItemPSVI#getActualNormalizedValueType() 271 */ 272 public short getActualNormalizedValueType() { 273 return this.fActualValueType; 274 } 275 276 /* (non-Javadoc) 277 * @see com.sun.org.apache.xerces.internal.xs.ItemPSVI#getItemValueTypes() 278 */ 279 public ShortList getItemValueTypes() { 280 return this.fItemValueTypes; 281 } 282 283 // REVISIT: Forbid serialization of PSVI DOM until 284 // we support object serialization of grammars -- mrglavas 285 286 private void writeObject(ObjectOutputStream out) 287 throws IOException { 288 throw new NotSerializableException(getClass().getName()); 289 } 290 291 private void readObject(ObjectInputStream in) 292 throws IOException, ClassNotFoundException { 293 throw new NotSerializableException(getClass().getName()); 294 } 295 }