Package ch.njol.skript.config
Class Node
java.lang.Object
ch.njol.skript.config.Node
- All Implemented Interfaces:
NodeNavigator
,AnyNamed
,AnyProvider
,Iterable<Node>
,Validated
- Direct Known Subclasses:
EntryNode
,SectionNode
,SimpleNode
,VoidNode
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
protected
Node
(String key, SectionNode parent) protected
Node
(String key, String comment, SectionNode parent, int lineNum) -
Method Summary
Modifier and TypeMethodDescriptionboolean
debug()
boolean
protected @Nullable String
final Config
@NotNull Node
Obtains the current node represented by this navigator.protected String
@Nullable String
getKey()
Key of this node.int
getLine()
@Nullable SectionNode
@Nullable String
getPath()
@NotNull String[]
Returns the node names in the path to this node from the config root.int
hashCode()
void
Mark a thing as no longer safe to use.boolean
isVoid()
void
move
(SectionNode newParent) @Nullable String
name()
void
remove()
Removes this node from its parent.void
final String
save()
void
save
(PrintWriter w) static NonNullPair
<String, String> Splits a line into value and comment.static NonNullPair
<String, String> splitLine
(String line, AtomicBoolean inBlockComment) Splits a line into value and comment.toString()
returns information about this node which looks like the following:
node value #including comments (config.sk, line xyz)
boolean
valid()
Implementations ought to specify what 'valid' means locally (e.g.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.njol.skript.lang.util.common.AnyNamed
setName, supportsNameChange
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
key
-
comment
-
lineNum
protected final int lineNum -
parent
-
config
-
-
Constructor Details
-
Node
-
Node
-
Node
-
-
Method Details
-
getKey
Key of this node. null for empty or invalid nodes, and the config's main node. -
getConfig
-
rename
-
move
-
splitLine
Splits a line into value and comment.Whitespace is preserved (whitespace in front of the comment is added to the value), and any ## in the value are replaced by a single #. The comment is returned with a leading #, except if there is no comment in which case it will be the empty string.
- Parameters:
line
- the line to split- Returns:
- A pair (value, comment).
-
splitLine
Splits a line into value and comment.Whitespace is preserved (whitespace in front of the comment is added to the value), and any ## not in quoted strings in the value are replaced by a single #. The comment is returned with a leading #, except if there is no comment in which case it will be the empty string.
- Parameters:
line
- the line to splitinBlockComment
- Whether we are currently inside a block comment- Returns:
- A pair (value, comment).
-
getComment
-
getIndentation
-
save
-
save
-
getParent
-
remove
public void remove()Removes this node from its parent. Does nothing if this node does not have a parent node. -
getLine
public int getLine()- Returns:
- Original line of this node at the time it was loaded. -1 if this node was created dynamically.
-
isVoid
public boolean isVoid()- Returns:
- Whether this node does not hold information (i.e. is empty or invalid)
-
toString
returns information about this node which looks like the following:
node value #including comments (config.sk, line xyz)
-
debug
public boolean debug() -
invalidate
Description copied from interface:Validated
Mark a thing as no longer safe to use. This should (typically) not be used by external modifiers, but implementations may differ.
Implementations that do not want to expose an invalidator hook may throw anUnsupportedOperationException
, which is protected by the internal contract.- Specified by:
invalidate
in interfaceValidated
- Throws:
UnsupportedOperationException
- If this is not something that can be externally invalidated.
-
valid
public boolean valid()Description copied from interface:Validated
Implementations ought to specify what 'valid' means locally (e.g. should a new copy be obtained?) when overriding this method. -
getPath
-
getCurrentNode
Description copied from interface:NodeNavigator
Obtains the current node represented by this navigator. If this navigator is itself a node, it should return itself.- Specified by:
getCurrentNode
in interfaceNodeNavigator
- Returns:
- The main node represented by this navigator
-
getPathSteps
Returns the node names in the path to this node from the config root. If this is not a section node, returns the path to its parent node.Getting the path of node
z
in the following example would return an array withw.x, y, z
.w.x: y: z: true # this node
- Returns:
- The path to this node in the config file.
-
name
-
equals
-
hashCode
public int hashCode()
-