Author: nbelaevski
Date: 2008-08-07 11:20:19 -0400 (Thu, 07 Aug 2008)
New Revision: 9974
Modified:
trunk/framework/api/src/main/java/org/richfaces/model/TreeRange.java
trunk/framework/api/src/main/java/org/richfaces/model/TreeRowKey.java
Log:
TreeRange refactoring
FIXED: TreeRowKey#isSubKey() returned false for equal objects
Modified: trunk/framework/api/src/main/java/org/richfaces/model/TreeRange.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/TreeRange.java 2008-08-07
15:06:12 UTC (rev 9973)
+++ trunk/framework/api/src/main/java/org/richfaces/model/TreeRange.java 2008-08-07
15:20:19 UTC (rev 9974)
@@ -45,4 +45,22 @@
* @return <code>true</code> or <code>false</code>
*/
public boolean processChildren(TreeRowKey rowKey);
+
+
+ /**
+ * Unconstrained variant of {@link TreeRange}.
+ * Is stateless and safe to use in multi-threaded environments.
+ *
+ * @since 3.2.2
+ * @author Nick Belaevski
+ */
+ public final static TreeRange RANGE_UNCONSTRAINED = new TreeRange() {
+ public boolean processChildren(TreeRowKey rowKey) {
+ return true;
+ }
+
+ public boolean processNode(TreeRowKey rowKey) {
+ return true;
+ }
+ };
}
Modified: trunk/framework/api/src/main/java/org/richfaces/model/TreeRowKey.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/TreeRowKey.java 2008-08-07
15:06:12 UTC (rev 9973)
+++ trunk/framework/api/src/main/java/org/richfaces/model/TreeRowKey.java 2008-08-07
15:20:19 UTC (rev 9974)
@@ -71,7 +71,15 @@
return false;
}
- return (rowKey.getPath() + AbstractTreeDataModel.SEPARATOR).startsWith(getPath());
+ String otherPath = rowKey.getPath();
+ String path = getPath();
+
+ if (otherPath.startsWith(path)) {
+ return otherPath.length() == path.length() ||
+ otherPath.charAt(path.length()) == AbstractTreeDataModel.SEPARATOR;
+ } else {
+ return false;
+ }
}
/**