org.bukkit.configuration.serialization
Class ConfigurationSerialization

java.lang.Object
  extended by org.bukkit.configuration.serialization.ConfigurationSerialization

public class ConfigurationSerialization
extends Object

Utility class for storing and retrieving classes for Configuration.


Field Summary
static String SERIALIZED_TYPE_KEY
           
 
Constructor Summary
protected ConfigurationSerialization(Class<? extends ConfigurationSerializable> clazz)
           
 
Method Summary
 ConfigurationSerializable deserialize(Map<String,Object> args)
           
static ConfigurationSerializable deserializeObject(Map<String,Object> args)
          Attempts to deserialize the given arguments into a new instance of the given class.
static ConfigurationSerializable deserializeObject(Map<String,Object> args, Class<? extends ConfigurationSerializable> clazz)
          Attempts to deserialize the given arguments into a new instance of the given class.
protected  ConfigurationSerializable deserializeViaCtor(Constructor<? extends ConfigurationSerializable> ctor, Map<String,Object> args)
           
protected  ConfigurationSerializable deserializeViaMethod(Method method, Map<String,Object> args)
           
static String getAlias(Class<? extends ConfigurationSerializable> clazz)
          Gets the correct alias for the given ConfigurationSerializable class
static Class<? extends ConfigurationSerializable> getClassByAlias(String alias)
          Attempts to get a registered ConfigurationSerializable class by its alias
protected  Constructor<? extends ConfigurationSerializable> getConstructor()
           
protected  Method getMethod(String name, boolean isStatic)
           
static void registerClass(Class<? extends ConfigurationSerializable> clazz)
          Registers the given ConfigurationSerializable class by its alias
static void registerClass(Class<? extends ConfigurationSerializable> clazz, String alias)
          Registers the given alias to the specified ConfigurationSerializable class
static void unregisterClass(Class<? extends ConfigurationSerializable> clazz)
          Unregisters any aliases for the specified ConfigurationSerializable class
static void unregisterClass(String alias)
          Unregisters the specified alias to a ConfigurationSerializable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SERIALIZED_TYPE_KEY

public static final String SERIALIZED_TYPE_KEY
See Also:
Constant Field Values
Constructor Detail

ConfigurationSerialization

protected ConfigurationSerialization(Class<? extends ConfigurationSerializable> clazz)
Method Detail

getMethod

protected Method getMethod(String name,
                           boolean isStatic)

getConstructor

protected Constructor<? extends ConfigurationSerializable> getConstructor()

deserializeViaMethod

protected ConfigurationSerializable deserializeViaMethod(Method method,
                                                         Map<String,Object> args)

deserializeViaCtor

protected ConfigurationSerializable deserializeViaCtor(Constructor<? extends ConfigurationSerializable> ctor,
                                                       Map<String,Object> args)

deserialize

public ConfigurationSerializable deserialize(Map<String,Object> args)

deserializeObject

public static ConfigurationSerializable deserializeObject(Map<String,Object> args,
                                                          Class<? extends ConfigurationSerializable> clazz)
Attempts to deserialize the given arguments into a new instance of the given class.

The class must implement ConfigurationSerializable, including the extra methods as specified in the javadoc of ConfigurationSerializable.

If a new instance could not be made, an example being the class not fully implementing the interface, null will be returned.

Parameters:
args - Arguments for deserialization
clazz - Class to deserialize into
Returns:
New instance of the specified class

deserializeObject

public static ConfigurationSerializable deserializeObject(Map<String,Object> args)
Attempts to deserialize the given arguments into a new instance of the given class.

The class must implement ConfigurationSerializable, including the extra methods as specified in the javadoc of ConfigurationSerializable.

If a new instance could not be made, an example being the class not fully implementing the interface, null will be returned.

Parameters:
args - Arguments for deserialization
Returns:
New instance of the specified class

registerClass

public static void registerClass(Class<? extends ConfigurationSerializable> clazz)
Registers the given ConfigurationSerializable class by its alias

Parameters:
clazz - Class to register

registerClass

public static void registerClass(Class<? extends ConfigurationSerializable> clazz,
                                 String alias)
Registers the given alias to the specified ConfigurationSerializable class

Parameters:
clazz - Class to register
alias - Alias to register as
See Also:
SerializableAs

unregisterClass

public static void unregisterClass(String alias)
Unregisters the specified alias to a ConfigurationSerializable

Parameters:
alias - Alias to unregister

unregisterClass

public static void unregisterClass(Class<? extends ConfigurationSerializable> clazz)
Unregisters any aliases for the specified ConfigurationSerializable class

Parameters:
clazz - Class to unregister

getClassByAlias

public static Class<? extends ConfigurationSerializable> getClassByAlias(String alias)
Attempts to get a registered ConfigurationSerializable class by its alias

Parameters:
alias - Alias of the serializable
Returns:
Registered class, or null if not found

getAlias

public static String getAlias(Class<? extends ConfigurationSerializable> clazz)
Gets the correct alias for the given ConfigurationSerializable class

Parameters:
clazz - Class to get alias for
Returns:
Alias to use for the class


Copyright © 2013. All Rights Reserved.