Class TagUtilities

java.lang.Object
com.inductiveautomation.ignition.common.tags.TagUtilities

public class TagUtilities extends Object
Since:
8.0
  • Field Details

    • TAG_GSON

      public static final com.inductiveautomation.ignition.common.gson.Gson TAG_GSON
  • Constructor Details

    • TagUtilities

      public TagUtilities()
  • Method Details

    • isValidName

      public static boolean isValidName(String name)
      Returns true if the given name is a valid name for a SQLTag or not. Valid names start with a letter, and contain any of : letters, digits, underscore, space, parenthesis, single quote, and dash
    • sanitizeName

      public static String sanitizeName(String name) throws IllegalArgumentException
      Takes a string and replaces any illegal characters with underscores. Any name that cannot be sanitized will throw an IllegalArgumentException.
      Throws:
      IllegalArgumentException
    • toTagConfiguration

      public static List<TagConfiguration> toTagConfiguration(Object o, TagPath basePath) throws Exception
      Converts the passed object into a PropertySet, and then wraps the PropertySet into a TagConfiguration object which can be sent to the gateway as a new tag or tag edit.
      Throws:
      Exception
    • toTagConfiguration

      public static List<TagConfiguration> toTagConfiguration(TagPath path, BoundPropertySet config)
    • configureEdit

      protected static void configureEdit(List<TagConfiguration> results, TagPath path, BoundPropertySet config)
    • toJsonObject

      public static com.inductiveautomation.ignition.common.gson.JsonObject toJsonObject(TagConfigurationModel editModel) throws Exception
      For folders and UDTs, this function will recursively export tag edit models and add the exported JSON to the passed parentJson object. For a simple tag, the function will export the passed tag edit model. Example export:

      {"tags":
      [{"valueSource":"memory",
      "name":"DynamicMemoryTag0",
      "tagType":"AtomicTag"}
      ]}

      Throws:
      Exception
    • jsonToString

      public static String jsonToString(com.inductiveautomation.ignition.common.gson.JsonElement json)
      Returns the passed JsonObject in string form. Handy to avoid extra creation of TagGson just to get a string.
    • stringToJson

      public static com.inductiveautomation.ignition.common.gson.JsonElement stringToJson(String jsonStr)
      Returns the JSON string as a JsonElement. Handy to avoid extra creation of TagGson just to get a JsonElement.
    • checkTagFilter

      public static boolean checkTagFilter(BrowseFilter filter, TagPath tagPath, NodeDescription node)
      Verifies that a tag's properties meet the criteria of the passed BrowseFilter. A name filter check, tag properties check, and a quality code check are run, if each of those properties were added to the BrowseFilter. A tag automatically meets the criteria if the tag does not contain any of the properties in the browse filter, or the browse filter is empty.
    • getTagPropertyType

      public static Class<?> getTagPropertyType(PropertySet config, Property<?> prop, Object possibleVal)
    • cloneAndSetArrayValue

      public static QualifiedValue cloneAndSetArrayValue(Object arrayValue, Object newVal, int pos) throws IllegalArgumentException
      Takes an array value- either raw, or inside a QV, and updates one element. However, it clones the whole array, which is necessary for many aspects of tag functionality, which compares prev value to current value. If we don't clone, we end up updating the same instance that other parts of the system are holding as "previous".
      Parameters:
      arrayValue - a raw array or a QualifiedValue that's holding an array
      newVal - the scalar value to set at the position
      pos - the index position to set at
      Returns:
      A qualified value with the new value if successful, or a quality code indicating the failure if unsuccessful.
      Throws:
      IllegalArgumentException - if the arrayValue is not an array.