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

Object
  extended by BoxUtilities

public class BoxUtilities
extends Object

Author:
Simone Giannecchini, GeoSolutions, Daniele Romagnoli, GeoSolutions

Field Summary
static Map<Integer,Class<? extends BaseJP2KBox>> boxClasses
          A Hashtable contains the class names for each type of the boxes.
static Map<Integer,String> boxNames
           
static String JP2_ASOC_LBL_GML_DATA
           
static Map<Integer,String> names
          The table to link tag names for all the JP2 boxes.
static Set<String> SUPERBOX_NAMES
           
 
Constructor Summary
BoxUtilities()
           
 
Method Summary
static void copyInt(byte[] data, int pos, int value)
          Copies that four bytes of an integer into the byte array.
static JP2KBox createBox(int type, byte[] data)
          Creates a Box object with the provided type based on the provided data object based on reflection.
static JP2KBox createBox(int type, Node node)
          Creates a Box object with the provided type based on the provided Node object based on reflection.
static Object getAttribute(Node node, String name)
          Extracts the value of the attribute from name.
static Class<? extends BaseJP2KBox> getBoxClass(int type)
          Returns the Box class for the box with the provided type.
static String getBoxName(int type)
          Returns the BoxName for the box with the provided type.
static byte[] getByteArrayElementValue(Node node)
          Gets the byte array from an IIOMetadataNode.
static byte getByteElementValue(Node node)
          Gets its byte value from an IIOMetadataNode.
static byte[] getContent(Jp2_input_box box)
           
static int[] getIntArrayElementValue(Node node)
          Gets the integer array from an IIOMetadataNode.
static int getIntElementValue(Node node)
          Gets its integer value from an IIOMetadataNode.
static String getName(int type)
          Returns the XML tag name defined in JP2 XML xsd/dtd for the box with the provided type.
static short getShortElementValue(Node node)
          Gets its short value from an IIOMetadataNode.
static String getStringElementValue(Node node)
          Gets its String value from an IIOMetadataNode.
static String getTypeByName(String name)
          Returns the type String based on the provided name.
static int getTypeInt(String s)
          Converts the box type from integer to string.
static String getTypeString(int type)
          Converts the box type from integer to string.
static int getValue(int c)
          Return the numeric decimal value of an ASCII code representing a Hexadecimal value.
static byte[] parseByteArray(String value)
          Parses the byte array expressed by a string.
static int[] parseIntArray(String value)
          Parses the integer array expressed a string.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JP2_ASOC_LBL_GML_DATA

public static final String JP2_ASOC_LBL_GML_DATA
See Also:
Constant Field Values

boxClasses

public static final Map<Integer,Class<? extends BaseJP2KBox>> boxClasses
A Hashtable contains the class names for each type of the boxes. This table will be used to construct a Box object from a Node object by using reflection.


boxNames

public static final Map<Integer,String> boxNames

names

public static final Map<Integer,String> names
The table to link tag names for all the JP2 boxes.


SUPERBOX_NAMES

public static final Set<String> SUPERBOX_NAMES
Constructor Detail

BoxUtilities

public BoxUtilities()
Method Detail

copyInt

public static void copyInt(byte[] data,
                           int pos,
                           int value)
Copies that four bytes of an integer into the byte array. Necessary for the subclasses to compose the content array from the data elements


createBox

public static JP2KBox createBox(int type,
                                Node node)
                         throws IIOInvalidTreeException
Creates a Box object with the provided type based on the provided Node object based on reflection.

Throws:
IIOInvalidTreeException

createBox

public static JP2KBox createBox(int type,
                                byte[] data)
Creates a Box object with the provided type based on the provided data object based on reflection.


getAttribute

public static Object getAttribute(Node node,
                                  String name)
Extracts the value of the attribute from name.


getByteArrayElementValue

public static byte[] getByteArrayElementValue(Node node)
Gets the byte array from an IIOMetadataNode.


getByteElementValue

public static byte getByteElementValue(Node node)
Gets its byte value from an IIOMetadataNode.


getIntArrayElementValue

public static int[] getIntArrayElementValue(Node node)
Gets the integer array from an IIOMetadataNode.


getIntElementValue

public static int getIntElementValue(Node node)
Gets its integer value from an IIOMetadataNode.


getName

public static String getName(int type)
Returns the XML tag name defined in JP2 XML xsd/dtd for the box with the provided type. If the type is not known, the string "unknown" is returned.


getBoxName

public static String getBoxName(int type)
Returns the BoxName for the box with the provided type. If the type is not known, the string "unknown" is returned.


getShortElementValue

public static short getShortElementValue(Node node)
Gets its short value from an IIOMetadataNode.


getStringElementValue

public static String getStringElementValue(Node node)
Gets its String value from an IIOMetadataNode.


getTypeByName

public static String getTypeByName(String name)
Returns the type String based on the provided name.


getTypeInt

public static int getTypeInt(String s)
Converts the box type from integer to string. This is necessary because type is defined as String in xsd/dtd and integer in the box classes.


getTypeString

public static String getTypeString(int type)
Converts the box type from integer to string. This is necessary because type is defined as String in xsd/dtd and integer in the box classes.


parseByteArray

public static byte[] parseByteArray(String value)
Parses the byte array expressed by a string.


parseIntArray

public static int[] parseIntArray(String value)
Parses the integer array expressed a string.


getBoxClass

public static Class<? extends BaseJP2KBox> getBoxClass(int type)
Returns the Box class for the box with the provided type.


getValue

public static int getValue(int c)
Return the numeric decimal value of an ASCII code representing a Hexadecimal value.

Parameters:
c - the ASCII code representing a Hexadecimal value.
Returns:
the numeric decimal value of an ASCII code representing a Hexadecimal value.

getContent

public static byte[] getContent(Jp2_input_box box)
                         throws KduException
Parameters:
box -
Returns:
Throws:
KduException - TODO optimize me


Copyright © 2006-2010 GeoSolutions. All Rights Reserved.