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.data;
|
11
|
|
|
12
|
|
import java.util.Collections;
|
13
|
|
import java.util.Iterator;
|
14
|
|
import java.util.ListIterator;
|
15
|
|
import java.util.Map;
|
16
|
|
|
17
|
|
import org.jbind.xml.base.IHasLocation;
|
18
|
|
import org.jbind.xml.base.ILocation;
|
19
|
|
import org.jbind.xml.core.base.ITextContentMemento;
|
20
|
|
import org.jbind.xml.core.base.ITextContentProvider;
|
21
|
|
import org.jbind.xml.core.bridge.IDataImpl;
|
22
|
|
import org.jbind.xml.core.bridge.IDataImplVisitor;
|
23
|
|
import org.jbind.xml.core.bridge.IImplContainer;
|
24
|
|
import org.jbind.xml.core.data.IAnyTypeData;
|
25
|
|
|
26
|
|
public class StringDataImpl implements IDataImpl {
|
27
|
|
|
28
|
|
private String myString = null;
|
29
|
|
private Map myPrefixToNamespaceMapping;
|
30
|
|
private ITextContentProvider myTextContentProvider = null;
|
31
|
|
|
32
|
|
private IHasLocation myHasLocation = null;
|
33
|
|
private IAnyTypeData myData = null;
|
34
|
|
|
35
|
429
|
public StringDataImpl(String aString, Map aPrefixToNamespaceMapping, IHasLocation aHasLocation) {
|
36
|
429
|
myString = aString;
|
37
|
429
|
myPrefixToNamespaceMapping = aPrefixToNamespaceMapping;
|
38
|
429
|
myHasLocation = aHasLocation;
|
39
|
|
}
|
40
|
|
|
41
|
0
|
public IAnyTypeData getAttributeData(String aNamespace, String aLocalName) {
|
42
|
0
|
return null;
|
43
|
|
}
|
44
|
|
|
45
|
12
|
public Map getPrefixToNamespaceMapping() {
|
46
|
12
|
return myPrefixToNamespaceMapping;
|
47
|
|
}
|
48
|
|
|
49
|
1087
|
public String getTextContent() {
|
50
|
1087
|
String res = null;
|
51
|
1087
|
if (myString != null) {
|
52
|
1087
|
res = myString;
|
53
|
|
} else {
|
54
|
0
|
res = myTextContentProvider.getTextContent_();
|
55
|
|
}
|
56
|
1087
|
return res;
|
57
|
|
}
|
58
|
|
|
59
|
0
|
public void setTextContent(String aString) {
|
60
|
0
|
myString = aString;
|
61
|
0
|
myTextContentProvider = null;
|
62
|
|
}
|
63
|
|
|
64
|
0
|
public void setTextContent(ITextContentProvider aTextContentProvider) {
|
65
|
0
|
myTextContentProvider = aTextContentProvider;
|
66
|
0
|
myString = null;
|
67
|
|
}
|
68
|
|
|
69
|
0
|
public boolean isDefault() {
|
70
|
0
|
return false;
|
71
|
|
}
|
72
|
0
|
public boolean isNil() {
|
73
|
0
|
return false;
|
74
|
|
}
|
75
|
|
|
76
|
0
|
public ListIterator iterElementData(String aNamespace, String aLocalName) {
|
77
|
0
|
return Collections.EMPTY_LIST.listIterator();
|
78
|
|
}
|
79
|
|
|
80
|
12
|
public ILocation getLocation() {
|
81
|
12
|
ILocation res = null;
|
82
|
12
|
if (myHasLocation != null) {
|
83
|
12
|
res = myHasLocation.getLocation();
|
84
|
|
}
|
85
|
12
|
return res;
|
86
|
|
}
|
87
|
|
|
88
|
0
|
public ITextContentMemento saveTextContent() {
|
89
|
0
|
return new Memento(myString, myTextContentProvider);
|
90
|
|
}
|
91
|
|
|
92
|
0
|
public void restoreTextContent(ITextContentMemento aMemento) {
|
93
|
0
|
myString = ((Memento)aMemento).string;
|
94
|
0
|
myTextContentProvider = ((Memento)aMemento).textContentProvider;
|
95
|
|
}
|
96
|
|
|
97
|
0
|
public boolean hasTextContent() {
|
98
|
0
|
return (null != myTextContentProvider) || (null != myString);
|
99
|
|
}
|
100
|
|
|
101
|
0
|
public ListIterator iterChildren() {
|
102
|
0
|
return Collections.EMPTY_LIST.listIterator();
|
103
|
|
}
|
104
|
|
|
105
|
0
|
public void accept(IDataImplVisitor aVisitor) {}
|
106
|
|
|
107
|
0
|
public String getPartName() {
|
108
|
0
|
return null;
|
109
|
|
}
|
110
|
0
|
public String getNamespace() {
|
111
|
0
|
return null;
|
112
|
|
}
|
113
|
0
|
public IAnyTypeData getData() {
|
114
|
0
|
return myData;
|
115
|
|
}
|
116
|
0
|
public void setData(IAnyTypeData aData) {
|
117
|
0
|
myData = aData;
|
118
|
|
}
|
119
|
0
|
public Iterator iterAttributes(String aNamespace, String aName) {
|
120
|
0
|
return Collections.EMPTY_LIST.iterator();
|
121
|
|
}
|
122
|
|
|
123
|
0
|
public IImplContainer getParentImpl() {
|
124
|
0
|
return null;
|
125
|
|
}
|
126
|
|
|
127
|
|
private static class Memento implements ITextContentMemento {
|
128
|
|
public String string;
|
129
|
|
public ITextContentProvider textContentProvider;
|
130
|
0
|
public Memento(String aString, ITextContentProvider aProvider) {
|
131
|
0
|
string = aString;
|
132
|
0
|
textContentProvider = aProvider;
|
133
|
|
}
|
134
|
|
}
|
135
|
|
}
|
136
|
|
|