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.xml.dom3.types.IDomDocument;
|
13
|
|
import org.jbind.xml.dom3.types.IDomObject;
|
14
|
|
import org.w3c.dom.Document;
|
15
|
|
|
16
|
|
public class DomObject implements IDomObject {
|
17
|
|
|
18
|
|
/**
|
19
|
|
* The <code>Document</code> object associated with this node. This is
|
20
|
|
* also the <code>Document</code> object used to create new nodes. When
|
21
|
|
* this node is a <code>Document</code> or a <code>DocumentType</code>
|
22
|
|
* which is not used with any <code>Document</code> yet, this is
|
23
|
|
* <code>null</code>.
|
24
|
|
*/
|
25
|
|
protected IDomDocument myOwnerDocument = null;
|
26
|
|
// Allow protected access because the getter method looses some type information.
|
27
|
|
|
28
|
|
private boolean myIsReadOnly;
|
29
|
|
|
30
|
0
|
public DomObject(IDomDocument aDomDocument) {
|
31
|
0
|
this(aDomDocument, false);
|
32
|
|
}
|
33
|
|
|
34
|
0
|
public DomObject(IDomDocument aDomDocument, boolean anIsReadOnly) {
|
35
|
|
assert (null != aDomDocument) || (this instanceof DomDocument) || (this instanceof DomDocumentType) :
|
36
|
|
"node must have an owner document";
|
37
|
0
|
myOwnerDocument = aDomDocument;
|
38
|
0
|
myIsReadOnly = anIsReadOnly;
|
39
|
|
}
|
40
|
|
|
41
|
0
|
protected DomObject(IDomObject aDomObject, boolean aDeep) {
|
42
|
0
|
myOwnerDocument = (IDomDocument)aDomObject.getOwnerDocument();
|
43
|
0
|
myIsReadOnly = aDomObject.isReadOnly();
|
44
|
|
}
|
45
|
|
|
46
|
0
|
public Document getOwnerDocument() {
|
47
|
0
|
return myOwnerDocument;
|
48
|
|
}
|
49
|
|
|
50
|
0
|
protected void checkOwnerDocument(IDomObject aDomObject) {
|
51
|
0
|
if (myOwnerDocument != aDomObject.getOwnerDocument()) {
|
52
|
0
|
throw new DomException(DomException.WRONG_DOCUMENT_ERR);
|
53
|
|
}
|
54
|
|
}
|
55
|
|
|
56
|
0
|
protected void checkMutability() throws DomException {
|
57
|
0
|
if (isReadOnly()) {
|
58
|
0
|
throw new DomException(DomException.NO_MODIFICATION_ALLOWED_ERR);
|
59
|
|
}
|
60
|
|
}
|
61
|
|
|
62
|
0
|
public boolean isReadOnly() {
|
63
|
0
|
return myIsReadOnly;
|
64
|
|
}
|
65
|
|
|
66
|
|
}
|
67
|
|
|