Package org.exbin.xbup.parser_tree
Class XBTreeNode
- java.lang.Object
-
- org.exbin.xbup.parser_tree.XBTreeNode
-
- All Implemented Interfaces:
java.io.Serializable,javax.swing.tree.TreeNode,org.exbin.xbup.core.block.XBBlock,org.exbin.xbup.core.block.XBEditableBlock,org.exbin.xbup.core.ubnumber.UBStreamable
public class XBTreeNode extends java.lang.Object implements org.exbin.xbup.core.block.XBEditableBlock, javax.swing.tree.TreeNode, org.exbin.xbup.core.ubnumber.UBStreamableBasic object model parser XBUP level 0 document block / tree node.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description XBTreeNode()XBTreeNode(XBTreeNode parent)Creates a new instance of XBTreeNode with parent node assigned.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAttribute(org.exbin.xbup.core.parser.token.XBAttribute attribute)voidaddChild(XBTreeNode child)intattributesSizeUB()voidclear()voidclearData()XBTreeNodecloneNode(boolean recursive)XBTreeNodecreateNewChild(int childIndex)This method instantiates new child node.static XBTreeNodecreateTreeCopy(org.exbin.xbup.core.block.XBBlock block)Creates XBTreeNode copy of given block and all of its children.static XBTreeNodecreateTreeCopy(org.exbin.xbup.core.block.XBBlock block, XBTreeNode parent)Creates XBTreeNode copy of given block and all of its children.XBTreeNodefindNodeByIndex(long index)Finds node of given index (recursive, no cache).intfromStreamUB(java.io.InputStream stream)intfromStreamUB(java.io.InputStream stream, boolean terminable)Loads this node from data stream.booleangetAllowsChildren()org.exbin.xbup.core.parser.token.XBAttributegetAttributeAt(int index)org.exbin.xbup.core.parser.token.XBAttribute[]getAttributes()intgetAttributesCount()org.exbin.auxiliary.paged_data.BinaryDatagetBlockData()intgetBlockIndex()Gets index in depth-first order.longgetBlockSize()java.io.InputStreamgetData()org.exbin.xbup.core.block.XBBlockDataModegetDataMode()longgetDataSize()XBTreeNodegetChildAt(int childIndex)intgetChildCount()org.exbin.xbup.core.block.XBBlock[]getChildren()intgetChildrenCount()intgetIndex(javax.swing.tree.TreeNode node)Returns index of child.intgetNodeIndexAfter()XBTreeNodegetParent()java.util.Optional<org.exbin.xbup.core.block.XBBlock>getParentBlock()intgetSizeUB()intgetSubNodesCount()Gets count of all subnodes.org.exbin.xbup.core.block.XBBlockTerminationModegetTerminationMode()java.util.Enumerationchildren()intchildrenFromStreamUB(java.io.InputStream stream, java.lang.Integer maxSize)Loads children from data stream.intchildrenSizeUB()intchildrenToStreamUB(java.io.OutputStream stream)booleanisLeaf()voidremoveAttribute(int index)voidremoveChild(int index)voidsetAttributeAt(org.exbin.xbup.core.parser.token.XBAttribute attribute, int attributeIndex)voidsetAttributes(org.exbin.xbup.core.parser.token.XBAttribute[] attributes)voidsetAttributesCount(int count)voidsetData(java.io.InputStream source)voidsetData(org.exbin.auxiliary.paged_data.BinaryData newData)voidsetDataMode(org.exbin.xbup.core.block.XBBlockDataMode dataMode)voidsetChildAt(org.exbin.xbup.core.block.XBBlock block, int childIndex)voidsetChildren(org.exbin.xbup.core.block.XBBlock[] children)voidsetChildrenCount(int count)voidsetParent(org.exbin.xbup.core.block.XBBlock parent)voidsetTerminationMode(org.exbin.xbup.core.block.XBBlockTerminationMode terminationMode)inttoStreamUB(java.io.OutputStream stream)
-
-
-
Constructor Detail
-
XBTreeNode
public XBTreeNode()
-
XBTreeNode
public XBTreeNode(XBTreeNode parent)
Creates a new instance of XBTreeNode with parent node assigned. This is NOT copy constructor.- Parameters:
parent- Set it as parent node
-
-
Method Detail
-
getSubNodesCount
public int getSubNodesCount()
Gets count of all subnodes.- Returns:
- count of child nodes and all their child nodes
-
getBlockIndex
public int getBlockIndex()
Gets index in depth-first order.- Returns:
- node index
-
getNodeIndexAfter
public int getNodeIndexAfter()
-
findNodeByIndex
public XBTreeNode 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:
fromStreamUBin interfaceorg.exbin.xbup.core.ubnumber.UBStreamable- Throws:
java.io.IOExceptionorg.exbin.xbup.core.parser.XBProcessingException
-
fromStreamUB
public int fromStreamUB(java.io.InputStream stream, boolean terminable) throws java.io.IOException, org.exbin.xbup.core.parser.XBProcessingExceptionLoads 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
-
childrenFromStreamUB
public int childrenFromStreamUB(java.io.InputStream stream, java.lang.Integer maxSize) throws java.io.IOException, org.exbin.xbup.core.parser.XBProcessingExceptionLoads children from data stream.- Parameters:
stream- input streammaxSize- Maximum size of bytes to consume. Otherwise Exception. Zero means terminationMode block.- Returns:
- size of bytes read
- 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:
toStreamUBin 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:
getSizeUBin interfaceorg.exbin.xbup.core.ubnumber.UBStreamable
-
getAllowsChildren
public boolean getAllowsChildren()
- Specified by:
getAllowsChildrenin interfacejavax.swing.tree.TreeNode
-
isLeaf
public boolean isLeaf()
- Specified by:
isLeafin interfacejavax.swing.tree.TreeNode
-
children
public java.util.Enumeration children()
- Specified by:
childrenin interfacejavax.swing.tree.TreeNode
-
clear
public void clear()
- Specified by:
clearin interfaceorg.exbin.xbup.core.block.XBEditableBlock
-
childrenSizeUB
public int childrenSizeUB()
-
attributesSizeUB
public int attributesSizeUB()
-
getData
public java.io.InputStream getData()
- Specified by:
getDatain interfaceorg.exbin.xbup.core.block.XBBlock
-
getBlockData
public org.exbin.auxiliary.paged_data.BinaryData getBlockData()
- Specified by:
getBlockDatain interfaceorg.exbin.xbup.core.block.XBBlock
-
getDataSize
public long getDataSize()
-
setData
public void setData(java.io.InputStream source) throws java.io.IOException- Specified by:
setDatain interfaceorg.exbin.xbup.core.block.XBEditableBlock- Throws:
java.io.IOException
-
setData
public void setData(org.exbin.auxiliary.paged_data.BinaryData newData)
- Specified by:
setDatain interfaceorg.exbin.xbup.core.block.XBEditableBlock
-
clearData
public void clearData()
-
cloneNode
public XBTreeNode cloneNode(boolean recursive)
-
createNewChild
public XBTreeNode createNewChild(int childIndex)
This method instantiates new child node.- Specified by:
createNewChildin interfaceorg.exbin.xbup.core.block.XBEditableBlock- Parameters:
childIndex- child index- Returns:
- new
-
getBlockSize
public long getBlockSize()
-
getParent
@Nullable public XBTreeNode getParent()
- Specified by:
getParentin interfacejavax.swing.tree.TreeNode
-
getParentBlock
@Nonnull public java.util.Optional<org.exbin.xbup.core.block.XBBlock> getParentBlock()
- Specified by:
getParentBlockin interfaceorg.exbin.xbup.core.block.XBBlock
-
setParent
public void setParent(org.exbin.xbup.core.block.XBBlock parent)
- Specified by:
setParentin interfaceorg.exbin.xbup.core.block.XBEditableBlock
-
getTerminationMode
public org.exbin.xbup.core.block.XBBlockTerminationMode getTerminationMode()
- Specified by:
getTerminationModein interfaceorg.exbin.xbup.core.block.XBBlock
-
setTerminationMode
public void setTerminationMode(org.exbin.xbup.core.block.XBBlockTerminationMode terminationMode)
- Specified by:
setTerminationModein interfaceorg.exbin.xbup.core.block.XBEditableBlock
-
getDataMode
public org.exbin.xbup.core.block.XBBlockDataMode getDataMode()
- Specified by:
getDataModein interfaceorg.exbin.xbup.core.block.XBBlock
-
setDataMode
public void setDataMode(org.exbin.xbup.core.block.XBBlockDataMode dataMode)
- Specified by:
setDataModein interfaceorg.exbin.xbup.core.block.XBEditableBlock
-
getAttributeAt
public org.exbin.xbup.core.parser.token.XBAttribute getAttributeAt(int index)
- Specified by:
getAttributeAtin interfaceorg.exbin.xbup.core.block.XBBlock
-
setAttributeAt
public void setAttributeAt(org.exbin.xbup.core.parser.token.XBAttribute attribute, int attributeIndex)- Specified by:
setAttributeAtin interfaceorg.exbin.xbup.core.block.XBEditableBlock
-
getAttributesCount
public int getAttributesCount()
- Specified by:
getAttributesCountin interfaceorg.exbin.xbup.core.block.XBBlock
-
setAttributesCount
public void setAttributesCount(int count)
- Specified by:
setAttributesCountin interfaceorg.exbin.xbup.core.block.XBEditableBlock
-
addAttribute
public void addAttribute(org.exbin.xbup.core.parser.token.XBAttribute attribute)
-
removeAttribute
public void removeAttribute(int index)
- Specified by:
removeAttributein interfaceorg.exbin.xbup.core.block.XBEditableBlock
-
getAttributes
public org.exbin.xbup.core.parser.token.XBAttribute[] getAttributes()
- Specified by:
getAttributesin interfaceorg.exbin.xbup.core.block.XBBlock
-
setAttributes
public void setAttributes(org.exbin.xbup.core.parser.token.XBAttribute[] attributes)
- Specified by:
setAttributesin interfaceorg.exbin.xbup.core.block.XBEditableBlock
-
getChildAt
public XBTreeNode getChildAt(int childIndex)
- Specified by:
getChildAtin interfacejavax.swing.tree.TreeNode- Specified by:
getChildAtin interfaceorg.exbin.xbup.core.block.XBBlock
-
setChildAt
public void setChildAt(org.exbin.xbup.core.block.XBBlock block, int childIndex)- Specified by:
setChildAtin interfaceorg.exbin.xbup.core.block.XBEditableBlock
-
getIndex
public int getIndex(javax.swing.tree.TreeNode node)
Returns index of child.- Specified by:
getIndexin interfacejavax.swing.tree.TreeNode- Parameters:
node- node to search match for- Returns:
- index of node if node found
-
addChild
public void addChild(XBTreeNode child)
-
removeChild
public void removeChild(int index)
- Specified by:
removeChildin interfaceorg.exbin.xbup.core.block.XBEditableBlock
-
getChildrenCount
public int getChildrenCount()
- Specified by:
getChildrenCountin interfaceorg.exbin.xbup.core.block.XBBlock
-
getChildCount
public int getChildCount()
- Specified by:
getChildCountin interfacejavax.swing.tree.TreeNode
-
setChildrenCount
public void setChildrenCount(int count)
- Specified by:
setChildrenCountin interfaceorg.exbin.xbup.core.block.XBEditableBlock
-
getChildren
public org.exbin.xbup.core.block.XBBlock[] getChildren()
- Specified by:
getChildrenin interfaceorg.exbin.xbup.core.block.XBBlock
-
setChildren
public void setChildren(org.exbin.xbup.core.block.XBBlock[] children)
- Specified by:
setChildrenin interfaceorg.exbin.xbup.core.block.XBEditableBlock
-
createTreeCopy
public static XBTreeNode createTreeCopy(org.exbin.xbup.core.block.XBBlock block)
Creates XBTreeNode copy of given block and all of its children.- Parameters:
block- source block- Returns:
- node
-
createTreeCopy
public static XBTreeNode createTreeCopy(org.exbin.xbup.core.block.XBBlock block, XBTreeNode parent)
Creates XBTreeNode copy of given block and all of its children.- Parameters:
block- source blockparent- parent node- Returns:
- node
-
-