KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > org > apache > xerces > internal > impl > xs > AttributePSVImpl


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 2000-2002 The Apache Software Foundation.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Apache Software Foundation (http://www.apache.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "Xerces" and "Apache Software Foundation" must
28  * not be used to endorse or promote products derived from this
29  * software without prior written permission. For written
30  * permission, please contact apache@apache.org.
31  *
32  * 5. Products derived from this software may not be called "Apache",
33  * nor may "Apache" appear in their name, without prior written
34  * permission of the Apache Software Foundation.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47  * SUCH DAMAGE.
48  * ====================================================================
49  *
50  * This software consists of voluntary contributions made by many
51  * individuals on behalf of the Apache Software Foundation and was
52  * originally based on software copyright (c) 2001, International
53  * Business Machines, Inc., http://www.apache.org. For more
54  * information on the Apache Software Foundation, please see
55  * <http://www.apache.org/>.
56  */

57
58 package com.sun.org.apache.xerces.internal.impl.xs;
59
60 import com.sun.org.apache.xerces.internal.xs.ShortList;
61 import com.sun.org.apache.xerces.internal.xs.StringList;
62 import com.sun.org.apache.xerces.internal.xs.XSAttributeDeclaration;
63 import com.sun.org.apache.xerces.internal.xs.XSSimpleTypeDefinition;
64 import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition;
65 import com.sun.org.apache.xerces.internal.impl.xs.util.StringListImpl;
66 import com.sun.org.apache.xerces.internal.xs.AttributePSVI;
67 import com.sun.org.apache.xerces.internal.xs.XSConstants;
68
69 /**
70  * Attribute PSV infoset augmentations implementation.
71  * The PSVI information for attributes will be available at the startElement call.
72  *
73  * @author Elena Litani IBM
74  * @version $Id: AttributePSVImpl.java,v 1.20 2003/11/12 23:17:33 sandygao Exp $
75  */

76 public class AttributePSVImpl implements AttributePSVI {
77
78     /** attribute declaration */
79     protected XSAttributeDeclaration fDeclaration = null;
80
81     /** type of attribute, simpleType */
82     protected XSTypeDefinition fTypeDecl = null;
83
84     /** If this attribute was explicitly given a
85      * value in the original document, this is false; otherwise, it is true */

86     protected boolean fSpecified = false;
87
88     /** schema normalized value property */
89     protected String JavaDoc fNormalizedValue = null;
90     
91     /** schema actual value */
92     protected Object JavaDoc fActualValue = null;
93
94     /** schema actual value type */
95     protected short fActualValueType = XSConstants.UNAVAILABLE_DT;
96
97     /** actual value types if the value is a list */
98     protected ShortList fItemValueTypes = null;
99
100     /** member type definition against which attribute was validated */
101     protected XSSimpleTypeDefinition fMemberType = null;
102
103     /** validation attempted: none, partial, full */
104     protected short fValidationAttempted = AttributePSVI.VALIDATION_NONE;
105
106     /** validity: valid, invalid, unknown */
107     protected short fValidity = AttributePSVI.VALIDITY_NOTKNOWN;
108
109     /** error codes */
110     protected String JavaDoc[] fErrorCodes = null;
111
112     /** validation context: could be QName or XPath expression*/
113     protected String JavaDoc fValidationContext = null;
114
115     //
116
// AttributePSVI methods
117
//
118

119     /**
120      * [schema default]
121      *
122      * @return The canonical lexical representation of the declaration's {value constraint} value.
123      * @see <a HREF="http://www.w3.org/TR/xmlschema-1/#e-schema_default>XML Schema Part 1: Structures [schema default]</a>
124      */

125     public String JavaDoc getSchemaDefault() {
126         return fDeclaration == null ? null : fDeclaration.getConstraintValue();
127     }
128
129     /**
130      * [schema normalized value]
131      *
132      *
133      * @see <a HREF="http://www.w3.org/TR/xmlschema-1/#e-schema_normalized_value>XML Schema Part 1: Structures [schema normalized value]</a>
134      * @return the normalized value of this item after validation
135      */

136     public String JavaDoc getSchemaNormalizedValue() {
137         return fNormalizedValue;
138     }
139
140     /**
141      * [schema specified]
142      * @see <a HREF="http://www.w3.org/TR/xmlschema-1/#e-schema_specified">XML Schema Part 1: Structures [schema specified]</a>
143      * @return true - value was specified in schema, false - value comes from the infoset
144      */

145     public boolean getIsSchemaSpecified() {
146         return fSpecified;
147     }
148
149
150     /**
151      * Determines the extent to which the document has been validated
152      *
153      * @return return the [validation attempted] property. The possible values are
154      * NO_VALIDATION, PARTIAL_VALIDATION and FULL_VALIDATION
155      */

156     public short getValidationAttempted() {
157         return fValidationAttempted;
158     }
159
160     /**
161      * Determine the validity of the node with respect
162      * to the validation being attempted
163      *
164      * @return return the [validity] property. Possible values are:
165      * UNKNOWN_VALIDITY, INVALID_VALIDITY, VALID_VALIDITY
166      */

167     public short getValidity() {
168         return fValidity;
169     }
170
171     /**
172      * A list of error codes generated from validation attempts.
173      * Need to find all the possible subclause reports that need reporting
174      *
175      * @return list of error codes
176      */

177     public StringList getErrorCodes() {
178         if (fErrorCodes == null)
179             return null;
180         return new StringListImpl(fErrorCodes, fErrorCodes.length);
181     }
182
183     // This is the only information we can provide in a pipeline.
184
public String JavaDoc getValidationContext() {
185         return fValidationContext;
186     }
187
188     /**
189      * An item isomorphic to the type definition used to validate this element.
190      *
191      * @return a type declaration
192      */

193     public XSTypeDefinition getTypeDefinition() {
194         return fTypeDecl;
195     }
196
197     /**
198      * If and only if that type definition is a simple type definition
199      * with {variety} union, or a complex type definition whose {content type}
200      * is a simple thype definition with {variety} union, then an item isomorphic
201      * to that member of the union's {member type definitions} which actually
202      * validated the element item's normalized value.
203      *
204      * @return a simple type declaration
205      */

206     public XSSimpleTypeDefinition getMemberTypeDefinition() {
207         return fMemberType;
208     }
209
210     /**
211      * An item isomorphic to the attribute declaration used to validate
212      * this attribute.
213      *
214      * @return an attribute declaration
215      */

216     public XSAttributeDeclaration getAttributeDeclaration() {
217         return fDeclaration;
218     }
219     
220     /* (non-Javadoc)
221      * @see com.sun.org.apache.xerces.internal.xs.ItemPSVI#getActualNormalizedValue()
222      */

223     public Object JavaDoc 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     /**
242      * Reset()
243      */

244     public void reset() {
245         fNormalizedValue = null;
246         fActualValue = null;
247         fActualValueType = XSConstants.UNAVAILABLE_DT;
248         fItemValueTypes = null;
249         fDeclaration = null;
250         fTypeDecl = null;
251         fSpecified = false;
252         fMemberType = null;
253         fValidationAttempted = AttributePSVI.VALIDATION_NONE;
254         fValidity = AttributePSVI.VALIDITY_NOTKNOWN;
255         fErrorCodes = null;
256         fValidationContext = null;
257     }
258 }
259
Popular Tags