Class ResourceUtil
java.lang.Object
com.inductiveautomation.ignition.common.util.ResourceUtil
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringFilenames that are reserved for use by the Windows OS, and will cause errors if you attempt to create them on the filesystem.static final intstatic final PatternA basic name validation pattern.static final Comparator<Resource>static final String -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TdecodeOrCreate(Resource r, XMLDeserializer deserializer, Class<T> clazz, LoggerEx log) static <T> TdecodeOrNull(byte[] data, XMLDeserializer deserializer, Class<T> clazz) static <T> TdecodeOrNull(Resource r, XMLDeserializer deserializer, Class<T> clazz) static StringUses URL encoding to escape illegal characters in a resource name, so that the name can be used as a filename, according to the following logic: If the name is a reserved name like COM3, all characters are replaced by their %XX hex If the name contains a percent sign, it is replaced by %25 If the name contains two dots in a row, they are replaced by %2E%2E If the name ends with a dot, it is replaced by %2E If the name ends with a space, it is replaced by %20 If the name starts with a space, it is replaced by %20 For each illegal character, it is replaced by %XX its hex encoding.static Stringstatic ResourceSignaturegetTrueSignature(Resource resource) Returns the signature of the resource for the resource collection in which it is defined, rather than the resource collection it was loaded into.static StringgetValidFolderName(String folderName) static booleanstatic booleanisLegalName(String proposedName) static Stringstatic StringDecodes a URL-encoded resource name, replacing %XX hex codes with their corresponding characters.
-
Field Details
-
INVALID_WINDOWS_FILENAMES
Filenames that are reserved for use by the Windows OS, and will cause errors if you attempt to create them on the filesystem. -
MAX_NAME_LENGTH
public static final int MAX_NAME_LENGTH- See Also:
-
NAME_PATTERN
A basic name validation pattern. Decoding the pattern:First character: Allows any unicode letter, number, punctuation, white space, or symbol, except for space, period, or characters that cause problems in file names. Subsequent characters: As above, except spaces and periods are allowed. isLegalName function will check for two dots in a row. Last character: cannot be a space or period. Uses canonical equivalence.
-
SORT_BY_MOST_RECENT
-
ENABLED_KEY
- See Also:
-
UUID_KEY
- See Also:
-
-
Method Details
-
getResourceName
-
subPath
- Returns:
- the
ResourcePath.getPath()of the resource, or null if the resource was null.
-
decodeOrCreate
public static <T> T decodeOrCreate(Resource r, XMLDeserializer deserializer, Class<T> clazz, LoggerEx log) throws Exception - Throws:
Exception
-
decodeOrNull
@Nullable public static <T> T decodeOrNull(Resource r, XMLDeserializer deserializer, Class<T> clazz) throws Exception - Throws:
Exception
-
decodeOrNull
@Nullable public static <T> T decodeOrNull(byte[] data, XMLDeserializer deserializer, Class<T> clazz) throws Exception - Throws:
Exception
-
getValidFolderName
-
isLegalName
- Returns:
trueif this resource name is valid for all supported filesystems
-
escapeIllegalCharacters
Uses URL encoding to escape illegal characters in a resource name, so that the name can be used as a filename, according to the following logic:- If the name is a reserved name like COM3, all characters are replaced by their %XX hex
- If the name contains a percent sign, it is replaced by %25
- If the name contains two dots in a row, they are replaced by %2E%2E
- If the name ends with a dot, it is replaced by %2E
- If the name ends with a space, it is replaced by %20
- If the name starts with a space, it is replaced by %20
- For each illegal character, it is replaced by %XX its hex encoding. Illegal characters are: /, ?, \, *, :, |, ", <, >
-
unescapeIllegalCharacters
Decodes a URL-encoded resource name, replacing %XX hex codes with their corresponding characters. -
getTrueSignature
Returns the signature of the resource for the resource collection in which it is defined, rather than the resource collection it was loaded into. -
isEnabled
- Returns:
- the "enabled" value of the resource, which is a synthetic property stored in the attribute map with the key "enabled" a default-if-absent value of true.
-
getUuid
-