01: /*
02: * The contents of this file are subject to the terms
03: * of the Common Development and Distribution License
04: * (the "License"). You may not use this file except
05: * in compliance with the License.
06: *
07: * You can obtain a copy of the license at
08: * https://jwsdp.dev.java.net/CDDLv1.0.html
09: * See the License for the specific language governing
10: * permissions and limitations under the License.
11: *
12: * When distributing Covered Code, include this CDDL
13: * HEADER in each file and include the License file at
14: * https://jwsdp.dev.java.net/CDDLv1.0.html If applicable,
15: * add the following below this CDDL HEADER, with the
16: * fields enclosed by brackets "[]" replaced with your
17: * own identifying information: Portions Copyright [yyyy]
18: * [name of copyright owner]
19: */
20: package com.sun.xml.xsom.impl;
21:
22: import com.sun.xml.xsom.XSAttributeDecl;
23: import com.sun.xml.xsom.XSAttributeUse;
24: import com.sun.xml.xsom.XmlString;
25: import com.sun.xml.xsom.impl.parser.SchemaDocumentImpl;
26: import com.sun.xml.xsom.visitor.XSFunction;
27: import com.sun.xml.xsom.visitor.XSVisitor;
28: import org.xml.sax.Locator;
29:
30: public class AttributeUseImpl extends ComponentImpl implements
31: XSAttributeUse {
32: public AttributeUseImpl(SchemaDocumentImpl owner,
33: AnnotationImpl ann, Locator loc, ForeignAttributesImpl fa,
34: Ref.Attribute _decl, XmlString def, XmlString fixed,
35: boolean req) {
36:
37: super (owner, ann, loc, fa);
38:
39: this .att = _decl;
40: this .defaultValue = def;
41: this .fixedValue = fixed;
42: this .required = req;
43: }
44:
45: private final Ref.Attribute att;
46:
47: public XSAttributeDecl getDecl() {
48: return att.getAttribute();
49: }
50:
51: private final XmlString defaultValue;
52:
53: public XmlString getDefaultValue() {
54: if (defaultValue != null)
55: return defaultValue;
56: else
57: return getDecl().getDefaultValue();
58: }
59:
60: private final XmlString fixedValue;
61:
62: public XmlString getFixedValue() {
63: if (fixedValue != null)
64: return fixedValue;
65: else
66: return getDecl().getFixedValue();
67: }
68:
69: private final boolean required;
70:
71: public boolean isRequired() {
72: return required;
73: }
74:
75: public Object apply(XSFunction f) {
76: return f.attributeUse(this );
77: }
78:
79: public void visit(XSVisitor v) {
80: v.attributeUse(this);
81: }
82: }
|