Class NameUtils
- Author:
- Matthew Tropiano
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
checkValidEntryName
(String name) Tests if an input string is a valid entry name, and if not, throws an exception.static void
checkValidTextureName
(String name) Tests if an input string is a valid entry name, and if not, throws an exception.static boolean
isStringEmpty
(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 boolean
isValidEntryName
(String name) Tests if an input string is a valid entry name.static boolean
isValidTextureName
(String name) Tests if an input string is a valid texture name.static String
Cuts 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 String
toValidEntryName
(String name) Tests if an input string is a valid entry name, and if not, converts it into a valid one.static String
toValidTextureName
(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
The name of the "blank" texture.- See Also:
-
-
Method Details
-
nullTrim
Cuts a string at the first null character.- Parameters:
s
- the input string.- Returns:
- the resultant string, after the trim.
-
toASCIIBytes
Converts a String to an ASCII-encoded, byte-length-aligned vector. If the string length is less thanbytelen
it 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.
-