KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xerces > dom > PSVIAttrNSImpl


1 /*
2  * Copyright 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.dom;
18
19 import java.io.IOException JavaDoc;
20 import java.io.NotSerializableException JavaDoc;
21 import java.io.ObjectInputStream JavaDoc;
22 import java.io.ObjectOutputStream JavaDoc;
23
24 import org.apache.xerces.xs.AttributePSVI;
25 import org.apache.xerces.xs.*;
26
27 /**
28  * Attribute namespace implementation; stores PSVI attribute items.
29  *
30  * @xerces.internal
31  *
32  * @author Sandy Gao, IBM
33  *
34  * @version $Id: PSVIAttrNSImpl.java,v 1.9 2004/10/05 17:12:51 mrglavas Exp $
35  */

36 public class PSVIAttrNSImpl extends AttrNSImpl implements AttributePSVI {
37
38     /** Serialization version. */
39     static final long serialVersionUID = -3241738699421018889L;
40
41     /**
42      * Construct an attribute node.
43      */

44     public PSVIAttrNSImpl(CoreDocumentImpl ownerDocument, String JavaDoc namespaceURI,
45                           String JavaDoc qualifiedName, String JavaDoc localName) {
46         super(ownerDocument, namespaceURI, qualifiedName, localName);
47     }
48     
49     /**
50      * Construct an attribute node.
51      */

52     public PSVIAttrNSImpl(CoreDocumentImpl ownerDocument, String JavaDoc namespaceURI,
53                           String JavaDoc qualifiedName) {
54         super(ownerDocument, namespaceURI, qualifiedName);
55     }
56     
57     /** attribute declaration */
58     protected XSAttributeDeclaration fDeclaration = null;
59
60     /** type of attribute, simpleType */
61     protected XSTypeDefinition fTypeDecl = null;
62
63     /** If this attribute was explicitly given a
64      * value in the original document, this is true; otherwise, it is false */

65     protected boolean fSpecified = true;
66
67     /** schema normalized value property */
68     protected String JavaDoc fNormalizedValue = null;
69     
70     /** schema actual value */
71     protected Object JavaDoc fActualValue = null;
72
73     /** schema actual value type */
74     protected short fActualValueType = XSConstants.UNAVAILABLE_DT;
75
76     /** actual value types if the value is a list */
77     protected ShortList fItemValueTypes = null;
78
79     /** member type definition against which attribute was validated */
80     protected XSSimpleTypeDefinition fMemberType = null;
81
82     /** validation attempted: none, partial, full */
83     protected short fValidationAttempted = AttributePSVI.VALIDATION_NONE;
84
85     /** validity: valid, invalid, unknown */
86     protected short fValidity = AttributePSVI.VALIDITY_NOTKNOWN;
87
88     /** error codes */
89     protected StringList fErrorCodes = null;
90
91     /** validation context: could be QName or XPath expression*/
92     protected String JavaDoc fValidationContext = null;
93
94     //
95
// AttributePSVI methods
96
//
97

98     /**
99      * [schema default]
100      *
101      * @return The canonical lexical representation of the declaration's {value constraint} value.
102      * @see <a HREF="http://www.w3.org/TR/xmlschema-1/#e-schema_default>XML Schema Part 1: Structures [schema default]</a>
103      */

104     public String JavaDoc getSchemaDefault() {
105         return fDeclaration == null ? null : fDeclaration.getConstraintValue();
106     }
107
108     /**
109      * [schema normalized value]
110      *
111      *
112      * @see <a HREF="http://www.w3.org/TR/xmlschema-1/#e-schema_normalized_value>XML Schema Part 1: Structures [schema normalized value]</a>
113      * @return the normalized value of this item after validation
114      */

115     public String JavaDoc getSchemaNormalizedValue() {
116         return fNormalizedValue;
117     }
118
119     /**
120      * [schema specified]
121      * @see <a HREF="http://www.w3.org/TR/xmlschema-1/#e-schema_specified">XML Schema Part 1: Structures [schema specified]</a>
122      * @return false value was specified in schema, true value comes from the infoset
123      */

124     public boolean getIsSchemaSpecified() {
125         return fSpecified;
126     }
127
128
129     /**
130      * Determines the extent to which the document has been validated
131      *
132      * @return return the [validation attempted] property. The possible values are
133      * NO_VALIDATION, PARTIAL_VALIDATION and FULL_VALIDATION
134      */

135     public short getValidationAttempted() {
136         return fValidationAttempted;
137     }
138
139     /**
140      * Determine the validity of the node with respect
141      * to the validation being attempted
142      *
143      * @return return the [validity] property. Possible values are:
144      * UNKNOWN_VALIDITY, INVALID_VALIDITY, VALID_VALIDITY
145      */

146     public short getValidity() {
147         return fValidity;
148     }
149
150     /**
151      * A list of error codes generated from validation attempts.
152      * Need to find all the possible subclause reports that need reporting
153      *
154      * @return list of error codes
155      */

156     public StringList getErrorCodes() {
157         return fErrorCodes;
158     }
159
160     // This is the only information we can provide in a pipeline.
161
public String JavaDoc getValidationContext() {
162         return fValidationContext;
163     }
164
165     /**
166      * An item isomorphic to the type definition used to validate this element.
167      *
168      * @return a type declaration
169      */

170     public XSTypeDefinition getTypeDefinition() {
171         return fTypeDecl;
172     }
173
174     /**
175      * If and only if that type definition is a simple type definition
176      * with {variety} union, or a complex type definition whose {content type}
177      * is a simple thype definition with {variety} union, then an item isomorphic
178      * to that member of the union's {member type definitions} which actually
179      * validated the element item's normalized value.
180      *
181      * @return a simple type declaration
182      */

183     public XSSimpleTypeDefinition getMemberTypeDefinition() {
184         return fMemberType;
185     }
186
187     /**
188      * An item isomorphic to the attribute declaration used to validate
189      * this attribute.
190      *
191      * @return an attribute declaration
192      */

193     public XSAttributeDeclaration getAttributeDeclaration() {
194         return fDeclaration;
195     }
196
197     /**
198      * Copy PSVI properties from another psvi item.
199      *
200      * @param attr the source of attribute PSVI items
201      */

202     public void setPSVI(AttributePSVI attr) {
203         this.fDeclaration = attr.getAttributeDeclaration();
204         this.fValidationContext = attr.getValidationContext();
205         this.fValidity = attr.getValidity();
206         this.fValidationAttempted = attr.getValidationAttempted();
207         this.fErrorCodes = attr.getErrorCodes();
208         this.fNormalizedValue = attr.getSchemaNormalizedValue();
209         this.fActualValue = attr.getActualNormalizedValue();
210         this.fActualValueType = attr.getActualNormalizedValueType();
211         this.fItemValueTypes = attr.getItemValueTypes();
212         this.fTypeDecl = attr.getTypeDefinition();
213         this.fMemberType = attr.getMemberTypeDefinition();
214         this.fSpecified = attr.getIsSchemaSpecified();
215     }
216     
217     /* (non-Javadoc)
218      * @see org.apache.xerces.xs.ItemPSVI#getActualNormalizedValue()
219      */

220     public Object JavaDoc getActualNormalizedValue() {
221         return this.fActualValue;
222     }
223
224     /* (non-Javadoc)
225      * @see org.apache.xerces.xs.ItemPSVI#getActualNormalizedValueType()
226      */

227     public short getActualNormalizedValueType() {
228         return this.fActualValueType;
229     }
230
231     /* (non-Javadoc)
232      * @see org.apache.xerces.xs.ItemPSVI#getItemValueTypes()
233      */

234     public ShortList getItemValueTypes() {
235         return this.fItemValueTypes;
236     }
237     
238     // REVISIT: Forbid serialization of PSVI DOM until
239
// we support object serialization of grammars -- mrglavas
240

241     private void writeObject(ObjectOutputStream JavaDoc out)
242         throws IOException JavaDoc {
243         throw new NotSerializableException JavaDoc(getClass().getName());
244     }
245
246     private void readObject(ObjectInputStream JavaDoc in)
247         throws IOException JavaDoc, ClassNotFoundException JavaDoc {
248         throw new NotSerializableException JavaDoc(getClass().getName());
249     }
250 }
251
Popular Tags