KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xerces > impl > xs > AttributePSVImpl


1 /*
2  * Copyright 2000-2002,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.xerces.impl.xs;
18
19 import org.apache.xerces.xs.ShortList;
20 import org.apache.xerces.xs.StringList;
21 import org.apache.xerces.xs.XSAttributeDeclaration;
22 import org.apache.xerces.xs.XSSimpleTypeDefinition;
23 import org.apache.xerces.xs.XSTypeDefinition;
24 import org.apache.xerces.impl.xs.util.StringListImpl;
25 import org.apache.xerces.xs.AttributePSVI;
26 import org.apache.xerces.xs.XSConstants;
27
28 /**
29  * Attribute PSV infoset augmentations implementation.
30  * The PSVI information for attributes will be available at the startElement call.
31  *
32  * @xerces.internal
33  *
34  * @author Elena Litani IBM
35  * @version $Id: AttributePSVImpl.java,v 1.22 2004/10/06 15:14:55 mrglavas Exp $
36  */

37 public class AttributePSVImpl implements AttributePSVI {
38
39     /** attribute declaration */
40     protected XSAttributeDeclaration fDeclaration = null;
41
42     /** type of attribute, simpleType */
43     protected XSTypeDefinition fTypeDecl = null;
44
45     /** If this attribute was explicitly given a
46      * value in the original document, this is false; otherwise, it is true */

47     protected boolean fSpecified = false;
48
49     /** schema normalized value property */
50     protected String JavaDoc fNormalizedValue = null;
51     
52     /** schema actual value */
53     protected Object JavaDoc fActualValue = null;
54
55     /** schema actual value type */
56     protected short fActualValueType = XSConstants.UNAVAILABLE_DT;
57
58     /** actual value types if the value is a list */
59     protected ShortList fItemValueTypes = null;
60
61     /** member type definition against which attribute was validated */
62     protected XSSimpleTypeDefinition fMemberType = null;
63
64     /** validation attempted: none, partial, full */
65     protected short fValidationAttempted = AttributePSVI.VALIDATION_NONE;
66
67     /** validity: valid, invalid, unknown */
68     protected short fValidity = AttributePSVI.VALIDITY_NOTKNOWN;
69
70     /** error codes */
71     protected String JavaDoc[] fErrorCodes = null;
72
73     /** validation context: could be QName or XPath expression*/
74     protected String JavaDoc fValidationContext = null;
75
76     //
77
// AttributePSVI methods
78
//
79

80     /**
81      * [schema default]
82      *
83      * @return The canonical lexical representation of the declaration's {value constraint} value.
84      * @see <a HREF="http://www.w3.org/TR/xmlschema-1/#e-schema_default>XML Schema Part 1: Structures [schema default]</a>
85      */

86     public String JavaDoc getSchemaDefault() {
87         return fDeclaration == null ? null : fDeclaration.getConstraintValue();
88     }
89
90     /**
91      * [schema normalized value]
92      *
93      *
94      * @see <a HREF="http://www.w3.org/TR/xmlschema-1/#e-schema_normalized_value>XML Schema Part 1: Structures [schema normalized value]</a>
95      * @return the normalized value of this item after validation
96      */

97     public String JavaDoc getSchemaNormalizedValue() {
98         return fNormalizedValue;
99     }
100
101     /**
102      * [schema specified]
103      * @see <a HREF="http://www.w3.org/TR/xmlschema-1/#e-schema_specified">XML Schema Part 1: Structures [schema specified]</a>
104      * @return true - value was specified in schema, false - value comes from the infoset
105      */

106     public boolean getIsSchemaSpecified() {
107         return fSpecified;
108     }
109
110
111     /**
112      * Determines the extent to which the document has been validated
113      *
114      * @return return the [validation attempted] property. The possible values are
115      * NO_VALIDATION, PARTIAL_VALIDATION and FULL_VALIDATION
116      */

117     public short getValidationAttempted() {
118         return fValidationAttempted;
119     }
120
121     /**
122      * Determine the validity of the node with respect
123      * to the validation being attempted
124      *
125      * @return return the [validity] property. Possible values are:
126      * UNKNOWN_VALIDITY, INVALID_VALIDITY, VALID_VALIDITY
127      */

128     public short getValidity() {
129         return fValidity;
130     }
131
132     /**
133      * A list of error codes generated from validation attempts.
134      * Need to find all the possible subclause reports that need reporting
135      *
136      * @return list of error codes
137      */

138     public StringList getErrorCodes() {
139         if (fErrorCodes == null)
140             return null;
141         return new StringListImpl(fErrorCodes, fErrorCodes.length);
142     }
143
144     // This is the only information we can provide in a pipeline.
145
public String JavaDoc getValidationContext() {
146         return fValidationContext;
147     }
148
149     /**
150      * An item isomorphic to the type definition used to validate this element.
151      *
152      * @return a type declaration
153      */

154     public XSTypeDefinition getTypeDefinition() {
155         return fTypeDecl;
156     }
157
158     /**
159      * If and only if that type definition is a simple type definition
160      * with {variety} union, or a complex type definition whose {content type}
161      * is a simple thype definition with {variety} union, then an item isomorphic
162      * to that member of the union's {member type definitions} which actually
163      * validated the element item's normalized value.
164      *
165      * @return a simple type declaration
166      */

167     public XSSimpleTypeDefinition getMemberTypeDefinition() {
168         return fMemberType;
169     }
170
171     /**
172      * An item isomorphic to the attribute declaration used to validate
173      * this attribute.
174      *
175      * @return an attribute declaration
176      */

177     public XSAttributeDeclaration getAttributeDeclaration() {
178         return fDeclaration;
179     }
180     
181     /* (non-Javadoc)
182      * @see org.apache.xerces.xs.ItemPSVI#getActualNormalizedValue()
183      */

184     public Object JavaDoc getActualNormalizedValue() {
185         return this.fActualValue;
186     }
187
188     /* (non-Javadoc)
189      * @see org.apache.xerces.xs.ItemPSVI#getActualNormalizedValueType()
190      */

191     public short getActualNormalizedValueType() {
192         return this.fActualValueType;
193     }
194
195     /* (non-Javadoc)
196      * @see org.apache.xerces.xs.ItemPSVI#getItemValueTypes()
197      */

198     public ShortList getItemValueTypes() {
199         return this.fItemValueTypes;
200     }
201
202     /**
203      * Reset()
204      */

205     public void reset() {
206         fNormalizedValue = null;
207         fActualValue = null;
208         fActualValueType = XSConstants.UNAVAILABLE_DT;
209         fItemValueTypes = null;
210         fDeclaration = null;
211         fTypeDecl = null;
212         fSpecified = false;
213         fMemberType = null;
214         fValidationAttempted = AttributePSVI.VALIDATION_NONE;
215         fValidity = AttributePSVI.VALIDITY_NOTKNOWN;
216         fErrorCodes = null;
217         fValidationContext = null;
218     }
219 }
220
Popular Tags