001: /**
002: * $RCSfile$
003: * $Revision: $
004: * $Date: $
005: *
006: * Copyright (C) 2007 Jive Software. All rights reserved.
007: *
008: * This software is published under the terms of the GNU Public License (GPL),
009: * a copy of which is included in this distribution.
010: */package org.jivesoftware.util.cache;
011:
012: import java.io.*;
013: import java.util.Collection;
014: import java.util.List;
015: import java.util.Map;
016: import java.util.Set;
017:
018: /**
019: * Interface that allows to provide different ways for implementing serialization of objects.
020: * The open source version of the server will just provide a dummy implementation that does
021: * nothing. The enterprise version will use Coherence as its underlying mechanism.
022: *
023: * @author Gaston Dombiak
024: */
025: public interface ExternalizableUtilStrategy {
026:
027: /**
028: * Writes a Map of String key and value pairs. This method handles the
029: * case when the Map is <tt>null</tt>.
030: *
031: * @param out the output stream.
032: * @param stringMap the Map of String key/value pairs.
033: * @throws java.io.IOException if an error occurs.
034: */
035: void writeStringMap(DataOutput out, Map<String, String> stringMap)
036: throws IOException;
037:
038: /**
039: * Reads a Map of String key and value pairs. This method will return
040: * <tt>null</tt> if the Map written to the stream was <tt>null</tt>.
041: *
042: * @param in the input stream.
043: * @return a Map of String key/value pairs.
044: * @throws IOException if an error occurs.
045: */
046: Map<String, String> readStringMap(DataInput in) throws IOException;
047:
048: /**
049: * Writes a Map of Long key and Integer value pairs. This method handles
050: * the case when the Map is <tt>null</tt>.
051: *
052: * @param out the output stream.
053: * @param map the Map of Long key/Integer value pairs.
054: * @throws IOException if an error occurs.
055: */
056: void writeLongIntMap(DataOutput out, Map<Long, Integer> map)
057: throws IOException;
058:
059: /**
060: * Reads a Map of Long key and Integer value pairs. This method will return
061: * <tt>null</tt> if the Map written to the stream was <tt>null</tt>.
062: *
063: * @param in the input stream.
064: * @return a Map of Long key/Integer value pairs.
065: * @throws IOException if an error occurs.
066: */
067: Map readLongIntMap(DataInput in) throws IOException;
068:
069: /**
070: * Writes a List of Strings. This method handles the case when the List is
071: * <tt>null</tt>.
072: *
073: * @param out the output stream.
074: * @param stringList the List of Strings.
075: * @throws IOException if an error occurs.
076: */
077: void writeStringList(DataOutput out, List stringList)
078: throws IOException;
079:
080: /**
081: * Reads a List of Strings. This method will return <tt>null</tt> if the List
082: * written to the stream was <tt>null</tt>.
083: *
084: * @param in the input stream.
085: * @return a List of Strings.
086: * @throws IOException if an error occurs.
087: */
088: List<String> readStringList(DataInput in) throws IOException;
089:
090: /**
091: * Writes an array of long values. This method handles the case when the
092: * array is <tt>null</tt>.
093: *
094: * @param out the output stream.
095: * @param array the array of long values.
096: * @throws IOException if an error occurs.
097: */
098: void writeLongArray(DataOutput out, long[] array)
099: throws IOException;
100:
101: /**
102: * Reads an array of long values. This method will return <tt>null</tt> if
103: * the array written to the stream was <tt>null</tt>.
104: *
105: * @param in the input stream.
106: * @return an array of long values.
107: * @throws IOException if an error occurs.
108: */
109: long[] readLongArray(DataInput in) throws IOException;
110:
111: void writeLong(DataOutput out, long value) throws IOException;
112:
113: long readLong(DataInput in) throws IOException;
114:
115: void writeBoolean(DataOutput out, boolean value) throws IOException;
116:
117: boolean readBoolean(DataInput in) throws IOException;
118:
119: void writeByteArray(DataOutput out, byte[] value)
120: throws IOException;
121:
122: byte[] readByteArray(DataInput in) throws IOException;
123:
124: void writeSerializable(DataOutput out, Serializable value)
125: throws IOException;
126:
127: Serializable readSerializable(DataInput in) throws IOException;
128:
129: void writeSafeUTF(DataOutput out, String value) throws IOException;
130:
131: String readSafeUTF(DataInput in) throws IOException;
132:
133: void writeExternalizableCollection(DataOutput out,
134: Collection<? extends Externalizable> value)
135: throws IOException;
136:
137: int readExternalizableCollection(DataInput in,
138: Collection<? extends Externalizable> value,
139: ClassLoader loader) throws IOException;
140:
141: void writeExternalizableMap(DataOutput out,
142: Map<String, ? extends Externalizable> map)
143: throws IOException;
144:
145: int readExternalizableMap(DataInput in,
146: Map<String, ? extends Externalizable> map,
147: ClassLoader loader) throws IOException;
148:
149: void writeStringsMap(DataOutput out, Map<String, Set<String>> map)
150: throws IOException;
151:
152: int readStringsMap(DataInput in, Map<String, Set<String>> map)
153: throws IOException;
154:
155: void writeStrings(DataOutput out, Collection<String> collection)
156: throws IOException;
157:
158: int readStrings(DataInput in, Collection<String> collection)
159: throws IOException;
160:
161: void writeInt(DataOutput out, int value) throws IOException;
162:
163: int readInt(DataInput in) throws IOException;
164: }
|