Class NameUtils
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckValidEntryName(String name) Tests if an input string is a valid entry name, and if not, throws an exception.static voidcheckValidTextureName(String name) Tests if an input string is a valid entry name, and if not, throws an exception.static booleanisStringEmpty(Object obj) Checks if a string is "empty." A string is considered "empty" if the string the empty string, or areString.trim()'ed down to the empty string.static booleanisValidEntryName(String name) Tests if an input string is a valid entry name.static booleanisValidTextureName(String name) Tests if an input string is a valid texture name.static StringCuts a string at the first null character.static byte[]toASCIIBytes(String s, int bytelen) Converts a String to an ASCII-encoded, byte-length-aligned vector.static StringtoValidEntryName(String name) Tests if an input string is a valid entry name, and if not, converts it into a valid one.static StringtoValidTextureName(String name) Tests if an input string is a valid entry name, and if not, converts it into a valid one.
-
Field Details
-
ENTRY_NAME
A regex pattern that matches valid entry names. -
TEXTURE_NAME
A regex pattern that matches valid texture names. -
EMPTY_TEXTURE_NAME
-
-
Method Details
-
nullTrim
-
toASCIIBytes
Converts a String to an ASCII-encoded, byte-length-aligned vector. If the string length is less thanbytelenit is null-byte padded to the length.- Parameters:
s- the input string.bytelen- the output byte array length.- Returns:
- the resultant byte array.
-
isValidEntryName
Tests if an input string is a valid entry name.A WadEntry must have a name that is up to 8 characters long, and can only contain A-Z (uppercase only), 0-9, and most symbols plus the backslash ("\").
- Parameters:
name- the input name to test.- Returns:
- true if so, false if not.
-
toValidEntryName
Tests if an input string is a valid entry name, and if not, converts it into a valid one.In a valid entry, all characters must be A-Z (uppercase only), 0-9, and most symbols plus the backslash ("\").
Lowercase letters are made uppercase and unknown characters are converted to dashes. Latin characters with diacritical marks are converted to their normalized forms. Names are truncated to 8 characters. The entry will also be cut at the first null character, if any.
An empty string (see
isStringEmpty(Object)is converted to "-".- Parameters:
name- the input name to test.- Returns:
- true if so, false if not.
-
checkValidEntryName
Tests if an input string is a valid entry name, and if not, throws an exception.- Parameters:
name- the input name to test.- Throws:
IllegalArgumentException- if the entry name is invalid.- See Also:
-
isValidTextureName
Tests if an input string is a valid texture name.A Texture must have an alphanumeric name that is up to 8 characters long, and can only contain A-Z (uppercase only), 0-9, and most symbols plus the backslash ("\") or just "-".
- Parameters:
name- the input name to test.- Returns:
- true if so, false if not.
-
toValidTextureName
Tests if an input string is a valid entry name, and if not, converts it into a valid one.In a valid texture, all characters must be A-Z (uppercase only), 0-9, and most symbols plus the backslash ("\").
Blank/null names are changed to "-".
Lowercase letters are made uppercase and unknown characters are converted to dashes. Latin characters with diacritical marks are converted to their normalized forms. Names are truncated to 8 characters. The entry will also be cut at the first null character, if any.
- Parameters:
name- the input name to test.- Returns:
- true if so, false if not.
-
checkValidTextureName
Tests if an input string is a valid entry name, and if not, throws an exception.- Parameters:
name- the input name to test.- Throws:
IllegalArgumentException- if the entry name is invalid.- See Also:
-
isStringEmpty
Checks if a string is "empty." A string is considered "empty" if the string the empty string, or areString.trim()'ed down to the empty string.- Parameters:
obj- the object to check.- Returns:
- true if the provided object is considered "empty", false otherwise.
-