org.jopendocument.dom.style.data
Class DataStyle

java.lang.Object
  extended by org.jopendocument.dom.ODNode
      extended by org.jopendocument.dom.Style
          extended by org.jopendocument.dom.style.data.DataStyle
Direct Known Subclasses:
BooleanStyle, CurrencyStyle, DateStyle, NumberStyle, PercentStyle, TextStyle, TimeStyle

public abstract class DataStyle
extends Style


Nested Class Summary
static class DataStyle.DataStyleDesc<S extends DataStyle>
           
 
Field Summary
static Set<Class<? extends DataStyle>> DATA_STYLES
           
static int DEFAULT_DECIMAL_PLACES
           
 
Constructor Summary
protected DataStyle(ODPackage pkg, org.jdom.Element elem, ODValueType type)
           
 
Method Summary
static void addStringLiteral(StringBuilder formatSB, String s)
           
 boolean canFormat(Class<?> toFormat)
          Whether instances of the passed class can be formatted.
 Object convert(Object o)
          Convert the passed object to something that format(Object, CellStyle, boolean) can accept.
protected abstract  Object convertNonNull(Object o)
           
abstract  String format(Object o, CellStyle defaultStyle, boolean lenient)
           
protected  String formatNumberOrScientificNumber(org.jdom.Element elem, Number n, CellStyle defaultStyle)
           
protected  String formatNumberOrScientificNumber(org.jdom.Element elem, Number n, int multiplier, CellStyle defaultStyle)
           
 ODValueType getDataType()
           
static int getDecimalPlaces(CellStyle defaultStyle)
           
static
<S extends DataStyle>
DataStyle.DataStyleDesc<S>
getDesc(Class<S> clazz, XMLVersion version)
           
 ODEpoch getEpoch()
           
 TextStyle.StyleTextProperties getTextProperties()
           
 String getTitle()
           
static void registerDesc()
           
protected static void reportError(String msg, boolean lenient)
           
 
Methods inherited from class org.jopendocument.dom.Style
checkElemName, dup, equals, getDesc, getFormattingProperties, getFormattingProperties, getFormattingProperties, getName, getNonNullStyleDesc, getNS, getPackage, getReferencedStyle, getReferencedStyleElement, getReferences, getSTYLE, getStyle, getStyleDesc, getStyleStyleDesc, hashCode, isReferencedAtMostOnce, isStandardStyleResolution, register, registerAllVersions, setStandardStyleResolution, warp
 
Methods inherited from class org.jopendocument.dom.ODNode
getElement, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_DECIMAL_PLACES

public static final int DEFAULT_DECIMAL_PLACES
See Also:
Constant Field Values

DATA_STYLES

public static final Set<Class<? extends DataStyle>> DATA_STYLES
Constructor Detail

DataStyle

protected DataStyle(ODPackage pkg,
                    org.jdom.Element elem,
                    ODValueType type)
Method Detail

getDecimalPlaces

public static int getDecimalPlaces(CellStyle defaultStyle)

addStringLiteral

public static void addStringLiteral(StringBuilder formatSB,
                                    String s)

registerDesc

public static void registerDesc()

getDesc

public static <S extends DataStyle> DataStyle.DataStyleDesc<S> getDesc(Class<S> clazz,
                                                                       XMLVersion version)

getDataType

public final ODValueType getDataType()

getEpoch

public final ODEpoch getEpoch()

convert

public final Object convert(Object o)
                     throws NullPointerException
Convert the passed object to something that format(Object, CellStyle, boolean) can accept.

Parameters:
o - the object to convert.
Returns:
an object that can be formatted, null if o cannot be converted.
Throws:
NullPointerException - if o is null.
See Also:
canFormat(Class)

convertNonNull

protected abstract Object convertNonNull(Object o)

canFormat

public final boolean canFormat(Class<?> toFormat)
Whether instances of the passed class can be formatted.

Parameters:
toFormat - the class.
Returns:
true if instances of toFormat can be formatted.

getTitle

public final String getTitle()

getTextProperties

public final TextStyle.StyleTextProperties getTextProperties()

format

public abstract String format(Object o,
                              CellStyle defaultStyle,
                              boolean lenient)
                       throws UnsupportedOperationException
Throws:
UnsupportedOperationException

reportError

protected static final void reportError(String msg,
                                        boolean lenient)
                                 throws UnsupportedOperationException
Throws:
UnsupportedOperationException

formatNumberOrScientificNumber

protected final String formatNumberOrScientificNumber(org.jdom.Element elem,
                                                      Number n,
                                                      CellStyle defaultStyle)

formatNumberOrScientificNumber

protected final String formatNumberOrScientificNumber(org.jdom.Element elem,
                                                      Number n,
                                                      int multiplier,
                                                      CellStyle defaultStyle)


Copyright © 2010 jOpenDocument All Rights Reserved.