1
|
|
/*
|
2
|
|
* JBind
|
3
|
|
*
|
4
|
|
* Copyright (c) by Stefan Wachter. All rights reserved.
|
5
|
|
*
|
6
|
|
* Usage, modification, and redistribution is subject to license terms that are
|
7
|
|
* available at 'http://www.jbind.org'. The JBind license is like the
|
8
|
|
* 'Apache Software License V 1.1'.
|
9
|
|
*/
|
10
|
|
package org.jbind.xml.schema.cmp;
|
11
|
|
|
12
|
|
import java.util.Iterator;
|
13
|
|
import java.util.List;
|
14
|
|
import java.util.Map;
|
15
|
|
|
16
|
|
import org.jbind.xml.base.Compositor;
|
17
|
|
import org.jbind.xml.base.IRange;
|
18
|
|
import org.jbind.xml.base.IRef;
|
19
|
|
import org.jbind.xml.core.cmp.IComponentVisitor;
|
20
|
|
import org.jbind.xml.core.cmp.ISourceInfo;
|
21
|
|
import org.jbind.xml.core.content.IAllDecl;
|
22
|
|
import org.jbind.xml.core.content.IAllRef;
|
23
|
|
import org.jbind.xml.core.content.IChoiceDecl;
|
24
|
|
import org.jbind.xml.core.content.IChoiceRef;
|
25
|
|
import org.jbind.xml.core.content.IContentDesc;
|
26
|
|
import org.jbind.xml.core.content.IElemGroupDesc;
|
27
|
|
import org.jbind.xml.core.content.ISequenceDecl;
|
28
|
|
import org.jbind.xml.core.content.ISequenceRef;
|
29
|
|
import org.jbind.xml.core.content.IUseState;
|
30
|
|
import org.jbind.xml.instance.use.AllUseState;
|
31
|
|
import org.jbind.xml.instance.use.ChoiceUseState;
|
32
|
|
import org.jbind.xml.instance.use.SequenceUseState;
|
33
|
|
import org.jbind.xml.msg.IConstraintViolations;
|
34
|
|
import org.jbind.xml.msg.XmlException;
|
35
|
|
|
36
|
|
public abstract class ElemGroupRef extends ElemGroupDesc {
|
37
|
|
|
38
|
|
private IElemGroupDesc myContent;
|
39
|
|
|
40
|
79
|
public ElemGroupRef(ISourceInfo aSourceInfo, IRange aRange, IElemGroupDesc aContent) {
|
41
|
79
|
super(aSourceInfo, aContent.getNamespace(), aContent.getName(), aRange);
|
42
|
79
|
myContent = aContent;
|
43
|
|
}
|
44
|
|
|
45
|
0
|
public String getDesc() {
|
46
|
0
|
return "ref(" + myContent.getDesc() + ")";
|
47
|
|
}
|
48
|
|
|
49
|
2551
|
public IRange getInnerRange(IRef aRef) {
|
50
|
2551
|
return myContent.getInnerRange(aRef);
|
51
|
|
}
|
52
|
|
|
53
|
568
|
public Iterator iterContent() {
|
54
|
568
|
return myContent.iterContent();
|
55
|
|
}
|
56
|
|
|
57
|
79
|
public void validate(IConstraintViolations aViolations) {}
|
58
|
|
|
59
|
0
|
public boolean isReference() {
|
60
|
0
|
return true;
|
61
|
|
}
|
62
|
|
|
63
|
0
|
public IElemGroupDesc createReference(ISourceInfo aSourceInfo, IRange aRange) {
|
64
|
|
assert false;
|
65
|
0
|
return null;
|
66
|
|
}
|
67
|
|
|
68
|
0
|
public void add(IContentDesc aContent) {
|
69
|
|
assert false;
|
70
|
|
}
|
71
|
|
|
72
|
194
|
public void collectElemDescs(Map anElemRefOrDecls, List anElemWildcards, IConstraintViolations aViolations) {
|
73
|
194
|
myContent.collectElemDescs(anElemRefOrDecls, anElemWildcards, aViolations);
|
74
|
|
}
|
75
|
|
|
76
|
4
|
public Compositor getCompositor() {
|
77
|
4
|
return myContent.getCompositor();
|
78
|
|
}
|
79
|
90
|
public int getNbParticles() {
|
80
|
90
|
return myContent.getNbParticles();
|
81
|
|
}
|
82
|
|
|
83
|
|
static class AllRef extends ElemGroupRef implements IAllRef {
|
84
|
|
|
85
|
0
|
AllRef(ISourceInfo aSourceInfo, IRange aRange, IAllDecl aContent) {
|
86
|
0
|
super(aSourceInfo, aRange, aContent);
|
87
|
|
}
|
88
|
0
|
public IUseState createUseState(IUseState aParent) {
|
89
|
0
|
return new AllUseState(this, aParent);
|
90
|
|
}
|
91
|
0
|
public void accept(IComponentVisitor aVisitor) throws XmlException {
|
92
|
0
|
aVisitor.visitAllRefStart(this);
|
93
|
0
|
visitSubComponents(aVisitor);
|
94
|
0
|
aVisitor.visitAllRefEnd(this);
|
95
|
|
}
|
96
|
0
|
public boolean isPointless(IElemGroupDesc aParent) {
|
97
|
0
|
return isPointlessAll(aParent);
|
98
|
|
}
|
99
|
0
|
public IElemGroupDesc createGroup() {
|
100
|
0
|
return new AllDecl(this, null, null, getRange());
|
101
|
|
}
|
102
|
0
|
public IElemGroupDesc createGroup(IRange aRange) {
|
103
|
0
|
return new AllDecl(this, null, null, aRange);
|
104
|
|
}
|
105
|
|
}
|
106
|
|
|
107
|
|
static class ChoiceRef extends ElemGroupRef implements IChoiceRef {
|
108
|
|
|
109
|
44
|
ChoiceRef(ISourceInfo aSourceInfo, IRange aRange, IChoiceDecl aContent) {
|
110
|
44
|
super(aSourceInfo, aRange, aContent);
|
111
|
|
}
|
112
|
318
|
public IUseState createUseState(IUseState aParent) {
|
113
|
318
|
return new ChoiceUseState(this, aParent);
|
114
|
|
}
|
115
|
88
|
public void accept(IComponentVisitor aVisitor) throws XmlException {
|
116
|
88
|
aVisitor.visitChoiceRefStart(this);
|
117
|
88
|
visitSubComponents(aVisitor);
|
118
|
88
|
aVisitor.visitChoiceRefEnd(this);
|
119
|
|
}
|
120
|
28
|
public boolean isPointless(IElemGroupDesc aParent) {
|
121
|
28
|
return isPointlessChoice(aParent);
|
122
|
|
}
|
123
|
62
|
public IElemGroupDesc createGroup() {
|
124
|
62
|
return new ChoiceDecl(this, null, null, getRange());
|
125
|
|
}
|
126
|
0
|
public IElemGroupDesc createGroup(IRange aRange) {
|
127
|
0
|
return new ChoiceDecl(this, null, null, aRange);
|
128
|
|
}
|
129
|
|
}
|
130
|
|
|
131
|
|
static class SequenceRef extends ElemGroupRef implements ISequenceRef {
|
132
|
|
|
133
|
35
|
SequenceRef(ISourceInfo aSourceInfo, IRange aRange, ISequenceDecl aContent) {
|
134
|
35
|
super(aSourceInfo, aRange, aContent);
|
135
|
|
}
|
136
|
131
|
public IUseState createUseState(IUseState aParent) {
|
137
|
131
|
return new SequenceUseState(this, aParent);
|
138
|
|
}
|
139
|
73
|
public void accept(IComponentVisitor aVisitor) throws XmlException {
|
140
|
73
|
aVisitor.visitSequenceRefStart(this);
|
141
|
73
|
visitSubComponents(aVisitor);
|
142
|
73
|
aVisitor.visitSequenceRefEnd(this);
|
143
|
|
}
|
144
|
27
|
public boolean isPointless(IElemGroupDesc aParent) {
|
145
|
27
|
return isPointlessSequence(aParent);
|
146
|
|
}
|
147
|
31
|
public IElemGroupDesc createGroup() {
|
148
|
31
|
return new SequenceDecl(this, null, null, getRange());
|
149
|
|
}
|
150
|
0
|
public IElemGroupDesc createGroup(IRange aRange) {
|
151
|
0
|
return new SequenceDecl(this, null, null, aRange);
|
152
|
|
}
|
153
|
|
}
|
154
|
|
}
|
155
|
|
|