Package com.hybris.cockpitng.core.util
Class ObjectValuePath
- java.lang.Object
-
- com.hybris.cockpitng.core.util.ObjectValuePath
-
public class ObjectValuePath extends java.lang.Object
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedObjectValuePath()protectedObjectValuePath(java.lang.String... elements)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectValuePathappend(java.lang.String element)Adds new element of path at the end of path.ObjectValuePathappendPath(ObjectValuePath path)Adds path at the end of path.ObjectValuePathappendPath(java.lang.String path)Parses provided path and adds it at the end of path.java.lang.StringbuildPath()Merges all path elements into singleStringrepresentationstatic ObjectValuePathcopy(ObjectValuePath path)Creates a copy of pathprotected java.util.List<java.lang.String>createPath(java.lang.String... elements)static ObjectValuePathempty()Creates an instance of empty pathbooleanequals(java.lang.Object o)java.lang.StringgetLocale()Gets localization code from pathstatic java.lang.StringgetLocaleFromPath(java.lang.String path)Gets a locale from provided path if it is a path with locale includedstatic java.lang.StringgetLocalePath(java.lang.String path, java.lang.String locale)Appends locale specification to provided path.static java.lang.StringgetNotLocalizedPath(java.lang.String path)Removes all locale specifications from path.ObjectValuePathgetParent()Gets a parent path for current.static java.lang.StringgetPath(java.lang.String... elements)Gets full validation path for specified elements.ObjectValuePathgetRelative(ObjectValuePath root)Builds new path that should be interpreted as relative to providedObjectValuePathgetRelative(java.lang.String root)Builds new path that should be interpreted as relative to providedObjectValuePathgetRoot()Get a root of current path.inthashCode()ObjectValuePathinternationalize()Removes localization from pathbooleanisEmpty()Checks whether path contains any elementsstatic booleanisLocalePath(java.lang.String path, java.lang.String locale)Checks whether provided path contains specified localebooleanisLocalized()Checks whether path contains localization definitionstatic booleanisLocalizedPath(java.lang.String path)Checks whether provided path is a path with locale includedObjectValuePathlocalize(java.lang.String locale)Adds localization to pathstatic ObjectValuePathparse(java.lang.String path)Parses provided pathObjectValuePathprepend(ObjectValuePath root)Adds new path at the beginning of path.ObjectValuePathprepend(java.lang.String element)Adds new path at the beginning of path.intsize()Gets number of elements in pathjava.lang.String[]split()Splits current path to array fo elementsbooleanstartsWith(ObjectValuePath root)Checks whether current path starts with providedbooleanstartsWith(java.lang.String root)Checks whether current path starts with providedjava.lang.StringtoString()static ObjectValuePathunmodifiable(ObjectValuePath path)Creates a reference to provided path that prevents it from changing
-
-
-
Method Detail
-
getPath
public static java.lang.String getPath(java.lang.String... elements)
Gets full validation path for specified elements.- Parameters:
elements- path elements- Returns:
- full validation path built with provided path elements
-
getLocaleFromPath
public static java.lang.String getLocaleFromPath(java.lang.String path)
Gets a locale from provided path if it is a path with locale included- Parameters:
path- path to be checked- Returns:
- locale from path or
null
-
isLocalizedPath
public static boolean isLocalizedPath(java.lang.String path)
Checks whether provided path is a path with locale included- Parameters:
path- path to be checked- Returns:
trueif path contains locale specification
-
isLocalePath
public static boolean isLocalePath(java.lang.String path, java.lang.String locale)Checks whether provided path contains specified locale- Parameters:
path- path to be checkedlocale- locale expected- Returns:
trueif path contains locale specification and it points to locale provided
-
getNotLocalizedPath
public static java.lang.String getNotLocalizedPath(java.lang.String path)
Removes all locale specifications from path.- Parameters:
path- path to be cleared- Returns:
- path with no locale specifications
-
getLocalePath
public static java.lang.String getLocalePath(java.lang.String path, java.lang.String locale)Appends locale specification to provided path.Any current locale specification in provided path will be removed.
- Parameters:
path- path to be decoratedlocale- locale to be added- Returns:
- path with locale added
-
parse
public static ObjectValuePath parse(java.lang.String path)
Parses provided path- Parameters:
path- full path String representation- Returns:
- parsed path
- See Also:
buildPath()
-
empty
public static ObjectValuePath empty()
Creates an instance of empty path- Returns:
- empty path
-
copy
public static ObjectValuePath copy(ObjectValuePath path)
Creates a copy of path- Parameters:
path- path to be copied- Returns:
- copy
-
unmodifiable
public static ObjectValuePath unmodifiable(ObjectValuePath path)
Creates a reference to provided path that prevents it from changing- Parameters:
path- referenced path- Returns:
- a reference that may not be changed
-
createPath
protected java.util.List<java.lang.String> createPath(java.lang.String... elements)
-
isEmpty
public boolean isEmpty()
Checks whether path contains any elements- Returns:
trueif path does not contain any elements
-
size
public int size()
Gets number of elements in path- Returns:
- number of path elements
-
getRoot
public ObjectValuePath getRoot()
Get a root of current path.- Returns:
- root or empty path if no root exists
-
getParent
public ObjectValuePath getParent()
Gets a parent path for current.- Returns:
- parent path or empty path if no parent exists
-
append
public ObjectValuePath append(java.lang.String element)
Adds new element of path at the end of path.Method actually changes current path.
- Parameters:
element- new path element- Returns:
- current path after change
-
appendPath
public ObjectValuePath appendPath(ObjectValuePath path)
Adds path at the end of path.Method actually changes current path.
- Parameters:
path- new path- Returns:
- current path after change
-
appendPath
public ObjectValuePath appendPath(java.lang.String path)
Parses provided path and adds it at the end of path.Method actually changes current path.
- Parameters:
path- new path- Returns:
- current path after change
-
localize
public ObjectValuePath localize(java.lang.String locale)
Adds localization to pathMethod actually changes current path.
- Parameters:
locale- localization symbol- Returns:
- current path after change
-
internationalize
public ObjectValuePath internationalize()
Removes localization from pathMethod actually changes current path.
- Returns:
- current path after change
-
isLocalized
public boolean isLocalized()
Checks whether path contains localization definition- Returns:
trueif path is localized
-
getLocale
public java.lang.String getLocale()
Gets localization code from path- Returns:
- locale or
nullif path is not localized - See Also:
Locale.getLanguage()
-
prepend
public ObjectValuePath prepend(java.lang.String element)
Adds new path at the beginning of path.Method actually changes current path.
- Parameters:
element- path to be prepended- Returns:
- current path after change
-
prepend
public ObjectValuePath prepend(ObjectValuePath root)
Adds new path at the beginning of path.Method actually changes current path.
- Parameters:
root- path to be prepended- Returns:
- current path after change
-
startsWith
public boolean startsWith(java.lang.String root)
Checks whether current path starts with provided- Parameters:
root- reference path- Returns:
trueif current path is relative or equal to provided
-
startsWith
public boolean startsWith(ObjectValuePath root)
Checks whether current path starts with provided- Parameters:
root- reference path- Returns:
trueif current path is relative or equal to provided
-
getRelative
public ObjectValuePath getRelative(java.lang.String root)
Builds new path that should be interpreted as relative to provided- Parameters:
root- reference path- Returns:
- current path as relative to provided
- Throws:
java.lang.IllegalArgumentException- thrown if current path is not relative to provided
-
getRelative
public ObjectValuePath getRelative(ObjectValuePath root)
Builds new path that should be interpreted as relative to provided- Parameters:
root- reference path- Returns:
- current path as relative to provided
- Throws:
java.lang.IllegalArgumentException- thrown if current path is not relative to provided
-
split
public java.lang.String[] split()
Splits current path to array fo elements- Returns:
- arrays of elements in path
-
buildPath
public java.lang.String buildPath()
Merges all path elements into singleStringrepresentation- Returns:
- path representation
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-