Package org.exbin.xbup.core.block
Class XBTDefaultBlock
- java.lang.Object
-
- org.exbin.xbup.core.block.XBTDefaultBlock
-
-
Constructor Summary
Constructors Constructor Description XBTDefaultBlock()Creates new instance of XBDefaultBlock as an empty data block.XBTDefaultBlock(XBBlockTerminationMode terminationMode, org.exbin.auxiliary.paged_data.BinaryData data)Creates new instance of XBTDefaultBlock as a data block with given values and no parent block.XBTDefaultBlock(XBBlockTerminationMode terminationMode, XBBlockType blockType, XBAttribute[] attributes, XBTBlock[] children)Creates new instance of XBTDefaultBlock as a node block with given values and no parent block.XBTDefaultBlock(XBTBlock parent, XBBlockTerminationMode terminationMode, org.exbin.auxiliary.paged_data.BinaryData data)Creates new instance of XBTDefaultBlock as a data block with given values.XBTDefaultBlock(XBTBlock parent, XBBlockTerminationMode terminationMode, XBBlockType blockType, XBAttribute[] attributes, XBTBlock[] children)Creates new instance of XBTDefaultBlock as a node block with given values.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description XBAttributegetAttributeAt(int attributeIndex)Gets attribute of given index.XBAttribute[]getAttributes()Gets array of attributes in order of appearance.intgetAttributesCount()Gets count of attributes.org.exbin.auxiliary.paged_data.BinaryDatagetBlockData()Gets block data.static intgetBlockIndex(XBTBlock block)Gets block position in depth-first scan of the tree.XBBlockTypegetBlockType()Gets block type.java.io.InputStreamgetData()Gets block data.XBBlockDataModegetDataMode()Returns whether this block is data block.XBTBlockgetChildAt(int childIndex)Gets children of given index.static intgetChildIndexOf(XBTBlock parent, XBTBlock block)Gets block position in parents direct child list.XBTBlock[]getChildren()Gets array of all children.intgetChildrenCount()Gets count of children blocks.java.util.Optional<XBTBlock>getParentBlock()Gets parent block or null if block has no parent.XBBlockTerminationModegetTerminationMode()Returns whether this block is using sequence of children ended with termination block.voidsetParent(XBTBlock parent)Allows to set parent block, which is not cosidered as a part of the block value and allows to move this block in tree.
-
-
-
Constructor Detail
-
XBTDefaultBlock
public XBTDefaultBlock()
Creates new instance of XBDefaultBlock as an empty data block.
-
XBTDefaultBlock
public XBTDefaultBlock(@Nullable XBTBlock parent, @Nullable XBBlockTerminationMode terminationMode, @Nullable org.exbin.auxiliary.paged_data.BinaryData data)Creates new instance of XBTDefaultBlock as a data block with given values.- Parameters:
parent- parent nodeterminationMode- termination modedata- block data
-
XBTDefaultBlock
public XBTDefaultBlock(@Nullable XBBlockTerminationMode terminationMode, @Nullable org.exbin.auxiliary.paged_data.BinaryData data)Creates new instance of XBTDefaultBlock as a data block with given values and no parent block.- Parameters:
terminationMode- termination modedata- block data
-
XBTDefaultBlock
public XBTDefaultBlock(@Nullable XBTBlock parent, @Nullable XBBlockTerminationMode terminationMode, @Nullable XBBlockType blockType, @Nullable XBAttribute[] attributes, @Nullable XBTBlock[] children)Creates new instance of XBTDefaultBlock as a node block with given values.- Parameters:
parent- parent nodeterminationMode- termination modeblockType- block typeattributes- attributeschildren- children blocks
-
XBTDefaultBlock
public XBTDefaultBlock(@Nullable XBBlockTerminationMode terminationMode, @Nullable XBBlockType blockType, @Nullable XBAttribute[] attributes, @Nullable XBTBlock[] children)Creates new instance of XBTDefaultBlock as a node block with given values and no parent block.- Parameters:
terminationMode- termination modeblockType- block typeattributes- attributeschildren- children blocks
-
-
Method Detail
-
getParentBlock
@Nonnull public java.util.Optional<XBTBlock> getParentBlock()
Description copied from interface:XBTBlockGets parent block or null if block has no parent.- Specified by:
getParentBlockin interfaceXBTBlock- Returns:
- parent block
-
setParent
public void setParent(@Nullable XBTBlock parent)Allows to set parent block, which is not cosidered as a part of the block value and allows to move this block in tree.- Parameters:
parent- parent block
-
getDataMode
@Nonnull public XBBlockDataMode getDataMode()
Description copied from interface:XBTBlockReturns whether this block is data block.- Specified by:
getDataModein interfaceXBTBlock- Returns:
- data mode
-
getTerminationMode
@Nonnull public XBBlockTerminationMode getTerminationMode()
Description copied from interface:XBTBlockReturns whether this block is using sequence of children ended with termination block.- Specified by:
getTerminationModein interfaceXBTBlock- Returns:
- terminated mode
-
getBlockType
@Nonnull public XBBlockType getBlockType()
Description copied from interface:XBTBlockGets block type.- Specified by:
getBlockTypein interfaceXBTBlock- Returns:
- block type
-
getAttributes
@Nullable public XBAttribute[] getAttributes()
Description copied from interface:XBTBlockGets array of attributes in order of appearance.- Specified by:
getAttributesin interfaceXBTBlock- Returns:
- array of attributes
-
getAttributeAt
@Nullable public XBAttribute getAttributeAt(int attributeIndex)
Description copied from interface:XBTBlockGets attribute of given index. Returns zero if attribute index greater than attributes count.- Specified by:
getAttributeAtin interfaceXBTBlock- Parameters:
attributeIndex- index of attribute- Returns:
- attribute value
-
getAttributesCount
public int getAttributesCount()
Description copied from interface:XBTBlockGets count of attributes.- Specified by:
getAttributesCountin interfaceXBTBlock- Returns:
- count of attributes
-
getChildren
@Nullable public XBTBlock[] getChildren()
Description copied from interface:XBTBlockGets array of all children.- Specified by:
getChildrenin interfaceXBTBlock- Returns:
- array of child blocks
-
getChildAt
@Nullable public XBTBlock getChildAt(int childIndex)
Description copied from interface:XBTBlockGets children of given index. If no child for given index exist, return null.- Specified by:
getChildAtin interfaceXBTBlock- Parameters:
childIndex- index of child block- Returns:
- child block
-
getChildrenCount
public int getChildrenCount()
Description copied from interface:XBTBlockGets count of children blocks.- Specified by:
getChildrenCountin interfaceXBTBlock- Returns:
- count of children
-
getData
@Nonnull public java.io.InputStream getData()
Description copied from interface:XBTBlockGets block data.
-
getBlockData
@Nonnull public org.exbin.auxiliary.paged_data.BinaryData getBlockData()
Description copied from interface:XBTBlockGets block data.- Specified by:
getBlockDatain interfaceXBTBlock- Returns:
- block data or throws invalid operation on non-data block
-
getBlockIndex
public static int getBlockIndex(@Nullable XBTBlock block)Gets block position in depth-first scan of the tree. Returns -1 for null block or if tree structure is corrupted.- Parameters:
block- target block- Returns:
- position index
-
-