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.instance.use;
|
11
|
|
|
12
|
|
import org.jbind.xml.base.IHasLocation;
|
13
|
|
import org.jbind.xml.base.IRef;
|
14
|
|
import org.jbind.xml.core.content.IElemDesc;
|
15
|
|
import org.jbind.xml.core.content.IElemRefOrDecl;
|
16
|
|
import org.jbind.xml.core.content.IElemUseState;
|
17
|
|
import org.jbind.xml.core.content.IUseState;
|
18
|
|
import org.jbind.xml.core.type.IAnyType;
|
19
|
|
import org.jbind.xml.msg.XmlException;
|
20
|
|
|
21
|
|
public class ElemRefOrDeclUseState extends ElemUseState implements IElemRefOrDeclUseState {
|
22
|
|
|
23
|
|
private String myNamespace = null;
|
24
|
|
private String myName = null;
|
25
|
|
|
26
|
|
private IElemDesc myCurrentDataDecl = null;
|
27
|
|
private IElemRefOrDecl mySubstitutionHead = null;
|
28
|
|
|
29
|
4241
|
public ElemRefOrDeclUseState(IElemRefOrDecl aContent, IUseState aParent) {
|
30
|
4241
|
super(aContent, aParent);
|
31
|
4241
|
IRef ref = aContent.getGlobalRef();
|
32
|
4241
|
myNamespace = ref.getNamespace();
|
33
|
4241
|
myName = ref.getLocalPart();
|
34
|
|
}
|
35
|
|
|
36
|
6173
|
public IElemUseState getNextUseState(String aNamespace, String aName, IAnyType anOverloadingType, IHasLocation aHasLocation) throws XmlException {
|
37
|
6173
|
IElemRefOrDeclUseState res = null;
|
38
|
6173
|
mySubstitutionHead = null;
|
39
|
6173
|
if (mayIncrementUseCounter()) {
|
40
|
5259
|
if (myName.equals(aName) && myNamespace.equals(aNamespace)) {
|
41
|
2082
|
incrementUseCounter();
|
42
|
2082
|
res = this;
|
43
|
2082
|
myCurrentDataDecl = (IElemRefOrDecl)getContentDesc();
|
44
|
|
} else {
|
45
|
3177
|
myCurrentDataDecl = ((IElemRefOrDecl)getContentDesc()).getSubstitute(aNamespace, aName);
|
46
|
3177
|
if (null != myCurrentDataDecl) {
|
47
|
96
|
incrementUseCounter();
|
48
|
96
|
res = this;
|
49
|
96
|
mySubstitutionHead = (IElemRefOrDecl)getContentDesc();
|
50
|
|
}
|
51
|
|
}
|
52
|
|
}
|
53
|
6173
|
return res;
|
54
|
|
}
|
55
|
|
|
56
|
1022
|
protected void doIsValidEnd(IHasLocation aHasLocation) {}
|
57
|
|
|
58
|
2178
|
public IElemDesc getElemDesc() {
|
59
|
2178
|
return myCurrentDataDecl;
|
60
|
|
}
|
61
|
|
|
62
|
2178
|
public IElemRefOrDecl getSubstitutionHead() {
|
63
|
2178
|
return mySubstitutionHead;
|
64
|
|
}
|
65
|
|
}
|
66
|
|
|