org.odftoolkit.simple.form
Class Field

java.lang.Object
  extended by org.odftoolkit.simple.Component
      extended by org.odftoolkit.simple.form.FormControl
          extended by org.odftoolkit.simple.form.Field
Direct Known Subclasses:
CurrencyField, DateField, NumericField, PatternField, TimeField

public class Field
extends FormControl

This class represents the form control of Field, provides methods to get/set the form properties and the style formatting of this control.

Since:
0.8

Field Summary
 
Fields inherited from class org.odftoolkit.simple.form.FormControl
drawingShape, formElement, mElement, mFormProperties
 
Method Summary
 String getCurrentValue()
          Get the current value of this control
 String getFormatString(OfficeValueTypeAttribute.Value typeValue)
          Get the format string of the field.
 String getId()
          Get the control id.
static Field getInstanceOf(FormFormattedTextElement element)
          Get an instance of field by an instance of FormFormattedTextElement, while searching the document content to make a bind with the DrawControl which already reference to this field.
 String getName()
          Get the control name.
static Iterator<FormControl> getSimpleIterator(Form container)
          Get a simple iterator for Field.
 String getValue()
          Get the default value of this control
 void setControlImplementation(String controlImpl)
          Set the implementation of this control.
 void setCurrentValue(String value)
          Set the current value of this control, it override the default value.
protected  void setFormatString(String formatStr, OfficeValueTypeAttribute.Value type, Locale locale)
          Set the format string of the field.
 void setId(String id)
          Set the control id.
 void setName(String name)
          Set the control name.
 void setSpinButonVisible(boolean isVisible)
          Set the visibility of the spin button
 void setValue(String value)
          Set the default value of this control, it will be override by current value.
 
Methods inherited from class org.odftoolkit.simple.form.FormControl
getDrawControl, getOdfElement, getRectangle, remove, setAnchorType, setFormProperty, setRectangle
 
Methods inherited from class org.odftoolkit.simple.Component
getComponentByElement, getOwnerDocument, registerComponent, unregisterComponent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstanceOf

public static Field getInstanceOf(FormFormattedTextElement element)
Get an instance of field by an instance of FormFormattedTextElement, while searching the document content to make a bind with the DrawControl which already reference to this field.

Parameters:
element - - an instance of FormFormattedTextElement
Returns:
an instance of field

getId

public String getId()
Description copied from class: FormControl
Get the control id.

Specified by:
getId in class FormControl
Returns:
the control id.

setControlImplementation

public void setControlImplementation(String controlImpl)
Description copied from class: FormControl
Set the implementation of this control.

Specified by:
setControlImplementation in class FormControl
Parameters:
controlImpl - - the implementation description of this control

setId

public void setId(String id)
Description copied from class: FormControl
Set the control id.

Specified by:
setId in class FormControl
Parameters:
id - -the control id.

getName

public String getName()
Description copied from class: FormControl
Get the control name.

Specified by:
getName in class FormControl
Returns:
the control name.

setName

public void setName(String name)
Description copied from class: FormControl
Set the control name.

Specified by:
setName in class FormControl
Parameters:
name - - the control name.

setValue

public void setValue(String value)
Set the default value of this control, it will be override by current value.

Parameters:
value - - default value

getValue

public String getValue()
Get the default value of this control

Returns:
default value

setCurrentValue

public void setCurrentValue(String value)
Set the current value of this control, it override the default value.

Parameters:
currentValue - - current value

getCurrentValue

public String getCurrentValue()
Get the current value of this control

Returns:
current value

setSpinButonVisible

public void setSpinButonVisible(boolean isVisible)
Set the visibility of the spin button

Parameters:
isVisible - - true means the spin button is visible; false means the spin button is hidden

setFormatString

protected void setFormatString(String formatStr,
                               OfficeValueTypeAttribute.Value type,
                               Locale locale)
Set the format string of the field.

This function only works for float, date, time and percentage, otherwise an IllegalArgumentException will be thrown.

For value type float and percentage, the formatStr must follow the encoding rule of java.text.DecimalFormat. For value type date and time, the formatStr must follow the encoding rule of java.text.SimpleDateFormat.

ValueType Distinguish Symbol Distinguish Priority
percentage % 1
time H, k, m, s, S 2
date y, M, w, W, D, d, F, E, K, h 3
float #, 0 4
If adaptive failed, an UnsupportedOperationException will be thrown.

Parameters:
formatStr - the cell need be formatted as this specified format string.
Throws:
IllegalArgumentException - if formatStr is null or the cell value type is supported.
See Also:
SimpleDateFormat, DecimalFormat

getFormatString

public String getFormatString(OfficeValueTypeAttribute.Value typeValue)
Get the format string of the field.

Returns:
the format string of the field

getSimpleIterator

public static Iterator<FormControl> getSimpleIterator(Form container)
Get a simple iterator for Field.

Parameters:
container - - an instance of form where to traverse the date fields


Copyright © 2010-2017 The Apache Software Foundation. All Rights Reserved.