Blame view
node_modules/xmlcreate/lib/nodes/XmlNode.d.ts
4.52 KB
f7563de62
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
/** * Copyright (C) 2016 Michael Kourlas * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { IStringOptions } from "../options"; /** * Represents an XML node. * * This class is the root class of the XML node hierarchy. It should not be * directly instantiated; one of its subclasses should be used instead. * * @protected */ export default class XmlNode { protected _children: XmlNode[]; private _parent?; /** * Initializes a new instance of the {@link XmlNode} class. */ constructor(); /** * Gets the parent of this node. * * @returns The parent of this node. */ readonly parent: XmlNode | undefined; /** * Gets this node's children. * * Throws an exception if this node cannot have any children. Consult the * appropriate subclass documentation for more details. * * @returns This node's children. */ children(): XmlNode[]; /** * Inserts the specified node into this node's children at the specified * index. The node is not inserted if it is already present. If this node * already has a parent, it is removed from that parent. * * Throws an exception if this node cannot have any children, or if the * specified node cannot be added at the specified index. Consult the * appropriate subclass documentation for more details. * * @param node The node to insert. * @param index The index at which to insert the node. Nodes at or after * the index are shifted to the right. If no index is * specified, the node is inserted at the end. * * @returns The node inserted into this node's children, or undefined if no * node was inserted. */ insertChild(node: XmlNode, index?: number): XmlNode | undefined; /** * Gets the node that follows this one, or undefined if no such node * exists or if this node has no parent. * * @returns The node that follows this one, or undefined if no such node * exists or if this node has no parent. */ next(): XmlNode | undefined; /** * Gets the node that is previous to this one, or undefined if no such node * exists or if this node has no parent. * * @returns The node that is previous to this one, or undefined if no such * node exists or if this node has no parent. */ prev(): XmlNode | undefined; /** * Removes this node from its parent if this node has a parent. * * @returns This node's parent, or undefined if it has no parent. */ remove(): XmlNode | undefined; /** * Removes the specified node from this node's children. * * Throws an exception if this node cannot have any children, or if the * specified node cannot be removed. Consult the appropriate subclass * documentation for more details. * * @param node The node to remove. * * @returns Whether a node was removed. */ removeChild(node: XmlNode): boolean; /** * Removes the node at the specified index from this node's children. * * Throws an exception if this node cannot have any children, or if the * node at the specified index cannot be removed. Consult the appropriate * subclass documentation for more details. * * @param index The index at which the node to be removed is located. * * @returns The node that was removed. */ removeChildAtIndex(index: number): XmlNode; /** * Returns an XML string representation of this node. * * @param options Formatting options for the string representation. * * @returns An XML string representation of this node. */ toString(options?: IStringOptions): string; /** * Returns the root node of the current hierarchy. If this node has no * parent, this node itself is returned. * * @returns The root node of the current hierarchy. */ top(): XmlNode; /** * Gets the parent of this node. */ up(): XmlNode | undefined; } |