com.java4less.ocr.docparser.fields
Class FieldDef

java.lang.Object
  extended by com.java4less.ocr.docparser.fields.FieldDef
All Implemented Interfaces:
IReference

public class FieldDef
extends java.lang.Object
implements IReference

defines the location, type, format... of a field


Field Summary
static java.lang.String TYPE_D
          type date
static java.lang.String TYPE_N
          type number
static java.lang.String TYPE_S
          type string
 
Constructor Summary
FieldDef(java.lang.String name, FieldPositionDef x, FieldPositionDef y)
          create field definition
 
Method Summary
 java.lang.String getFormat()
          get format of the field.
 java.lang.String getName()
          name of the field
 FieldPositionDef getPosX()
          get column position
 FieldPositionDef getPosY()
          get line position
 java.lang.String getType()
          can be TYPE_D (date), TYPE_N (number), TYPE_S (string)
 TextValue getValue()
          return current value for this field
 boolean isMandatory()
          is this field mandatory or optional? default is mandatory
 void load(org.w3c.dom.Node n, SectionDef sec)
          load from XML node
 void saveToXml(org.w3c.dom.Document document, org.w3c.dom.Node parent)
          save field definition to XML
 void setFormat(java.lang.String format)
          set format of the field.
 void setMandatory(boolean f)
          is this field mandatory or optional? default is mandatory
 void setName(java.lang.String name)
          name of the field
 void setType(java.lang.String type)
          can be TYPE_D (date), TYPE_N (number), TYPE_S (string)
 void setValue(TextValue v)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_S

public static java.lang.String TYPE_S
type string


TYPE_D

public static java.lang.String TYPE_D
type date


TYPE_N

public static java.lang.String TYPE_N
type number

Constructor Detail

FieldDef

public FieldDef(java.lang.String name,
                FieldPositionDef x,
                FieldPositionDef y)
create field definition

Parameters:
name - name
x - position x
y - position y (line)
Method Detail

setMandatory

public void setMandatory(boolean f)
is this field mandatory or optional? default is mandatory

Parameters:
f -

isMandatory

public boolean isMandatory()
is this field mandatory or optional? default is mandatory

Returns:

getValue

public TextValue getValue()
return current value for this field

Specified by:
getValue in interface IReference

setValue

public void setValue(TextValue v)

getName

public java.lang.String getName()
name of the field

Specified by:
getName in interface IReference

setName

public void setName(java.lang.String name)
name of the field

Parameters:
name -

getPosX

public FieldPositionDef getPosX()
get column position

Returns:

getPosY

public FieldPositionDef getPosY()
get line position

Returns:

saveToXml

public void saveToXml(org.w3c.dom.Document document,
                      org.w3c.dom.Node parent)
               throws java.lang.Exception
save field definition to XML

Parameters:
document -
parent -
Throws:
java.lang.Exception

load

public void load(org.w3c.dom.Node n,
                 SectionDef sec)
load from XML node

Parameters:
n -

getFormat

public java.lang.String getFormat()
get format of the field. If set the parser will check the format and report an error if it does not match. For string, the format has to be a regular expression, for dates a java.text.SimpleDateFormat and for number a java.text.DecimalFormat format.

Returns:

setFormat

public void setFormat(java.lang.String format)
set format of the field. If set the parser will check the format and report an error if it does not match. For string, the format has to be a regular expression, for dates a java.text.SimpleDateFormat and for number a java.text.DecimalFormat format.

Parameters:
format -

getType

public java.lang.String getType()
can be TYPE_D (date), TYPE_N (number), TYPE_S (string)

Returns:

setType

public void setType(java.lang.String type)
can be TYPE_D (date), TYPE_N (number), TYPE_S (string)

Parameters:
type -