Class ResourceUtil

java.lang.Object
com.inductiveautomation.ignition.common.util.ResourceUtil

public class ResourceUtil extends Object
  • Field Details

    • INVALID_WINDOWS_FILENAMES

      public static final Set<String> 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.
    • SORT_BY_MOST_RECENT

      public static final Comparator<Resource> SORT_BY_MOST_RECENT
    • ENABLED_KEY

      public static final String ENABLED_KEY
      See Also:
    • UUID_KEY

      public static final String UUID_KEY
      See Also:
  • Method Details

    • getResourceName

      public static String getResourceName(ResourceId id)
    • subPath

      public static String subPath(Resource resource)
      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

      public static String getValidFolderName(String folderName)
    • isLegalName

      public static boolean isLegalName(String proposedName)
      Returns:
      true if this resource name is valid for all supported filesystems
    • escapeIllegalCharacters

      public static String escapeIllegalCharacters(String name)
      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:
      1. If the name is a reserved name like COM3, all characters are replaced by their %XX hex
      2. If the name contains a percent sign, it is replaced by %25
      3. If the name contains two dots in a row, they are replaced by %2E%2E
      4. If the name ends with a dot, it is replaced by %2E
      5. If the name ends with a space, it is replaced by %20
      6. If the name starts with a space, it is replaced by %20
      7. For each illegal character, it is replaced by %XX its hex encoding. Illegal characters are: /, ?, \, *, :, |, ", <, >
    • unescapeIllegalCharacters

      public static String unescapeIllegalCharacters(String name)
      Decodes a URL-encoded resource name, replacing %XX hex codes with their corresponding characters.
    • getTrueSignature

      public static ResourceSignature getTrueSignature(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.
    • isEnabled

      public static boolean isEnabled(Resource resource)
      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

      public static Optional<UUID> getUuid(Resource resource)