Class TagPathParser
- java.lang.Object
-
- com.inductiveautomation.ignition.common.tags.paths.parser.TagPathParser
-
public class TagPathParser extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
PARENT_RELATIVE
Indicates that path is relative from the given parent path.static java.lang.String
PATH_SEPARATOR
static java.lang.String
PROPERTY_SEPARATOR
static java.lang.String
RELATIVE_DIR_UP
static java.lang.String
ROOT_RELATIVE
Indicates the path is relative to the root of the given path
-
Constructor Summary
Constructors Constructor Description TagPathParser()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.List<java.lang.String>
chopPath(java.lang.String string)
Chops the given string into the basic components of a tag path.static TagPath
derelativize(TagPath tagPath, TagPath relativeRoot)
De-relativizes a tag, given a full parent path.static boolean
isRelativePath(TagPath path)
Returns whether the given tag path is a relative path or not.static TagPath
parse(java.lang.String string)
Parses the given string into a TagPath.static TagPath
parse(java.lang.String defaultSource, java.lang.String string)
Parses the tag path, setting the source to the default if not present.static TagPath
parseSafe(java.lang.String string)
Calls parse, but catches exceptions and returns null for bad tag paths.static TagPath
parseSafe(java.lang.String defaultSource, java.lang.String string)
Calls parse, but catches exceptions and returns null for bad tag paths.static TagPath
relativize(TagPath newPath, TagPath relativeTo)
Returns a path based on newPath, but made relative to the second path.protected static java.io.IOException
unwrap(java.lang.Throwable e)
-
-
-
Field Detail
-
PATH_SEPARATOR
public static java.lang.String PATH_SEPARATOR
-
PROPERTY_SEPARATOR
public static java.lang.String PROPERTY_SEPARATOR
-
RELATIVE_DIR_UP
public static java.lang.String RELATIVE_DIR_UP
-
PARENT_RELATIVE
public static java.lang.String PARENT_RELATIVE
Indicates that path is relative from the given parent path.
-
ROOT_RELATIVE
public static java.lang.String ROOT_RELATIVE
Indicates the path is relative to the root of the given path
-
-
Method Detail
-
isRelativePath
public static boolean isRelativePath(TagPath path)
Returns whether the given tag path is a relative path or not. Looks at whether the source is "." or "~".
-
chopPath
public static java.util.List<java.lang.String> chopPath(java.lang.String string) throws java.io.IOException
Chops the given string into the basic components of a tag path. Sources and properties are ignored, as are trailing separators indicating folder status. For example, this string:"[Source/System]Path/To/Tag.property"
would return the array:
["Path", "To", "Tag"]
- Throws:
java.io.IOException
-
parse
public static TagPath parse(java.lang.String string) throws java.io.IOException
Parses the given string into a TagPath. sources and property names are suppored, but not necessary. Paths look like:[Source]Path/To/Tag.property
- Throws:
java.io.IOException
-
parseSafe
@Nullable public static TagPath parseSafe(java.lang.String string)
Calls parse, but catches exceptions and returns null for bad tag paths.
-
parseSafe
@Nullable public static TagPath parseSafe(java.lang.String defaultSource, java.lang.String string)
Calls parse, but catches exceptions and returns null for bad tag paths.
-
parse
public static TagPath parse(java.lang.String defaultSource, java.lang.String string) throws java.io.IOException
Parses the tag path, setting the source to the default if not present. This is basically used to fully qualify paths that may have been stored without a source.- Throws:
java.io.IOException
-
unwrap
protected static java.io.IOException unwrap(java.lang.Throwable e)
-
derelativize
public static TagPath derelativize(TagPath tagPath, TagPath relativeRoot) throws java.lang.RuntimeException
De-relativizes a tag, given a full parent path. This function works with relative sources, but also paths in the style of "../../Tag". The relative root is expected to be the path to the folder that would be containing the tag, not a peer tag.- Throws:
java.lang.RuntimeException
-
relativize
public static TagPath relativize(TagPath newPath, TagPath relativeTo)
Returns a path based on newPath, but made relative to the second path. If the common ancestor is the root, the tag path returned will have a root-relative source ("~"), otherwise the source will be ".". If the relativeTo path is null, the newPath is returned directly.It is expected that the relativeTo path is a folder.
-
-