it.geosolutions.imageio.plugins.jp2k.box
Class BaseJP2KBox

Object
  extended by DefaultMutableTreeNode
      extended by BaseJP2KBox
All Implemented Interfaces:
JP2KBox, JP2KBoxMetadata, Serializable, Cloneable, MutableTreeNode, TreeNode
Direct Known Subclasses:
ASOCBox, BitsPerComponentBox, ChannelDefinitionBox, CodestreamHeaderBox, ColorSpecificationBox, ComponentMappingBox, CompositingLayerHeaderBox, ContiguousCodestreamBox, DataEntryURLBox, FileTypeBox, ImageHeaderBox, IPRBox, JP2HeaderBox, JP2KFileBox, LabelBox, PaletteBox, ReaderRequirementsBox, ResolutionBox, SignatureBox, UUIDBox, UUIDInfoBox, UUIDListBox, XMLBox

public abstract class BaseJP2KBox
extends DefaultMutableTreeNode
implements JP2KBoxMetadata

This class is defined to create the box of JP2 file format. A box has a length, a type, an optional extra length and its content. The subclasses should explain the content information.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
 
Constructor Summary
BaseJP2KBox(int length, int type, byte[] data)
          Constructs a Box instance using the provided the box type and the box content in byte array format.
BaseJP2KBox(int length, int type, long extraLength, byte[] data)
          Constructs a Box instance using the provided the box type, the box extra length, and the box content in byte array format.
BaseJP2KBox(Node node)
          Constructs a Box from an "unknown" Node.
 
Method Summary
 Object clone()
           
protected abstract  byte[] compose()
          Composes the content byte array from the data elements.
 byte[] getContent()
          Returns the box content in byte array.
 long getExtraLength()
          Returns the box extra length.
 int getLength()
          Returns the box length.
 IIOMetadataNode getNativeNode()
          Creates an IIOMetadataNode from this box.
protected  IIOMetadataNode getNativeNodeForSimpleBox()
          Creates an IIOMetadataNode from this box.
 int getType()
          Returns the box type.
protected abstract  void parse(byte[] data)
          Parses the data elements from the byte array.
protected  void setDefaultAttributes(IIOMetadataNode node)
          Sets the default attributes, "Length", "Type", and "ExtraLength", to the provided IIOMetadataNode.
 void setExtraLength(long extraLength)
          Sets the box extra length length to the provided value.
 void setLength(int length)
          Sets the box length to the provided value.
 void setType(int type)
           
 String toString()
           
 
Methods inherited from class DefaultMutableTreeNode
add, breadthFirstEnumeration, children, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildAt, getChildBefore, getChildCount, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, getPathToRoot, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, insert, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent, setUserObject
 
Methods inherited from class Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface MutableTreeNode
insert, remove, remove, removeFromParent, setParent, setUserObject
 
Methods inherited from interface TreeNode
children, getAllowsChildren, getChildAt, getChildCount, getIndex, getParent, isLeaf
 

Constructor Detail

BaseJP2KBox

public BaseJP2KBox(int length,
                   int type,
                   byte[] data)
Constructs a Box instance using the provided the box type and the box content in byte array format.

Parameters:
length - The provided box length.
type - The provided box type.
data - The provided box content in a byte array.
Throws:
IllegalArgumentException - If the length of the content byte array is not length - 8.

BaseJP2KBox

public BaseJP2KBox(int length,
                   int type,
                   long extraLength,
                   byte[] data)
Constructs a Box instance using the provided the box type, the box extra length, and the box content in byte array format. In this case, the length of the box is set to 1, which indicates the extra length is meaningful.

Parameters:
length - The provided box length.
type - The provided box type.
extraLength - The provided box extra length.
data - The provided box content in a byte array.
Throws:
IllegalArgumentException - If the length of the content byte array is not extra length - 16.

BaseJP2KBox

public BaseJP2KBox(Node node)
            throws IIOInvalidTreeException
Constructs a Box from an "unknown" Node. This node has at least the attribute "Type", and may have the attribute "Length", "ExtraLength" and a child "Content". The child node content is a IIOMetaDataNode with a byte[] user object.

Throws:
IIOInvalidTreeException
Method Detail

getNativeNodeForSimpleBox

protected IIOMetadataNode getNativeNodeForSimpleBox()
Creates an IIOMetadataNode from this box. The format of this node is defined in the XML dtd and xsd for the JP2 image file. This method is designed for the types of boxes whose XML tree only has 2 levels.


getContent

public byte[] getContent()
Returns the box content in byte array.

Specified by:
getContent in interface JP2KBox
Returns:
a byte array with the box content or null if this is a super box.

parse

protected abstract void parse(byte[] data)
Parses the data elements from the byte array. The subclasses should override this method and implement the proper behvaior.


compose

protected abstract byte[] compose()
Composes the content byte array from the data elements.


getNativeNode

public IIOMetadataNode getNativeNode()
Creates an IIOMetadataNode from this box. The format of this node is defined in the XML dtd and xsd for the JP2 image file.

Specified by:
getNativeNode in interface JP2KBoxMetadata

getExtraLength

public long getExtraLength()
Description copied from interface: JP2KBox
Returns the box extra length.

Specified by:
getExtraLength in interface JP2KBox
See Also:
it.geosolutions.imageio.plugins.jp2k.box.JPEG2000SimpleBox#getExtraLength()
UML property:
name="extraLength"

getLength

public int getLength()
Description copied from interface: JP2KBox
Returns the box length.

Specified by:
getLength in interface JP2KBox
See Also:
it.geosolutions.imageio.plugins.jp2k.box.JPEG2000SimpleBox#getLength()
UML property:
name="length"

getType

public int getType()
Description copied from interface: JP2KBox
Returns the box type.

Specified by:
getType in interface JP2KBox
See Also:
it.geosolutions.imageio.plugins.jp2k.box.JPEG2000SimpleBox#getType()
UML property:
name="type"

setDefaultAttributes

protected void setDefaultAttributes(IIOMetadataNode node)
Sets the default attributes, "Length", "Type", and "ExtraLength", to the provided IIOMetadataNode.


setExtraLength

public void setExtraLength(long extraLength)
Sets the box extra length length to the provided value.

UML property:
name="extraLength"

setLength

public void setLength(int length)
Sets the box length to the provided value.

UML property:
name="length"

setType

public void setType(int type)
Parameters:
type -
UML property:
name="type"

toString

public String toString()
Overrides:
toString in class DefaultMutableTreeNode

clone

public Object clone()
Specified by:
clone in interface JP2KBox
Overrides:
clone in class DefaultMutableTreeNode


Copyright © 2006-2010 GeoSolutions. All Rights Reserved.