org.jopendocument.dom.spreadsheet
Class Cell<D extends ODDocument>

java.lang.Object
  extended by org.jopendocument.dom.ODNode
      extended by org.jopendocument.dom.StyledNode<S,D>
          extended by org.jopendocument.dom.ImmutableDocStyledNode<S,D>
              extended by org.jopendocument.dom.spreadsheet.Cell<D>
Type Parameters:
D - type of document
Direct Known Subclasses:
MutableCell

public class Cell<D extends ODDocument>
extends ImmutableDocStyledNode<S,D>

A cell in a calc document. If you want to change a cell value you must obtain a MutableCell.

Author:
Sylvain

Method Summary
protected  boolean coversOtherCells()
           
 int getColumnsSpanned()
           
 Calendar getDateValue()
          Get the date as a Calendar.
 Calendar getDateValue(TimeZone tz, Locale locale)
          Get the date as a Calendar with the passed parameters.
protected  org.jdom.Namespace getDefaultFormulaNS()
           
 String getError()
          Tries to find out if this cell computation resulted in an error.
 String getFormula()
          Get the formula text if it's from the default OpenFormula namespace.
 Tuple3<org.jdom.Namespace,String,String> getFormulaAndNamespace()
          Get the formula text and its namespace.
static Tuple2.List2<String> getFormulaNSPrefix(String formula)
           
protected  XMLVersion getNS()
           
 String getRawFormula()
          Get the raw value of the formula attribute.
 String getRawValue(ODValueType requiredType)
           
protected  Row<D> getRow()
           
 int getRowsSpanned()
           
protected  String getStyleName()
           
protected  org.jdom.Namespace getTABLE()
           
 String getTextValue()
          Calls getTextValue(boolean) using getTextValueMode().
 String getTextValue(boolean ooMode)
          Return the text value of this cell.
static boolean getTextValueMode()
           
protected  String getType()
           
 Object getValue()
          The value of this cell.
protected  org.jdom.Namespace getValueNS()
           
 ODValueType getValueType()
          The value type of this cell.
protected  boolean isCovered()
           
 boolean isEmpty()
           
 boolean isValid()
           
static void setTextValueMode(boolean ooMode)
          Set whether getTextValue() parses strings using the standard way or using the OpenOffice.org way.
 
Methods inherited from class org.jopendocument.dom.ImmutableDocStyledNode
getContent, getODDocument
 
Methods inherited from class org.jopendocument.dom.StyledNode
getPrivateStyle, getStyle, getStyle, getStyle, getStyle, getStyleDesc, getStyleDesc, getStyleDesc, getStyleStyleDesc, setStyleName, setStyleName
 
Methods inherited from class org.jopendocument.dom.ODNode
getElement, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

setTextValueMode

public static void setTextValueMode(boolean ooMode)
Set whether getTextValue() parses strings using the standard way or using the OpenOffice.org way.

Parameters:
ooMode - true if strings should be parsed the OO way.
See Also:
getTextValue(boolean)

getTextValueMode

public static boolean getTextValueMode()

getFormulaNSPrefix

public static final Tuple2.List2<String> getFormulaNSPrefix(String formula)

getRow

protected final Row<D> getRow()

getNS

protected final XMLVersion getNS()

getValueNS

protected final org.jdom.Namespace getValueNS()

getType

protected final String getType()

getValueType

public final ODValueType getValueType()
The value type of this cell.

Returns:
the value type of this cell, null if not specified.

getStyleName

protected String getStyleName()
Overrides:
getStyleName in class StyledNode<CellStyle,D extends ODDocument>

getRawValue

public final String getRawValue(ODValueType requiredType)

getValue

public Object getValue()
The value of this cell. If the value type is null this method assumes ODValueType.STRING. If the string value is null returns getTextValue().

Returns:
the value of this cell, never null.
See Also:
getValueType()

getDateValue

public final Calendar getDateValue()
                            throws ParseException
Get the date as a Calendar.

Returns:
a calendar with the local time of this cell.
Throws:
ParseException - if the value couldn't be parsed.
See Also:
ODValueType.getCalendar()

getDateValue

public final Calendar getDateValue(TimeZone tz,
                                   Locale locale)
                            throws ParseException
Get the date as a Calendar with the passed parameters.

Parameters:
tz - the time zone of the returned calendar, null meaning ODValueType#getTimeZone().
locale - the locale of the returned calendar, null meaning ODValueType#getLocale().
Returns:
a calendar with the local time of this cell.
Throws:
ParseException - if the value couldn't be parsed.
See Also:
ODValueType.parseDateValue(String, TimeZone, Locale, Boolean)

getTextValue

public String getTextValue()
Calls getTextValue(boolean) using getTextValueMode().

Returns:
a string for the content of this cell.

getTextValue

public String getTextValue(boolean ooMode)
Return the text value of this cell. This is often the formatted string of a value, e.g. "11 novembre 2009" for a date. This method doesn't just return the text content it also parses XML elements (like paragraphs, tabs and line-breaks). For the differences between the OO way (as of 3.1) and the OpenDocument way see section 5.1.1 White-space Characters of OpenDocument-v1.0-os and OpenDocument-v1.2-part1. In essence OpenOffice never trim strings.

Parameters:
ooMode - whether to use the OO way or the standard way.
Returns:
a string for the content of this cell.

getRawFormula

public final String getRawFormula()
Get the raw value of the formula attribute.

Returns:
the raw value, e.g. "of:sum(A1:A2)".
See Also:
getFormula()

getDefaultFormulaNS

protected final org.jdom.Namespace getDefaultFormulaNS()

getFormula

public final String getFormula()
                        throws IllegalStateException
Get the formula text if it's from the default OpenFormula namespace.

Returns:
the OpenFormula text, e.g. "sum(A1:A2)".
Throws:
IllegalStateException - if there's no default namespace defined for this version of XML or if the formula is from a different namespace.
See Also:
getFormulaAndNamespace()

getFormulaAndNamespace

public final Tuple3<org.jdom.Namespace,String,String> getFormulaAndNamespace()
Get the formula text and its namespace. The result can be passed to MutableCell.setFormulaAndNamespace(org.jopendocument.util.Tuple2). NOTE : XMLVersion.OOo doesn't support namespaces.

Returns:
the namespace (can be null if not included in this document), the text, the namespace prefix (can be null), e.g. [urn:oasis:names:tc:opendocument:xmlns:of:1.2, "sum(A1:A2)", null].
See Also:
getFormula()

getError

public String getError()
Tries to find out if this cell computation resulted in an error. This method cannot be robust since there's no error attribute in OpenDocument, we must match the value of the cell against a pattern. E.g. whether a cell has '=A0' for formula or '= "#N" & "/A"', this method will return a non-null error.

Returns:
the error or null.

isValid

public boolean isValid()

isCovered

protected final boolean isCovered()

isEmpty

public final boolean isEmpty()

getColumnsSpanned

public final int getColumnsSpanned()

getRowsSpanned

public final int getRowsSpanned()

coversOtherCells

protected final boolean coversOtherCells()

getTABLE

protected final org.jdom.Namespace getTABLE()


Copyright © 2010 jOpenDocument All Rights Reserved.