Package ch.nolix.common.node
Class Node
- java.lang.Object
-
- ch.nolix.common.node.BaseNode
-
- ch.nolix.common.node.Node
-
- All Implemented Interfaces:
Castable
,IFluentObject<Node>
,ISmartObject<Node>
,Listable<Node>
,Transformable<Node>
,OptionalHeaderable<BaseNode>
,OptionalHeadered
public final class Node extends BaseNode implements ISmartObject<Node>
- Author:
- Silvan Wyss
-
-
Field Summary
-
Fields inherited from class ch.nolix.common.node.BaseNode
CLOSED_BRACKET_CODE, COMMA_CODE, DOLLAR_SYMBOL_CODE, OPEN_BRACKET_CODE
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Node
addAttribute(BaseNode attribute)
Adds the given attribute to the currentBaseNode
.static Node
fromFile(java.lang.String filePath)
static Node
fromIntPair(IntPair intPair)
static Node
fromString(java.lang.String string)
int
getAttributeCount()
java.lang.String
getHeader()
IContainer<BaseNode>
getRefAttributes()
boolean
hasHeader()
void
removeAttributes()
Removes the attributes of the currentNode
.void
removeFirstAttribute(IElementTakerBooleanGetter<BaseNode> selector)
Removes the first attribute the given selector selects from the currentNode
.Node
removeHeader()
Removes the header of currentOptionalHeaderable
.Node
setHeader(java.lang.String header)
Sets the header of the currentNode
.static Node
withAttribute(boolean attribute)
static Node
withAttribute(boolean... attributes)
static Node
withAttribute(double attribute)
static Node
withAttribute(double... attributes)
static Node
withAttribute(long attribute)
static Node
withAttribute(long... attributes)
static <BN extends BaseNode>
NodewithAttribute(BN attribute)
static <BN extends BaseNode>
NodewithAttribute(BN... attributes)
static Node
withAttribute(java.lang.String attribute)
static Node
withAttribute(java.lang.String... attributes)
static <BN extends BaseNode>
NodewithAttributes(java.lang.Iterable<BN> attributes)
static Node
withHeader(boolean header)
static Node
withHeader(double header)
static Node
withHeader(long header)
static Node
withHeader(java.lang.String header)
static Node
withHeaderAndAttribute(java.lang.String header, boolean attribute)
static Node
withHeaderAndAttribute(java.lang.String header, boolean... attributes)
static Node
withHeaderAndAttribute(java.lang.String header, double attribute)
static Node
withHeaderAndAttribute(java.lang.String header, double... attributes)
static Node
withHeaderAndAttribute(java.lang.String header, long attribute)
static Node
withHeaderAndAttribute(java.lang.String header, long... attributes)
static <BN extends BaseNode>
NodewithHeaderAndAttribute(java.lang.String header, BN attribute)
static <BN extends BaseNode>
NodewithHeaderAndAttribute(java.lang.String header, BN... attributes)
static Node
withHeaderAndAttribute(java.lang.String header, java.lang.String attribute)
static Node
withHeaderAndAttribute(java.lang.String header, java.lang.String... attributes)
static <BN extends BaseNode>
NodewithHeaderAndAttributes(java.lang.String header, java.lang.Iterable<BN> attributes)
-
Methods inherited from class ch.nolix.common.node.BaseNode
addAttribute, addAttribute, addAttributes, addPostfixToHeader, addPrefixToHeader, containsAttribute, containsAttributes, containsOneAttribute, containsOneAttributeWithHeader, equals, getAttributesAsStrings, getCopy, getEscapeStringFor, getFirstAttributeAsInt, getFirstAttributeAsLong, getOneAttributeAsBoolean, getOneAttributeAsDouble, getOneAttributeAsInt, getOneAttributeAsLong, getOneAttributeHeader, getOriginStringFromEscapeString, getRefAttributeAt, getRefAttributes, getRefAttributes, getRefAttributesOfFirstAttribute, getRefFirstAttribute, getRefFirstAttribute, getRefFirstAttribute, getRefOneAttribute, getRefOneAttributeOfFirstAttribute, getRefOneAttributeOfFirstAttributeAsString, hashCode, removeFirstAttribute, reset, resetAttributes, resetFromFile, resetFromString, saveToFile, saveToFile, toBoolean, toDouble, toFormatedString, toInt, toIntPair, toLong, toString, toXML
-
Methods inherited from interface ch.nolix.common.generalskillapi.IFluentObject
asConcrete
-
Methods inherited from interface ch.nolix.common.generalskillapi.Listable
intoList, intoListAs
-
Methods inherited from interface ch.nolix.common.optionalattributeapi.OptionalHeadered
getHeaderInQuotes, getHeaderOrEmptyString, hasHeader, hasSameHeaderAs
-
Methods inherited from interface ch.nolix.common.generalskillapi.Transformable
to, to
-
-
-
-
Constructor Detail
-
Node
public Node()
Creates a newNode
.
-
-
Method Detail
-
fromFile
public static Node fromFile(java.lang.String filePath)
- Parameters:
filePath
-- Returns:
- a new
Node
from the file with the given file path. - Throws:
InvalidArgumentException
- if the given file path is not valid.InvalidArgumentException
- if the file with the given file path does not represent aNode
.
-
fromIntPair
public static Node fromIntPair(IntPair intPair)
- Parameters:
intPair
-- Returns:
- a new
Node
from the given intPair. - Throws:
ArgumentIsNullException
- if the given intPair is null.
-
fromString
public static Node fromString(java.lang.String string)
- Parameters:
string
-- Returns:
- a new
Node
from the given string. - Throws:
UnrepresentingArgumentException
- if the given string does not represent aNode
.
-
withAttribute
public static <BN extends BaseNode> Node withAttribute(BN attribute)
- Type Parameters:
BN
- is the type of the given attribute.- Parameters:
attribute
-- Returns:
- a new
Node
with the given attribute. - Throws:
ArgumentIsNullException
- if the given attribute is null.
-
withAttribute
public static <BN extends BaseNode> Node withAttribute(BN... attributes)
- Type Parameters:
BN
- is the type of the given attributes.- Parameters:
attributes
-- Returns:
- a new
Node
with the given attributes.
-
withAttribute
public static Node withAttribute(boolean attribute)
- Parameters:
attribute
-- Returns:
- a new
Node
with the given attribute.
-
withAttribute
public static Node withAttribute(boolean... attributes)
- Parameters:
attributes
-- Returns:
- a new
Node
with the given attributes.
-
withAttribute
public static Node withAttribute(double attribute)
- Parameters:
attribute
-- Returns:
- a new
Node
with the given attribute.
-
withAttribute
public static Node withAttribute(double... attributes)
- Parameters:
attributes
-- Returns:
- a new
Node
with the given attributes.
-
withAttribute
public static Node withAttribute(long attribute)
- Parameters:
attribute
-- Returns:
- a new
Node
with the given attribute.
-
withAttribute
public static Node withAttribute(long... attributes)
- Parameters:
attributes
-- Returns:
- a new
Node
with the given attributes.
-
withAttribute
public static Node withAttribute(java.lang.String attribute)
- Parameters:
attribute
-- Returns:
- a new
Node
with the given attribute. - Throws:
ArgumentIsNullException
- if the given attribute is null.InvalidArgumentException
- with the given attribute.
-
withAttribute
public static Node withAttribute(java.lang.String... attributes)
- Parameters:
attributes
-- Returns:
- a new
Node
with the given attributes.
-
withAttributes
public static <BN extends BaseNode> Node withAttributes(java.lang.Iterable<BN> attributes)
- Type Parameters:
BN
- is the type of the given attributes.- Parameters:
attributes
-- Returns:
- a new
Node
with the given attributes.
-
withHeader
public static Node withHeader(boolean header)
- Parameters:
header
-- Returns:
- a new
Node
with the given header.
-
withHeader
public static Node withHeader(double header)
- Parameters:
header
-- Returns:
- a new
Node
with the given header.
-
withHeader
public static Node withHeader(long header)
- Parameters:
header
-- Returns:
- a new
Node
with the given header.
-
withHeader
public static Node withHeader(java.lang.String header)
- Parameters:
header
-- Returns:
- a new
Node
with the given header. - Throws:
ArgumentIsNullException
- if the given header is null.InvalidArgumentException
- if the given header is blank.
-
withHeaderAndAttribute
public static <BN extends BaseNode> Node withHeaderAndAttribute(java.lang.String header, BN attribute)
- Type Parameters:
BN
- is the type of the given attributes.- Parameters:
header
-attribute
-- Returns:
- a new
Node
with the given header and attribute. - Throws:
ArgumentIsNullException
- if the given header is null.InvalidArgumentException
- if the given header is blank.ArgumentIsNullException
- if the given attribute is null.
-
withHeaderAndAttribute
public static <BN extends BaseNode> Node withHeaderAndAttribute(java.lang.String header, BN... attributes)
- Type Parameters:
BN
- is the type of the given attributes.- Parameters:
header
-attributes
-- Returns:
- a new
Node
with the given header and attributes. - Throws:
ArgumentIsNullException
- if the given header is null.InvalidArgumentException
- if the given header is blank.ArgumentIsNullException
- if one of the given attributes is null.
-
withHeaderAndAttribute
public static Node withHeaderAndAttribute(java.lang.String header, boolean attribute)
- Parameters:
header
-attribute
-- Returns:
- a new
Node
with the given header and attribute. - Throws:
ArgumentIsNullException
- if the given header is null.InvalidArgumentException
- if the given header is blank.
-
withHeaderAndAttribute
public static Node withHeaderAndAttribute(java.lang.String header, boolean... attributes)
- Parameters:
header
-attributes
-- Returns:
- a new
Node
with the given header and attributes. - Throws:
ArgumentIsNullException
- if the given header is null.InvalidArgumentException
- if the given header is blank.
-
withHeaderAndAttribute
public static Node withHeaderAndAttribute(java.lang.String header, double attribute)
- Parameters:
header
-attribute
-- Returns:
- a new
Node
with the given header and attribute. - Throws:
ArgumentIsNullException
- if the given header is null.InvalidArgumentException
- if the given header is blank.
-
withHeaderAndAttribute
public static Node withHeaderAndAttribute(java.lang.String header, double... attributes)
- Parameters:
header
-attributes
-- Returns:
- a new
Node
with the given header and attributes. - Throws:
ArgumentIsNullException
- if the given header is null.InvalidArgumentException
- if the given header is blank.
-
withHeaderAndAttribute
public static Node withHeaderAndAttribute(java.lang.String header, long attribute)
- Parameters:
header
-attribute
-- Returns:
- a new
Node
with the given header and attribute. - Throws:
ArgumentIsNullException
- if the given header is null.InvalidArgumentException
- if the given header is blank.
-
withHeaderAndAttribute
public static Node withHeaderAndAttribute(java.lang.String header, long... attributes)
- Parameters:
header
-attributes
-- Returns:
- a new
Node
with the given header and attributes. - Throws:
ArgumentIsNullException
- if the given header is null.InvalidArgumentException
- if the given header is blank.
-
withHeaderAndAttribute
public static Node withHeaderAndAttribute(java.lang.String header, java.lang.String attribute)
- Parameters:
header
-attribute
-- Returns:
- a new
Node
with the given header and attribute. - Throws:
ArgumentIsNullException
- if the given header is null.InvalidArgumentException
- if the given header is blank.ArgumentIsNullException
- if the given attribute is null.InvalidArgumentException
- if the given attribute is blank.
-
withHeaderAndAttribute
public static Node withHeaderAndAttribute(java.lang.String header, java.lang.String... attributes)
- Parameters:
header
-attributes
-- Returns:
- a new
Node
with the given header and attributes. - Throws:
ArgumentIsNullException
- if the given header is null.InvalidArgumentException
- if the given header is blank.ArgumentIsNullException
- if one of the given attributes is null.InvalidArgumentException
- if one of the given attributes is blank.
-
withHeaderAndAttributes
public static <BN extends BaseNode> Node withHeaderAndAttributes(java.lang.String header, java.lang.Iterable<BN> attributes)
- Type Parameters:
BN
- is the type of the given attributes.- Parameters:
header
-attributes
-- Returns:
- a new
Node
with the given attributes. - Throws:
ArgumentIsNullException
- if the given header is null.InvalidArgumentException
- if the given header is blank.
-
addAttribute
public Node addAttribute(BaseNode attribute)
Adds the given attribute to the currentBaseNode
.- Specified by:
addAttribute
in classBaseNode
- Returns:
- the current
BaseNode
-
getAttributeCount
public int getAttributeCount()
- Specified by:
getAttributeCount
in classBaseNode
- Returns:
- the number of attributes of the current
BaseNode
.
-
getHeader
public java.lang.String getHeader()
- Specified by:
getHeader
in interfaceOptionalHeadered
- Returns:
- the header of this specification.
- Throws:
ArgumentDoesNotHaveAttributeException
- if the currentNode
does not have a header.
-
getRefAttributes
public IContainer<BaseNode> getRefAttributes()
- Specified by:
getRefAttributes
in classBaseNode
- Returns:
- the attributes of the current
BaseNode
.
-
hasHeader
public boolean hasHeader()
- Specified by:
hasHeader
in interfaceOptionalHeadered
- Returns:
- true if the current
Node
has a header
-
removeAttributes
public void removeAttributes()
Removes the attributes of the currentNode
.- Specified by:
removeAttributes
in classBaseNode
-
removeFirstAttribute
public void removeFirstAttribute(IElementTakerBooleanGetter<BaseNode> selector)
Removes the first attribute the given selector selects from the currentNode
.- Specified by:
removeFirstAttribute
in classBaseNode
- Parameters:
selector
-- Throws:
InvalidArgumentException
- if the currentNode
does not contain an attribute the given selector selects.
-
removeHeader
public Node removeHeader()
Removes the header of currentOptionalHeaderable
.- Specified by:
removeHeader
in interfaceOptionalHeaderable<BaseNode>
- Returns:
- the current
OptionalHeaderable
.
-
setHeader
public Node setHeader(java.lang.String header)
Sets the header of the currentNode
.- Specified by:
setHeader
in interfaceOptionalHeaderable<BaseNode>
- Parameters:
header
-- Returns:
- the current
Node
. - Throws:
ArgumentIsNullException
- if the given header is null.InvalidArgumentException
- if the given header is blank.
-
-