Author: julien(a)jboss.com
Date: 2008-04-03 14:00:53 -0400 (Thu, 03 Apr 2008)
New Revision: 10492
Added:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/navigational/
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/navigational/NavigationalStateContextImpl.java
Removed:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model/state/navigational/
Modified:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/AbstractModelTestCase.java
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/TraversalModelTestCase.java
Log:
moved NavigationalStateContextImpl in a better place
Added:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/navigational/NavigationalStateContextImpl.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/navigational/NavigationalStateContextImpl.java
(rev 0)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/impl/state/navigational/NavigationalStateContextImpl.java 2008-04-03
18:00:53 UTC (rev 10492)
@@ -0,0 +1,113 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.impl.state.navigational;
+
+import org.jboss.portal.presentation.state.navigational.NavigationalStateContext;
+import org.jboss.portal.presentation.state.StateChangeVetoException;
+import org.jboss.portal.presentation.state.StateException;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class NavigationalStateContextImpl implements NavigationalStateContext
+{
+
+ /** . */
+ private final Map<Key, Object> map;
+
+ public NavigationalStateContextImpl(Map<Key, Object> map)
+ {
+ this.map = map;
+ }
+
+ public NavigationalStateContextImpl()
+ {
+ this(new HashMap<Key, Object>());
+ }
+
+ public void set(String objectId, String key, Object navigationalState) throws
StateChangeVetoException, StateException, IllegalArgumentException
+ {
+ Key key2 = new Key(objectId, key);
+
+ //
+ if (navigationalState != null)
+ {
+ map.put(key2, navigationalState);
+ }
+ else
+ {
+ map.remove(key2);
+ }
+ }
+
+ public Object get(String objectId, String key) throws IllegalArgumentException
+ {
+ return map.get(new Key(objectId, key));
+ }
+
+ private final class Key
+ {
+ /** . */
+ private final String objectId;
+
+ /** . */
+ private final String key;
+
+ private Key(String objectId, String key)
+ {
+ if (objectId == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (key == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.objectId = objectId;
+ this.key = key;
+ }
+
+ public int hashCode()
+ {
+ return objectId.hashCode() * 43 + key.hashCode();
+ }
+
+ public boolean equals(Object o)
+ {
+ if (o == this)
+ {
+ return true;
+ }
+ if (o instanceof Key)
+ {
+ Key that = (Key)o;
+ return objectId.equals(that.objectId) && key.equals(that.key);
+ }
+ return false;
+ }
+ }
+}
\ No newline at end of file
Modified:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/AbstractModelTestCase.java
===================================================================
---
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/AbstractModelTestCase.java 2008-04-03
15:04:02 UTC (rev 10491)
+++
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/AbstractModelTestCase.java 2008-04-03
18:00:53 UTC (rev 10492)
@@ -25,7 +25,7 @@
import org.jboss.portal.presentation.model2.UIModel;
import org.jboss.portal.presentation.test.model.state.structural.MockModel;
import org.jboss.portal.presentation.test.model.state.structural.MockModelImpl;
-import
org.jboss.portal.presentation.test.model.state.navigational.NavigationalStateContextImpl;
+import
org.jboss.portal.presentation.impl.state.navigational.NavigationalStateContextImpl;
import org.jboss.portal.presentation.state.structural.StructuralStateContext;
import org.jboss.portal.presentation.impl.model2.UIModelImpl;
import junit.framework.TestCase;
Modified:
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/TraversalModelTestCase.java
===================================================================
---
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/TraversalModelTestCase.java 2008-04-03
15:04:02 UTC (rev 10491)
+++
modules/presentation/trunk/presentation/src/test/java/org/jboss/portal/presentation/test/model3/TraversalModelTestCase.java 2008-04-03
18:00:53 UTC (rev 10492)
@@ -26,7 +26,7 @@
import org.jboss.portal.presentation.model2.UIModel;
import org.jboss.portal.presentation.test.model.state.structural.MockModel;
import org.jboss.portal.presentation.test.model.state.structural.MockModelImpl;
-import
org.jboss.portal.presentation.test.model.state.navigational.NavigationalStateContextImpl;
+import
org.jboss.portal.presentation.impl.state.navigational.NavigationalStateContextImpl;
import org.jboss.portal.presentation.state.structural.StructuralStateContext;
import org.jboss.portal.presentation.impl.model2.UIModelImpl;