SDDS.java.SDDS
Class SDDSUtil

java.lang.Object
  |
  +--SDDS.java.SDDS.SDDSUtil

public class SDDSUtil
extends java.lang.Object

The SDDS Utility object is used for miscellaneous static methods. It it reqired by the SDDS File, SDDS Parameter, and SDDS Column object.

Since:
JDK 1.2
Version:
1.0 (November 1, 1999)
Author:
Robert Soliday soliday@aps.anl.gov

Field Summary
static int SDDS_CHARACTER
           
static int SDDS_DOUBLE
           
static int SDDS_FLOAT
           
static int SDDS_LONG
           
static int SDDS_NUM_TYPES
           
static int SDDS_SHORT
           
static int SDDS_STRING
           
static java.lang.String[] SDDS_type_name
           
 
Constructor Summary
SDDSUtil()
           
 
Method Summary
static double[] castArrayAsDouble(float[] array)
          Convert elements to double precision
static double[] castArrayAsDouble(java.lang.Object[] array, int type)
          Convert elements to double precision
static long[] castArrayAsLong(int[] array)
          Convert elements to long precision
static long[] castArrayAsLong(short[] array)
          Convert elements to long precision
static java.lang.String[] castArrayAsString(char[] array)
          Convert elements to Strings
static boolean compare(java.lang.String value1, java.lang.String value2)
          Compare two strings to see if one starts with the other
static java.lang.String getTypeName(int type)
          Get data type name from integer data type value.
static boolean globMatch(java.lang.String s1, java.lang.String pattern)
          Do a glob style string match
static int identifyType(java.lang.String typeName)
          Get integer data type value from data type name.
static boolean isValidName(java.lang.String name)
          Determine if string is a valid name.
static boolean isValidType(int type)
          Determine if data type is a valid type.
static java.lang.String[][] parseCommandLine(java.lang.String[] args)
          Parse the command line into a string array
static java.lang.String prepareString(java.lang.String data)
          Prepare string to be written to a file
static java.lang.String removeBackSlashes(java.lang.String s1)
          Remove backslashes from the string
static java.lang.String removeComments(java.lang.String s1)
          Search for \ and ! in the string
static java.lang.Object resize(java.lang.Object array, int newLength)
          Resize array while keeping existing elements
static java.lang.Object resize(java.lang.Object array, int offset, int newLength)
          Resize array while keeping existing elements
static char returnCharValueFromOctalCode(java.lang.String s1)
          Return character from octal code
static java.lang.String strchop(java.lang.String s1, int index)
          Return the substring from the index to the end of the string
static boolean strncmp(java.lang.String s1, java.lang.String s2, int length)
          Compare two strings up to a given length
static boolean verifyPrintfFormat(java.lang.String s, int type)
          Verify that format string is valid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SDDS_SHORT

public static final int SDDS_SHORT

SDDS_LONG

public static final int SDDS_LONG

SDDS_FLOAT

public static final int SDDS_FLOAT

SDDS_DOUBLE

public static final int SDDS_DOUBLE

SDDS_STRING

public static final int SDDS_STRING

SDDS_CHARACTER

public static final int SDDS_CHARACTER

SDDS_NUM_TYPES

public static final int SDDS_NUM_TYPES

SDDS_type_name

public static java.lang.String[] SDDS_type_name
Constructor Detail

SDDSUtil

public SDDSUtil()
Method Detail

castArrayAsLong

public static long[] castArrayAsLong(short[] array)
Convert elements to long precision
Parameters:
array - a short precision number array
Returns:
a long precision number array

castArrayAsLong

public static long[] castArrayAsLong(int[] array)
Convert elements to long precision
Parameters:
array - a int precision number array
Returns:
a long precision number array

castArrayAsDouble

public static double[] castArrayAsDouble(float[] array)
Convert elements to double precision
Parameters:
array - a float precision number array
Returns:
a double precision number array

