ExternalizableUtilStrategy.java 5.34 KB
Newer Older
Gaston Dombiak's avatar
Gaston Dombiak committed
1 2 3 4 5
/**
 * $RCSfile$
 * $Revision: $
 * $Date: $
 *
6
 * Copyright (C) 2005-2008 Jive Software. All rights reserved.
Gaston Dombiak's avatar
Gaston Dombiak committed
7 8
 *
 * This software is published under the terms of the GNU Public License (GPL),
9 10
 * a copy of which is included in this distribution, or a commercial license
 * agreement with Jive.
Gaston Dombiak's avatar
Gaston Dombiak committed
11 12 13
 */
package org.jivesoftware.util.cache;

Gaston Dombiak's avatar
Gaston Dombiak committed
14
import java.io.*;
15
import java.util.Collection;
Gaston Dombiak's avatar
Gaston Dombiak committed
16 17
import java.util.List;
import java.util.Map;
Gaston Dombiak's avatar
Gaston Dombiak committed
18
import java.util.Set;
Gaston Dombiak's avatar
Gaston Dombiak committed
19 20 21 22 23 24 25 26 27

/**
 * Interface that allows to provide different ways for implementing serialization of objects.
 * The open source version of the server will just provide a dummy implementation that does
 * nothing. The enterprise version will use Coherence as its underlying mechanism.
 *
 * @author Gaston Dombiak
 */
public interface ExternalizableUtilStrategy {
28

Gaston Dombiak's avatar
Gaston Dombiak committed
29 30 31 32 33 34 35 36
    /**
     * Writes a Map of String key and value pairs. This method handles the
     * case when the Map is <tt>null</tt>.
     *
     * @param out       the output stream.
     * @param stringMap the Map of String key/value pairs.
     * @throws java.io.IOException if an error occurs.
     */
37
    void writeStringMap(DataOutput out, Map<String, String> stringMap) throws IOException;
Gaston Dombiak's avatar
Gaston Dombiak committed
38 39 40 41 42 43 44 45 46

    /**
     * Reads a Map of String key and value pairs. This method will return
     * <tt>null</tt> if the Map written to the stream was <tt>null</tt>.
     *
     * @param in the input stream.
     * @return a Map of String key/value pairs.
     * @throws IOException if an error occurs.
     */
47
    Map<String, String> readStringMap(DataInput in) throws IOException;
Gaston Dombiak's avatar
Gaston Dombiak committed
48 49 50 51 52 53 54 55 56

    /**
     * Writes a Map of Long key and Integer value pairs. This method handles
     * the case when the Map is <tt>null</tt>.
     *
     * @param out the output stream.
     * @param map the Map of Long key/Integer value pairs.
     * @throws IOException if an error occurs.
     */
57
    void writeLongIntMap(DataOutput out, Map<Long, Integer> map) throws IOException;
Gaston Dombiak's avatar
Gaston Dombiak committed
58 59 60 61 62 63 64 65 66

    /**
     * Reads a Map of Long key and Integer value pairs. This method will return
     * <tt>null</tt> if the Map written to the stream was <tt>null</tt>.
     *
     * @param in the input stream.
     * @return a Map of Long key/Integer value pairs.
     * @throws IOException if an error occurs.
     */
67
    Map readLongIntMap(DataInput in) throws IOException;
Gaston Dombiak's avatar
Gaston Dombiak committed
68 69 70 71 72 73 74 75 76

    /**
     * Writes a List of Strings. This method handles the case when the List is
     * <tt>null</tt>.
     *
     * @param out        the output stream.
     * @param stringList the List of Strings.
     * @throws IOException if an error occurs.
     */
77
    void writeStringList(DataOutput out, List stringList) throws IOException;
Gaston Dombiak's avatar
Gaston Dombiak committed
78 79 80 81 82 83 84 85 86

    /**
     * Reads a List of Strings. This method will return <tt>null</tt> if the List
     * written to the stream was <tt>null</tt>.
     *
     * @param in the input stream.
     * @return a List of Strings.
     * @throws IOException if an error occurs.
     */
87
    List<String> readStringList(DataInput in) throws IOException;
Gaston Dombiak's avatar
Gaston Dombiak committed
88 89 90 91 92 93 94 95 96

    /**
     * Writes an array of long values. This method handles the case when the
     * array is <tt>null</tt>.
     *
     * @param out   the output stream.
     * @param array the array of long values.
     * @throws IOException if an error occurs.
     */
97
    void writeLongArray(DataOutput out, long[] array) throws IOException;
Gaston Dombiak's avatar
Gaston Dombiak committed
98 99 100 101 102 103 104 105 106

    /**
     * Reads an array of long values. This method will return <tt>null</tt> if
     * the array written to the stream was <tt>null</tt>.
     *
     * @param in the input stream.
     * @return an array of long values.
     * @throws IOException if an error occurs.
     */
107 108 109 110 111
    long[] readLongArray(DataInput in) throws IOException;

    void writeLong(DataOutput out, long value) throws IOException;

    long readLong(DataInput in) throws IOException;
Gaston Dombiak's avatar
Gaston Dombiak committed
112

113
    void writeBoolean(DataOutput out, boolean value) throws IOException;
Gaston Dombiak's avatar
Gaston Dombiak committed
114

115
    boolean readBoolean(DataInput in) throws IOException;
Gaston Dombiak's avatar
Gaston Dombiak committed
116

117 118 119 120
    void writeByteArray(DataOutput out, byte[] value) throws IOException;

    byte[] readByteArray(DataInput in) throws IOException;

Gaston Dombiak's avatar
Gaston Dombiak committed
121 122 123 124
    void writeSerializable(DataOutput out, Serializable value) throws IOException;

    Serializable readSerializable(DataInput in) throws IOException;

125
    void writeSafeUTF(DataOutput out, String value) throws IOException;
Gaston Dombiak's avatar
Gaston Dombiak committed
126

127
    String readSafeUTF(DataInput in) throws IOException;
Gaston Dombiak's avatar
Gaston Dombiak committed
128

129
    void writeExternalizableCollection(DataOutput out, Collection<? extends Externalizable> value) throws IOException;
Gaston Dombiak's avatar
Gaston Dombiak committed
130

131 132
    int readExternalizableCollection(DataInput in, Collection<? extends Externalizable> value, ClassLoader loader)
            throws IOException;
Gaston Dombiak's avatar
Gaston Dombiak committed
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148

    void writeExternalizableMap(DataOutput out, Map<String, ? extends Externalizable> map) throws IOException;

    int readExternalizableMap(DataInput in, Map<String, ? extends Externalizable> map, ClassLoader loader) throws IOException;

    void writeStringsMap(DataOutput out, Map<String, Set<String>> map)  throws IOException;

    int readStringsMap(DataInput in, Map<String, Set<String>> map) throws IOException;

    void writeStrings(DataOutput out, Collection<String> collection) throws IOException;

    int readStrings(DataInput in, Collection<String> collection) throws IOException;

    void writeInt(DataOutput out, int value) throws IOException;

    int readInt(DataInput in) throws IOException;
Gaston Dombiak's avatar
Gaston Dombiak committed
149
}