KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > org > apache > xerces > internal > dom > PSVIAttrNSImpl


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 2002-2004 The Apache Software Foundation. All rights
6  * 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) 1999, 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.dom;
59
60 import java.io.IOException JavaDoc;
61 import java.io.NotSerializableException JavaDoc;
62 import java.io.ObjectInputStream JavaDoc;
63 import java.io.ObjectOutputStream JavaDoc;
64
65 import com.sun.org.apache.xerces.internal.xs.AttributePSVI;
66 import com.sun.org.apache.xerces.internal.xs.*;
67
68 /**
69  * Attribute namespace implementation; stores PSVI attribute items.
70  *
71  * @author Sandy Gao, IBM
72  *
73  * @version $Id: PSVIAttrNSImpl.java,v 1.7 2004/02/05 18:26:31 mrglavas Exp $
74  */

75 public class PSVIAttrNSImpl extends AttrNSImpl implements AttributePSVI {
76
77     /** Serialization version. */
78     static final long serialVersionUID = -3241738699421018889L;
79
80     /**
81      * Construct an attribute node.
82      */

83     public PSVIAttrNSImpl(CoreDocumentImpl ownerDocument, String JavaDoc namespaceURI,
84                           String JavaDoc qualifiedName, String JavaDoc localName) {
85         super(ownerDocument, namespaceURI, qualifiedName, localName);
86     }
87     
88     /**
89      * Construct an attribute node.
90      */

91     public PSVIAttrNSImpl(CoreDocumentImpl ownerDocument, String JavaDoc namespaceURI,
92                           String JavaDoc qualifiedName) {
93         super(ownerDocument, namespaceURI, qualifiedName);
94     }
95     
96     /** attribute declaration */
97     protected XSAttributeDeclaration fDeclaration = null;
98
99     /** type of attribute, simpleType */
100     protected XSTypeDefinition fTypeDecl = null;
101
102     /** If this attribute was explicitly given a
103      * value in the original document, this is true; otherwise, it is false */

104     protected boolean fSpecified = true;
105
106     /** schema normalized value property */
107     protected String JavaDoc fNormalizedValue = null;
108     
109     /** schema actual value */
110     protected Object JavaDoc fActualValue = null;
111
112     /** schema actual value type */
113     protected short fActualValueType = XSConstants.UNAVAILABLE_DT;
114
115     /** actual value types if the value is a list */
116     protected ShortList fItemValueTypes = null;
117
118     /** member type definition against which attribute was validated */
119     protected XSSimpleTypeDefinition fMemberType = null;
120
121     /** validation attempted: none, partial, full */
122     protected short fValidationAttempted = AttributePSVI.VALIDATION_NONE;
123
124     /** validity: valid, invalid, unknown */
125     protected short fValidity = AttributePSVI.VALIDITY_NOTKNOWN;
126
127     /** error codes */
128     protected StringList fErrorCodes = null;
129
130     /** validation context: could be QName or XPath expression*/
131     protected String JavaDoc fValidationContext = null;
132
133     //
134
// AttributePSVI methods
135
//
136

137     /**
138      * [schema default]
139      *
140      * @return The canonical lexical representation of the declaration's {value constraint} value.
141      * @see <a HREF="http://www.w3.org/TR/xmlschema-1/#e-schema_default>XML Schema Part 1: Structures [schema default]</a>
142      */

143     public String JavaDoc getSchemaDefault() {
144         return fDeclaration == null ? null : fDeclaration.getConstraintValue();
145     }
146
147     /**
148      * [schema normalized value]
149      *
150      *
151      * @see <a HREF="http://www.w3.org/TR/xmlschema-1/#e-schema_normalized_value>XML Schema Part 1: Structures [schema normalized value]</a>
152      * @return the normalized value of this item after validation
153      */

154     public String JavaDoc getSchemaNormalizedValue() {
155         return fNormalizedValue;
156     }
157
158     /**
159      * [schema specified]
160      * @see <a HREF="http://www.w3.org/TR/xmlschema-1/#e-schema_specified">XML Schema Part 1: Structures [schema specified]</a>
161      * @return false value was specified in schema, true value comes from the infoset
162      */

163     public boolean getIsSchemaSpecified() {
164         return fSpecified;
165     }
166
167
168     /**
169      * Determines the extent to which the document has been validated
170      *
171      * @return return the [validation attempted] property. The possible values are
172      * NO_VALIDATION, PARTIAL_VALIDATION and FULL_VALIDATION
173      */

174     public short getValidationAttempted() {
175         return fValidationAttempted;
176     }
177
178     /**
179      * Determine the validity of the node with respect
180      * to the validation being attempted
181      *
182      * @return return the [validity] property. Possible values are:
183      * UNKNOWN_VALIDITY, INVALID_VALIDITY, VALID_VALIDITY
184      */

185     public short getValidity() {
186         return fValidity;
187     }
188
189     /**
190      * A list of error codes generated from validation attempts.
191      * Need to find all the possible subclause reports that need reporting
192      *
193      * @return list of error codes
194      */

195     public StringList getErrorCodes() {
196         return fErrorCodes;
197     }
198
199     // This is the only information we can provide in a pipeline.
200
public String JavaDoc getValidationContext() {
201         return fValidationContext;
202     }
203
204     /**
205      * An item isomorphic to the type definition used to validate this element.
206      *
207      * @return a type declaration
208      */

209     public XSTypeDefinition getTypeDefinition() {
210         return fTypeDecl;
211     }
212
213     /**
214      * If and only if that type definition is a simple type definition
215      * with {variety} union, or a complex type definition whose {content type}
216      * is a simple thype definition with {variety} union, then an item isomorphic
217      * to that member of the union's {member type definitions} which actually
218      * validated the element item's normalized value.
219      *
220      * @return a simple type declaration
221      */

222     public XSSimpleTypeDefinition getMemberTypeDefinition() {
223         return fMemberType;
224     }
225
226     /**
227      * An item isomorphic to the attribute declaration used to validate
228      * this attribute.
229      *
230      * @return an attribute declaration
231      */

232     public XSAttributeDeclaration getAttributeDeclaration() {
233         return fDeclaration;
234     }
235
236     /**
237      * Copy PSVI properties from another psvi item.
238      *
239      * @param attr the source of attribute PSVI items
240      */

241     public void setPSVI(AttributePSVI attr) {
242         this.fDeclaration = attr.getAttributeDeclaration();
243         this.fValidationContext = attr.getValidationContext();
244         this.fValidity = attr.getValidity();
245         this.fValidationAttempted = attr.getValidationAttempted();
246         this.fErrorCodes = attr.getErrorCodes();
247         this.fNormalizedValue = attr.getSchemaNormalizedValue();
248         this.fActualValue = attr.getActualNormalizedValue();
249         this.fActualValueType = attr.getActualNormalizedValueType();
250         this.fItemValueTypes = attr.getItemValueTypes();
251         this.fTypeDecl = attr.getTypeDefinition();
252         this.fMemberType = attr.getMemberTypeDefinition();
253         this.fSpecified = attr.getIsSchemaSpecified();
254     }
255     
256     /* (non-Javadoc)
257      * @see com.sun.org.apache.xerces.internal.xs.ItemPSVI#getActualNormalizedValue()
258      */

259     public Object JavaDoc getActualNormalizedValue() {
260         return this.fActualValue;
261     }
262
263     /* (non-Javadoc)
264      * @see com.sun.org.apache.xerces.internal.xs.ItemPSVI#getActualNormalizedValueType()
265      */

266     public short getActualNormalizedValueType() {
267         return this.fActualValueType;
268     }
269
270     /* (non-Javadoc)
271      * @see com.sun.org.apache.xerces.internal.xs.ItemPSVI#getItemValueTypes()
272      */

273     public ShortList getItemValueTypes() {
274         return this.fItemValueTypes;
275     }
276     
277     // REVISIT: Forbid serialization of PSVI DOM until
278
// we support object serialization of grammars -- mrglavas
279

280     private void writeObject(ObjectOutputStream JavaDoc out)
281         throws IOException JavaDoc {
282         throw new NotSerializableException JavaDoc(getClass().getName());
283     }
284
285     private void readObject(ObjectInputStream JavaDoc in)
286         throws IOException JavaDoc, ClassNotFoundException JavaDoc {
287         throw new NotSerializableException JavaDoc(getClass().getName());
288     }
289 }
290
Popular Tags