Class QualifiedPath
- java.lang.Object
-
- com.inductiveautomation.ignition.common.QualifiedPath
-
- All Implemented Interfaces:
Path
,java.io.Serializable
public class QualifiedPath extends java.lang.Object implements java.io.Serializable, Path
This class is a path to anything in Ignition, across any system. It dictates how the path is formed, but the actual meaning of different subcomponents will depend on the context in which the path is used.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
QualifiedPath.Builder
A builder to assist in constructingQualifiedPath
s.static class
QualifiedPath.Part
static class
QualifiedPath.QualifiedPathSimpleTypeAdapter
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.String
COMPONENTID_SEPERATOR
protected static java.lang.String
PART_SEPERATOR
protected static java.lang.String
SUBPART_SEPERATOR
-
Fields inherited from interface com.inductiveautomation.ignition.common.Path
SERIALIZATION_WHITELIST
-
-
Constructor Summary
Constructors Constructor Description QualifiedPath()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
QualifiedPath
extend(java.lang.String id, java.lang.String value)
Returns a path with the provided component added on at the end.java.lang.String
getFirstPathComponent()
java.lang.String
getFirstPathComponentId()
java.lang.String
getLastPathComponent()
Convenience function to return the last path element.java.lang.String
getLastPathComponentId()
QualifiedPath
getParentPath()
Returns a path representing the element above the current path.QualifiedPath.Part
getPart(int i)
protected QualifiedPath.Part[]
getPartsFor(java.lang.String id)
Returns all of the sub parts for a specified id, or null if they don't exist.java.lang.String
getPathComponent(int i)
Returns the path element at the specified location.java.lang.String
getPathComponent(java.lang.String id)
java.lang.String
getPathComponentOrElse(java.lang.String id, java.lang.String orElse)
int
getPathLength()
Returns the number of elements in the path, which can be retrieved through getPathComponent().int
hashCode()
boolean
hasPathComponent(java.lang.String id)
protected int
indexOf(java.lang.String id)
QualifiedPath
insert(java.lang.String id, java.lang.String value, java.lang.String beforeComponentId)
Locates the component specified and inserts the new component before it.boolean
isAncestorOf(Path child)
Returns whether the provided path is a child path of this one.static QualifiedPath
of(java.lang.String... idValPairs)
Creates a path out of the specified id/value pairs.static QualifiedPath
parse(java.lang.String value)
Attempts to parse the string into an QualifiedPath.static QualifiedPath
parseSafe(java.lang.String value)
Same as parse(), but catches exceptions and returns null on bad paths.protected static java.util.List<QualifiedPath.Part>
parseSubParts(java.lang.String id, java.lang.String value)
Returns at least one part for the root, with id.QualifiedPath
prepend(java.lang.String id, java.lang.String value)
Returns a new path with the provided component added at the beginning.QualifiedPath
remove(java.lang.String id)
Removes the given component, if present.QualifiedPath
replace(java.lang.String id, java.lang.String value)
If the component specified by the given id exists in the path, the value will be replaced with the new value.QualifiedPath
strip()
Removes the last fully-qualified component from the path.QualifiedPath
subpath()
Removes the first path component and returns the rest as a new path.QualifiedPath
subpath(java.lang.String id)
Returns the paths that comes after the first instance of the specified id.java.lang.String
toString()
java.lang.String
toStringSimple()
Returns the path in a friendlier to read form, without component ids.
-
-
-
Field Detail
-
SUBPART_SEPERATOR
protected static final java.lang.String SUBPART_SEPERATOR
- See Also:
- Constant Field Values
-
PART_SEPERATOR
protected static final java.lang.String PART_SEPERATOR
- See Also:
- Constant Field Values
-
COMPONENTID_SEPERATOR
protected static final java.lang.String COMPONENTID_SEPERATOR
- See Also:
- Constant Field Values
-
-
Method Detail
-
of
public static QualifiedPath of(java.lang.String... idValPairs)
Creates a path out of the specified id/value pairs. The parameters must be in the form "id,value,id,value".
-
extend
public QualifiedPath extend(java.lang.String id, java.lang.String value)
Returns a path with the provided component added on at the end.
-
prepend
public QualifiedPath prepend(java.lang.String id, java.lang.String value)
Returns a new path with the provided component added at the beginning.
-
insert
public QualifiedPath insert(java.lang.String id, java.lang.String value, java.lang.String beforeComponentId)
Locates the component specified and inserts the new component before it.
-
getPathLength
public int getPathLength()
Description copied from interface:Path
Returns the number of elements in the path, which can be retrieved through getPathComponent().- Specified by:
getPathLength
in interfacePath
-
getPart
@Nullable public QualifiedPath.Part getPart(int i)
-
getPathComponent
public java.lang.String getPathComponent(int i)
Description copied from interface:Path
Returns the path element at the specified location.- Specified by:
getPathComponent
in interfacePath
-
getLastPathComponent
public java.lang.String getLastPathComponent()
Description copied from interface:Path
Convenience function to return the last path element.- Specified by:
getLastPathComponent
in interfacePath
-
getLastPathComponentId
@Nullable public java.lang.String getLastPathComponentId()
-
getFirstPathComponent
public java.lang.String getFirstPathComponent()
-
getFirstPathComponentId
public java.lang.String getFirstPathComponentId()
-
subpath
public QualifiedPath subpath()
Removes the first path component and returns the rest as a new path.
-
subpath
public QualifiedPath subpath(java.lang.String id)
Returns the paths that comes after the first instance of the specified id.- Parameters:
id
- component id after which the subsequent path parts will be returned.- Returns:
- everything after the specified id, or null if id is not found.
-
strip
public QualifiedPath strip()
Removes the last fully-qualified component from the path. This differs from getParentPath() in that that function doesn't care whether the component is qualified or not.
-
remove
public QualifiedPath remove(java.lang.String id)
Removes the given component, if present.
-
replace
public QualifiedPath replace(java.lang.String id, java.lang.String value)
If the component specified by the given id exists in the path, the value will be replaced with the new value.
-
indexOf
protected int indexOf(java.lang.String id)
-
getPathComponent
@Nullable public java.lang.String getPathComponent(@Nullable java.lang.String id)
-
getPathComponentOrElse
@Nonnull public java.lang.String getPathComponentOrElse(@Nullable java.lang.String id, @Nonnull java.lang.String orElse)
-
getPartsFor
@Nullable protected QualifiedPath.Part[] getPartsFor(@Nullable java.lang.String id)
Returns all of the sub parts for a specified id, or null if they don't exist.
-
hasPathComponent
public boolean hasPathComponent(java.lang.String id)
-
getParentPath
public QualifiedPath getParentPath()
Description copied from interface:Path
Returns a path representing the element above the current path.- Specified by:
getParentPath
in interfacePath
-
toString
@Nonnull public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
toStringSimple
@Nonnull public java.lang.String toStringSimple()
Returns the path in a friendlier to read form, without component ids.
-
isAncestorOf
public boolean isAncestorOf(Path child)
Description copied from interface:Path
Returns whether the provided path is a child path of this one.- Specified by:
isAncestorOf
in interfacePath
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
parse
public static QualifiedPath parse(java.lang.String value) throws java.io.IOException
Attempts to parse the string into an QualifiedPath. IOException is thrown on invalid path.- Throws:
java.io.IOException
-
parseSafe
public static QualifiedPath parseSafe(java.lang.String value)
Same as parse(), but catches exceptions and returns null on bad paths.
-
parseSubParts
protected static java.util.List<QualifiedPath.Part> parseSubParts(java.lang.String id, java.lang.String value)
Returns at least one part for the root, with id. If the value contains sub parts, those will be returned as well. The root part will have the sub part count set on it already.
-
-