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.dom3.core;
|
11
|
|
|
12
|
|
import org.jbind.util.other.StrBuffer;
|
13
|
|
import org.jbind.xml.core.base.ITextContentProvider;
|
14
|
|
import org.jbind.xml.dom3.types.IDomCharacterData;
|
15
|
|
import org.jbind.xml.dom3.types.IDomDocument;
|
16
|
|
import org.jbind.xml.dom3.types.IDomNodeList;
|
17
|
|
|
18
|
|
public abstract class DomCharacterData extends DomNonAttrOrElm implements IDomCharacterData {
|
19
|
|
|
20
|
|
private StrBuffer myDataBuffer = null;
|
21
|
|
|
22
|
|
/**
|
23
|
|
* Constructor for sub classes that initialize the data buffer lazily.
|
24
|
|
*/
|
25
|
0
|
protected DomCharacterData(IDomDocument aDomDocument) {
|
26
|
0
|
super(aDomDocument);
|
27
|
|
}
|
28
|
|
|
29
|
0
|
public DomCharacterData(IDomDocument aDomDocument, String aString) {
|
30
|
0
|
super(aDomDocument);
|
31
|
0
|
myDataBuffer = new StrBuffer(aString);
|
32
|
|
}
|
33
|
|
|
34
|
0
|
protected DomCharacterData(IDomCharacterData aDomCharacterData, boolean aDeep) {
|
35
|
0
|
super(aDomCharacterData, aDeep);
|
36
|
0
|
myDataBuffer = new StrBuffer(aDomCharacterData.getData());
|
37
|
|
}
|
38
|
|
|
39
|
0
|
protected StrBuffer getDataBuffer() {
|
40
|
0
|
return myDataBuffer;
|
41
|
|
}
|
42
|
|
|
43
|
0
|
protected void setDataBuffer(StrBuffer aDataBuffer) {
|
44
|
0
|
myDataBuffer = aDataBuffer;
|
45
|
|
}
|
46
|
|
|
47
|
0
|
public String getData() {
|
48
|
0
|
return getDataBuffer().toString();
|
49
|
|
}
|
50
|
|
|
51
|
0
|
public void appendData(String arg) throws DomException {
|
52
|
0
|
checkMutability();
|
53
|
0
|
getDataBuffer().append(arg);
|
54
|
|
}
|
55
|
|
|
56
|
0
|
public void deleteData(int offset, int count) throws DomException {
|
57
|
0
|
checkMutability();
|
58
|
0
|
if ((offset < 0) || (count < 0) || (offset + count > getDataBuffer().length())) {
|
59
|
0
|
throw new DomException(DomException.INDEX_SIZE_ERR);
|
60
|
|
}
|
61
|
0
|
getDataBuffer().delete(offset, offset + count);
|
62
|
|
}
|
63
|
|
|
64
|
0
|
public void deleteData(int offset) throws DomException {
|
65
|
0
|
checkMutability();
|
66
|
0
|
if ((offset < 0) || (offset > getDataBuffer().length())) {
|
67
|
0
|
throw new DomException(DomException.INDEX_SIZE_ERR);
|
68
|
|
}
|
69
|
0
|
getDataBuffer().delete(offset, getDataBuffer().length());
|
70
|
|
}
|
71
|
|
|
72
|
0
|
public int getLength() {
|
73
|
0
|
return getDataBuffer().length();
|
74
|
|
}
|
75
|
|
|
76
|
0
|
public String getNodeValue() throws DomException {
|
77
|
0
|
return getData();
|
78
|
|
}
|
79
|
|
|
80
|
0
|
public void insertData(int offset, String arg) throws DomException {
|
81
|
0
|
checkMutability();
|
82
|
0
|
if ((offset < 0) || (offset > getDataBuffer().length())) {
|
83
|
0
|
throw new DomException(DomException.INDEX_SIZE_ERR);
|
84
|
|
}
|
85
|
0
|
getDataBuffer().insert(offset, arg);
|
86
|
|
}
|
87
|
|
|
88
|
0
|
public void replaceData(int offset, int count, String arg) throws DomException {
|
89
|
0
|
checkMutability();
|
90
|
0
|
getDataBuffer().replace(offset, offset + count, arg);
|
91
|
|
}
|
92
|
|
|
93
|
0
|
public void setData(String data) throws DomException {
|
94
|
0
|
checkMutability();
|
95
|
0
|
getDataBuffer().setLength(0);
|
96
|
0
|
getDataBuffer().append(data);
|
97
|
|
}
|
98
|
|
|
99
|
0
|
public void setNodeValue(String nodeValue) throws DomException {
|
100
|
0
|
setData(nodeValue);
|
101
|
|
}
|
102
|
|
|
103
|
0
|
public String substringData(int offset, int count) throws DomException {
|
104
|
0
|
if ((offset < 0) || (offset > getDataBuffer().length())) {
|
105
|
0
|
throw new DomException(DomException.INDEX_SIZE_ERR);
|
106
|
|
}
|
107
|
0
|
return getDataBuffer().substring(offset, offset + count);
|
108
|
|
}
|
109
|
|
|
110
|
0
|
protected IDomNodeList doCloneChildNodes(IDomNodeList aDomNodeList, boolean aDeep) {
|
111
|
0
|
return aDomNodeList;
|
112
|
|
}
|
113
|
|
|
114
|
0
|
public String substringData(int offset) throws DomException {
|
115
|
0
|
if ((offset < 0) || (offset > getDataBuffer().length())) {
|
116
|
0
|
throw new DomException(DomException.INDEX_SIZE_ERR);
|
117
|
|
}
|
118
|
0
|
return getDataBuffer().substring(offset);
|
119
|
|
}
|
120
|
|
|
121
|
0
|
public String getTextContent() {
|
122
|
0
|
return getNodeValue();
|
123
|
|
}
|
124
|
|
|
125
|
0
|
public void setTextContent(ITextContentProvider aTextContentProvider) {
|
126
|
0
|
setNodeValue(aTextContentProvider.getTextContent_());
|
127
|
|
}
|
128
|
|
|
129
|
0
|
public void setTextContent(String aString) {
|
130
|
0
|
setNodeValue(aString);
|
131
|
|
}
|
132
|
|
}
|
133
|
|
|