Enhancement: Add a "userData" property to the TextPane "Node" class
so that applications building a document can attach their own data
structures to the various nodes of the document for cross-referencing
or other uses (such as syntax coloring).
git-svn-id: https://svn.apache.org/repos/asf/pivot/trunk@1747377 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/wtk/src/org/apache/pivot/wtk/text/Node.java b/wtk/src/org/apache/pivot/wtk/text/Node.java
index 69f7d09..b462b54 100644
--- a/wtk/src/org/apache/pivot/wtk/text/Node.java
+++ b/wtk/src/org/apache/pivot/wtk/text/Node.java
@@ -83,6 +83,7 @@
private Element parent = null;
private int offset = 0;
+ private Object userData = null;
private NodeListenerList nodeListeners = new NodeListenerList();
@@ -294,4 +295,25 @@
public ListenerList<NodeListener> getNodeListeners() {
return nodeListeners;
}
+
+ /**
+ * @return The user data associated with this node.
+ */
+ public Object getUserData() {
+ return this.userData;
+ }
+
+ /**
+ * Set the user data associated with this node. This can be any
+ * piece of data that has meaning to the application, and is meant
+ * to link any underlying data structure used to build the document
+ * with the document itself.
+ *
+ * @param userData Any piece of data that has meaning to the user
+ * application (can be {@code null}).
+ */
+ public void setUserData(Object userData) {
+ this.userData = userData;
+ }
+
}