|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.unihalle.informatik.Alida.helpers.ALDParser
public class ALDParser
Helper class for parsing/formatting objects for data I/O in Alida.
This class supplies convenience methods to parse and format objects according to Alida's DataIO conventions.
Field Summary | |
---|---|
static HashMap<Character,Character> |
brackets
Hashmap to hold pairs of opening and closing brackets. |
Constructor Summary | |
---|---|
ALDParser()
|
Method Summary | |
---|---|
static String |
arrayToString(Object obj)
Formats an array according to Alida data I/O conventions. |
static String |
parseBracket(String str)
Parses a string for a matching bracket. |
static String |
parseBracket(String str,
char closeBracket)
Parses a string for a matching bracket. |
static HashMap<String,String> |
parseNameValuePairs(String str)
Parses a comma separated list of 'name=value' pairs into a hash map. |
static Object |
readArray1D(Class<?> cl,
String valueString)
Parses a string into a 1D-array. |
static Object |
readArray2D(Class<?> cl,
String valueString)
Parses a string into a 2D-array. |
static LinkedList<String> |
split(String str,
char sepChar)
Split a string at each occurance of sepChar . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static HashMap<Character,Character> brackets
Constructor Detail |
---|
public ALDParser()
Method Detail |
---|
public static String parseBracket(String str)
The first character of this string is interpreted as opening backet,
the closing bracket is assumed to coincide with the internal
definition in brackets
. Upon return the outmost matching
pair of brackets is removed from str
.
str
- String to parse
public static String parseBracket(String str, char closeBracket)
The first character of this string is interpreted as opening backet,
the character closeBracket
as closing bracket.
str
- String to parse.closeBracket
- Closing bracket character.
public static HashMap<String,String> parseNameValuePairs(String str) throws ALDDataIOProviderException
The names found are used as keys in the hash map, while the values are put into the map as corresponding values.
str
- String to parse.
ALDDataIOProviderException
public static LinkedList<String> split(String str, char sepChar)
sepChar
.
Note that occurances of sepChar
enclosed in
brackets are not considered as separators.
str
- String to split.sepChar
- Separating character.
str
.public static String arrayToString(Object obj)
obj
- Array to be formatted.
public static Object readArray1D(Class<?> cl, String valueString) throws ALDDataIOProviderException
The type of the returned array depends on the specified class.
Only primitive and data wrapper types as well as strings are support at the moment.
The valueString
is assume to contain a comma separated list
of nested valueString
for each element of the array enclosed in matching square brackets,
e.g. [1.2 , 2.2 , 3.1]
.
cl
- Desired type of array.valueString
- String to parse.
ALDDataIOProviderException
public static Object readArray2D(Class<?> cl, String valueString) throws ALDDataIOProviderException
cl
- Desired type of array.valueString
- Input string to parse.
ALDDataIOProviderException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |