Author: jason.greene(a)jboss.com
Date: 2008-10-14 19:18:15 -0400 (Tue, 14 Oct 2008)
New Revision: 6952
Added:
core/branches/flat/src/main/java/org/jboss/starobrno/marshall/EntryData.java
core/branches/flat/src/main/java/org/jboss/starobrno/marshall/EntryDataExceptionMarker.java
core/branches/flat/src/main/java/org/jboss/starobrno/marshall/EntryDataMarker.java
Log:
Add new entry wrappers
Added: core/branches/flat/src/main/java/org/jboss/starobrno/marshall/EntryData.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/marshall/EntryData.java
(rev 0)
+++
core/branches/flat/src/main/java/org/jboss/starobrno/marshall/EntryData.java 2008-10-14
23:18:15 UTC (rev 6952)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.starobrno.marshall;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Map;
+
+/**
+ * Serializable representation of the data of a node (FQN and attributes)
+ *
+ * @author Bela Ban
+ * @version $Id: NodeData.java 6776 2008-09-22 17:35:46Z manik.surtani(a)jboss.com $
+ */
+// TODO: 3.0.0: remove Externalizable and rely on the CacheMarshaller.
+public class EntryData<K, V> implements Externalizable, Map.Entry<K, V>
+{
+ private K key;
+ private V value;
+
+ static final long serialVersionUID = -7571995794010294485L;
+
+ public EntryData(K key, V value)
+ {
+ this.key = key;
+ this.value = value;
+ }
+
+ public K getKey()
+ {
+ return key;
+ }
+
+ public V getValue()
+ {
+ return value;
+ }
+
+ // TODO: 3.0.0: Remove and replace with marshallNodeData/unmarshallNodeData methods in
the CacheMarshaller so that we can use the same marshalling framework for Fqns.
+ public void writeExternal(ObjectOutput out) throws IOException
+ {
+ out.writeObject(key);
+ out.writeObject(value);
+ }
+
+ // TODO: 3.0.0: Remove in and replace with marshallNodeData/unmarshallNodeData methods
in the CacheMarshaller so that we can use the same marshalling framework for Fqns.
+ @SuppressWarnings("unchecked")
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ {
+ key = (K) in.readObject();
+ value = (V) in.readObject();
+ }
+
+ @Override
+ public String toString()
+ {
+ return "{" + key + "=" + value + "}";
+ }
+
+ private static boolean eq(Object a, Object b)
+ {
+ return a == b || (a != null && a.equals(b));
+ }
+
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o) return true;
+ if (! (o instanceof EntryData))
+ return false;
+
+ EntryData<?,?> other = (EntryData<?,?>)o;
+ return eq(key, other.key) && eq(value, other.value);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result;
+ result = (key != null ? key.hashCode() : 0);
+ result = 31 * result + (value != null ? value.hashCode() : 0);
+ return result;
+ }
+
+ public V setValue(V value)
+ {
+ throw new UnsupportedOperationException();
+ }
+}
Added:
core/branches/flat/src/main/java/org/jboss/starobrno/marshall/EntryDataExceptionMarker.java
===================================================================
---
core/branches/flat/src/main/java/org/jboss/starobrno/marshall/EntryDataExceptionMarker.java
(rev 0)
+++
core/branches/flat/src/main/java/org/jboss/starobrno/marshall/EntryDataExceptionMarker.java 2008-10-14
23:18:15 UTC (rev 6952)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.starobrno.marshall;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+public class EntryDataExceptionMarker implements Externalizable
+{
+ private static final long serialVersionUID = 240199474174502551L;
+ private Throwable cause;
+ private Object cacheNodeIdentity;
+
+ public EntryDataExceptionMarker(Throwable t, Object node)
+ {
+ cause = t;
+ cacheNodeIdentity = node;
+ }
+
+ public Throwable getCause()
+ {
+ return cause;
+ }
+
+ public Object getCacheNodeIdentity()
+ {
+ return cacheNodeIdentity;
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException
+ {
+ out.writeObject(cause);
+ out.writeObject(cacheNodeIdentity);
+ }
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ {
+ cause = (Throwable) in.readObject();
+ cacheNodeIdentity = in.readObject();
+ }
+}
\ No newline at end of file
Added: core/branches/flat/src/main/java/org/jboss/starobrno/marshall/EntryDataMarker.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/marshall/EntryDataMarker.java
(rev 0)
+++
core/branches/flat/src/main/java/org/jboss/starobrno/marshall/EntryDataMarker.java 2008-10-14
23:18:15 UTC (rev 6952)
@@ -0,0 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.starobrno.marshall;
+
+import java.io.Serializable;
+
+public class EntryDataMarker implements Serializable
+{
+ private static final long serialVersionUID = 4851793846346021014L;
+}