1 /* |
1 /* |
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
68 this.form = _form; |
68 this.form = _form; |
69 this.type = _type; |
69 this.type = _type; |
70 this.substHead = _substHead; |
70 this.substHead = _substHead; |
71 this.substDisallowed = _substDisallowed; |
71 this.substDisallowed = _substDisallowed; |
72 this.substExcluded = _substExcluded; |
72 this.substExcluded = _substExcluded; |
73 this.idConstraints = Collections.unmodifiableList((List<? extends XSIdentityConstraint>)idConstraints); |
73 this.idConstraints = (List<XSIdentityConstraint>) Collections.unmodifiableList((List<? extends XSIdentityConstraint>)idConstraints); |
74 |
74 |
75 for (IdentityConstraintImpl idc : idConstraints) |
75 for (IdentityConstraintImpl idc : idConstraints) |
76 idc.setParent(this); |
76 idc.setParent(this); |
77 |
77 |
78 if(type==null) |
78 if(type==null) |
79 throw new IllegalArgumentException(); |
79 throw new IllegalArgumentException(); |
80 } |
80 } |
81 |
81 |
82 private XmlString defaultValue; |
82 private XmlString defaultValue; |
|
83 @Override |
83 public XmlString getDefaultValue() { return defaultValue; } |
84 public XmlString getDefaultValue() { return defaultValue; } |
84 |
85 |
85 private XmlString fixedValue; |
86 private XmlString fixedValue; |
|
87 @Override |
86 public XmlString getFixedValue() { return fixedValue; } |
88 public XmlString getFixedValue() { return fixedValue; } |
87 |
89 |
88 private boolean nillable; |
90 private boolean nillable; |
|
91 @Override |
89 public boolean isNillable() { return nillable; } |
92 public boolean isNillable() { return nillable; } |
90 |
93 |
91 private boolean _abstract; |
94 private boolean _abstract; |
|
95 @Override |
92 public boolean isAbstract() { return _abstract; } |
96 public boolean isAbstract() { return _abstract; } |
93 |
97 |
94 private Ref.Type type; |
98 private Ref.Type type; |
|
99 @Override |
95 public XSType getType() { return type.getType(); } |
100 public XSType getType() { return type.getType(); } |
96 |
101 |
97 private Ref.Element substHead; |
102 private Ref.Element substHead; |
|
103 @Override |
98 public XSElementDecl getSubstAffiliation() { |
104 public XSElementDecl getSubstAffiliation() { |
99 if(substHead==null) return null; |
105 if(substHead==null) return null; |
100 return substHead.get(); |
106 return substHead.get(); |
101 } |
107 } |
102 |
108 |
103 private int substDisallowed; |
109 private int substDisallowed; |
|
110 @Override |
104 public boolean isSubstitutionDisallowed( int method ) { |
111 public boolean isSubstitutionDisallowed( int method ) { |
105 return (substDisallowed&method)!=0; |
112 return (substDisallowed&method)!=0; |
106 } |
113 } |
107 |
114 |
108 private int substExcluded; |
115 private int substExcluded; |
|
116 @Override |
109 public boolean isSubstitutionExcluded( int method ) { |
117 public boolean isSubstitutionExcluded( int method ) { |
110 return (substExcluded&method)!=0; |
118 return (substExcluded&method)!=0; |
111 } |
119 } |
112 |
120 |
113 private final List<XSIdentityConstraint> idConstraints; |
121 private final List<XSIdentityConstraint> idConstraints; |
|
122 @Override |
114 public List<XSIdentityConstraint> getIdentityConstraints() { |
123 public List<XSIdentityConstraint> getIdentityConstraints() { |
115 return idConstraints; |
124 return idConstraints; |
116 } |
125 } |
117 |
126 |
118 private Boolean form; |
127 private Boolean form; |
|
128 @Override |
119 public Boolean getForm() { |
129 public Boolean getForm() { |
120 return form; |
130 return form; |
121 } |
131 } |
122 |
132 |
123 |
133 |
124 /** |
134 /** |
125 * @deprecated |
135 * @deprecated |
126 */ |
136 */ |
|
137 @Override |
127 public XSElementDecl[] listSubstitutables() { |
138 public XSElementDecl[] listSubstitutables() { |
128 Set<? extends XSElementDecl> s = getSubstitutables(); |
139 Set<? extends XSElementDecl> s = getSubstitutables(); |
129 return s.toArray(new XSElementDecl[s.size()]); |
140 return s.toArray(new XSElementDecl[s.size()]); |
130 } |
141 } |
131 |
142 |
133 private Set<XSElementDecl> substitutables = null; |
144 private Set<XSElementDecl> substitutables = null; |
134 |
145 |
135 /** Unmodifieable view of {@link #substitutables}. */ |
146 /** Unmodifieable view of {@link #substitutables}. */ |
136 private Set<XSElementDecl> substitutablesView = null; |
147 private Set<XSElementDecl> substitutablesView = null; |
137 |
148 |
|
149 @Override |
138 public Set<? extends XSElementDecl> getSubstitutables() { |
150 public Set<? extends XSElementDecl> getSubstitutables() { |
139 if( substitutables==null ) { |
151 if( substitutables==null ) { |
140 // if the field is null by the time this method |
152 // if the field is null by the time this method |
141 // is called, it means this element is substitutable by itself only. |
153 // is called, it means this element is substitutable by itself only. |
142 substitutables = substitutablesView = Collections.singleton((XSElementDecl)this); |
154 substitutables = substitutablesView = Collections.singleton((XSElementDecl)this); |
192 // this element can substitute "parent" |
204 // this element can substitute "parent" |
193 parent.addSubstitutable(this); |
205 parent.addSubstitutable(this); |
194 } |
206 } |
195 } |
207 } |
196 |
208 |
|
209 @Override |
197 public boolean canBeSubstitutedBy(XSElementDecl e) { |
210 public boolean canBeSubstitutedBy(XSElementDecl e) { |
198 return getSubstitutables().contains(e); |
211 return getSubstitutables().contains(e); |
199 } |
212 } |
200 |
213 |
|
214 @Override |
201 public boolean isWildcard() { return false; } |
215 public boolean isWildcard() { return false; } |
|
216 @Override |
202 public boolean isModelGroupDecl() { return false; } |
217 public boolean isModelGroupDecl() { return false; } |
|
218 @Override |
203 public boolean isModelGroup() { return false; } |
219 public boolean isModelGroup() { return false; } |
|
220 @Override |
204 public boolean isElementDecl() { return true; } |
221 public boolean isElementDecl() { return true; } |
205 |
222 |
|
223 @Override |
206 public XSWildcard asWildcard() { return null; } |
224 public XSWildcard asWildcard() { return null; } |
|
225 @Override |
207 public XSModelGroupDecl asModelGroupDecl() { return null; } |
226 public XSModelGroupDecl asModelGroupDecl() { return null; } |
|
227 @Override |
208 public XSModelGroup asModelGroup() { return null; } |
228 public XSModelGroup asModelGroup() { return null; } |
|
229 @Override |
209 public XSElementDecl asElementDecl() { return this; } |
230 public XSElementDecl asElementDecl() { return this; } |
210 |
231 |
211 |
232 |
212 |
233 |
213 |
234 |
|
235 @Override |
214 public void visit( XSVisitor visitor ) { |
236 public void visit( XSVisitor visitor ) { |
215 visitor.elementDecl(this); |
237 visitor.elementDecl(this); |
216 } |
238 } |
|
239 @Override |
217 public void visit( XSTermVisitor visitor ) { |
240 public void visit( XSTermVisitor visitor ) { |
218 visitor.elementDecl(this); |
241 visitor.elementDecl(this); |
219 } |
242 } |
|
243 @Override |
220 public Object apply( XSTermFunction function ) { |
244 public Object apply( XSTermFunction function ) { |
221 return function.elementDecl(this); |
245 return function.elementDecl(this); |
222 } |
246 } |
223 |
247 |
|
248 @Override |
224 public <T,P> T apply(XSTermFunctionWithParam<T, P> function, P param) { |
249 public <T,P> T apply(XSTermFunctionWithParam<T, P> function, P param) { |
225 return function.elementDecl(this,param); |
250 return function.elementDecl(this,param); |
226 } |
251 } |
227 |
252 |
|
253 @Override |
228 public Object apply( XSFunction function ) { |
254 public Object apply( XSFunction function ) { |
229 return function.elementDecl(this); |
255 return function.elementDecl(this); |
230 } |
256 } |
231 |
257 |
232 |
258 |
233 // Ref.Term implementation |
259 // Ref.Term implementation |
|
260 @Override |
234 public XSTerm getTerm() { return this; } |
261 public XSTerm getTerm() { return this; } |
235 } |
262 } |