com.ohrasys.cad.gds
Class GDSSpecificDataConverter

java.lang.Object
  extended by com.ohrasys.cad.gds.GDSSpecificDataConverter

public class GDSSpecificDataConverter
extends java.lang.Object

Converts java floating point and string types to the corresponding GDSII types.

Since:
1.5

Constructor Summary
GDSSpecificDataConverter()
           
 
Method Summary
static java.util.List flattenList(java.util.List flat, java.util.List hier)
          Returns a flattened representation of a hierarchical list.
static java.io.ByteArrayOutputStream fromJavaDouble(double data, java.io.ByteArrayOutputStream baos)
          Converts a java double to a GDSII double and stores it in the specified stream.
static java.io.ByteArrayOutputStream fromJavaFloat(float data, java.io.ByteArrayOutputStream baos)
          Converts a java float to a GDSII float and stores it in the specified stream.
static java.io.ByteArrayOutputStream fromJavaString(java.lang.String data, java.io.ByteArrayOutputStream baos)
          Converts a java string to a GDSII string and stores it in the specified stream.
static java.io.ByteArrayOutputStream fromJavaString(java.lang.String data, int len, java.io.ByteArrayOutputStream baos)
          Converts a java string to a GDSII string and stores it in the specified stream.
static double readDouble(java.io.InputStream in)
          Reads a GDSII double from the stream and converts it to a java double.
static float readFloat(java.io.InputStream in)
          Reads a GDSII float from the stream and converts it to a java float.
static double toDouble(byte[] bytes)
          Converts a GDSII double to a java double.
static float toFloat(byte[] bytes)
          Converts a GDSII float to a java float.
static java.lang.String toJavaString(byte[] data)
          Converts a GDSII string to a java string.
 java.lang.String toString()
          Returns a string representation of this class
static byte[] writeJavaDouble(double data)
          Returns a GDSII representation of the double.
static byte[] writeJavaFloat(float data)
          Returns a GDSII representation of the java float.
static byte[] writeJavaString(java.lang.String data)
          Returns a GDSII string.
static byte[] writeJavaString(java.lang.String data, int len)
          Returns a GDSII string of specified length.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GDSSpecificDataConverter

public GDSSpecificDataConverter()
Method Detail

flattenList

public static java.util.List flattenList(java.util.List flat,
                                         java.util.List hier)
Returns a flattened representation of a hierarchical list.

Parameters:
flat - The list in which to store the results
hier - The list to flatten
Returns:
The flattened list

fromJavaDouble

public static java.io.ByteArrayOutputStream fromJavaDouble(double data,
                                                           java.io.ByteArrayOutputStream baos)
Converts a java double to a GDSII double and stores it in the specified stream.

Parameters:
data - The double to process.
baos - The output stream to store the double.
Returns:
A GDSII double.

fromJavaFloat

public static java.io.ByteArrayOutputStream fromJavaFloat(float data,
                                                          java.io.ByteArrayOutputStream baos)
Converts a java float to a GDSII float and stores it in the specified stream.

Parameters:
data - The float to process.
baos - The output stream to store the float.
Returns:
A GDSII float.

fromJavaString

public static java.io.ByteArrayOutputStream fromJavaString(java.lang.String data,
                                                           java.io.ByteArrayOutputStream baos)
Converts a java string to a GDSII string and stores it in the specified stream.

Parameters:
data - The string to process.
baos - The output stream to store the string.
Returns:
A GDSII string.

fromJavaString

public static java.io.ByteArrayOutputStream fromJavaString(java.lang.String data,
                                                           int len,
                                                           java.io.ByteArrayOutputStream baos)
Converts a java string to a GDSII string and stores it in the specified stream.

Parameters:
data - The string to process.
len - The required length of the resulting string.
baos - The output stream to store the string.
Returns:
A GDSII string of specified length.

readDouble

public static double readDouble(java.io.InputStream in)
                         throws java.lang.NumberFormatException
Reads a GDSII double from the stream and converts it to a java double.

Parameters:
in - The stream to read the GDSII double from.
Returns:
A java double.
Throws:
java.lang.NumberFormatException - If a number format exception occurs.

readFloat

public static float readFloat(java.io.InputStream in)
                       throws java.lang.NumberFormatException
Reads a GDSII float from the stream and converts it to a java float.

Parameters:
in - The stream to read the GDSII float from.
Returns:
A java float.
Throws:
java.lang.NumberFormatException - If a number format exception occurs.

toDouble

public static double toDouble(byte[] bytes)
                       throws java.lang.NumberFormatException
Converts a GDSII double to a java double.

Parameters:
bytes - The GDSII double to process.
Returns:
A java double.
Throws:
java.lang.NumberFormatException - If a number format exception occurs.

toFloat

public static float toFloat(byte[] bytes)
                     throws java.lang.NumberFormatException
Converts a GDSII float to a java float.

Parameters:
bytes - The GDSII float to process.
Returns:
A java float.
Throws:
java.lang.NumberFormatException - If a number format exception occurs.

toJavaString

public static java.lang.String toJavaString(byte[] data)
Converts a GDSII string to a java string.

Parameters:
data - The GDSII string to process.
Returns:
A java string.

writeJavaDouble

public static byte[] writeJavaDouble(double data)
Returns a GDSII representation of the double.

Parameters:
data - The double to process.
Returns:
A GDSII double.
Throws:
java.lang.IllegalArgumentException - If a number format exception occurs.

writeJavaFloat

public static byte[] writeJavaFloat(float data)
Returns a GDSII representation of the java float.

Parameters:
data - The float to process.
Returns:
A GDSII float.
Throws:
java.lang.IllegalArgumentException - If a number format exception is encountered.

writeJavaString

public static byte[] writeJavaString(java.lang.String data)
Returns a GDSII string.

Parameters:
data - The string to process.
Returns:
A byte array representation of the string.

writeJavaString

public static byte[] writeJavaString(java.lang.String data,
                                     int len)
Returns a GDSII string of specified length.

Parameters:
data - The string to process.
len - The required length of the resulting string.
Returns:
A byte array representation of the string.
Throws:
java.lang.IllegalArgumentException - If the string is not an even number of characters.

toString

public java.lang.String toString()
Returns a string representation of this class

Overrides:
toString in class java.lang.Object
Returns:
The physical address of this instance