Author: alexsmirnov
Date: 2008-05-28 14:57:34 -0400 (Wed, 28 May 2008)
New Revision: 8813
Added:
trunk/framework/impl/src/main/java/org/ajax4jsf/application/TreeStructureNode.java
Removed:
trunk/framework/impl/src/main/java/org/ajax4jsf/application/TreeStrutureNode.java
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxStateManager.java
trunk/framework/test/src/test/java/org/ajax4jsf/application/AjaxStateManagerTest.java
Log:
fix class name grammar error
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxStateManager.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxStateManager.java 2008-05-28
18:25:43 UTC (rev 8812)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxStateManager.java 2008-05-28
18:57:34 UTC (rev 8813)
@@ -160,7 +160,7 @@
* @see
javax.faces.application.StateManager#getTreeStructureToSave(javax.faces.context.FacesContext)
*/
protected Object getTreeStructureToSave(FacesContext context) {
- TreeStrutureNode treeStructure = new TreeStrutureNode();
+ TreeStructureNode treeStructure = new TreeStructureNode();
treeStructure.apply(context, context.getViewRoot(), new HashSet<String>());
return treeStructure;
}
@@ -214,10 +214,10 @@
UIViewRoot viewRoot = null;
ResponseStateManager responseStateManager = getRenderKit(context,
renderKitId).getResponseStateManager();
- TreeStrutureNode treeStructure = null;
+ TreeStructureNode treeStructure = null;
Object[] state = null;
if (isSavingStateInClient(context)) {
- treeStructure = (TreeStrutureNode) responseStateManager
+ treeStructure = (TreeStructureNode) responseStateManager
.getTreeStructureToRestore(context, viewId);
// viewRoot = parent.restoreView(context, viewId, renderKitId);
state = (Object[]) responseStateManager
@@ -226,7 +226,7 @@
Object[] serializedView = restoreStateFromSession(context, viewId,
renderKitId);
if (null != serializedView) {
- treeStructure = (TreeStrutureNode) serializedView[0];
+ treeStructure = (TreeStructureNode) serializedView[0];
state = (Object[]) serializedView[1];
}
}
@@ -268,7 +268,7 @@
SerializedView serializedView = null;
UIViewRoot viewRoot = context.getViewRoot();
if (null !=viewRoot && !viewRoot.isTransient()) {
- TreeStrutureNode treeStructure = (TreeStrutureNode) getTreeStructureToSave(context);
+ TreeStructureNode treeStructure = (TreeStructureNode)
getTreeStructureToSave(context);
Object state = getComponentStateToSave(context);
if (isSavingStateInClient(context)) {
serializedView = new SerializedView(treeStructure, state);
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/application/TreeStructureNode.java
(from rev 8808,
trunk/framework/impl/src/main/java/org/ajax4jsf/application/TreeStrutureNode.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/application/TreeStructureNode.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/application/TreeStructureNode.java 2008-05-28
18:57:34 UTC (rev 8813)
@@ -0,0 +1,220 @@
+/**
+ *
+ */
+package org.ajax4jsf.application;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+/**
+ * @author asmirnov
+ *
+ */
+final class TreeStructureNode implements Externalizable {
+ /**
+ * TODO - implement Externalizable to reduce serialized state.
+ */
+ private static final long serialVersionUID = -9038742487716977911L;
+
+ private static final String NULL_ID = "";
+
+ private Map<String, TreeStructureNode> facets = null;
+
+ private List<TreeStructureNode> children = null;
+
+ private String type;
+
+ private String id;
+
+ public TreeStructureNode() {
+ }
+
+ public void apply(FacesContext context, UIComponent component,
+ Set<String> uniqueIds) {
+ type = component.getClass().getName();
+ id = component.getId();
+ String clientId = component.getClientId(context);
+ if (!uniqueIds.add(clientId)) {
+ throw new IllegalStateException("duplicate Id for a component "
+ + clientId);
+ }
+ Map<String, UIComponent> componentFacets = component.getFacets();
+ for (Iterator<Entry<String,UIComponent>> i =
componentFacets.entrySet().iterator(); i
+ .hasNext();) {
+ Entry<String,UIComponent> element = i.next();
+ UIComponent f = element.getValue();
+ if (!f.isTransient()) {
+ TreeStructureNode facet = new TreeStructureNode();
+ facet.apply(context, f, uniqueIds);
+ if (null == facets) {
+ facets = new HashMap<String, TreeStructureNode>();
+ }
+ facets.put(element.getKey(), facet);
+
+ }
+ }
+ for (Iterator<UIComponent> i = component.getChildren().iterator(); i.hasNext();)
{
+ UIComponent child = i.next();
+ if (!child.isTransient()) {
+ TreeStructureNode t = new TreeStructureNode();
+ t.apply(context, child, uniqueIds);
+ if (null == children) {
+ children = new ArrayList<TreeStructureNode>();
+ }
+ children.add(t);
+
+ }
+ }
+ }
+
+ public UIComponent restore(ComponentsLoader loader) {
+ UIComponent component;
+ component = loader.createComponent(type);
+ component.setId(id);
+ if (null != facets) {
+ for (Iterator<Entry<String, TreeStructureNode>> i =
facets.entrySet().iterator(); i.hasNext();) {
+ Entry<String, TreeStructureNode> element = i.next();
+ UIComponent facet = ( element.getValue())
+ .restore(loader);
+ component.getFacets().put(element.getKey(), facet);
+ }
+
+ }
+ if (null != children) {
+ for (Iterator<TreeStructureNode> i = children.iterator(); i.hasNext();) {
+ TreeStructureNode node = i.next();
+ UIComponent child = node.restore(loader);
+ component.getChildren().add(child);
+ }
+
+ }
+ return component;
+ }
+
+ /**
+ * @return the facets
+ */
+ public Map<String, TreeStructureNode> getFacets() {
+ return facets;
+ }
+
+ /**
+ * @param facets
+ * the facets to set
+ */
+ public void setFacets(Map<String, TreeStructureNode> facets) {
+ this.facets = facets;
+ }
+
+ /**
+ * @return the children
+ */
+ public List<TreeStructureNode> getChildren() {
+ return children;
+ }
+
+ /**
+ * @param children
+ * the children to set
+ */
+ public void setChildren(List<TreeStructureNode> children) {
+ this.children = children;
+ }
+
+ /**
+ * @return the type
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * @param type
+ * the type to set
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ /**
+ * @return the id
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @param id
+ * the id to set
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public void readExternal(ObjectInput in) throws IOException,
+ ClassNotFoundException {
+ type = in.readUTF();
+ id = in.readUTF();
+ if (NULL_ID.equals(id)) {
+ id = null;
+ }
+ int facetsSize = in.readInt();
+ if (facetsSize > 0) {
+ facets = new HashMap<String, TreeStructureNode>(facetsSize);
+ for (int i = 0; i < facetsSize; i++) {
+ String facetName = in.readUTF();
+ TreeStructureNode facet = new TreeStructureNode();
+ facet.readExternal(in);
+ facets.put(facetName, facet);
+ }
+ }
+ int childrenSize = in.readInt();
+ if (childrenSize > 0) {
+ children = new ArrayList<TreeStructureNode>(childrenSize);
+ for (int i = 0; i < childrenSize; i++) {
+ TreeStructureNode child = new TreeStructureNode();
+ child.readExternal(in);
+ children.add(child);
+ }
+ }
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeUTF(type);
+ out.writeUTF(null == id ? NULL_ID : id);
+ if (null != facets) {
+ out.writeInt(facets.size());
+ for (Iterator<Map.Entry<String, TreeStructureNode>> i =
facets.entrySet().iterator(); i.hasNext();) {
+ Map.Entry<String, TreeStructureNode> entry = i.next();
+ out.writeUTF(entry.getKey());
+ TreeStructureNode node = entry.getValue();
+ node.writeExternal(out);
+ }
+
+ } else {
+ out.writeInt(0);
+ }
+ if (null != children) {
+ out.writeInt(children.size());
+ for (Iterator<TreeStructureNode> i = children.iterator(); i.hasNext();) {
+ TreeStructureNode child = i.next();
+ child.writeExternal(out);
+ }
+
+ } else {
+ out.writeInt(0);
+ }
+ }
+}
\ No newline at end of file
Property changes on:
trunk/framework/impl/src/main/java/org/ajax4jsf/application/TreeStructureNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Revision Author
Deleted:
trunk/framework/impl/src/main/java/org/ajax4jsf/application/TreeStrutureNode.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/application/TreeStrutureNode.java 2008-05-28
18:25:43 UTC (rev 8812)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/application/TreeStrutureNode.java 2008-05-28
18:57:34 UTC (rev 8813)
@@ -1,220 +0,0 @@
-/**
- *
- */
-package org.ajax4jsf.application;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Map.Entry;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-/**
- * @author asmirnov
- *
- */
-final class TreeStrutureNode implements Externalizable {
- /**
- * TODO - implement Externalizable to reduce serialized state.
- */
- private static final long serialVersionUID = -9038742487716977911L;
-
- private static final String NULL_ID = "";
-
- private Map<String, TreeStrutureNode> facets = null;
-
- private List<TreeStrutureNode> children = null;
-
- private String type;
-
- private String id;
-
- public TreeStrutureNode() {
- }
-
- public void apply(FacesContext context, UIComponent component,
- Set<String> uniqueIds) {
- type = component.getClass().getName();
- id = component.getId();
- String clientId = component.getClientId(context);
- if (!uniqueIds.add(clientId)) {
- throw new IllegalStateException("duplicate Id for a component "
- + clientId);
- }
- Map<String, UIComponent> componentFacets = component.getFacets();
- for (Iterator<Entry<String,UIComponent>> i =
componentFacets.entrySet().iterator(); i
- .hasNext();) {
- Entry<String,UIComponent> element = i.next();
- UIComponent f = element.getValue();
- if (!f.isTransient()) {
- TreeStrutureNode facet = new TreeStrutureNode();
- facet.apply(context, f, uniqueIds);
- if (null == facets) {
- facets = new HashMap<String, TreeStrutureNode>();
- }
- facets.put(element.getKey(), facet);
-
- }
- }
- for (Iterator<UIComponent> i = component.getChildren().iterator(); i.hasNext();)
{
- UIComponent child = i.next();
- if (!child.isTransient()) {
- TreeStrutureNode t = new TreeStrutureNode();
- t.apply(context, child, uniqueIds);
- if (null == children) {
- children = new ArrayList<TreeStrutureNode>();
- }
- children.add(t);
-
- }
- }
- }
-
- public UIComponent restore(ComponentsLoader loader) {
- UIComponent component;
- component = loader.createComponent(type);
- component.setId(id);
- if (null != facets) {
- for (Iterator<Entry<String, TreeStrutureNode>> i =
facets.entrySet().iterator(); i.hasNext();) {
- Entry<String, TreeStrutureNode> element = i.next();
- UIComponent facet = ( element.getValue())
- .restore(loader);
- component.getFacets().put(element.getKey(), facet);
- }
-
- }
- if (null != children) {
- for (Iterator<TreeStrutureNode> i = children.iterator(); i.hasNext();) {
- TreeStrutureNode node = i.next();
- UIComponent child = node.restore(loader);
- component.getChildren().add(child);
- }
-
- }
- return component;
- }
-
- /**
- * @return the facets
- */
- public Map<String, TreeStrutureNode> getFacets() {
- return facets;
- }
-
- /**
- * @param facets
- * the facets to set
- */
- public void setFacets(Map<String, TreeStrutureNode> facets) {
- this.facets = facets;
- }
-
- /**
- * @return the children
- */
- public List<TreeStrutureNode> getChildren() {
- return children;
- }
-
- /**
- * @param children
- * the children to set
- */
- public void setChildren(List<TreeStrutureNode> children) {
- this.children = children;
- }
-
- /**
- * @return the type
- */
- public String getType() {
- return type;
- }
-
- /**
- * @param type
- * the type to set
- */
- public void setType(String type) {
- this.type = type;
- }
-
- /**
- * @return the id
- */
- public String getId() {
- return id;
- }
-
- /**
- * @param id
- * the id to set
- */
- public void setId(String id) {
- this.id = id;
- }
-
- public void readExternal(ObjectInput in) throws IOException,
- ClassNotFoundException {
- type = in.readUTF();
- id = in.readUTF();
- if (NULL_ID.equals(id)) {
- id = null;
- }
- int facetsSize = in.readInt();
- if (facetsSize > 0) {
- facets = new HashMap<String, TreeStrutureNode>(facetsSize);
- for (int i = 0; i < facetsSize; i++) {
- String facetName = in.readUTF();
- TreeStrutureNode facet = new TreeStrutureNode();
- facet.readExternal(in);
- facets.put(facetName, facet);
- }
- }
- int childrenSize = in.readInt();
- if (childrenSize > 0) {
- children = new ArrayList<TreeStrutureNode>(childrenSize);
- for (int i = 0; i < childrenSize; i++) {
- TreeStrutureNode child = new TreeStrutureNode();
- child.readExternal(in);
- children.add(child);
- }
- }
- }
-
- public void writeExternal(ObjectOutput out) throws IOException {
- out.writeUTF(type);
- out.writeUTF(null == id ? NULL_ID : id);
- if (null != facets) {
- out.writeInt(facets.size());
- for (Iterator<Map.Entry<String, TreeStrutureNode>> i =
facets.entrySet().iterator(); i.hasNext();) {
- Map.Entry<String, TreeStrutureNode> entry = i.next();
- out.writeUTF(entry.getKey());
- TreeStrutureNode node = entry.getValue();
- node.writeExternal(out);
- }
-
- } else {
- out.writeInt(0);
- }
- if (null != children) {
- out.writeInt(children.size());
- for (Iterator<TreeStrutureNode> i = children.iterator(); i.hasNext();) {
- TreeStrutureNode child = i.next();
- child.writeExternal(out);
- }
-
- } else {
- out.writeInt(0);
- }
- }
-}
\ No newline at end of file
Modified:
trunk/framework/test/src/test/java/org/ajax4jsf/application/AjaxStateManagerTest.java
===================================================================
---
trunk/framework/test/src/test/java/org/ajax4jsf/application/AjaxStateManagerTest.java 2008-05-28
18:25:43 UTC (rev 8812)
+++
trunk/framework/test/src/test/java/org/ajax4jsf/application/AjaxStateManagerTest.java 2008-05-28
18:57:34 UTC (rev 8813)
@@ -133,11 +133,11 @@
public void testTreeNodeApply() throws Exception {
buildTestTree();
- TreeStrutureNode node = new TreeStrutureNode();
+ TreeStructureNode node = new TreeStructureNode();
node.apply(facesContext, facesContext.getViewRoot(), new HashSet());
assertEquals(2, node.getChildren().size());
assertEquals(1, node.getFacets().size());
- TreeStrutureNode nodeA = (TreeStrutureNode) node.getFacets().get(FACET_A);
+ TreeStructureNode nodeA = (TreeStructureNode) node.getFacets().get(FACET_A);
assertNotNull(nodeA);
assertEquals(1, nodeA.getChildren().size());
assertEquals(1, nodeA.getFacets().size());
@@ -145,7 +145,7 @@
public void testTreeNodeCheckUniqueId() throws Exception {
buildTestTree();
- TreeStrutureNode node = new TreeStrutureNode();
+ TreeStructureNode node = new TreeStructureNode();
UIViewRoot viewRoot = facesContext.getViewRoot();
((UIComponent)viewRoot.getChildren().get(0)).setId(FACET_A);
((UIComponent)viewRoot.getChildren().get(1)).setId(FACET_A);
@@ -161,17 +161,17 @@
public void testTreeNodeSerialisation() throws Exception {
buildTestTree();
- TreeStrutureNode node = new TreeStrutureNode();
+ TreeStructureNode node = new TreeStructureNode();
node.apply(facesContext, facesContext.getViewRoot(), new HashSet());
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(byteOut);
out.writeObject(node);
ByteArrayInputStream byteIn = new ByteArrayInputStream(byteOut.toByteArray());
ObjectInputStream in = new ObjectInputStream(byteIn);
- TreeStrutureNode nodeIn = (TreeStrutureNode) in.readObject();
+ TreeStructureNode nodeIn = (TreeStructureNode) in.readObject();
assertEquals(2, nodeIn.getChildren().size());
assertEquals(1, nodeIn.getFacets().size());
- TreeStrutureNode nodeA = (TreeStrutureNode) nodeIn.getFacets().get(FACET_A);
+ TreeStructureNode nodeA = (TreeStructureNode) nodeIn.getFacets().get(FACET_A);
assertNotNull(nodeA);
assertEquals(1, nodeA.getChildren().size());
assertEquals(1, nodeA.getFacets().size());