org.equanda.ymport
Class ImportParser

java.lang.Object
  extended by org.equanda.ymport.ImportParser

public final class ImportParser
extends Object

functions for parsing import data (commands and data)

Author:
NetRom team, Joachim Van der Auwera

Field Summary
static ImportParser NULL
          marker to indicate the literal parsed "null", has to be a distinguishable object
 
Method Summary
static String extractSelector(String tableSelector)
          Extract the selector name (including slash) from a possible combined table/selector name
static String extractTable(String tableSelector)
          Extract the table name from a possible combined table/selector name
static boolean isMultipleTableFields(String line)
          Indicates that a creator/selector field definition can define multiple records.
static Collection parse(String line)
          Parse a data line.
static byte[] parseBlob(Object value)
           
static boolean parseBoolean(Object value)
          Parse a boolean.
static String parseClob(Object value)
           
static Date parseDate(Object value)
          Parse a date.
static double parseDouble(Object value)
          Parse a double.
static int parseInt(Object value)
          Parse an int.
static String parseSelectorTable(String line)
          Get the table name from selector/creater definition.
static String parseString(Object value)
          Parse a string.
static Collection<String> parseTableFields(String line)
          Get a collection of fieldnames from the table definition.
static String parseTableTable(String line)
          Get the table name with optional selector from the given table definition.
static Timestamp parseTimestamp(Object value)
          Parses a timestamp.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULL

public static final ImportParser NULL
marker to indicate the literal parsed "null", has to be a distinguishable object

Method Detail

parse

public static Collection parse(String line)
                        throws ImportHandlerException
Parse a data line. The line is split up in a series of object. Each of these objects is either a string (simple field proxy), or a fresh collection (recursive), or null (proxy not specified), or ImportParser.NULL if the proxy was the literal "null".

Parameters:
line - line to be parsed
Returns:
collection with all the data to be processed
Throws:
ImportHandlerException - if the line format is wrong (bracket or quote mismatch etc)

parseTableTable

public static String parseTableTable(String line)
                              throws ImportHandlerException
Get the table name with optional selector from the given table definition. The given line is either a table directive, excluding the ":table:", or a part of such a line which contains the definition of a contained table.

Parameters:
line - table definition string
Returns:
the combined table/selector
Throws:
ImportHandlerException - when no field definition is included

parseSelectorTable

public static String parseSelectorTable(String line)
Get the table name from selector/creater definition. The specification of field names is not enforced (contrary to parseTableTable).

Parameters:
line - table definition string
Returns:
the combined table/selector

isMultipleTableFields

public static boolean isMultipleTableFields(String line)
Indicates that a creator/selector field definition can define multiple records.

Parameters:
line - data to check
Returns:
true when multiple field

parseTableFields

public static Collection<String> parseTableFields(String line)
                                           throws ImportHandlerException
Get a collection of fieldnames from the table definition.

Parameters:
line - table definition string
Returns:
collection of strings with either fieldnames, or other table definitions
Throws:
ImportHandlerException - oops

extractTable

public static String extractTable(String tableSelector)
Extract the table name from a possible combined table/selector name

Parameters:
tableSelector - combined table and selector name
Returns:
the table name

extractSelector

public static String extractSelector(String tableSelector)
Extract the selector name (including slash) from a possible combined table/selector name

Parameters:
tableSelector - combined table and selector name
Returns:
the selector name with separator

parseString

public static String parseString(Object value)
                          throws ImportHandlerException
Parse a string. To be used in field FieldHandler.

Parameters:
value - parsed proxy expected to be a String or NULL
Returns:
a string (to be set in a proxy object)
Throws:
ImportHandlerException - invalid format

parseBoolean

public static boolean parseBoolean(Object value)
                            throws ImportHandlerException
Parse a boolean. To be used in FieldHandler.

Parameters:
value - parsed proxy expected to be a one of ("1", "0", "true", "false", "yes", no")
Returns:
a boolean (to be set in a proxy object)
Throws:
ImportHandlerException - invalid format

parseDate

public static Date parseDate(Object value)
                      throws ImportHandlerException
Parse a date. To be used in FieldHandler.

Parameters:
value - parsed proxy expected in the format yyyy-MM-dd, or NULL
Returns:
a date (to be set in a proxy object)
Throws:
ImportHandlerException - invalid format

parseTimestamp

public static Timestamp parseTimestamp(Object value)
                                throws ImportHandlerException
Parses a timestamp. To be used in FieldHandler.

Parameters:
value - parsed proxy expected in the format yyyy-MM-dd HH:mm:ss, or NULL
Returns:
a timestamp (to be set in a proxy object)
Throws:
ImportHandlerException - invalid format

parseBlob

public static byte[] parseBlob(Object value)

parseClob

public static String parseClob(Object value)
                        throws ImportHandlerException
Throws:
ImportHandlerException

parseInt

public static int parseInt(Object value)
                    throws ImportHandlerException
Parse an int. To be used in FieldHandler.

Parameters:
value - parsed proxy, an integer as a string ("1", "22" etc)
Returns:
an int (to be set in a proxy object)
Throws:
ImportHandlerException - invalid format

parseDouble

public static double parseDouble(Object value)
                          throws ImportHandlerException
Parse a double. To be used in FieldHandler.

Parameters:
value - parsed proxy, a double as a string ("1.1", "2" etc)
Returns:
a date (to be set in a proxy object)
Throws:
ImportHandlerException - invalid format


Copyright © 2007-2009. All Rights Reserved.