Package org.exbin.xbup.parser_tree
Class XBTTreeNode
- java.lang.Object
-
- org.exbin.xbup.parser_tree.XBTTreeNode
-
- All Implemented Interfaces:
java.io.Serializable
,javax.swing.tree.TreeNode
,org.exbin.xbup.core.block.XBTBlock
,org.exbin.xbup.core.block.XBTEditableBlock
,org.exbin.xbup.core.ubnumber.UBStreamable
public class XBTTreeNode extends java.lang.Object implements javax.swing.tree.TreeNode, org.exbin.xbup.core.block.XBTEditableBlock, org.exbin.xbup.core.ubnumber.UBStreamable
Basic object model parser XBUP level 1 document block / tree node.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description XBTTreeNode()
XBTTreeNode(XBTTreeNode parent)
Creates a new instance of XBTTreeNode.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAttribute(org.exbin.xbup.core.parser.token.XBAttribute attribute)
void
addChild(XBTTreeNode child)
int
attributesSizeUB()
void
clear()
void
clearAttributes()
XBTTreeNode
cloneNode()
Creates deep copy of this node.XBTTreeNode
cloneNode(boolean recursive)
Creates copy of this nodeXBTTreeNode
createNewChild(int childIndex)
This method instantiates new child node.static XBTTreeNode
createTreeCopy(org.exbin.xbup.core.block.XBTBlock block)
Creates XBTTreeNode copy of given block and all of its children.static XBTTreeNode
createTreeCopy(org.exbin.xbup.core.block.XBTBlock block, XBTTreeNode parent)
Creates XBTTreeNode copy of given block and all of its children.java.util.Optional<XBTTreeNode>
findNodeByIndex(long index)
Finds node of given index (recursive, no cache).XBTTreeNode
followPointer(int index)
int
fromStreamUB(java.io.InputStream stream)
int
fromStreamUB(java.io.InputStream stream, boolean terminable)
Loads this node from data stream.boolean
getAllowsChildren()
org.exbin.xbup.core.parser.token.XBAttribute
getAttributeAt(int attributeIndex)
org.exbin.xbup.core.parser.token.XBAttribute[]
getAttributes()
int
getAttributesCount()
int
getAttributeValue(int attributeIndex)
org.exbin.auxiliary.paged_data.BinaryData
getBlockData()
org.exbin.xbup.core.block.declaration.XBBlockDecl
getBlockDecl()
int
getBlockIndex()
Gets block position in tree in depth-first scan.long
getBlockSize()
org.exbin.xbup.core.block.XBBlockType
getBlockType()
org.exbin.xbup.core.block.declaration.XBContext
getContext()
java.io.InputStream
getData()
org.exbin.xbup.core.block.XBBlockDataMode
getDataMode()
long
getDataSize()
org.exbin.xbup.core.block.XBFixedBlockType
getFixedBlockType()
XBTTreeNode
getChildAt(int childIndex)
int
getChildCount()
org.exbin.xbup.core.block.XBTBlock[]
getChildren()
int
getChildrenCount()
int
getIndex(javax.swing.tree.TreeNode node)
Returns index of child.int
getNodeIndexAfter()
XBTTreeNode
getParent()
java.util.Optional<org.exbin.xbup.core.block.XBTBlock>
getParentBlock()
boolean
getSingleAttributeType()
int
getSizeUB()
int
getSubNodesCount()
Gets count of all subnodes.org.exbin.xbup.core.block.XBBlockTerminationMode
getTerminationMode()
java.util.Enumeration
children()
int
childrenFromStreamUB(java.io.InputStream stream, java.lang.Integer maxSize)
Reads all children blocks.int
childrenSizeUB()
int
childrenToStreamUB(java.io.OutputStream stream)
boolean
isLeaf()
void
processSpec(org.exbin.xbup.core.catalog.XBCatalog catalog, org.exbin.xbup.core.block.declaration.XBContext parentContext)
Performs tree depth specification processing.void
removeAttribute(int index)
void
removeChild(int index)
void
setAttributeAt(org.exbin.xbup.core.parser.token.XBAttribute attribute, int attributeIndex)
void
setAttributes(org.exbin.xbup.core.parser.token.XBAttribute[] attributes)
void
setAttributesCount(int count)
void
setBlockDecl(org.exbin.xbup.core.block.declaration.XBBlockDecl blockDecl)
void
setBlockType(org.exbin.xbup.core.block.XBBlockType blockType)
void
setContext(org.exbin.xbup.core.block.declaration.XBContext context)
void
setData(java.io.InputStream source)
void
setData(org.exbin.auxiliary.paged_data.BinaryData newData)
void
setDataMode(org.exbin.xbup.core.block.XBBlockDataMode dataMode)
void
setFixedBlockType(org.exbin.xbup.core.block.XBFixedBlockType blockType)
void
setChildAt(org.exbin.xbup.core.block.XBTBlock block, int childIndex)
void
setChildren(org.exbin.xbup.core.block.XBTBlock[] children)
void
setChildrenCount(int count)
void
setParent(org.exbin.xbup.core.block.XBTBlock parent)
void
setSingleAttributeType(boolean singleAttributeType)
void
setTerminationMode(org.exbin.xbup.core.block.XBBlockTerminationMode terminationMode)
int
toStreamUB(java.io.OutputStream stream)
-
-
-
Constructor Detail
-
XBTTreeNode
public XBTTreeNode()
-
XBTTreeNode
public XBTTreeNode(XBTTreeNode parent)
Creates a new instance of XBTTreeNode. This is not copy constructor.- Parameters:
parent
- set it as parent node
-
-
Method Detail
-
getIndex
public int getIndex(javax.swing.tree.TreeNode node)
Returns index of child.- Specified by:
getIndex
in interfacejavax.swing.tree.TreeNode
- Parameters:
node
- node to search match for- Returns:
- index of node if node found
-
getSubNodesCount
public int getSubNodesCount()
Gets count of all subnodes.- Returns:
- count of child nodes and all their child nodes
-
getBlockIndex
public int getBlockIndex()
Gets block position in tree in depth-first scan.- Returns:
- position index
-
getNodeIndexAfter
public int getNodeIndexAfter()
-
findNodeByIndex
@Nonnull public java.util.Optional<XBTTreeNode> findNodeByIndex(long index)
Finds node of given index (recursive, no cache).- Parameters:
index
- depth-first order index- Returns:
- node if found
-
fromStreamUB
public int fromStreamUB(java.io.InputStream stream) throws java.io.IOException, org.exbin.xbup.core.parser.XBProcessingException
- Specified by:
fromStreamUB
in interfaceorg.exbin.xbup.core.ubnumber.UBStreamable
- Throws:
java.io.IOException
org.exbin.xbup.core.parser.XBProcessingException
-
fromStreamUB
public int fromStreamUB(java.io.InputStream stream, boolean terminable) throws java.io.IOException, org.exbin.xbup.core.parser.XBProcessingException
Loads this node from data stream.- Parameters:
stream
- data streamterminable
- specify if terminator can be read- Returns:
- size of read bytes
- Throws:
java.io.IOException
- exception on input/output errororg.exbin.xbup.core.parser.XBProcessingException
-
toStreamUB
public int toStreamUB(java.io.OutputStream stream) throws java.io.IOException
- Specified by:
toStreamUB
in interfaceorg.exbin.xbup.core.ubnumber.UBStreamable
- Throws:
java.io.IOException
-
childrenToStreamUB
public int childrenToStreamUB(java.io.OutputStream stream) throws java.io.IOException
- Throws:
java.io.IOException
-
getSizeUB
public int getSizeUB()
- Specified by:
getSizeUB
in interfaceorg.exbin.xbup.core.ubnumber.UBStreamable
-
childrenSizeUB
public int childrenSizeUB()
-
attributesSizeUB
public int attributesSizeUB()
-
clear
public void clear()
- Specified by:
clear
in interfaceorg.exbin.xbup.core.block.XBTEditableBlock
-
getData
@Nonnull public java.io.InputStream getData()
- Specified by:
getData
in interfaceorg.exbin.xbup.core.block.XBTBlock
-
getBlockData
@Nonnull public org.exbin.auxiliary.paged_data.BinaryData getBlockData()
- Specified by:
getBlockData
in interfaceorg.exbin.xbup.core.block.XBTBlock
-
getDataSize
public long getDataSize()
-
setData
public void setData(java.io.InputStream source) throws java.io.IOException
- Specified by:
setData
in interfaceorg.exbin.xbup.core.block.XBTEditableBlock
- Throws:
java.io.IOException
-
setData
public void setData(org.exbin.auxiliary.paged_data.BinaryData newData)
- Specified by:
setData
in interfaceorg.exbin.xbup.core.block.XBTEditableBlock
-
cloneNode
public XBTTreeNode cloneNode()
Creates deep copy of this node.- Returns:
- tree node
-
cloneNode
public XBTTreeNode cloneNode(boolean recursive)
Creates copy of this node- Parameters:
recursive
- if true, perform deep copy or else shallow copy.- Returns:
- tree node
-
createNewChild
public XBTTreeNode createNewChild(int childIndex)
This method instantiates new child node.- Specified by:
createNewChild
in interfaceorg.exbin.xbup.core.block.XBTEditableBlock
- Parameters:
childIndex
- child index- Returns:
- new
-
getBlockSize
public long getBlockSize()
-
clearAttributes
public void clearAttributes()
-
addAttribute
public void addAttribute(org.exbin.xbup.core.parser.token.XBAttribute attribute)
-
removeAttribute
public void removeAttribute(int index)
- Specified by:
removeAttribute
in interfaceorg.exbin.xbup.core.block.XBTEditableBlock
-
getParent
@Nullable public XBTTreeNode getParent()
- Specified by:
getParent
in interfacejavax.swing.tree.TreeNode
-
getParentBlock
@Nonnull public java.util.Optional<org.exbin.xbup.core.block.XBTBlock> getParentBlock()
- Specified by:
getParentBlock
in interfaceorg.exbin.xbup.core.block.XBTBlock
-
setParent
public void setParent(org.exbin.xbup.core.block.XBTBlock parent)
- Specified by:
setParent
in interfaceorg.exbin.xbup.core.block.XBTEditableBlock
-
getTerminationMode
public org.exbin.xbup.core.block.XBBlockTerminationMode getTerminationMode()
- Specified by:
getTerminationMode
in interfaceorg.exbin.xbup.core.block.XBTBlock
-
setTerminationMode
public void setTerminationMode(org.exbin.xbup.core.block.XBBlockTerminationMode terminationMode)
- Specified by:
setTerminationMode
in interfaceorg.exbin.xbup.core.block.XBTEditableBlock
-
getDataMode
public org.exbin.xbup.core.block.XBBlockDataMode getDataMode()
- Specified by:
getDataMode
in interfaceorg.exbin.xbup.core.block.XBTBlock
-
setDataMode
public void setDataMode(org.exbin.xbup.core.block.XBBlockDataMode dataMode)
- Specified by:
setDataMode
in interfaceorg.exbin.xbup.core.block.XBTEditableBlock
-
getBlockType
public org.exbin.xbup.core.block.XBBlockType getBlockType()
- Specified by:
getBlockType
in interfaceorg.exbin.xbup.core.block.XBTBlock
-
setBlockType
public void setBlockType(org.exbin.xbup.core.block.XBBlockType blockType)
- Specified by:
setBlockType
in interfaceorg.exbin.xbup.core.block.XBTEditableBlock
-
getFixedBlockType
public org.exbin.xbup.core.block.XBFixedBlockType getFixedBlockType()
-
setFixedBlockType
public void setFixedBlockType(org.exbin.xbup.core.block.XBFixedBlockType blockType)
-
getAttributeAt
public org.exbin.xbup.core.parser.token.XBAttribute getAttributeAt(int attributeIndex)
- Specified by:
getAttributeAt
in interfaceorg.exbin.xbup.core.block.XBTBlock
-
setAttributeAt
public void setAttributeAt(org.exbin.xbup.core.parser.token.XBAttribute attribute, int attributeIndex)
- Specified by:
setAttributeAt
in interfaceorg.exbin.xbup.core.block.XBTEditableBlock
-
getAttributeValue
public int getAttributeValue(int attributeIndex)
-
getAttributesCount
public int getAttributesCount()
- Specified by:
getAttributesCount
in interfaceorg.exbin.xbup.core.block.XBTBlock
-
setAttributesCount
public void setAttributesCount(int count)
- Specified by:
setAttributesCount
in interfaceorg.exbin.xbup.core.block.XBTEditableBlock
-
getAttributes
public org.exbin.xbup.core.parser.token.XBAttribute[] getAttributes()
- Specified by:
getAttributes
in interfaceorg.exbin.xbup.core.block.XBTBlock
-
setAttributes
public void setAttributes(org.exbin.xbup.core.parser.token.XBAttribute[] attributes)
- Specified by:
setAttributes
in interfaceorg.exbin.xbup.core.block.XBTEditableBlock
-
getChildAt
public XBTTreeNode getChildAt(int childIndex)
- Specified by:
getChildAt
in interfacejavax.swing.tree.TreeNode
- Specified by:
getChildAt
in interfaceorg.exbin.xbup.core.block.XBTBlock
-
setChildAt
public void setChildAt(org.exbin.xbup.core.block.XBTBlock block, int childIndex)
- Specified by:
setChildAt
in interfaceorg.exbin.xbup.core.block.XBTEditableBlock
-
addChild
public void addChild(XBTTreeNode child)
-
removeChild
public void removeChild(int index)
- Specified by:
removeChild
in interfaceorg.exbin.xbup.core.block.XBTEditableBlock
-
getChildrenCount
public int getChildrenCount()
- Specified by:
getChildrenCount
in interfaceorg.exbin.xbup.core.block.XBTBlock
-
getChildCount
public int getChildCount()
- Specified by:
getChildCount
in interfacejavax.swing.tree.TreeNode
-
setChildrenCount
public void setChildrenCount(int count)
- Specified by:
setChildrenCount
in interfaceorg.exbin.xbup.core.block.XBTEditableBlock
-
getChildren
public org.exbin.xbup.core.block.XBTBlock[] getChildren()
- Specified by:
getChildren
in interfaceorg.exbin.xbup.core.block.XBTBlock
-
setChildren
public void setChildren(org.exbin.xbup.core.block.XBTBlock[] children)
- Specified by:
setChildren
in interfaceorg.exbin.xbup.core.block.XBTEditableBlock
-
getAllowsChildren
public boolean getAllowsChildren()
- Specified by:
getAllowsChildren
in interfacejavax.swing.tree.TreeNode
-
isLeaf
public boolean isLeaf()
- Specified by:
isLeaf
in interfacejavax.swing.tree.TreeNode
-
children
public java.util.Enumeration children()
- Specified by:
children
in interfacejavax.swing.tree.TreeNode
-
setContext
public void setContext(org.exbin.xbup.core.block.declaration.XBContext context)
-
getContext
public org.exbin.xbup.core.block.declaration.XBContext getContext()
-
getBlockDecl
public org.exbin.xbup.core.block.declaration.XBBlockDecl getBlockDecl()
-
setBlockDecl
public void setBlockDecl(org.exbin.xbup.core.block.declaration.XBBlockDecl blockDecl)
-
getSingleAttributeType
public boolean getSingleAttributeType()
-
setSingleAttributeType
public void setSingleAttributeType(boolean singleAttributeType)
-
processSpec
public void processSpec(org.exbin.xbup.core.catalog.XBCatalog catalog, org.exbin.xbup.core.block.declaration.XBContext parentContext)
Performs tree depth specification processing.- Parameters:
catalog
- instance of catalogparentContext
- parent context
-
followPointer
public XBTTreeNode followPointer(int index)
-
childrenFromStreamUB
public int childrenFromStreamUB(java.io.InputStream stream, @Nullable java.lang.Integer maxSize) throws java.io.IOException, org.exbin.xbup.core.parser.XBProcessingException
Reads all children blocks.- Parameters:
stream
- Source input streammaxSize
- Maximum size of bytes to consume. Otherwise Exception.- Returns:
- size in bytes
- Throws:
java.io.IOException
- exception on input/output errororg.exbin.xbup.core.parser.XBProcessingException
-
createTreeCopy
@Nonnull public static XBTTreeNode createTreeCopy(org.exbin.xbup.core.block.XBTBlock block)
Creates XBTTreeNode copy of given block and all of its children.- Parameters:
block
- source block- Returns:
- node
-
createTreeCopy
@Nonnull public static XBTTreeNode createTreeCopy(org.exbin.xbup.core.block.XBTBlock block, XBTTreeNode parent)
Creates XBTTreeNode copy of given block and all of its children.- Parameters:
block
- source blockparent
- parent node- Returns:
- node
-
-