Class TagUtilities
java.lang.Object
com.inductiveautomation.ignition.common.tags.TagUtilities
- Since:
- 8.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.inductiveautomation.ignition.common.gson.Gson
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
checkTagFilter
(BrowseFilter filter, TagPath tagPath, NodeDescription node) Verifies that a tag's properties meet the criteria of the passed BrowseFilter.static QualifiedValue
cloneAndSetArrayValue
(Object arrayValue, Object newVal, int pos) Takes an array value- either raw, or inside a QV, and updates one element.protected static void
configureEdit
(List<TagConfiguration> results, TagPath path, BoundPropertySet config) static Class<?>
getTagPropertyType
(PropertySet config, Property<?> prop, Object possibleVal) static boolean
isValidName
(String name) Returns true if the given name is a valid name for a SQLTag or not.static String
jsonToString
(com.inductiveautomation.ignition.common.gson.JsonElement json) Returns the passed JsonObject in string form.static String
sanitizeName
(String name) Takes a string and replaces any illegal characters with underscores.static com.inductiveautomation.ignition.common.gson.JsonElement
stringToJson
(String jsonStr) Returns the JSON string as a JsonElement.static com.inductiveautomation.ignition.common.gson.JsonObject
toJsonObject
(TagConfigurationModel editModel) For folders and UDTs, this function will recursively export tag edit models and add the exported JSON to the passed parentJson object.static List<TagConfiguration>
toTagConfiguration
(TagPath path, BoundPropertySet config) static List<TagConfiguration>
toTagConfiguration
(Object o, TagPath basePath) 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.
-
Field Details
-
TAG_GSON
public static final com.inductiveautomation.ignition.common.gson.Gson TAG_GSON
-
-
Constructor Details
-
TagUtilities
public TagUtilities()
-
-
Method Details
-
isValidName
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
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
-
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
Returns the passed JsonObject in string form. Handy to avoid extra creation of TagGson just to get a string. -
stringToJson
Returns the JSON string as a JsonElement. Handy to avoid extra creation of TagGson just to get a JsonElement. -
checkTagFilter
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
-
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 arraynewVal
- the scalar value to set at the positionpos
- 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.
-