1 /* 2 * Copyright (C) 2005-2008 Jive Software. All rights reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package org.jivesoftware.util.cache; 17 18 import java.io.*; 19 import java.util.*; 20 21 /** 22 * Dummy implementation that does nothing. The open source version of the server uses this 23 * strategy. 24 * 25 * @author Gaston Dombiak 26 * @deprecated Use {@link DefaultExternalizableUtil} which, unlike this implementation, provides actual serialization functionality. 27 */ 28 @Deprecated 29 public class DummyExternalizableUtil implements ExternalizableUtilStrategy { 30 /** 31 * Writes a Map of String key and value pairs. This method handles the 32 * case when the Map is {@code null}. 33 * 34 * @param out the output stream. 35 * @param stringMap the Map of String key/value pairs. 36 * @throws java.io.IOException if an error occurs. 37 */ 38 @Override writeStringMap(DataOutput out, Map<String, String> stringMap)39 public void writeStringMap(DataOutput out, Map<String, String> stringMap) throws IOException { 40 // Do nothing 41 } 42 43 /** 44 * Reads a Map of String key and value pairs. This method will return 45 * {@code null} if the Map written to the stream was {@code null}. 46 * 47 * @param in the input stream. 48 * @return a Map of String key/value pairs. 49 * @throws IOException if an error occurs. 50 */ 51 @Override readStringMap(DataInput in)52 public Map<String, String> readStringMap(DataInput in) throws IOException { 53 // Do nothing 54 return Collections.emptyMap(); 55 } 56 57 /** 58 * Writes a Map of Long key and Integer value pairs. This method handles 59 * the case when the Map is {@code null}. 60 * 61 * @param out the output stream. 62 * @param map the Map of Long key/Integer value pairs. 63 * @throws IOException if an error occurs. 64 */ 65 @Override writeLongIntMap(DataOutput out, Map<Long, Integer> map)66 public void writeLongIntMap(DataOutput out, Map<Long, Integer> map) throws IOException { 67 // Do nothing 68 } 69 70 /** 71 * Reads a Map of Long key and Integer value pairs. This method will return 72 * {@code null} if the Map written to the stream was {@code null}. 73 * 74 * @param in the input stream. 75 * @return a Map of Long key/Integer value pairs. 76 * @throws IOException if an error occurs. 77 */ 78 @Override readLongIntMap(DataInput in)79 public Map<Long, Integer> readLongIntMap(DataInput in) throws IOException { 80 // Do nothing 81 return Collections.emptyMap(); 82 } 83 84 /** 85 * Writes a List of Strings. This method handles the case when the List is 86 * {@code null}. 87 * 88 * @param out the output stream. 89 * @param stringList the List of Strings. 90 * @throws IOException if an error occurs. 91 */ 92 @Override writeStringList(DataOutput out, List<String> stringList)93 public void writeStringList(DataOutput out, List<String> stringList) throws IOException { 94 // Do nothing 95 } 96 97 /** 98 * Reads a List of Strings. This method will return {@code null} if the List 99 * written to the stream was {@code null}. 100 * 101 * @param in the input stream. 102 * @return a List of Strings. 103 * @throws IOException if an error occurs. 104 */ 105 @Override readStringList(DataInput in)106 public List<String> readStringList(DataInput in) throws IOException { 107 // Do nothing 108 return Collections.emptyList(); 109 } 110 111 /** 112 * Writes an array of long values. This method handles the case when the 113 * array is {@code null}. 114 * 115 * @param out the output stream. 116 * @param array the array of long values. 117 * @throws IOException if an error occurs. 118 */ 119 @Override writeLongArray(DataOutput out, long[] array)120 public void writeLongArray(DataOutput out, long[] array) throws IOException { 121 // Do nothing 122 } 123 124 /** 125 * Reads an array of long values. This method will return {@code null} if 126 * the array written to the stream was {@code null}. 127 * 128 * @param in the input stream. 129 * @return an array of long values. 130 * @throws IOException if an error occurs. 131 */ 132 @Override readLongArray(DataInput in)133 public long[] readLongArray(DataInput in) throws IOException { 134 // Do nothing 135 return new long[]{}; 136 } 137 138 @Override writeLong(DataOutput out, long value)139 public void writeLong(DataOutput out, long value) { 140 // Do nothing 141 } 142 143 @Override readLong(DataInput in)144 public long readLong(DataInput in) { 145 // Do nothing 146 return 0; 147 } 148 149 @Override writeBoolean(DataOutput out, boolean value)150 public void writeBoolean(DataOutput out, boolean value) { 151 // Do nothing 152 } 153 154 @Override readBoolean(DataInput in)155 public boolean readBoolean(DataInput in) { 156 // Do nothing 157 return false; 158 } 159 160 @Override writeByteArray(DataOutput out, byte[] value)161 public void writeByteArray(DataOutput out, byte[] value) throws IOException { 162 // Do nothing 163 } 164 165 @Override readByteArray(DataInput in)166 public byte[] readByteArray(DataInput in) throws IOException { 167 // Do nothing 168 return new byte[0]; 169 } 170 171 @Override writeSerializable(DataOutput out, Serializable value)172 public void writeSerializable(DataOutput out, Serializable value) throws IOException { 173 // Do nothing 174 } 175 176 @Override readSerializable(DataInput in)177 public Serializable readSerializable(DataInput in) throws IOException { 178 // Do nothing 179 return null; 180 } 181 182 @Override writeSafeUTF(DataOutput out, String value)183 public void writeSafeUTF(DataOutput out, String value) { 184 // Do nothing 185 } 186 187 @Override readSafeUTF(DataInput in)188 public String readSafeUTF(DataInput in) { 189 // Do nothing 190 return ""; 191 } 192 193 @Override writeExternalizableCollection(DataOutput out, Collection<? extends Externalizable> value)194 public void writeExternalizableCollection(DataOutput out, Collection<? extends Externalizable> value) 195 throws IOException { 196 // Do nothing 197 } 198 199 @Override readExternalizableCollection(DataInput in, Collection<? extends Externalizable> value, ClassLoader loader)200 public int readExternalizableCollection(DataInput in, Collection<? extends Externalizable> value, 201 ClassLoader loader) throws IOException { 202 // Do nothing 203 return 0; 204 } 205 206 @Override writeSerializableCollection(DataOutput out, Collection<? extends Serializable> value)207 public void writeSerializableCollection(DataOutput out, Collection<? extends Serializable> value) 208 throws IOException { 209 // Do nothing 210 } 211 212 @Override readSerializableCollection(DataInput in, Collection<? extends Serializable> value, ClassLoader loader)213 public int readSerializableCollection(DataInput in, Collection<? extends Serializable> value, 214 ClassLoader loader) throws IOException { 215 // Do nothing 216 return 0; 217 } 218 219 @Override writeExternalizableMap(DataOutput out, Map<String, ? extends Externalizable> map)220 public void writeExternalizableMap(DataOutput out, Map<String, ? extends Externalizable> map) throws IOException { 221 // Do nothing 222 } 223 224 @Override readExternalizableMap(DataInput in, Map<String, ? extends Externalizable> map, ClassLoader loader)225 public int readExternalizableMap(DataInput in, Map<String, ? extends Externalizable> map, ClassLoader loader) 226 throws IOException { 227 // Do nothing 228 return 0; 229 } 230 231 @Override writeSerializableMap(DataOutput out, Map<? extends Serializable, ? extends Serializable> map)232 public void writeSerializableMap(DataOutput out, Map<? extends Serializable, ? extends Serializable> map) throws IOException { 233 // Do nothing 234 } 235 236 @Override readSerializableMap(DataInput in, Map<? extends Serializable, ? extends Serializable> map, ClassLoader loader)237 public int readSerializableMap(DataInput in, Map<? extends Serializable, ? extends Serializable> map, ClassLoader loader) 238 throws IOException { 239 // Do nothing 240 return 0; 241 } 242 @Override writeStringsMap(DataOutput out, Map<String, Set<String>> map)243 public void writeStringsMap(DataOutput out, Map<String, Set<String>> map) throws IOException { 244 // Do nothing 245 } 246 247 @Override readStringsMap(DataInput in, Map<String, Set<String>> map)248 public int readStringsMap(DataInput in, Map<String, Set<String>> map) throws IOException { 249 // Do nothing 250 return 0; 251 } 252 253 @Override writeStrings(DataOutput out, Collection<String> collection)254 public void writeStrings(DataOutput out, Collection<String> collection) throws IOException { 255 // Do nothing 256 } 257 258 @Override readStrings(DataInput in, Collection<String> collection)259 public int readStrings(DataInput in, Collection<String> collection) throws IOException { 260 // Do nothing 261 return 0; 262 } 263 264 @Override writeInt(DataOutput out, int value)265 public void writeInt(DataOutput out, int value) { 266 // Do nothing 267 } 268 269 @Override readInt(DataInput in)270 public int readInt(DataInput in) { 271 // Do nothing 272 return 0; 273 } 274 } 275