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
|
|
|
14
|
|
import org.jbind.xml.base.Compositor;
|
15
|
|
import org.jbind.xml.base.IRange;
|
16
|
|
import org.jbind.xml.base.IRef;
|
17
|
|
import org.jbind.xml.base.Range;
|
18
|
|
import org.jbind.xml.core.cmp.IComponentVisitor;
|
19
|
|
import org.jbind.xml.core.cmp.ISourceInfo;
|
20
|
|
import org.jbind.xml.core.content.IContentDesc;
|
21
|
|
import org.jbind.xml.core.content.IElemGroupDesc;
|
22
|
|
import org.jbind.xml.core.content.ISequenceDecl;
|
23
|
|
import org.jbind.xml.core.content.IUseState;
|
24
|
|
import org.jbind.xml.instance.use.SequenceUseState;
|
25
|
|
import org.jbind.xml.msg.XmlException;
|
26
|
|
|
27
|
|
public class SequenceDecl extends ElemGroupDecl implements ISequenceDecl {
|
28
|
|
|
29
|
796
|
public SequenceDecl(ISourceInfo aSourceInfo, String aNamespace, String aName, IRange aRange) {
|
30
|
796
|
super(aSourceInfo, aNamespace, aName, aRange);
|
31
|
|
}
|
32
|
|
|
33
|
1802
|
public IUseState createUseState(IUseState aParent) {
|
34
|
1802
|
return new SequenceUseState(this, aParent);
|
35
|
|
}
|
36
|
|
|
37
|
11
|
public String getDesc() {
|
38
|
11
|
return "sequence group";
|
39
|
|
}
|
40
|
|
|
41
|
5555
|
public IRange getInnerRange(IRef aRef) {
|
42
|
5555
|
int min = 0;
|
43
|
5555
|
int max = 0;
|
44
|
5555
|
boolean isUnbounded = false;
|
45
|
5555
|
for (Iterator i = iterContent(); i.hasNext(); ) {
|
46
|
9581
|
IContentDesc content = (IContentDesc)i.next();
|
47
|
9581
|
IRange r = content.getRange(aRef);
|
48
|
9581
|
min += r.getMinOccurs();
|
49
|
9581
|
if (r.isUnbounded()) {
|
50
|
1749
|
isUnbounded = true;
|
51
|
|
} else {
|
52
|
7832
|
max += r.getMaxOccurs();
|
53
|
|
}
|
54
|
|
}
|
55
|
5555
|
return isUnbounded ? new Range(min) : new Range(min, max);
|
56
|
|
}
|
57
|
|
|
58
|
486
|
public void accept(IComponentVisitor aVisitor) throws XmlException {
|
59
|
486
|
aVisitor.visitSequenceDeclStart(this);
|
60
|
486
|
visitSubComponents(aVisitor);
|
61
|
486
|
aVisitor.visitSequenceDeclEnd(this);
|
62
|
|
}
|
63
|
|
|
64
|
35
|
public IElemGroupDesc createReference(ISourceInfo aSourceInfo, IRange aRange) {
|
65
|
35
|
return new ElemGroupRef.SequenceRef(aSourceInfo, aRange, this);
|
66
|
|
}
|
67
|
499
|
public IElemGroupDesc createGroup() {
|
68
|
499
|
return new SequenceDecl(this, null, null, getRange());
|
69
|
|
}
|
70
|
4
|
public IElemGroupDesc createGroup(IRange aRange) {
|
71
|
4
|
return new SequenceDecl(this, null, null, aRange);
|
72
|
|
}
|
73
|
|
|
74
|
565
|
public boolean isPointless(IElemGroupDesc aParent) {
|
75
|
565
|
return isPointlessSequence(aParent);
|
76
|
|
}
|
77
|
|
|
78
|
487
|
public Compositor getCompositor() {
|
79
|
487
|
return Compositor.SEQUENCE;
|
80
|
|
}
|
81
|
|
}
|
82
|
|
|