Package org.gvsig.dwg.lib
Class DwgUtil
java.lang.Object
org.gvsig.dwg.lib.DwgUtil
The DwgUtil class contains the essential set of functions for reading bitstreams
in DWG files
- Author:
- jmorell
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int[]bytesToMachineBytes(byte[] data) Convert bytes to machine value bytesstatic ArrayListgetBitDouble(int[] data, int offset) Read a double value from a group of unsigned bytesstatic ArrayListgetBitLong(int[] data, int offset) Read a long value from a group of unsigned bytesstatic ObjectgetBits(int[] data, int count, int offset) Returns a set of bits from a group of unsigned bytesstatic ArrayListgetBitShort(int[] data, int offset) Read a short value from a group of unsigned bytesstatic ArrayListgetCmColor(int[] intData, int offset, String version) Read a CmColor from a group of unsigned bytesstatic ArrayListgetDefaultDouble(int[] data, int offset, double defVal) Read a double value from a group of unsigned bytes and a default doublestatic ArrayListgetHandle(int[] data, int offset) Read a int value (the handle of a DWG object) from a group of unsigned bytesstatic ArrayListgetModularChar(int[] data, int offset) Read a char value from a group of unsigned bytesstatic intRead a int value (the size of a modular short) from a ByteBufferstatic ArrayListgetRawChar(int[] data, int offset) Read a char value from a group of unsigned bytesstatic ArrayListgetRawDouble(int[] data, int offset) Read a double value from a group of unsigned bytesstatic ArrayListgetRawLong(int[] data, int offset) Read a long value from a group of unsigned bytesstatic ArrayListgetRawShort(int[] data, int offset) Read a short value from a group of unsigned bytesstatic ArrayListgetTextString(int[] data, int offset) Read a String from a group of unsigned bytesstatic inthandleBinToHandleInt(ArrayList layerHandle) Obtain the int value of a handle given in binary formatstatic inthandleToInt(List fromGetHandle) It receives the list procedent from getHandle method, and return the handle as intstatic ArrayListreadExtendedData(int[] data, int offset) Read the extended data for a DWG object Don't use in this version.static ArrayListtestBit(int[] data, int offset) Test a bit obtained from a set of unsigned bytesstatic int[]toIntArray(byte[] bytes)
-
Constructor Details
-
DwgUtil
public DwgUtil()
-
-
Method Details
-
readExtendedData
Read the extended data for a DWG object Don't use in this version. Serious bugs detected- Parameters:
data- Array of unsigned bytes obtained from the DWG binary fileoffset- The current bit offset where the value begins- Returns:
- ArrayList This ArrayList has two parts. First is an int value that represents the new offset, and second is the extended data of a DWG object
- Throws:
RuntimeException- If an unexpected bit value is found in the DWG file. Occurs when we are looking for LwPolylines.
-
getDefaultDouble
public static ArrayList getDefaultDouble(int[] data, int offset, double defVal) throws RuntimeException Read a double value from a group of unsigned bytes and a default double- Parameters:
data- Array of unsigned bytes obtained from the DWG binary fileoffset- The current bit offset where the value beginsdefVal- Default double value- Returns:
- ArrayList This ArrayList has two parts. First is an int value that represents the new offset, and second is the double value
- Throws:
RuntimeException- If an unexpected bit value is found in the DWG file. Occurs when we are looking for LwPolylines.
-
getBitDouble
Read a double value from a group of unsigned bytes- Parameters:
data- Array of unsigned bytes obtained from the DWG binary fileoffset- The current bit offset where the value begins- Returns:
- ArrayList This ArrayList has two parts. First is an int value that represents the new offset, and second is the double value
- Throws:
RuntimeException- If an unexpected bit value is found in the DWG file. Occurs when we are looking for LwPolylines.
-
getRawDouble
Read a double value from a group of unsigned bytes- Parameters:
data- Array of unsigned bytes obtained from the DWG binary fileoffset- The current bit offset where the value begins- Returns:
- ArrayList This ArrayList has two parts. First is an int value that represents the new offset, and second is the double value
- Throws:
RuntimeException- If an unexpected bit value is found in the DWG file. Occurs when we are looking for LwPolylines.
-
getBitShort
Read a short value from a group of unsigned bytes- Parameters:
data- Array of unsigned bytes obtained from the DWG binary fileoffset- The current bit offset where the value begins- Returns:
- ArrayList This ArrayList has two parts. First is an int value that represents the new offset, and second is the short value
- Throws:
RuntimeException- If an unexpected bit value is found in the DWG file. Occurs when we are looking for LwPolylines.
-
getRawShort
Read a short value from a group of unsigned bytes- Parameters:
data- Array of unsigned bytes obtained from the DWG binary fileoffset- The current bit offset where the value begins- Returns:
- ArrayList This ArrayList has two parts. First is an int value that represents the new offset, and second is the short value
- Throws:
RuntimeException- If an unexpected bit value is found in the DWG file. Occurs when we are looking for LwPolylines.
-
getBitLong
Read a long value from a group of unsigned bytes- Parameters:
data- Array of unsigned bytes obtained from the DWG binary fileoffset- The current bit offset where the value begins- Returns:
- ArrayList This ArrayList has two parts. First is an int value that represents the new offset, and second is the long value
- Throws:
RuntimeException- If an unexpected bit value is found in the DWG file. Occurs when we are looking for LwPolylines.
-
getRawLong
Read a long value from a group of unsigned bytes- Parameters:
data- Array of unsigned bytes obtained from the DWG binary fileoffset- The current bit offset where the value begins- Returns:
- ArrayList This ArrayList has two parts. First is an int value that represents the new offset, and second is the long value
- Throws:
RuntimeException- If an unexpected bit value is found in the DWG file. Occurs when we are looking for LwPolylines.RuntimeException
-
getRawChar
Read a char value from a group of unsigned bytes- Parameters:
data- Array of unsigned bytes obtained from the DWG binary fileoffset- The current bit offset where the value begins- Returns:
- ArrayList This ArrayList has two parts. First is an int value that represents the new offset, and second is the char value
- Throws:
RuntimeException- If an unexpected bit value is found in the DWG file. Occurs when we are looking for LwPolylines.
-
getModularChar
Read a char value from a group of unsigned bytes- Parameters:
data- Array of unsigned bytes obtained from the DWG binary fileoffset- The current bit offset where the value begins- Returns:
- ArrayList This ArrayList has two parts. First is an int value that represents the new offset, and second is the char value
- Throws:
RuntimeException- If an unexpected bit value is found in the DWG file. Occurs when we are looking for LwPolylines.
-
getTextString
Read a String from a group of unsigned bytes- Parameters:
data- Array of unsigned bytes obtained from the DWG binary fileoffset- The current bit offset where the value begins- Returns:
- ArrayList This ArrayList has two parts. First is an int value that represents the new offset, and second is the String
- Throws:
RuntimeException- If an unexpected bit value is found in the DWG file. Occurs when we are looking for LwPolylines.
-
getCmColor
public static ArrayList getCmColor(int[] intData, int offset, String version) throws RuntimeException Read a CmColor from a group of unsigned bytes- Parameters:
intData-offset- The current bit offset where the value beginsversion-- Returns:
- ArrayList This ArrayList has two parts. First is an int value that represents the new offset, and second is the int value (handle of a DWG object)
- Throws:
RuntimeException- If an unexpected bit value is found in the DWG file. Occurs when we are looking for LwPolylines.
-
getHandle
Read a int value (the handle of a DWG object) from a group of unsigned bytes- Parameters:
data- Array of unsigned bytes obtained from the DWG binary fileoffset- The current bit offset where the value begins- Returns:
- ArrayList This ArrayList has two parts. First is an int value that represents the new offset, and second is the int value (handle of a DWG object)
- Throws:
RuntimeException- If an unexpected bit value is found in the DWG file. Occurs when we are looking for LwPolylines.
-
getModularShort
Read a int value (the size of a modular short) from a ByteBuffer- Parameters:
bb- Data given as a ByteBuffer- Returns:
- int Size of the modular short
-
getBits
Returns a set of bits from a group of unsigned bytes- Parameters:
data- Array of unsigned bytes obtained from the DWG binary filecount- Bit counteroffset- The current bit offset where the value begins- Returns:
- This method returns an array of bytes or an int value
- Throws:
RuntimeException- If an unexpected bit value is found in the DWG file. Occurs when we are looking for LwPolylines.
-
testBit
Test a bit obtained from a set of unsigned bytes- Parameters:
data- Array of unsigned bytes obtained from the DWG binary fileoffset- The current bit offset where the value begins- Returns:
- ArrayList This ArrayList has two parts. First is an int value that represents the new offset, and second is a bit flag
-
bytesToMachineBytes
public static int[] bytesToMachineBytes(byte[] data) Convert bytes to machine value bytes- Parameters:
data- Input of array of bytes- Returns:
- int[] Output of array of machine bytes
-
handleToInt
It receives the list procedent from getHandle method, and return the handle as int- Parameters:
fromGetHandle-- Returns:
-
handleBinToHandleInt
Obtain the int value of a handle given in binary format- Parameters:
layerHandle- Handle in binary format- Returns:
- int Int value of the handle
-
toIntArray
public static int[] toIntArray(byte[] bytes)
-