Author: nbelaevski
Date: 2009-03-18 16:10:19 -0400 (Wed, 18 Mar 2009)
New Revision: 13013
Added:
trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModelKey.java
Modified:
trunk/framework/api/src/main/java/org/ajax4jsf/Messages.java
trunk/framework/api/src/main/java/org/richfaces/model/ListRowKey.java
trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModel.java
trunk/framework/api/src/main/java/org/richfaces/model/TreeDataModel.java
trunk/framework/impl/src/main/resources/org/ajax4jsf/messages.properties
trunk/framework/test/src/test/java/org/richfaces/model/StackingTreeDataModelTest.java
trunk/framework/test/src/test/java/org/richfaces/model/StackingTreeModelKeyConversionTest.java
Log:
https://jira.jboss.org/jira/browse/RF-4351
Modified: trunk/framework/api/src/main/java/org/ajax4jsf/Messages.java
===================================================================
--- trunk/framework/api/src/main/java/org/ajax4jsf/Messages.java 2009-03-18 19:56:12 UTC
(rev 13012)
+++ trunk/framework/api/src/main/java/org/ajax4jsf/Messages.java 2009-03-18 20:10:19 UTC
(rev 13013)
@@ -324,6 +324,7 @@
public static final String INVALID_VALUE = "INVALID_VALUE";
public static final String DATASCROLLER_PAGE_MISSING =
"DATASCROLLER_PAGE_MISSING";
public static final String DATASCROLLER_PAGES_DIFFERENT =
"DATASCROLLER_PAGES_DIFFERENT";
+ public static final String COMPONENT_CONVERSION_ERROR =
"COMPONENT_CONVERSION_ERROR";
public static void main(String[] args) {
String m = getMessage(INVALID_ATTRIBUTE_VALUE, "A", "B");
Modified: trunk/framework/api/src/main/java/org/richfaces/model/ListRowKey.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/ListRowKey.java 2009-03-18
19:56:12 UTC (rev 13012)
+++ trunk/framework/api/src/main/java/org/richfaces/model/ListRowKey.java 2009-03-18
20:10:19 UTC (rev 13013)
@@ -105,16 +105,6 @@
this.path = new ArrayList<T>(list);
}
-
- /**
- * Path object constructor
- * @param path first path segment
- */
- public ListRowKey(T path) {
- super();
- this.path = new ArrayList<T>(1);
- this.path.add(path);
- }
public int depth() {
return path.size();
@@ -190,19 +180,8 @@
boolean hasNext = iterator.hasNext();
while (hasNext) {
- T segment = iterator.next();
- if (segment instanceof CompositeKey) {
- CompositeKey compositeKey = (CompositeKey) segment;
- Iterator keySegments = compositeKey.getKeySegments();
- while (keySegments.hasNext()) {
- appendSegment(result, keySegments.next().toString());
- if (keySegments.hasNext()) {
- result.append(AbstractTreeDataModel.SEPARATOR);
- }
- }
- } else {
- appendSegment(result, segment.toString());
- }
+ T segment = iterator.next();
+ appendSegment(result, segment.toString());
hasNext = iterator.hasNext();
@@ -243,10 +222,6 @@
return split;
}
- public static interface CompositeKey {
- public Iterator getKeySegments();
- }
-
public static void main(String[] args) {
System.out.println(Arrays.toString(fromString("test_:abc:123:a__b")));
}
Modified: trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModel.java
===================================================================
---
trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModel.java 2009-03-18
19:56:12 UTC (rev 13012)
+++
trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModel.java 2009-03-18
20:10:19 UTC (rev 13013)
@@ -21,14 +21,12 @@
package org.richfaces.model;
import java.io.IOException;
-import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.NoSuchElementException;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
@@ -39,7 +37,6 @@
import org.ajax4jsf.model.Range;
import org.apache.commons.collections.Predicate;
import org.apache.commons.collections.iterators.FilterIterator;
-import org.richfaces.model.ListRowKey.CompositeKey;
import org.w3c.dom.NamedNodeMap;
/**
@@ -141,7 +138,7 @@
}
}
- protected StackingTreeModel doSetupKey(Iterator<Key> keyIterator,
Iterator<StackEntry> entriesIterator, FacesContext context, Object modelKey) {
+ protected StackingTreeModel doSetupKey(Iterator<StackingTreeModelKey> keyIterator,
Iterator<StackEntry> entriesIterator, FacesContext context, Object modelKey) {
if (modelKey != null) {
if (!setupModel(modelKey, context)) {
//no key is available
@@ -153,7 +150,7 @@
}
if (keyIterator != null && keyIterator.hasNext()) {
- Key key = keyIterator.next();
+ StackingTreeModelKey key = keyIterator.next();
StackingTreeModel stackingTreeModel = this.getInternalModelById(key.modelId);
Iterator<StackEntry> nextEntriesIterator = null;
Object nextModelKey = key.modelKey;
@@ -186,9 +183,9 @@
return (stackEntries.getLast()).model;
}
} else {
- Iterator<Key> keyIterator = null;
+ Iterator<StackingTreeModelKey> keyIterator = null;
if (key != null) {
- keyIterator = ((ListRowKey<Key>) key).iterator();
+ keyIterator = ((ListRowKey<StackingTreeModelKey>) key).iterator();
}
StackingTreeModel model = doSetupKey(keyIterator, stackEntries.iterator(), context,
null);
@@ -401,7 +398,7 @@
throws IOException {
Argument a = (Argument) argument;
- ListRowKey listRowKey = new ListRowKey(a.listRowKey, new Key(
+ ListRowKey listRowKey = new ListRowKey(a.listRowKey, new StackingTreeModelKey(
a.model.id, rowKey));
//System.out.println(".walk() " + (theLast ? " * " : "")
+ listRowKey);
@@ -527,158 +524,6 @@
return parent;
}
- /**
- * That is intended for internal use
- *
- * @author Nick Belaevski
- */
- protected static class Key implements Serializable, CompositeKey {
- /**
- *
- */
- private static final long serialVersionUID = -6821854350257816571L;
- protected Object modelKey;
- protected String modelId;
-
- public Key(String modelId, Object modelKey) {
- super();
- this.modelId = modelId;
- this.modelKey = modelKey;
- }
-
- public String toString() {
- return this.modelId + ":" + this.modelKey;
- }
-
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result
- + ((modelId == null) ? 0 : modelId.hashCode());
- result = prime * result
- + ((modelKey == null) ? 0 : modelKey.hashCode());
- return result;
- }
-
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- final Key other = (Key) obj;
- if (modelId == null) {
- if (other.modelId != null)
- return false;
- } else if (!modelId.equals(other.modelId))
- return false;
- if (modelKey == null) {
- if (other.modelKey != null)
- return false;
- } else if (!modelKey.equals(other.modelKey))
- return false;
- return true;
- }
-
- static enum IteratorState {
- INITIAL {
- @Override
- protected boolean hasNext(Key arg0) {
- return true;
- }
-
- @Override
- protected Object next(Key arg0) {
- throw new IllegalStateException();
- }
-
- @Override
- protected IteratorState nextState() {
- return ID;
- }
- },
-
- ID {
- @Override
- protected boolean hasNext(Key arg0) {
- return true;
- }
-
- @Override
- protected Object next(Key arg0) {
- return arg0.modelId;
- }
-
- @Override
- protected IteratorState nextState() {
- return KEY;
- }
- },
-
- KEY {
- @Override
- protected boolean hasNext(Key arg0) {
- return false;
- }
-
- @Override
- protected Object next(Key arg0) {
- return arg0.modelKey;
- }
-
- @Override
- protected IteratorState nextState() {
- return DONE;
- }
- },
-
- DONE {
- @Override
- protected boolean hasNext(Key arg0) {
- return false;
- }
-
- @Override
- protected Object next(Key arg0) {
- throw new NoSuchElementException();
- }
-
- @Override
- protected IteratorState nextState() {
- return DONE;
- }
- };
-
- protected abstract boolean hasNext(Key key);
-
- protected abstract Object next(Key key);
-
- protected abstract IteratorState nextState();
- };
-
- public Iterator getKeySegments() {
-
- return new Iterator<Object>() {
- IteratorState state = IteratorState.INITIAL;
-
- public boolean hasNext() {
- return state.hasNext(Key.this);
- }
-
- public Object next() {
- state = state.nextState();
- return state.next(Key.this);
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- };
- }
- }
-
protected boolean isActiveData() {
return true;
}
@@ -733,7 +578,7 @@
return null;
}
- list.add(new Key(modelId, key));
+ list.add(new StackingTreeModelKey(modelId, key));
if (!model.setupModel(key, context) || !model.isActiveData()) {
return null;
Added: trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModelKey.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModelKey.java
(rev 0)
+++
trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModelKey.java 2009-03-18
20:10:19 UTC (rev 13013)
@@ -0,0 +1,87 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.model;
+
+import java.io.Serializable;
+
+/**
+ * That is intended for internal use
+ *
+ * @author Nick Belaevski
+ */
+public class StackingTreeModelKey<T> implements Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = -6821854350257816571L;
+ protected T modelKey;
+ protected String modelId;
+
+ public StackingTreeModelKey(String modelId, T modelKey) {
+ super();
+ this.modelId = modelId;
+ this.modelKey = modelKey;
+ }
+
+ public String toString() {
+ return this.modelId + AbstractTreeDataModel.SEPARATOR + this.modelKey;
+ }
+
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((modelId == null) ? 0 : modelId.hashCode());
+ result = prime * result
+ + ((modelKey == null) ? 0 : modelKey.hashCode());
+ return result;
+ }
+
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final StackingTreeModelKey other = (StackingTreeModelKey) obj;
+ if (modelId == null) {
+ if (other.modelId != null)
+ return false;
+ } else if (!modelId.equals(other.modelId))
+ return false;
+ if (modelKey == null) {
+ if (other.modelKey != null)
+ return false;
+ } else if (!modelKey.equals(other.modelKey))
+ return false;
+ return true;
+ }
+
+ public String getModelId() {
+ return modelId;
+ }
+
+ public Object getModelKey() {
+ return modelKey;
+ }
+}
\ No newline at end of file
Modified: trunk/framework/api/src/main/java/org/richfaces/model/TreeDataModel.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/TreeDataModel.java 2009-03-18
19:56:12 UTC (rev 13012)
+++ trunk/framework/api/src/main/java/org/richfaces/model/TreeDataModel.java 2009-03-18
20:10:19 UTC (rev 13013)
@@ -150,13 +150,7 @@
boolean isLast = nextChildNode == null;
- ListRowKey newRowKey;
- if (rowKey != null) {
- newRowKey = new ListRowKey(listRowKey, identifier);
- } else {
- newRowKey = new ListRowKey(identifier);
- }
-
+ ListRowKey newRowKey = new ListRowKey(listRowKey, identifier);
this.doWalk(context, dataVisitor, range, newRowKey, argument, isLast);
}
Modified: trunk/framework/impl/src/main/resources/org/ajax4jsf/messages.properties
===================================================================
--- trunk/framework/impl/src/main/resources/org/ajax4jsf/messages.properties 2009-03-18
19:56:12 UTC (rev 13012)
+++ trunk/framework/impl/src/main/resources/org/ajax4jsf/messages.properties 2009-03-18
20:10:19 UTC (rev 13013)
@@ -257,4 +257,5 @@
HIGHLIGHT_LIBRARY_NOT_FOUND="In order to use highlight attribute of the rich:insert
component, add jhighlight.jar from
https://jhighlight.dev.java.net/ into
application."
INVALID_VALUE="Component {0} has invalid value expression {1}"
DATASCROLLER_PAGE_MISSING=Datascroller {0}: The requested page #{1} isn''t found
in the model containing {2} pages. Paging is reset to page #{3}
-DATASCROLLER_PAGES_DIFFERENT=Datascroller components attached to component: {0} have
different values of ''page'' attribute : {1}
\ No newline at end of file
+DATASCROLLER_PAGES_DIFFERENT=Datascroller components attached to component\: {0} have
different values of ''page'' attribute \: {1}
+COMPONENT_CONVERSION_ERROR=Component {0}: conversion error occurred for value {1}
\ No newline at end of file
Modified:
trunk/framework/test/src/test/java/org/richfaces/model/StackingTreeDataModelTest.java
===================================================================
---
trunk/framework/test/src/test/java/org/richfaces/model/StackingTreeDataModelTest.java 2009-03-18
19:56:12 UTC (rev 13012)
+++
trunk/framework/test/src/test/java/org/richfaces/model/StackingTreeDataModelTest.java 2009-03-18
20:10:19 UTC (rev 13013)
@@ -29,7 +29,6 @@
import org.ajax4jsf.model.DataVisitor;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
-import org.richfaces.model.StackingTreeModel.Key;
import org.richfaces.model.entity.Directory;
import org.richfaces.model.entity.File;
import org.richfaces.model.entity.Named;
@@ -156,14 +155,14 @@
public void testBadKey() throws Exception {
StackingTreeDataModelTestVisitor1 visitor1 = new StackingTreeDataModelTestVisitor1();
this.stackingTreeModel.walk(facesContext, visitor1, null, null);
- this.stackingTreeModel.setRowKey(new ListRowKey(new
StackingTreeModel.Key("project", "projectA")));
+ this.stackingTreeModel.setRowKey(new ListRowKey(null, new
StackingTreeModelKey("project", "projectA")));
assertTrue(this.stackingTreeModel.isRowAvailable());
assertNotNull(this.stackingTreeModel.getRowData());
assertNull(this.stackingTreeModel.getTreeNode());
assertFalse(this.stackingTreeModel.isLeaf());
- this.stackingTreeModel.setRowKey(new ListRowKey(new
StackingTreeModel.Key("project", "projectAAAAA")));
+ this.stackingTreeModel.setRowKey(new ListRowKey(null, new
StackingTreeModelKey("project", "projectAAAAA")));
assertFalse(this.stackingTreeModel.isRowAvailable());
try {
Object rowData = this.stackingTreeModel.getRowData();
@@ -220,12 +219,12 @@
}
public void testKey() throws Exception {
- Key key = new Key("aaa", new Integer(10));
- Key key2 = new Key("aaa", new Integer(11));
- Key key3 = new Key("aaa", new Integer(10));
- Key key4 = new Key("bbb", new Integer(10));
+ StackingTreeModelKey key = new StackingTreeModelKey("aaa", new Integer(10));
+ StackingTreeModelKey key2 = new StackingTreeModelKey("aaa", new
Integer(11));
+ StackingTreeModelKey key3 = new StackingTreeModelKey("aaa", new
Integer(10));
+ StackingTreeModelKey key4 = new StackingTreeModelKey("bbb", new
Integer(10));
- assertFalse(key.equals(new Key("aaa", new Integer(0)) {} ));
+ assertFalse(key.equals(new StackingTreeModelKey("aaa", new Integer(0)) {}
));
assertTrue(key.equals(key3));
assertTrue(key3.equals(key));
@@ -259,10 +258,10 @@
assertFalse(key2.equals(key4));
assertFalse(key3.equals(key4));
- assertFalse(new Key("aaa", new Integer(10)).equals(null));
- assertFalse(new Key("aaa", null).equals(null));
- assertFalse(new Key(null, new Integer(10)).equals(null));
- assertFalse(new Key(null, null).equals(null));
+ assertFalse(new StackingTreeModelKey("aaa", new Integer(10)).equals(null));
+ assertFalse(new StackingTreeModelKey("aaa", null).equals(null));
+ assertFalse(new StackingTreeModelKey(null, new Integer(10)).equals(null));
+ assertFalse(new StackingTreeModelKey(null, null).equals(null));
assertFalse(key.hashCode() == key4.hashCode());
assertFalse(key2.hashCode() == key4.hashCode());
@@ -273,21 +272,21 @@
assertFalse(key3.hashCode() == 0);
assertFalse(key4.hashCode() == 0);
- assertTrue(new Key(null, new Integer(11)).equals(new Key(null, new Integer(11))));
- assertFalse(new Key(null, new Integer(10)).equals(new Key(null, new Integer(11))));
- assertFalse(new Key(null, new Integer(10)).equals(new Key("aaa", new
Integer(10))));
+ assertTrue(new StackingTreeModelKey(null, new Integer(11)).equals(new
StackingTreeModelKey(null, new Integer(11))));
+ assertFalse(new StackingTreeModelKey(null, new Integer(10)).equals(new
StackingTreeModelKey(null, new Integer(11))));
+ assertFalse(new StackingTreeModelKey(null, new Integer(10)).equals(new
StackingTreeModelKey("aaa", new Integer(10))));
- assertTrue(new Key(null, new Integer(11)).hashCode() == new Key(null, new
Integer(11)).hashCode());
- assertFalse(new Key(null, new Integer(10)).hashCode() == new Key(null, new
Integer(11)).hashCode());
- assertFalse(new Key(null, new Integer(10)).hashCode() == new Key("aaa", new
Integer(10)).hashCode());
+ assertTrue(new StackingTreeModelKey(null, new Integer(11)).hashCode() == new
StackingTreeModelKey(null, new Integer(11)).hashCode());
+ assertFalse(new StackingTreeModelKey(null, new Integer(10)).hashCode() == new
StackingTreeModelKey(null, new Integer(11)).hashCode());
+ assertFalse(new StackingTreeModelKey(null, new Integer(10)).hashCode() == new
StackingTreeModelKey("aaa", new Integer(10)).hashCode());
- assertTrue(new Key("aaa", null).equals(new Key("aaa", null)));
- assertFalse(new Key("aaa", null).equals(new Key("bbb", null)));
- assertFalse(new Key("aaa", null).equals(new Key("aaa", new
Integer(10))));
+ assertTrue(new StackingTreeModelKey("aaa", null).equals(new
StackingTreeModelKey("aaa", null)));
+ assertFalse(new StackingTreeModelKey("aaa", null).equals(new
StackingTreeModelKey("bbb", null)));
+ assertFalse(new StackingTreeModelKey("aaa", null).equals(new
StackingTreeModelKey("aaa", new Integer(10))));
- assertTrue(new Key("aaa", null).hashCode() == new Key("aaa",
null).hashCode());
- assertFalse(new Key("aaa", null).hashCode() == new Key("bbb",
null).hashCode());
- assertFalse(new Key("aaa", null).hashCode() == new Key("aaa", new
Integer(10)).hashCode());
+ assertTrue(new StackingTreeModelKey("aaa", null).hashCode() == new
StackingTreeModelKey("aaa", null).hashCode());
+ assertFalse(new StackingTreeModelKey("aaa", null).hashCode() == new
StackingTreeModelKey("bbb", null).hashCode());
+ assertFalse(new StackingTreeModelKey("aaa", null).hashCode() == new
StackingTreeModelKey("aaa", new Integer(10)).hashCode());
}
class StackingTreeDataModelTestVisitor1 implements DataVisitor, LastElementAware {
@@ -301,7 +300,7 @@
StackingTreeDataModelTestVisitor2 visitor2 = new StackingTreeDataModelTestVisitor2();
- stackingTreeModel.walk(context, visitor2, null, new ListRowKey(new
StackingTreeModel.Key("project", "projectA")),
+ stackingTreeModel.walk(context, visitor2, null, new ListRowKey(null, new
StackingTreeModelKey("project", "projectA")),
argument, false);
assertEquals(5, visitor2.getCounter());
@@ -318,7 +317,7 @@
return false;
}
- }, new ListRowKey(new StackingTreeModel.Key("project",
"projectA")),
+ }, new ListRowKey(null, new StackingTreeModelKey("project",
"projectA")),
argument, false);
assertEquals(0, visitor20.getCounter());
@@ -335,14 +334,14 @@
return true;
}
- }, new ListRowKey(new StackingTreeModel.Key("project",
"projectA")),
+ }, new ListRowKey(null, new StackingTreeModelKey("project",
"projectA")),
argument, false);
assertEquals(1, visitor21.getCounter());
StackingTreeDataModelTestVisitor2 visitor22 = new
StackingTreeDataModelTestVisitor2();
- stackingTreeModel.walk(context, visitor22, null, new ListRowKey(new
StackingTreeModel.Key("project", "projectB")),
+ stackingTreeModel.walk(context, visitor22, null, new ListRowKey(null, new
StackingTreeModelKey("project", "projectB")),
argument, false);
assertEquals(4, visitor22.getCounter());
@@ -363,7 +362,7 @@
return true;
}
- }, new ListRowKey(new StackingTreeModel.Key("project",
"projectB")),
+ }, new ListRowKey(null, new StackingTreeModelKey("project",
"projectB")),
argument, false);
assertEquals(4, visitor23.getCounter());
Modified:
trunk/framework/test/src/test/java/org/richfaces/model/StackingTreeModelKeyConversionTest.java
===================================================================
---
trunk/framework/test/src/test/java/org/richfaces/model/StackingTreeModelKeyConversionTest.java 2009-03-18
19:56:12 UTC (rev 13012)
+++
trunk/framework/test/src/test/java/org/richfaces/model/StackingTreeModelKeyConversionTest.java 2009-03-18
20:10:19 UTC (rev 13013)
@@ -21,20 +21,12 @@
package org.richfaces.model;
-import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
-import java.util.UUID;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.model.DataVisitor;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
-import org.richfaces.model.ListRowKey.CompositeKey;
-import junit.framework.TestCase;
-
/**
* @author Nick Belaevski
* @since 3.3.0
@@ -96,83 +88,76 @@
}
public void testConvertKey() throws Exception {
- ListRowKey<CompositeKey> convertedKey = (ListRowKey<CompositeKey>)
model.convertToKey(facesContext, "mapsModel:1:mapIteratorModel:17", null,
null);
+ ListRowKey<StackingTreeModelKey> convertedKey =
(ListRowKey<StackingTreeModelKey>) model.convertToKey(facesContext,
"mapsModel:1:mapIteratorModel:17", null, null);
assertEquals(2, convertedKey.depth());
- Iterator keySegments;
+ StackingTreeModelKey key;
- Iterator<CompositeKey> iterator = convertedKey.iterator();
- keySegments = iterator.next().getKeySegments();
+ Iterator<StackingTreeModelKey> iterator = convertedKey.iterator();
+ key = iterator.next();
- assertEquals("mapsModel", keySegments.next());
- assertEquals(Integer.valueOf(1), keySegments.next());
- assertFalse(keySegments.hasNext());
+ assertEquals("mapsModel", key.getModelId());
+ assertEquals(Integer.valueOf(1), key.getModelKey());
- keySegments = iterator.next().getKeySegments();
+ key = iterator.next();
- assertEquals("mapIteratorModel", keySegments.next());
- assertEquals(Long.valueOf(17), keySegments.next());
- assertFalse(keySegments.hasNext());
+ assertEquals("mapIteratorModel", key.getModelId());
+ assertEquals(Long.valueOf(17), key.getModelKey());
assertFalse(iterator.hasNext());
}
public void testConvertKey1() throws Exception {
- ListRowKey<CompositeKey> convertedKey = (ListRowKey<CompositeKey>)
model.convertToKey(facesContext, "mapsModel:1:mapIteratorModel:9", null, null);
+ ListRowKey<StackingTreeModelKey> convertedKey =
(ListRowKey<StackingTreeModelKey>) model.convertToKey(facesContext,
"mapsModel:1:mapIteratorModel:9", null, null);
assertEquals(2, convertedKey.depth());
- Iterator keySegments;
+ StackingTreeModelKey key;
- Iterator<CompositeKey> iterator = convertedKey.iterator();
- keySegments = iterator.next().getKeySegments();
+ Iterator<StackingTreeModelKey> iterator = convertedKey.iterator();
+ key = iterator.next();
- assertEquals("mapsModel", keySegments.next());
- assertEquals(Integer.valueOf(1), keySegments.next());
- assertFalse(keySegments.hasNext());
+ assertEquals("mapsModel", key.getModelId());
+ assertEquals(Integer.valueOf(1), key.getModelKey());
- keySegments = iterator.next().getKeySegments();
+ key = iterator.next();
- assertEquals("mapIteratorModel", keySegments.next());
- assertEquals("9", keySegments.next());
- assertFalse(keySegments.hasNext());
+ assertEquals("mapIteratorModel", key.getModelId());
+ assertEquals("9", key.getModelKey());
assertFalse(iterator.hasNext());
}
public void testConvertKey2() throws Exception {
- ListRowKey<CompositeKey> convertedKey = (ListRowKey<CompositeKey>)
model.convertToKey(facesContext, "mapsModel:1:mapIteratorModel:abc", null,
null);
+ ListRowKey<StackingTreeModelKey> convertedKey =
(ListRowKey<StackingTreeModelKey>) model.convertToKey(facesContext,
"mapsModel:1:mapIteratorModel:abc", null, null);
assertEquals(2, convertedKey.depth());
- Iterator keySegments;
+ StackingTreeModelKey key;
- Iterator<CompositeKey> iterator = convertedKey.iterator();
- keySegments = iterator.next().getKeySegments();
+ Iterator<StackingTreeModelKey> iterator = convertedKey.iterator();
+ key = iterator.next();
- assertEquals("mapsModel", keySegments.next());
- assertEquals(Integer.valueOf(1), keySegments.next());
- assertFalse(keySegments.hasNext());
+ assertEquals("mapsModel", key.getModelId());
+ assertEquals(Integer.valueOf(1), key.getModelKey());
- keySegments = iterator.next().getKeySegments();
+ key = iterator.next();
- assertEquals("mapIteratorModel", keySegments.next());
- assertEquals("abc", keySegments.next().toString());
- assertFalse(keySegments.hasNext());
+ assertEquals("mapIteratorModel", key.getModelId());
+ assertEquals("abc", key.getModelKey().toString());
assertFalse(iterator.hasNext());
}
public void testConvertKey3() throws Exception {
- ListRowKey<CompositeKey> convertedKey = (ListRowKey<CompositeKey>)
model.convertToKey(facesContext, "mapsModel:0", null, null);
+ ListRowKey<StackingTreeModelKey> convertedKey =
(ListRowKey<StackingTreeModelKey>) model.convertToKey(facesContext,
"mapsModel:0", null, null);
assertEquals(1, convertedKey.depth());
- Iterator keySegments;
+ StackingTreeModelKey key;
- Iterator<CompositeKey> iterator = convertedKey.iterator();
- keySegments = iterator.next().getKeySegments();
+ Iterator<StackingTreeModelKey> iterator = convertedKey.iterator();
+ key = iterator.next();
- assertEquals("mapsModel", keySegments.next());
- assertEquals(Integer.valueOf(0), keySegments.next());
- assertFalse(keySegments.hasNext());
+ assertEquals("mapsModel", key.getModelId());
+ assertEquals(Integer.valueOf(0), key.getModelKey());
assertFalse(iterator.hasNext());
}