| 79 |
79 |
|
| 80 |
80 |
import java.io.*;
|
| 81 |
81 |
import java.lang.reflect.*;
|
| 82 |
|
import java.nio.charset.StandardCharsets;
|
|
82 |
import java.nio.charset.*;
|
| 83 |
83 |
import java.util.*;
|
| 84 |
84 |
import java.util.function.*;
|
| 85 |
85 |
|
| ... | ... | |
| 123 |
123 |
/** A serializer for native <code>char</code> values. */
|
| 124 |
124 |
public static final CharSerializer CHAR_SERIALIZER = new CharSerializer();
|
| 125 |
125 |
|
| 126 |
|
/** A serializer for {@link String} values. */
|
| 127 |
|
public static final StringSerializer STRING_SERIALIZER = new StringSerializer();
|
| 128 |
|
|
| 129 |
126 |
/** Fallback serializer for other {@link Object} instances. */
|
| 130 |
127 |
public static final ObjectSerializer OBJECT_SERIALIZER = new ObjectSerializer();
|
| 131 |
128 |
|
| ... | ... | |
| 140 |
137 |
DOUBLE_SERIALIZER,
|
| 141 |
138 |
BOOLEAN_SERIALIZER,
|
| 142 |
139 |
CHAR_SERIALIZER,
|
| 143 |
|
STRING_SERIALIZER,
|
| 144 |
140 |
OBJECT_SERIALIZER
|
| 145 |
141 |
};
|
| 146 |
142 |
|
| ... | ... | |
| 1746 |
1742 |
{
|
| 1747 |
1743 |
return CHAR_SERIALIZER;
|
| 1748 |
1744 |
}
|
| 1749 |
|
else if (ftype == String.class)
|
| 1750 |
|
{
|
| 1751 |
|
return STRING_SERIALIZER;
|
| 1752 |
|
}
|
| 1753 |
1745 |
else
|
| 1754 |
1746 |
{
|
| 1755 |
1747 |
return OBJECT_SERIALIZER;
|
| ... | ... | |
| 2187 |
2179 |
}
|
| 2188 |
2180 |
|
| 2189 |
2181 |
/**
|
| 2190 |
|
* A serializer for {@link String} values.
|
| 2191 |
|
*/
|
| 2192 |
|
private static class StringSerializer
|
| 2193 |
|
extends NativeTypeSerializer
|
| 2194 |
|
{
|
| 2195 |
|
/**
|
| 2196 |
|
* Create serializer for {@link String} values and set its {@link NativeTypeSerializer#mark}
|
| 2197 |
|
* to <code>8</code>.
|
| 2198 |
|
*/
|
| 2199 |
|
protected StringSerializer()
|
| 2200 |
|
{
|
| 2201 |
|
super(8);
|
| 2202 |
|
}
|
| 2203 |
|
|
| 2204 |
|
/**
|
| 2205 |
|
* Worker to write the value to the specified destination, as a {@link String} value.
|
| 2206 |
|
*
|
| 2207 |
|
* @param value
|
| 2208 |
|
* The value to be written.
|
| 2209 |
|
* @param out
|
| 2210 |
|
* The destination.
|
| 2211 |
|
*
|
| 2212 |
|
* @throws IOException
|
| 2213 |
|
* In case of I/O errors.
|
| 2214 |
|
*/
|
| 2215 |
|
@Override
|
| 2216 |
|
protected void writeValueWorker(Object value, ObjectOutput out)
|
| 2217 |
|
throws IOException
|
| 2218 |
|
{
|
| 2219 |
|
out.writeUTF((String) value);
|
| 2220 |
|
}
|
| 2221 |
|
|
| 2222 |
|
/**
|
| 2223 |
|
* A worker to read the value from the specified source, as a {@link String} value.
|
| 2224 |
|
*
|
| 2225 |
|
* @param in
|
| 2226 |
|
* The source.
|
| 2227 |
|
*
|
| 2228 |
|
* @throws IOException
|
| 2229 |
|
* In case of I/O errors.
|
| 2230 |
|
*/
|
| 2231 |
|
@Override
|
| 2232 |
|
protected String readValueWorker(ObjectInput in)
|
| 2233 |
|
throws IOException
|
| 2234 |
|
{
|
| 2235 |
|
return in.readUTF();
|
| 2236 |
|
}
|
| 2237 |
|
}
|
| 2238 |
|
|
| 2239 |
|
/**
|
| 2240 |
2182 |
* A fallback serializer for {@link Object} instances.
|
| 2241 |
2183 |
*/
|
| 2242 |
2184 |
private static class ObjectSerializer
|
| ... | ... | |
| 2248 |
2190 |
*/
|
| 2249 |
2191 |
protected ObjectSerializer()
|
| 2250 |
2192 |
{
|
| 2251 |
|
super(9);
|
|
2193 |
super(8);
|
| 2252 |
2194 |
}
|
| 2253 |
2195 |
|
| 2254 |
2196 |
/**
|