Package com.networknt.schema
Enum PathType
- All Implemented Interfaces:
Serializable
,Comparable<PathType>
,java.lang.constant.Constable
Enumeration defining the different approached available to generate the paths added to validation messages.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionPaths as JSONPath expressions.Paths as JSONPointer expressions.The legacy approach, loosely based on JSONPath (but not guaranteed to give valid JSONPath expressions).Paths as a URI reference. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final BiFunction
<String, Integer, String> private final BiFunction
<String, String, String> static final PathType
The default path generation approach to use.private final String
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
PathType
(String rootToken, BiFunction<String, String, String> appendTokenFn, BiFunction<String, Integer, String> appendIndexFn) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionAppend the given index to the provided current path.Append the given child token to the provided current path.convertToJsonPointer
(String path) (package private) static String
fromJsonPath
(String str) (package private) static String
fromLegacy
(String path) getRoot()
Return the representation of the document root.(package private) static int
parseQuote
(StringBuilder sb, String s, int pos) Parses a single-quoted string.(package private) static int
parseSelector
(StringBuilder sb, String s, int pos) Parses a JSONPath selector(package private) static int
parseShorthand
(StringBuilder sb, String s, int pos) Parses a JSONPath shorthand selectorprivate static String
Replace common special characters that are to be considered for all types of paths.static PathType
Returns the enum constant of this type with the specified name.static PathType[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
LEGACY
The legacy approach, loosely based on JSONPath (but not guaranteed to give valid JSONPath expressions). -
JSON_PATH
Paths as JSONPath expressions. -
JSON_POINTER
Paths as JSONPointer expressions. -
URI_REFERENCE
Paths as a URI reference.
-
-
Field Details
-
DEFAULT
The default path generation approach to use. -
rootToken
-
appendTokenFn
-
appendIndexFn
-
-
Constructor Details
-
PathType
private PathType(String rootToken, BiFunction<String, String, String> appendTokenFn, BiFunction<String, Integer, String> appendIndexFn) Constructor.- Parameters:
rootToken
- The token representing the document root.appendTokenFn
- A function used to define the path fragment used to append a token (e.g. property) to an existing path.appendIndexFn
- A function used to append an index (for arrays) to an existing path.
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
replaceCommonSpecialCharactersIfPresent
Replace common special characters that are to be considered for all types of paths.- Parameters:
token
- The path token (property name or selector).- Returns:
- The token to use in the path.
-
append
Append the given child token to the provided current path.- Parameters:
currentPath
- The path to append to.child
- The child token.- Returns:
- The resulting complete path.
-
append
Append the given index to the provided current path.- Parameters:
currentPath
- The path to append to.index
- The index to append.- Returns:
- The resulting complete path.
-
getRoot
Return the representation of the document root.- Returns:
- The root token.
-
convertToJsonPointer
-
fromLegacy
-
fromJsonPath
-
parseShorthand
Parses a JSONPath shorthand selector- Parameters:
sb
- receives the results
- the source stringpos
- the index into s immediately following the dot- Returns:
- the index following the selector name
-
parseSelector
Parses a JSONPath selector- Parameters:
sb
- receives the results
- the source stringpos
- the index into s immediately following the open bracket- Returns:
- the index following the closing bracket
-
parseQuote
Parses a single-quoted string.- Parameters:
sb
- receives the results
- the source stringpos
- the index into s immediately following the open quote- Returns:
- the index following the closing quote
-