olg.csv.bean.impl
Class PropertyFormatter

Package class diagram package PropertyFormatter
java.lang.Object
  extended by olg.csv.bean.impl.PropertyFormatter
Direct Known Subclasses:
PropertyFormatter.ConcatePropertyReader, PropertyFormatter.DelegatePropertyReader, PropertyFormatter.PropertyReader

public abstract class PropertyFormatter
extends Object

In writing Bean, allows to represent a field of an object as a String. This class seems to be the same as Formatter class. But its motivation is different : We want to product a string which represents a characteristic of an object not the object itself.


Nested Class Summary
private static class PropertyFormatter.ConcatePropertyReader
          Allows to concate severals characteristics of an object into a single string.
private static class PropertyFormatter.DelegatePropertyReader
          PropertyFormatter to use to represent a characterstic of a field as a string.
private static class PropertyFormatter.PropertyReader
          Basic PropertyFormatter.
 
Field Summary
protected  String name
          Name of the property on which to apply the conversion.
 
Constructor Summary
PropertyFormatter()
           
 
Method Summary
 boolean equals(Object obj)
           
static PropertyFormatter getConcatePropertyReader(List<PropertyFormatter> formatters, AbstractStringFilter filtre)
          Returns a PropertyFormatter which concates strings the given propertyformatters returns.
static PropertyFormatter getDelegatePropertyReader(Method getter, String name, PropertyFormatter propertyFormatter)
          Returns a PropertyFormatter which extracts as a string a characteristic of a field.
 String getFullName()
          Return the full name of the property.
 String getName()
          Returns the name of the property.
static
<T> PropertyFormatter
getPropertyReader(Method getter, String name, Formatter<T> formatter, AbstractStringFilter filtre)
          Returns a basic PropertyFormatter.
 int hashCode()
           
abstract  String toString(Object object)
          Returns a string representation of the property.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected String name
Name of the property on which to apply the conversion.

Constructor Detail

PropertyFormatter

public PropertyFormatter()
Method Detail

toString

public abstract String toString(Object object)
Returns a string representation of the property.

Throws a PropertyException when errors occurs during the formatting.

Parameters:
object - Object from which product a string representation of its property
Returns:
the string representation.

getName

public String getName()
Returns the name of the property.

Returns:
the property name.

getFullName

public String getFullName()
Return the full name of the property. In case property is itself a property of a field, must indicate the field name followed by the property name like "field.property".

Returns:
the full name.

getConcatePropertyReader

public static PropertyFormatter getConcatePropertyReader(List<PropertyFormatter> formatters,
                                                         AbstractStringFilter filtre)
Returns a PropertyFormatter which concates strings the given propertyformatters returns.

Parameters:
formatters - list of PropertyFormatter to concate. Must be not null and not empty.
filtre - it's possible to filtre the string rendered by the given propertyFormatters before to be returned
Returns:
a new instance of PropertyFormatter

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

getDelegatePropertyReader

public static PropertyFormatter getDelegatePropertyReader(Method getter,
                                                          String name,
                                                          PropertyFormatter propertyFormatter)
Returns a PropertyFormatter which extracts as a string a characteristic of a field.

Parameters:
getter - the method to extract the field from its object. Must be not null.
name - the field name
propertyFormatter - the formatter to apply to the field, not to the owner object. May be obtained from getPropertyReader or get delegatePropertyReader methods.Must be not null.
Returns:
a new instance of PropertyFormatter

getPropertyReader

public static <T> PropertyFormatter getPropertyReader(Method getter,
                                                      String name,
                                                      Formatter<T> formatter,
                                                      AbstractStringFilter filtre)
Returns a basic PropertyFormatter.

Type Parameters:
T - the type of the property
Parameters:
getter - the method to extract the field from the object. Must not be null.
name - the property name
formatter - this formatter allows to transform the field into a string. if the given argument is null a default formatter is define which use the toString method of the field.
filtre - it's possible to filtre the string rendered by the formatter before to be returned
Returns:
a new instance of PropertyFormatter


Copyright © 2014. All Rights Reserved.