Class VABPathTools
- java.lang.Object
-
- org.eclipse.basyx.vab.modelprovider.VABPathTools
-
public class VABPathTools extends Object
Utility functions to handle a VAB path- Author:
- kuhn, espen
-
-
Constructor Summary
Constructors Constructor Description VABPathTools()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
append(String path, String element)
static String
buildPath(String[] pathElements, int startIndex)
Build and return a path with pathElements[startIndex] as the root elementstatic void
checkPathForNull(String path)
Checks if path is null, if yes throw exceptionstatic String
concatenatePaths(String... paths)
Concatenate two pathsstatic String
decodePathElement(String encodedElem)
Decodes sensitive characters, e.g.static String
encodePathElement(String elem)
Encodes sensitive characters, e.g.static String
getEntry(String path, int entry)
Returns the Nth entry of a path, e.g.static String
getFirstEndpoint(String fullPath)
Gets the first endpoint of a path.static String
getLastElement(String path)
Get the last element of a path.static String
getParentPath(String path)
Remove the last element from the pathstatic String
getPathFromURL(String url)
Gets the path from a URL e.g "http://localhost:8080/path/to/test.file" results in "/path/to/test.file"static String
harmonizePathWithSuffix(String path, String suffix)
Harmonizes a path so that it will always and with the suffix and no ending slash (even if the suffix contains one).static boolean
isEmptyPath(String path)
Check, if the path does not contain any elements.static boolean
isOperationInvokationPath(String path)
Check if the path to an VAB elements leads to the invocation of an operation.static String
removeFirstEndpoint(String fullPath)
Removes the first endpoint from a path.static String
removePrefix(String path, String prefix)
Remove prefix from beginning of pathstatic String
skipEntries(String path, int toSkip)
Skips the first N entries of a path.static String[]
splitPath(String path)
Split a path into path elements, e.g.static String
stripFromPath(String path, String elementToStrip)
Strips the last path element if it is elementToStripstatic String
stripInvokeFromPath(String path)
Strips the last path element if it is "invoke"static String
stripSlashes(String path)
Removes leading and trailing slashes
-
-
-
Field Detail
-
SEPERATOR
public static final String SEPERATOR
- See Also:
- Constant Field Values
-
-
Method Detail
-
stripSlashes
public static String stripSlashes(String path)
Removes leading and trailing slashes- Parameters:
path
-- Returns:
-
encodePathElement
public static String encodePathElement(String elem)
Encodes sensitive characters, e.g. "/" and "#"- Parameters:
elem
-- Returns:
-
decodePathElement
public static String decodePathElement(String encodedElem)
Decodes sensitive characters, e.g. "/" and "#"- Parameters:
encodedElem
-- Returns:
-
skipEntries
public static String skipEntries(String path, int toSkip)
Skips the first N entries of a path. E.g. for a/b/c skipping 2 means returning c- Parameters:
path
-toSkip
-- Returns:
-
getEntry
public static String getEntry(String path, int entry)
Returns the Nth entry of a path, e.g. the second entry of a/b/c is c- Parameters:
path
-entry
-- Returns:
-
splitPath
public static String[] splitPath(String path)
Split a path into path elements, e.g. /a/b/c -> [ a, b, c ]
-
getParentPath
public static String getParentPath(String path)
Remove the last element from the path
-
getLastElement
public static String getLastElement(String path)
Get the last element of a path. Return "" if there is no element in the path
-
removePrefix
public static String removePrefix(String path, String prefix)
Remove prefix from beginning of path
-
buildPath
public static String buildPath(String[] pathElements, int startIndex)
Build and return a path with pathElements[startIndex] as the root element
-
isOperationInvokationPath
public static boolean isOperationInvokationPath(String path)
Check if the path to an VAB elements leads to the invocation of an operation. In this case, the element path conforms to /aas/submodels/{subModelId}/submodelElements/{operationId}/invoke
-
isEmptyPath
public static boolean isEmptyPath(String path)
Check, if the path does not contain any elements.
-
getFirstEndpoint
public static String getFirstEndpoint(String fullPath)
Gets the first endpoint of a path.- Parameters:
fullPath
- A path that can contain 0..* endpoints.- Returns:
- The first address entry of a path. The address entry is the first endpoint combined with a protocol. If there is no protocol defined, the address entry is empty (""). E.g. basyx://127.0.0.1:6998//https://localhost/test/ will return basyx://127.0.0.1:6998, https://localhost/test//basyx://127.0.0.1:6998/ will return https://localhost/test and http://localhost/test/ will return "".
-
removeFirstEndpoint
public static String removeFirstEndpoint(String fullPath)
Removes the first endpoint from a path.- Parameters:
fullPath
-- Returns:
- The first endpoint. E.g. basyx://127.0.0.1:6998//https://localhost/test/ will return https://localhost/test/.
-
checkPathForNull
public static void checkPathForNull(String path) throws MalformedRequestException
Checks if path is null, if yes throw exception- Parameters:
path
-- Throws:
MalformedRequestException
-
stripInvokeFromPath
public static String stripInvokeFromPath(String path)
Strips the last path element if it is "invoke"- Parameters:
path
-- Returns:
- path without last element "invoke" or unchanged path
-
stripFromPath
public static String stripFromPath(String path, String elementToStrip)
Strips the last path element if it is elementToStrip- Parameters:
path
-elementToStrip
-- Returns:
- path without last element or unchanged path
-
getPathFromURL
public static String getPathFromURL(String url)
Gets the path from a URL e.g "http://localhost:8080/path/to/test.file" results in "/path/to/test.file"- Parameters:
url
-- Returns:
- the path from the URL
-
harmonizePathWithSuffix
public static String harmonizePathWithSuffix(String path, String suffix)
Harmonizes a path so that it will always and with the suffix and no ending slash (even if the suffix contains one).- Parameters:
path
- to harmonizesuffix
- to check for existance and append if necessary- Returns:
- harmonized path
-
-