Class StringOps
java.lang.Object
com.github.darksoulq.abyssallib.common.serialization.DynamicOps<String>
com.github.darksoulq.abyssallib.common.serialization.ops.StringOps
A
DynamicOps implementation that serializes values into a compact
string-based format.
The format encodes primitives using type suffixes and structures using bracketed notation:
- Strings:
"text"with escaping - Bytes:
1b - Shorts:
1s - Integers:
1 - Longs:
1L - Floats:
1.0f - Doubles:
1.0d - Lists:
[a,b,c] - Maps:
{k:v,k2:v2}
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionReturns the input unchanged.createBoolean(boolean value) Serializes a boolean value.createByte(byte value) Serializes a byte withbsuffix.createDouble(double value) Serializes a double withdsuffix.createFloat(float value) Serializes a float withfsuffix.createInt(int value) Serializes an integer as a plain numeric string.createList(List<String> elements) Serializes a list into a comma-separated bracketed structure.createLong(long value) Serializes a long withLsuffix.Serializes a map into a comma-separated key-value structure.createShort(short value) Serializes a short withssuffix.createString(String value) Serializes a string with escaping and quotes.empty()Returns an empty string representation.getBooleanValue(String input) Parses a boolean value.getDoubleValue(String input) Parses a double value withdsuffix.getFloatValue(String input) Parses a float value withfsuffix.getIntValue(String input) Parses an integer value if no type suffix is present.Returns all keys from a serialized map.Parses a list from bracketed comma-separated format.getLongValue(String input) Parses a long value withLsuffix.Parses a map from bracketed key-value format.getNumberValue(String input) Parses a numeric value using optional type suffixes.getStringValue(String input) Parses a quoted string and unescapes characters.Returns the size of a list or map.Methods inherited from class DynamicOps
compressMaps, convertTo, edit, edit, emptyList, emptyMap, exists, exists, mergeToList, mergeToMap, query, query, remove, remove, set, set
-
Field Details
-
INSTANCE
Singleton instance.
-
-
Method Details
-
createString
Serializes a string with escaping and quotes.- Specified by:
createStringin classDynamicOps<String>- Parameters:
value- input string- Returns:
- quoted and escaped string
-
createByte
Serializes a byte withbsuffix.- Specified by:
createBytein classDynamicOps<String>- Parameters:
value- byte value- Returns:
- encoded string
-
createShort
Serializes a short withssuffix.- Specified by:
createShortin classDynamicOps<String>- Parameters:
value- short value- Returns:
- encoded string
-
createInt
Serializes an integer as a plain numeric string.- Specified by:
createIntin classDynamicOps<String>- Parameters:
value- integer value- Returns:
- encoded string
-
createLong
Serializes a long withLsuffix.- Specified by:
createLongin classDynamicOps<String>- Parameters:
value- long value- Returns:
- encoded string
-
createFloat
Serializes a float withfsuffix.- Specified by:
createFloatin classDynamicOps<String>- Parameters:
value- float value- Returns:
- encoded string
-
createDouble
Serializes a double withdsuffix.- Specified by:
createDoublein classDynamicOps<String>- Parameters:
value- double value- Returns:
- encoded string
-
createBoolean
Serializes a boolean value.- Specified by:
createBooleanin classDynamicOps<String>- Parameters:
value- boolean value- Returns:
trueorfalse
-
createList
Serializes a list into a comma-separated bracketed structure.- Specified by:
createListin classDynamicOps<String>- Parameters:
elements- encoded elements- Returns:
- list string
-
createMap
-
getStringValue
Parses a quoted string and unescapes characters.- Specified by:
getStringValuein classDynamicOps<String>- Parameters:
input- encoded string- Returns:
- decoded value if valid
-
getNumberValue
Parses a numeric value using optional type suffixes.- Specified by:
getNumberValuein classDynamicOps<String>- Parameters:
input- encoded input- Returns:
- parsed number if valid
-
getIntValue
Parses an integer value if no type suffix is present.- Specified by:
getIntValuein classDynamicOps<String>- Parameters:
input- encoded input- Returns:
- integer value if valid
-
getLongValue
Parses a long value withLsuffix.- Specified by:
getLongValuein classDynamicOps<String>- Parameters:
input- encoded input- Returns:
- long value if valid
-
getFloatValue
Parses a float value withfsuffix.- Specified by:
getFloatValuein classDynamicOps<String>- Parameters:
input- encoded input- Returns:
- float value if valid
-
getDoubleValue
Parses a double value withdsuffix.- Specified by:
getDoubleValuein classDynamicOps<String>- Parameters:
input- encoded input- Returns:
- double value if valid
-
getBooleanValue
Parses a boolean value.- Specified by:
getBooleanValuein classDynamicOps<String>- Parameters:
input- encoded input- Returns:
- boolean if valid
-
getList
-
getMap
-
getKeys
-
size
Returns the size of a list or map.- Specified by:
sizein classDynamicOps<String>- Parameters:
input- encoded value- Returns:
- size if valid structure
-
copy
Returns the input unchanged.- Specified by:
copyin classDynamicOps<String>- Parameters:
input- value- Returns:
- identical value
-
empty
Returns an empty string representation.- Specified by:
emptyin classDynamicOps<String>- Returns:
- empty string
-