Class Serialization


  • public class Serialization
    extends Object
    Class for serialization utils such as writing any object value to a String and retrieving it by String + class name.
    Author:
    Eduardo Ramos
    • Field Detail

      • INSTANCE_WITHOUT_GRAPH_MODEL

        private static final Serialization INSTANCE_WITHOUT_GRAPH_MODEL
      • graphModel

        private final org.gephi.graph.api.GraphModel graphModel
      • colorPattern

        private final Pattern colorPattern
    • Constructor Detail

      • Serialization

        public Serialization()
      • Serialization

        public Serialization​(org.gephi.graph.api.GraphModel graphModel)
    • Method Detail

      • getValueAsText

        public static String getValueAsText​(Object value)
        Converts any value to a serialized String. Uses PropertyEditor for serialization except for values of Font class.
        Parameters:
        value - Value to serialize as String
        Returns:
        Result String or null if the value can't be serialized with a PropertyEditor
      • getValueAsText

        public static String getValueAsText​(Object value,
                                            Class valueClass)
        Converts any value to a serialized String. Uses PropertyEditor for serialization except for values of Font class.
        Parameters:
        value - Value to serialize as String
        valueClass - Class to use for the value
        Returns:
        Result String or null if the value can't be serialized with a PropertyEditor
      • readValueFromText

        public static Object readValueFromText​(String valueStr,
                                               Class valueClass)
        Deserializes a serialized String of the given class. Uses PropertyEditor for serialization except for values of Font class.
        Parameters:
        valueStr - String to deserialize
        valueClass - Class of the serialized value
        Returns:
        Deserialized value or null if it can't be deserialized with a PropertyEditor
      • readValueFromText

        public static Object readValueFromText​(String valueStr,
                                               String valueClassStr)
        Deserializes a serialized String of the given class name. Returns null if the class can't be found. Uses PropertyEditor for serialization except for values of Font class.
        Parameters:
        valueStr - String to deserialize
        valueClassStr - Class name of the serialized value
        Returns:
        Deserialized value or null if it can't be deserialized with a PropertyEditor
      • isPrimitiveOrPrimitiveWrapper

        public static boolean isPrimitiveOrPrimitiveWrapper​(Class<?> type)
      • parsePrimitiveOrWrapper

        public static Object parsePrimitiveOrWrapper​(Class valueClass,
                                                     String value)