ExternalizableUtilStrategy.java 6.27 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 9 10 11 12 13 14 15 16 17 18
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
Gaston Dombiak's avatar
Gaston Dombiak committed
19 20 21
 */
package org.jivesoftware.util.cache;

Gaston Dombiak's avatar
Gaston Dombiak committed
22
import java.io.*;
23
import java.util.Collection;
Gaston Dombiak's avatar
Gaston Dombiak committed
24 25
import java.util.List;
import java.util.Map;
Gaston Dombiak's avatar
Gaston Dombiak committed
26
import java.util.Set;
Gaston Dombiak's avatar
Gaston Dombiak committed
27 28 29 30 31 32 33 34 35

/**
 * 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 {
36

Gaston Dombiak's avatar
Gaston Dombiak committed
37 38 39 40 41 42 43 44
    /**
     * 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.
     */
45
    void writeStringMap(DataOutput out, Map<String, String> stringMap) throws IOException;
Gaston Dombiak's avatar
Gaston Dombiak committed
46 47 48 49 50 51 52 53 54

    /**
     * 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.
     */
55
    Map<String, String> readStringMap(DataInput in) throws IOException;
Gaston Dombiak's avatar
Gaston Dombiak committed
56 57 58 59 60 61 62 63 64

    /**
     * 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.
     */
65
    void writeLongIntMap(DataOutput out, Map<Long, Integer> map) throws IOException;
Gaston Dombiak's avatar
Gaston Dombiak committed
66 67 68 69 70 71 72 73 74

    /**
     * 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.
     */
75
    Map<Long, Integer> readLongIntMap(DataInput in) throws IOException;
Gaston Dombiak's avatar
Gaston Dombiak committed
76 77 78 79 80 81 82 83 84

    /**
     * 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.
     */
85
    void writeStringList(DataOutput out, List<String> stringList) throws IOException;
Gaston Dombiak's avatar
Gaston Dombiak committed
86 87 88 89 90 91 92 93 94

    /**
     * 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.
     */
95
    List<String> readStringList(DataInput in) throws IOException;
Gaston Dombiak's avatar
Gaston Dombiak committed
96 97 98 99 100 101 102 103 104

    /**
     * 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.
     */
105
    void writeLongArray(DataOutput out, long[] array) throws IOException;
Gaston Dombiak's avatar
Gaston Dombiak committed
106 107 108 109 110 111 112 113 114

    /**
     * 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.
     */
115 116 117 118 119
    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
120

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

123
    boolean readBoolean(DataInput in) throws IOException;
Gaston Dombiak's avatar
Gaston Dombiak committed
124

125 126 127 128
    void writeByteArray(DataOutput out, byte[] value) throws IOException;

    byte[] readByteArray(DataInput in) throws IOException;

Gaston Dombiak's avatar
Gaston Dombiak committed
129 130 131 132
    void writeSerializable(DataOutput out, Serializable value) throws IOException;

    Serializable readSerializable(DataInput in) throws IOException;

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

135
    String readSafeUTF(DataInput in) throws IOException;
Gaston Dombiak's avatar
Gaston Dombiak committed
136

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

139 140
    int readExternalizableCollection(DataInput in, Collection<? extends Externalizable> value, ClassLoader loader)
            throws IOException;
Gaston Dombiak's avatar
Gaston Dombiak committed
141

142 143 144 145 146
    void writeSerializableCollection(DataOutput out, Collection<? extends Serializable> value) throws IOException;

    int readSerializableCollection(DataInput in, Collection<? extends Serializable> value, ClassLoader loader)
            throws IOException;
    
Gaston Dombiak's avatar
Gaston Dombiak committed
147 148 149 150
    void writeExternalizableMap(DataOutput out, Map<String, ? extends Externalizable> map) throws IOException;

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

151
    void writeSerializableMap(DataOutput out, Map<? extends Serializable, ? extends Serializable> map) throws IOException;
152

153
    int readSerializableMap(DataInput in, Map<? extends Serializable, ? extends Serializable> map, ClassLoader loader) throws IOException;
154
    
Gaston Dombiak's avatar
Gaston Dombiak committed
155 156 157 158 159 160 161 162 163 164 165
    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
166
}