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.impl;
|
11
|
|
|
12
|
|
import java.util.ArrayList;
|
13
|
|
import java.util.ListIterator;
|
14
|
|
import java.util.Map;
|
15
|
|
|
16
|
|
import org.jbind.util.collection.FilterListIterator;
|
17
|
|
import org.jbind.xml.base.ILocation;
|
18
|
|
import org.jbind.xml.base.QName;
|
19
|
|
import org.jbind.xml.core.base.ITextContentProvider;
|
20
|
|
import org.jbind.xml.core.bridge.IElementImpl;
|
21
|
|
import org.jbind.xml.core.bridge.IImplContainer;
|
22
|
|
import org.jbind.xml.core.bridge.ITextImpl;
|
23
|
|
|
24
|
|
public class ImplList {
|
25
|
|
|
26
|
|
private ArrayList myImpls = new ArrayList();
|
27
|
|
private IImplContainer myOwner;
|
28
|
|
|
29
|
2978
|
public ImplList(IImplContainer anOwner) {
|
30
|
2978
|
myOwner = anOwner;
|
31
|
|
}
|
32
|
|
|
33
|
4
|
public IElementImpl addElement(String aNamespace, String aQName) {
|
34
|
4
|
return addElement(aNamespace, aQName, null, null);
|
35
|
|
}
|
36
|
|
|
37
|
2753
|
public IElementImpl addElement(String aNamespace, String aQName, Map aPrefixMapping, ILocation aLocation) {
|
38
|
2753
|
ElementImpl e = new ElementImpl(myOwner, aNamespace, QName.getLocalPart(aQName), aPrefixMapping, aLocation);
|
39
|
2753
|
myImpls.add(e);
|
40
|
2753
|
return e;
|
41
|
|
}
|
42
|
|
|
43
|
682
|
public ITextImpl addText(String aText, ILocation aLocation) {
|
44
|
682
|
TextImpl t = new TextImpl(myOwner, aText, aLocation);
|
45
|
682
|
myImpls.add(t);
|
46
|
682
|
return t;
|
47
|
|
}
|
48
|
|
|
49
|
12
|
public ITextImpl addText(ITextContentProvider aTextContentProvider, ILocation aLocation) {
|
50
|
12
|
TextImpl t = new TextImpl(myOwner, aTextContentProvider, aLocation);
|
51
|
12
|
myImpls.add(t);
|
52
|
12
|
return t;
|
53
|
|
}
|
54
|
|
|
55
|
170
|
public ListIterator iterElementImpls(final String aNamespace, final String aName) {
|
56
|
170
|
return new FilterListIterator(myImpls.listIterator(), new FilterListIterator.Test() {
|
57
|
|
|
58
|
170
|
public boolean test(Object anObject) {
|
59
|
170
|
if (!(anObject instanceof IElementImpl)) {
|
60
|
0
|
return false;
|
61
|
|
}
|
62
|
170
|
IElementImpl e = (IElementImpl)anObject;
|
63
|
170
|
boolean res = "*".equals(aNamespace) || (null == aNamespace) || aNamespace.equals(e.getNamespace());
|
64
|
170
|
if (res) {
|
65
|
170
|
if (!"*".equals(aName) && (aName != null)) {
|
66
|
0
|
res = aName.equals(e.getPartName());
|
67
|
|
}
|
68
|
|
}
|
69
|
170
|
return res;
|
70
|
|
}
|
71
|
|
});
|
72
|
|
}
|
73
|
|
|
74
|
11628
|
public ListIterator iterImpls() {
|
75
|
11628
|
return myImpls.listIterator();
|
76
|
|
}
|
77
|
|
|
78
|
15
|
public void clear() {
|
79
|
15
|
myImpls.clear();
|
80
|
|
}
|
81
|
|
}
|
82
|
|
|