castArrayAsDouble

public static double[] castArrayAsDouble(java.lang.Object[] array,
                                         int type)
Convert elements to double precision
Parameters:
array - a numerical Object array
Returns:
a double precision number array

castArrayAsString

public static java.lang.String[] castArrayAsString(char[] array)
Convert elements to Strings
Parameters:
array - a char array
Returns:
a String array

prepareString

public static java.lang.String prepareString(java.lang.String data)
Prepare string to be written to a file
Parameters:
data - string to be prepared
Returns:
a string that has special characters prefixed with a backslash

verifyPrintfFormat

public static boolean verifyPrintfFormat(java.lang.String s,
                                         int type)
Verify that format string is valid.
Parameters:
s - format string
type - valid data type
Returns:
true if valid false if not valid

isValidName

public static boolean isValidName(java.lang.String name)
Determine if string is a valid name.
Parameters:
name - name to be tested for validity, the first character should be a letter or .: every other character of the name should be a letter, digit, or one of the following: @:#+%-._$&/[]
Returns:
true if valid
false if invalid

isValidType

public static boolean isValidType(int type)
Determine if data type is a valid type.
Parameters:
type - valid values are:
  • 1 for double
  • 2 for float
  • 3 for long
  • 4 for short
  • 5 for string
  • 6 for character
Returns:
true if valid
false if invalid

getTypeName

public static java.lang.String getTypeName(int type)
Get data type name from integer data type value.
Parameters:
type - valid values are:
  • 1 for double
  • 2 for float
  • 3 for long
  • 4 for short
  • 5 for string
  • 6 for character
Returns:
type name if valid
null if invalid

identifyType

public static int identifyType(java.lang.String typeName)
Get integer data type value from data type name.
Parameters:
typeName - valid values are:
  • "double"
  • "float"
  • "long"
  • "short"
  • "string"
  • "character"
Returns:
int type if valid
0 if invalid

resize

public static java.lang.Object resize(java.lang.Object array,
                                      int offset,
                                      int newLength)
Resize array while keeping existing elements
Parameters:
array - array to be resized
offset - offset index
newLength - new length of array
Returns:
new array of different size

resize

public static java.lang.Object resize(java.lang.Object array,
                                      int newLength)
Resize array while keeping existing elements
Parameters:
array - array to be resized
newLength - new length of array
Returns:
new array of different size

strncmp

public static boolean strncmp(java.lang.String s1,
                              java.lang.String s2,
                              int length)
Compare two strings up to a given length
Parameters:
s1 - first string to compare
s2 - second string to compare
length - length to check strings

strchop

public static java.lang.String strchop(java.lang.String s1,
                                       int index)
Return the substring from the index to the end of the string
Parameters:
s1 - initial string
index - index of string

removeComments

public static java.lang.String removeComments(java.lang.String s1)
Search for \ and ! in the string
Parameters:
s1 - string to remove comments

removeBackSlashes

public static java.lang.String removeBackSlashes(java.lang.String s1)
Remove backslashes from the string
Parameters:
s1 - string to remove backslashes from

returnCharValueFromOctalCode

public static char returnCharValueFromOctalCode(java.lang.String s1)
Return character from octal code
Parameters:
s1 - string with octal code

parseCommandLine

public static java.lang.String[][] parseCommandLine(java.lang.String[] args)
Parse the command line into a string array
Parameters:
args - command line arguments
Returns:
two dimensional string array

compare

public static boolean compare(java.lang.String value1,
                              java.lang.String value2)
Compare two strings to see if one starts with the other
Parameters:
value1 - compare beginning with value2
value2 - compare entire string with beginning of value1

globMatch

public static boolean globMatch(java.lang.String s1,
                                java.lang.String pattern)
Do a glob style string match
Parameters:
s1 - String to test for glob style matching
pattern - Pattern used for glob style matching
Returns:
true if it does match
false if it does not match