01: /*
02: * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
03: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
04: *
05: * This code is free software; you can redistribute it and/or modify it
06: * under the terms of the GNU General Public License version 2 only, as
07: * published by the Free Software Foundation. Sun designates this
08: * particular file as subject to the "Classpath" exception as provided
09: * by Sun in the LICENSE file that accompanied this code.
10: *
11: * This code is distributed in the hope that it will be useful, but WITHOUT
12: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14: * version 2 for more details (a copy is included in the LICENSE file that
15: * accompanied this code).
16: *
17: * You should have received a copy of the GNU General Public License version
18: * 2 along with this work; if not, write to the Free Software Foundation,
19: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20: *
21: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22: * CA 95054 USA or visit www.sun.com if you need additional information or
23: * have any questions.
24: */
25: package com.sun.xml.internal.xsom.impl;
26:
27: import com.sun.xml.internal.xsom.XSAttGroupDecl;
28: import com.sun.xml.internal.xsom.XSAttributeUse;
29: import com.sun.xml.internal.xsom.XSWildcard;
30: import com.sun.xml.internal.xsom.impl.parser.DelayedRef;
31: import com.sun.xml.internal.xsom.impl.parser.SchemaDocumentImpl;
32: import com.sun.xml.internal.xsom.visitor.XSFunction;
33: import com.sun.xml.internal.xsom.visitor.XSVisitor;
34: import org.xml.sax.Locator;
35:
36: import java.util.Iterator;
37:
38: public class AttGroupDeclImpl extends AttributesHolder implements
39: XSAttGroupDecl {
40: public AttGroupDeclImpl(SchemaDocumentImpl _parent,
41: AnnotationImpl _annon, Locator _loc,
42: ForeignAttributesImpl _fa, String _name,
43: WildcardImpl _wildcard) {
44:
45: this (_parent, _annon, _loc, _fa, _name);
46: setWildcard(_wildcard);
47: }
48:
49: public AttGroupDeclImpl(SchemaDocumentImpl _parent,
50: AnnotationImpl _annon, Locator _loc,
51: ForeignAttributesImpl _fa, String _name) {
52:
53: super (_parent, _annon, _loc, _fa, _name, false);
54: }
55:
56: private WildcardImpl wildcard;
57:
58: public void setWildcard(WildcardImpl wc) {
59: wildcard = wc;
60: }
61:
62: public XSWildcard getAttributeWildcard() {
63: return wildcard;
64: }
65:
66: public XSAttributeUse getAttributeUse(String nsURI, String localName) {
67: UName name = new UName(nsURI, localName);
68: XSAttributeUse o = null;
69:
70: Iterator itr = iterateAttGroups();
71: while (itr.hasNext() && o == null)
72: o = ((XSAttGroupDecl) itr.next()).getAttributeUse(nsURI,
73: localName);
74:
75: if (o == null)
76: o = attributes.get(name);
77:
78: return o;
79: }
80:
81: public void redefine(AttGroupDeclImpl ag) {
82: for (Iterator itr = attGroups.iterator(); itr.hasNext();) {
83: DelayedRef.AttGroup r = (DelayedRef.AttGroup) itr.next();
84: r.redefine(ag);
85: }
86: }
87:
88: public void visit(XSVisitor visitor) {
89: visitor.attGroupDecl(this );
90: }
91:
92: public Object apply(XSFunction function) {
93: return function.attGroupDecl(this);
94: }
95: }
|