import { IVisitor } from '../visitors/IVisitor'; /** * Construct a node path from a string representation. * @param {string} path * @class * @author eric.wittmann@gmail.com */ export declare class NodePath { static SCAN_TYPE_PATH: number; static SCAN_TYPE_INDEX: number; segments: Array; constructor(path?: any); prependSegment(value: string, index?: boolean): void; appendSegment(value: string, index?: boolean): void; /** * Resolves a path to its target node within the document model. This basically * walks the tree according to the path segments until it reaches the node being * referenced. If the path does not point to a valid node, then this method * returns undefined. * @param {Document} document the document to resolve the path relative to * @return {Node} */ resolve(document: Document): Node; /** * Resolves a path to its target node while also visiting all nodes along the way. * @param {Document} document the document to resolve the path relative to * @param {*} visitor an optional visitor to invoke for each node in the path (can be null) * @return {Node} */ resolveWithVisitor(document: Document, visitor: IVisitor): Node; /** * Returns true if this path "contains" the given node. The path is said to contain * a node if the node is visited while resolving it. In other words, if one of the * segments of the path represents the node, then this will return true, otherwise it * will return false. * @param {Node} node * @return {boolean} */ contains(node: Node): boolean; toSegments(): Array; /** * @see java.lang.Object#toString() * @return {string} */ toString(): string; } export declare namespace NodePath { /** * Constructor. * * @param {string} value RAW (non-escaped) segment value or null * @param {boolean} index * @class * @author eric.wittmann@gmail.com */ class NodePathSegment { value: string; index: boolean; constructor(value?: any, index?: any); /** * @return {string} RAW (non-escaped) segment value or null */ getValue(): string; isIndex(): boolean; /** * Resolves a single segment. * @param {*} from * @return {*} */ resolve(from: any): any; /** * This is a reverse operation to {@link #fromString(String)}. * Not using "toString" as the method name is intentional, * since the format of that methods output should not be assumed * to be stable and precisely defined. * * @return {string} ESCAPED segment value or null */ asString(): string; /** * Creates a segment from an ESCAPED string. * @param {string} segment Escaped segment value. If it represents an "indexed" * node, it MUST be surrounded by '[' and ']'. * @return {NodePath.NodePathSegment} */ static fromString(segment: string): NodePath.NodePathSegment; /** * When a path is represented as a string, * we are using three characters with special meaning * to encode it's structure. * '/' to separate path segments, and '[' with ']' to denote a segment for an "indexed" node. * Since these characters can also appear in the segment values themselves (in their non-special meaning), * they have to be escaped. * The following rules are used, inspired by RFC 6901: * - The escape character is '~', preceding a number which determines which special character is encoded. * - '~1' = '/' * - '~2' = '[' * - '~3' = ']' * The escape character is itself encoded as '~0'. * * @param {boolean} escapeSlash In the "indexed" segment, '/' can be used unescaped. * @param {string} rawValue * @return {string} * @private */ static escapePathSegmentValue(rawValue: string, escapeSlash: boolean): string; /** * @see io.apicurio.datamodels.core.models.NodePath.NodePathSegment#escapePathSegmentValue(String, boolean) * @param {string} escapedValue * @return {string} * @private */ static unescapePathSegmentValue(escapedValue: string): string; } } import { Document } from './Document'; import { Node } from './Node';