Package cn.nukkit.nbt.snbt
Class BaseNode
java.lang.Object
cn.nukkit.nbt.snbt.BaseNode
- All Implemented Interfaces:
Node
,Comparable<Node>
- Direct Known Subclasses:
ByteArrayNBT
,CompoundNBT
,IntArrayNBT
,KeyValuePair
,ListNBT
,Root
,Value
The base concrete class for non-terminal Nodes
-
Nested Class Summary
Nested classes/interfaces inherited from interface cn.nukkit.nbt.snbt.Node
Node.Visitor
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
inserts a child Node at a specific index, displacing the nodes after the index by 1.void
appends a child node to this Nodevoid
addToNamedChildList
(String name, Node node) children()
void
Remove all the child nodesint
getChild
(int i) int
int
getNamedChild
(String name) getNamedChildList
(String name) boolean
removeChild
(int i) Remove the node at index i.void
setBeginOffset
(int beginOffset) Set the offset where the token begins, expressed in code units.void
Replace the node at index ivoid
setEndOffset
(int endOffset) Set the offset where the token ends, actually the location where the very next token should begin.static void
setListClass
(Class<? extends List> listClass) Sets the List class that is used to store child nodes.void
setNamedChild
(String name, Node node) void
void
setTokenSource
(SNBTLexer tokenSource) void
setUnparsed
(boolean unparsed) Mark whether this Node is unparsed, i.e.toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface cn.nukkit.nbt.snbt.Node
appendChild, children, childrenOfType, close, compareTo, copyLocationInfo, copyLocationInfo, descendants, descendants, descendants, descendants, descendantsOfType, dump, dump, firstAncestorOfType, firstChildOfType, firstChildOfType, firstChildOfType, firstDescendantOfType, firstDescendantOfType, getAllTokens, getBeginColumn, getBeginLine, getEndColumn, getEndLine, getFirstChild, getFirstToken, getInputSource, getLastChild, getLastToken, getLength, getLocation, getRealTokens, getRoot, getSource, getTokenType, hasChildNodes, indexOf, iterator, nextSibling, open, prependChild, previousSibling, removeChild, replace, replaceChild
-
Constructor Details
-
BaseNode
public BaseNode()
-
-
Method Details
-
getTokenSource
- Specified by:
getTokenSource
in interfaceNode
- Returns:
- the #SNBTLexer from which this Node object originated. There is no guarantee that this doesn't return null. Most likely that would simply be because you constructed the Node yourself, i.e. it didn't really come about via the parsing/tokenizing machinery.
-
setTokenSource
- Specified by:
setTokenSource
in interfaceNode
-
setListClass
Sets the List class that is used to store child nodes. By default, this is java.util.ArrayList. There is probably very little reason to ever use anything else, though you could use this method to replace this with LinkedList or your own java.util.List implementation even.- Parameters:
listClass
- the #java.util.List implementation to use internally for the child nodes. By default #java.util.ArrayList is used.
-
isUnparsed
public boolean isUnparsed()- Specified by:
isUnparsed
in interfaceNode
- Returns:
- whether this Node was created by regular operations of the parsing machinery.
-
setUnparsed
public void setUnparsed(boolean unparsed) Description copied from interface:Node
Mark whether this Node is unparsed, i.e. not the result of normal parsing- Specified by:
setUnparsed
in interfaceNode
- Parameters:
unparsed
- whether to set the Node as unparsed or parsed.
-
setParent
-
getParent
-
addChild
Description copied from interface:Node
appends a child node to this Node -
addChild
Description copied from interface:Node
inserts a child Node at a specific index, displacing the nodes after the index by 1. -
getChild
-
setChild
Description copied from interface:Node
Replace the node at index i -
removeChild
Description copied from interface:Node
Remove the node at index i. Any Nodes after i are shifted to the left.- Specified by:
removeChild
in interfaceNode
- Parameters:
i
- the index at which to remove- Returns:
- the removed Node
-
clearChildren
public void clearChildren()Description copied from interface:Node
Remove all the child nodes- Specified by:
clearChildren
in interfaceNode
-
getChildCount
public int getChildCount()- Specified by:
getChildCount
in interfaceNode
- Returns:
- the number of child nodes
-
children
-
getBeginOffset
public int getBeginOffset()- Specified by:
getBeginOffset
in interfaceNode
- Returns:
- the offset in the input source where the token begins, expressed in code units.
-
setBeginOffset
public void setBeginOffset(int beginOffset) Description copied from interface:Node
Set the offset where the token begins, expressed in code units.- Specified by:
setBeginOffset
in interfaceNode
-
getEndOffset
public int getEndOffset()- Specified by:
getEndOffset
in interfaceNode
- Returns:
- the offset in the input source where the token ends, expressed in code units. This is actually the offset where the very next token would begin.
-
setEndOffset
public void setEndOffset(int endOffset) Description copied from interface:Node
Set the offset where the token ends, actually the location where the very next token should begin.- Specified by:
setEndOffset
in interfaceNode
-
toString
-
getNamedChild
-
setNamedChild
-
getNamedChildList
-
addToNamedChildList
-