Package com.jalios.jstore
Class StoreUtil
java.lang.Object
com.jalios.jstore.StoreUtil
- All Implemented Interfaces:
StoreConstants
This class contains static utility methods
- Author:
- Olivier Dedieu
-
Field Summary
Fields inherited from interface com.jalios.jstore.StoreConstants
ARRAY_FLAG, CLEANING_STATE, COLLECTION_FLAG, CREATE_OP, DELETE_OP, IDLE_STATE, INNER_LOGS, INNER_MILESTONE, INNER_PREFIX, INNER_SYNC, ITEM_ESCAPE_CHAR, ITEM_SEPARATOR, LOADING_STATE, LOG_DIR_LOG_PREFIX, LOG_DIR_LOG_WORK, MAP_ASSIGN, MAP_CHARS_TO_ESCAPE, MAP_CLASS_SEPARATOR, MAP_FLAG, NAMESPACE, SH_SUFFIX, STORING_STATE, UPDATE_OP -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanChecks if the given urid is validstatic StampTablecomputeMinStampTable(Collection<StampTable> stampTables) Computes the minimal StampTable of a collection of stampTablestatic ArrayList<?> decodeArrayList(String listStr, Store store, DecodeContext ctxt) static boolean[]decodeBooleanArray(String arrayStr) static byte[]decodeByteArray(String arrayStr) static char[]decodeCharArray(String arrayStr) static Class<?> decodeClass(String classStr, Store store) static Collection<?> decodeCollection(String collStr, Store store, Collection<Object> coll, DecodeContext ctxt) static DatedecodeDate(String dateStr) static double[]decodeDoubleArray(String arrayStr) static float[]decodeFloatArray(String arrayStr) static HashMap<?, ?> decodeHashMap(String mapStr, Store store, DecodeContext ctxt) static HashSet<?> decodeHashSet(String setStr, Store store, DecodeContext ctxt) static Hashtable<?, ?> decodeHashtable(String mapStr, Store store, DecodeContext ctxt) static int[]decodeIntArray(String arrayStr) static LinkedHashMap<?, ?> decodeLinkedHashMap(String mapStr, Store store, DecodeContext ctxt) static LinkedList<?> decodeLinkedList(String listStr, Store store, DecodeContext ctxt) static long[]decodeLongArray(String arrayStr) static Map<?, ?> static <T> TdecodeObject(Class<T> clazz, String objStr, Store store, DecodeContext ctxt) Generic object decoderstatic Object[]decodeObjectArray(String arrayStr, Class<?> componentType, Store store) static Object[]decodeObjectArray(String arrayStr, Class<?> componentType, Store store, DecodeContext ctxt) static PropertiesdecodeProperties(String propertiesStr, DecodeContext ctxt) static short[]decodeShortArray(String arrayStr) static StorabledecodeStorable(String id, Store store) static TreeMap<?, ?> decodeTreeMap(String mapStr, Store store, DecodeContext ctxt) static TreeSet<?> decodeTreeSet(String setStr, Store store, DecodeContext ctxt) static Vector<?> decodeVector(String vectorStr, Store store, DecodeContext ctxt) static ZoneIddecodeZoneId(String objStr, DecodeContext ctxt) static StringencodeArrayList(ArrayList<?> list, Store store) static StringencodeBooleanArray(boolean[] array) static StringencodeByteArray(byte[] array) static StringencodeCharArray(char[] array) static StringencodeClass(Class<?> clazz) static StringencodeCollection(Collection<?> coll, Store store) static StringencodeDate(Date date) static StringencodeDoubleArray(double[] array) static StringencodeFloatArray(float[] array) static StringencodeHashMap(HashMap<?, ?> map, Store store) static StringencodeHashSet(HashSet<?> set, Store store) static StringencodeHashtable(Hashtable<?, ?> map, Store store) static StringencodeIntArray(int[] array) static StringencodeLinkedHashMap(LinkedHashMap<?, ?> map, Store store) static StringencodeLinkedList(LinkedList<?> list, Store store) static StringencodeLongArray(long[] array) static Stringstatic StringencodeObject(Object obj, Store store) Generic object encoderstatic StringencodeObjectArray(Object[] array, Store store) static StringencodeProperties(Properties properties) static StringencodeShortArray(short[] array) static StringencodeStorable(Storable storable, Store store) static StringencodeTreeMap(TreeMap<?, ?> map, Store store) static StringencodeTreeSet(TreeSet<?> set, Store store) static StringencodeVector(Vector<?> vector, Store store) static StringencodeZoneId(ZoneId zoneId) static StampfindGCS(List<StorableLogEntry> opList, StampTable minPT, Stamp minUnknownStamp) Find the GCS (Greatest Common Stamp) in the given list of operations according the given stampTable.static StampfindMinStamp(Collection<StampTable> stampTables, String urid) Find the minimal stamp for a given urid in a collection of StampTablestatic StringGenerates an URID based on the local hostnamestatic FieldReturns a Field object that reflects the specified declared field of the class or interface represented by this Class object.static ObjectgetFieldValue(Object instance, Field field) static StringgetGetterMethodName(Field field) static StringgetSetterMethodName(Field field) static booleanReturns true if this value is an array.static booleanisArrayOrCollection(String value) Returns true if this value is an array or a collection.static booleanisCollection(String value) Returns true if this value is a collection.static booleanReturns true if this value is a map.static voidstatic voidsetFieldValue(Storable storable, Field field, Object fieldValue)
-
Constructor Details
-
StoreUtil
public StoreUtil()
-
-
Method Details
-
generateUrid
Generates an URID based on the local hostname- Returns:
- the URID
- Since:
- jcms-4.0.2
-
checkUrid
Checks if the given urid is valid- Parameters:
urid- the urid to be checked- Returns:
- true if the urid is valid
- Since:
- jcms-5.0.0
-
main
-
getGetterMethodName
- Parameters:
field- the field- Returns:
- the getter method name
- See Also:
-
getSetterMethodName
- Parameters:
field- the field- Returns:
- the setter method name
- See Also:
-
getField
Returns a Field object that reflects the specified declared field of the class or interface represented by this Class object.- Parameters:
clazz- specifies the class or interfaceattName- the name of the desired field- Returns:
- the field instance
-
getFieldValue
- Parameters:
instance- the instance containing the fieldfield- the requested field- Returns:
- the value of the field
- See Also:
-
setFieldValue
- Parameters:
storable- the instance containing the fieldfield- the field to setfieldValue- the new field value- See Also:
-
encodeObject
Generic object encoder- Parameters:
obj- the object to encodestore- the Store (use to swizzle Storable)- Returns:
- a String containing the encoded value of the object. Or null, if decoding failed.
-
decodeObject
Generic object decoder- Parameters:
clazz- the object's class to decodeobjStr- the encoding representation of the objectstore- the Store (use to unswizzle Storable)ctxt- the DecodeContext (use to have more information when reporting error)- Returns:
- the object. Or null if decoding failed.
-
encodeBooleanArray
-
decodeBooleanArray
-
encodeByteArray
-
decodeByteArray
-
encodeCharArray
-
decodeCharArray
-
encodeDoubleArray
-
decodeDoubleArray
-
encodeFloatArray
-
decodeFloatArray
-
encodeIntArray
-
decodeIntArray
-
encodeLongArray
-
decodeLongArray
-
encodeShortArray
-
decodeShortArray
-
encodeObjectArray
-
decodeObjectArray
-
decodeObjectArray
public static Object[] decodeObjectArray(String arrayStr, Class<?> componentType, Store store, DecodeContext ctxt) -
encodeStorable
-
decodeStorable
-
encodeDate
-
decodeDate
-
encodeZoneId
-
decodeZoneId
-
encodeClass
-
decodeClass
-
encodeProperties
-
decodeProperties
-
encodeCollection
-
decodeCollection
public static Collection<?> decodeCollection(String collStr, Store store, Collection<Object> coll, DecodeContext ctxt) -
encodeArrayList
-
decodeArrayList
-
encodeLinkedList
-
decodeLinkedList
-
encodeVector
-
decodeVector
-
encodeHashSet
-
decodeHashSet
-
encodeTreeSet
-
decodeTreeSet
-
encodeMap
-
decodeMap
-
encodeLinkedHashMap
-
decodeLinkedHashMap
public static LinkedHashMap<?,?> decodeLinkedHashMap(String mapStr, Store store, DecodeContext ctxt) -
encodeHashMap
-
decodeHashMap
-
encodeHashtable
-
decodeHashtable
-
encodeTreeMap
-
decodeTreeMap
-
isArray
Returns true if this value is an array.- Parameters:
value- the encoded value.- Returns:
- true if this value is an array.
- Since:
- jcms-8.0.1
-
isCollection
Returns true if this value is a collection.- Parameters:
value- the encoded value.- Returns:
- true if this value is a collection.
- Since:
- jcms-8.0.1
-
isArrayOrCollection
Returns true if this value is an array or a collection.- Parameters:
value- the encoded value.- Returns:
- true if this value is an array or a collection.
- Since:
- jcms-8.0.1
-
isMap
Returns true if this value is a map.- Parameters:
value- the encoded value.- Returns:
- true if this value is a map.
- Since:
- jcms-8.0.1
-
computeMinStampTable
Computes the minimal StampTable of a collection of stampTable- Parameters:
stampTables- the collection of StampTable- Returns:
- the minimal StampTable
- Since:
- jcms-10.0.8
-
findMinStamp
Find the minimal stamp for a given urid in a collection of StampTable- Parameters:
stampTables- the collection of StampTableurid- the urid- Returns:
- the minimal stamp for a given urid in a collection of StampTable
-
findGCS
Find the GCS (Greatest Common Stamp) in the given list of operations according the given stampTable.- Parameters:
opList- a list of operationsminPT- the stampTable to checkminUnknownStamp- the minimal stamp present in a replica that the leader does not know- Returns:
- the GCS
- Since:
- jcms-10.0.8
-