Fixed the few uncheck warnings that I could... suppressed
the rest. Added an UnsupportedOperationException to SerializableSerializer so that it doesn't silently fail to do anything at all. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7219 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
49f65bd7aa
commit
0f1b05b405
@ -134,6 +134,7 @@ public abstract class Serializer {
|
||||
return registerClass(cls, true);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static SerializerRegistration registerClass(Class cls, boolean failOnMiss) {
|
||||
if (cls.isAnnotationPresent(Serializable.class)) {
|
||||
Serializable serializable = (Serializable)cls.getAnnotation(Serializable.class);
|
||||
@ -240,7 +241,8 @@ public abstract class Serializer {
|
||||
public static SerializerRegistration getExactSerializerRegistration(Class cls) {
|
||||
return classRegistrations.get(cls);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static SerializerRegistration getSerializerRegistration(Class cls) {
|
||||
SerializerRegistration reg = classRegistrations.get(cls);
|
||||
|
||||
@ -280,6 +282,7 @@ public abstract class Serializer {
|
||||
* @return The Object that was read.
|
||||
* @throws IOException If serialization failed.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Object readClassAndObject(ByteBuffer buffer) throws IOException {
|
||||
SerializerRegistration reg = readClass(buffer);
|
||||
if (reg == NULL_CLASS) return null;
|
||||
|
@ -43,6 +43,7 @@ import java.nio.ByteBuffer;
|
||||
*
|
||||
* @author Nathan Sweet
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class ArraySerializer extends Serializer {
|
||||
private int[] getDimensions (Object array) {
|
||||
int depth = 0;
|
||||
|
@ -41,6 +41,7 @@ import java.nio.ByteBuffer;
|
||||
*
|
||||
* @author Lars Wesselius
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class BooleanSerializer extends Serializer {
|
||||
|
||||
public Boolean readObject(ByteBuffer data, Class c) throws IOException {
|
||||
|
@ -41,7 +41,9 @@ import java.nio.ByteBuffer;
|
||||
*
|
||||
* @author Lars Wesselius
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class ByteSerializer extends Serializer {
|
||||
|
||||
public Byte readObject(ByteBuffer data, Class c) throws IOException {
|
||||
return data.get();
|
||||
}
|
||||
|
@ -41,7 +41,9 @@ import java.nio.ByteBuffer;
|
||||
*
|
||||
* @author Lars Wesselius
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class CharSerializer extends Serializer {
|
||||
|
||||
public Character readObject(ByteBuffer data, Class c) throws IOException {
|
||||
return data.getChar();
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ import java.util.logging.Level;
|
||||
*/
|
||||
public class CollectionSerializer extends Serializer {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T readObject(ByteBuffer data, Class<T> c) throws IOException {
|
||||
int length = data.getInt();
|
||||
|
||||
|
@ -42,7 +42,9 @@ import java.util.Date;
|
||||
*
|
||||
* @author Lars Wesselius
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class DateSerializer extends Serializer {
|
||||
|
||||
public Date readObject(ByteBuffer data, Class c) throws IOException {
|
||||
return new Date(data.getLong());
|
||||
}
|
||||
|
@ -41,7 +41,9 @@ import java.nio.ByteBuffer;
|
||||
*
|
||||
* @author Lars Wesselius
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class DoubleSerializer extends Serializer {
|
||||
|
||||
public Double readObject(ByteBuffer data, Class c) throws IOException {
|
||||
return data.getDouble();
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public class FieldSerializer extends Serializer {
|
||||
processingClass = processingClass.getSuperclass();
|
||||
}
|
||||
|
||||
List<SavedField> cachedFields = new ArrayList(fields.size());
|
||||
List<SavedField> cachedFields = new ArrayList<SavedField>(fields.size());
|
||||
for (Field field : fields) {
|
||||
int modifiers = field.getModifiers();
|
||||
if (Modifier.isTransient(modifiers)) continue;
|
||||
@ -87,6 +87,7 @@ public class FieldSerializer extends Serializer {
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T readObject(ByteBuffer data, Class<T> c) throws IOException {
|
||||
|
||||
// Read the null/non-null marker
|
||||
|
@ -41,7 +41,9 @@ import java.nio.ByteBuffer;
|
||||
*
|
||||
* @author Lars Wesselius
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class FloatSerializer extends Serializer {
|
||||
|
||||
public Float readObject(ByteBuffer data, Class c) throws IOException {
|
||||
return data.getFloat();
|
||||
}
|
||||
|
@ -49,6 +49,7 @@ import java.util.zip.GZIPOutputStream;
|
||||
*/
|
||||
public class GZIPSerializer extends Serializer {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T readObject(ByteBuffer data, Class<T> c) throws IOException {
|
||||
try
|
||||
{
|
||||
|
@ -41,7 +41,9 @@ import java.nio.ByteBuffer;
|
||||
*
|
||||
* @author Lars Wesselius
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class IntSerializer extends Serializer {
|
||||
|
||||
public Integer readObject(ByteBuffer data, Class c) throws IOException {
|
||||
return data.getInt();
|
||||
}
|
||||
|
@ -41,7 +41,9 @@ import java.nio.ByteBuffer;
|
||||
*
|
||||
* @author Lars Wesselius
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class LongSerializer extends Serializer {
|
||||
|
||||
public Long readObject(ByteBuffer data, Class c) throws IOException {
|
||||
return data.getLong();
|
||||
}
|
||||
|
@ -71,6 +71,7 @@ public class MapSerializer extends Serializer {
|
||||
|
||||
*/
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T readObject(ByteBuffer data, Class<T> c) throws IOException {
|
||||
int length = data.getInt();
|
||||
|
||||
@ -123,6 +124,7 @@ public class MapSerializer extends Serializer {
|
||||
return (T)map;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void writeObject(ByteBuffer buffer, Object object) throws IOException {
|
||||
Map map = (Map)object;
|
||||
int length = map.size();
|
||||
|
@ -101,6 +101,7 @@ public class SavableSerializer extends Serializer {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T readObject(ByteBuffer data, Class<T> c) throws IOException {
|
||||
BufferInputStream in = new BufferInputStream(data);
|
||||
Savable s = importer.load(in);
|
||||
|
@ -43,11 +43,14 @@ import java.nio.ByteBuffer;
|
||||
* TODO
|
||||
* @author Lars Wesselius
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class SerializableSerializer extends Serializer {
|
||||
|
||||
public Serializable readObject(ByteBuffer data, Class c) throws IOException {
|
||||
return null;
|
||||
throw new UnsupportedOperationException( "Serializable serialization not supported." );
|
||||
}
|
||||
|
||||
public void writeObject(ByteBuffer buffer, Object object) throws IOException {
|
||||
throw new UnsupportedOperationException( "Serializable serialization not supported." );
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ import java.nio.ByteBuffer;
|
||||
*
|
||||
* @author Lars Wesselius
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class ShortSerializer extends Serializer {
|
||||
public Short readObject(ByteBuffer data, Class c) throws IOException {
|
||||
return data.getShort();
|
||||
|
@ -42,7 +42,9 @@ import java.nio.ByteBuffer;
|
||||
*
|
||||
* @author Lars Wesselius
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class StringSerializer extends Serializer {
|
||||
|
||||
public String readObject(ByteBuffer data, Class c) throws IOException {
|
||||
|
||||
int length = -1;
|
||||
|
@ -8,7 +8,9 @@ import java.nio.ByteBuffer;
|
||||
/**
|
||||
* @author Kirill Vainer
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class Vector3Serializer extends Serializer {
|
||||
|
||||
public Vector3f readObject(ByteBuffer data, Class c) throws IOException {
|
||||
Vector3f vec3 = new Vector3f();
|
||||
vec3.x = data.getFloat();
|
||||
|
@ -50,6 +50,7 @@ import java.util.zip.ZipOutputStream;
|
||||
*/
|
||||
public class ZIPSerializer extends Serializer {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T readObject(ByteBuffer data, Class<T> c) throws IOException {
|
||||
try
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user