KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Copyright 1999-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.impl.dv.ValidatedInfo;
20 import org.apache.xerces.xs.ShortList;
21 import org.apache.xerces.xs.XSAttributeDeclaration;
22 import org.apache.xerces.xs.XSAttributeUse;
23 import org.apache.xerces.xs.XSConstants;
24 import org.apache.xerces.xs.XSNamespaceItem;
25
26 /**
27  * The XML representation for an attribute use
28  * schema component is a local <attribute> element information item
29  *
30  * @xerces.internal
31  *
32  * @author Sandy Gao, IBM
33  * @version $Id: XSAttributeUseImpl.java,v 1.9 2005/06/23 19:29:16 mrglavas Exp $
34  */

35 public class XSAttributeUseImpl implements XSAttributeUse {
36
37     // the referred attribute decl
38
public XSAttributeDecl fAttrDecl = null;
39     // use information: SchemaSymbols.USE_OPTIONAL, REQUIRED, PROHIBITED
40
public short fUse = SchemaSymbols.USE_OPTIONAL;
41     // value constraint type: default, fixed or !specified
42
public short fConstraintType = XSConstants.VC_NONE;
43     // value constraint value
44
public ValidatedInfo fDefault = null;
45
46     public void reset(){
47         fDefault = null;
48         fAttrDecl = null;
49         fUse = SchemaSymbols.USE_OPTIONAL;
50         fConstraintType = XSConstants.VC_NONE;
51     }
52
53     /**
54      * Get the type of the object, i.e ELEMENT_DECLARATION.
55      */

56     public short getType() {
57         return XSConstants.ATTRIBUTE_USE;
58     }
59
60     /**
61      * The <code>name</code> of this <code>XSObject</code> depending on the
62      * <code>XSObject</code> type.
63      */

64     public String JavaDoc getName() {
65         return null;
66     }
67
68     /**
69      * The namespace URI of this node, or <code>null</code> if it is
70      * unspecified. defines how a namespace URI is attached to schema
71      * components.
72      */

73     public String JavaDoc getNamespace() {
74         return null;
75     }
76
77     /**
78      * {required} determines whether this use of an attribute declaration
79      * requires an appropriate attribute information item to be present, or
80      * merely allows it.
81      */

82     public boolean getRequired() {
83         return fUse == SchemaSymbols.USE_REQUIRED;
84     }
85
86     /**
87      * {attribute declaration} provides the attribute declaration itself,
88      * which will in turn determine the simple type definition used.
89      */

90     public XSAttributeDeclaration getAttrDeclaration() {
91         return fAttrDecl;
92     }
93
94     /**
95      * Value Constraint: one of default, fixed.
96      */

97     public short getConstraintType() {
98         return fConstraintType;
99     }
100
101     /**
102      * Value Constraint: The actual value (with respect to the {type
103      * definition}).
104      */

105     public String JavaDoc getConstraintValue() {
106         // REVISIT: SCAPI: what's the proper representation
107
return getConstraintType() == XSConstants.VC_NONE ?
108                null :
109                ((fDefault != null && fDefault.actualValue != null) ?
110                        fDefault.actualValue.toString() : null);
111     }
112
113     /**
114      * @see org.apache.xerces.xs.XSObject#getNamespaceItem()
115      */

116     public XSNamespaceItem getNamespaceItem() {
117         return null;
118     }
119
120     public Object JavaDoc getActualVC() {
121         return getConstraintType() == XSConstants.VC_NONE ?
122                null :
123                fDefault.actualValue;
124     }
125
126     public short getActualVCType() {
127         return getConstraintType() == XSConstants.VC_NONE ?
128                XSConstants.UNAVAILABLE_DT :
129                fDefault.actualValueType;
130     }
131
132     public ShortList getItemValueTypes() {
133         return getConstraintType() == XSConstants.VC_NONE ?
134                null :
135                fDefault.itemValueTypes;
136     }
137
138 } // class XSAttributeUseImpl
139
Popular Tags