public class NodeObject
extends java.lang.Object
int
).
The NodeObject can be used to enable memory management on a native XML
tree. This means, that if you wrap a native XML node with NodeObject, and you
de-reference all handles to the NodeObject, the native memory allocated for the
Node will automatically be freed. This includes all memory allocated for child nodes.
Take care with using NodeObject on two nodes from which
one is the ancestor of another, since if the ancestor is garbage collected by the
Virtual Machine, the pointer to the child node has become invalid as well.Constructor and Description |
---|
NodeObject(int node)
Creates a new NodeObject wrapper around a native XML node.
|
Modifier and Type | Method and Description |
---|---|
void |
delete()
Delete the XML node wrapped by this NodeObject.
|
static int |
getInstanceCount()
Returns the total number of active
NodeObject instances. |
int |
getNode()
Returns the native handle of the wrapped node.
|
ResourceOwner |
getResourceOwner() |
int |
stopTracking()
Stops tracking this object.
|
public NodeObject(int node)
node
- The node to wrap.
public void nodeObject() {
Document oDocument = new Document();
int result = 0;
try {
result = oDocument.load("<element><child1/></element>".getBytes());
NodeObject nodeObj = new NodeObject(result);
result = nodeObj.getNode();
assertEquals("element", Node.getName(result));
} catch (XMLException e) {
e.printStackTrace();
}
}
NodeObject
public static int getInstanceCount()
NodeObject
instances.public int getNode()
public void getNodetest() {
Document oDocument = new Document();
try {
int result = 0;
result = oDocument.load("<element><child1/></element>".getBytes());
NodeObject nodeObj = new NodeObject(result);
result = nodeObj.getNode();
assertEquals("element", Node.getName(result));
} catch (XMLException e) {
e.printStackTrace();
}
}
public int stopTracking()
getNode()
will
return 0.
public void test() {
Document oDocument = new Document();
int result = 0;
try {
result = oDocument.load("<element><child1/></element>".getBytes());
NodeObject nodeObj = new NodeObject(result);
nodeObj.stopTracking();
int nodeResult = nodeObj.getNode();
assertEquals(0, nodeResult);
} catch (XMLException e) {
e.printStackTrace();
} finally {
Node.delete(result);
}
}
public void delete()
public void test() {
Document oDocument = new Document();
try {
int result = 0;
result = oDocument.load("<element><child1/></element>".getBytes());
NodeObject nodeObj = new NodeObject(result);
nodeObj.delete();
result = nodeObj.getNode();
assertEquals(0, result);
} catch (XMLException e) {
e.printStackTrace();
}
}
public ResourceOwner getResourceOwner()