org.progeeks.meta.format
Class DefaultPropertyFormat

java.lang.Object
  extended by org.progeeks.meta.format.AbstractPropertyFormat
      extended by org.progeeks.meta.format.DefaultPropertyFormat
All Implemented Interfaces:
PropertyFormat
Direct Known Subclasses:
EdgeUserObjectFormat

public class DefaultPropertyFormat
extends AbstractPropertyFormat

Default implementation for converting objects to and from text data. This assumes that the associated class has a useful toString() method that can also be passed to a String arg constructor.

Version:
$Revision: 1.6 $
Author:
Paul Speed

Constructor Summary
DefaultPropertyFormat()
          Creates a property formatter without a specified type.
DefaultPropertyFormat(java.lang.Class type)
          Creates a property formatter that will convert objects to string for the format method and attempt to instantiate an object of the specified type for the parseObject() method.
 
Method Summary
 java.lang.String format(MetaObject obj)
          Returns the formatted String for the specified MetaObject.
 java.lang.String format(java.lang.Object obj)
          Returns the formatted String for the specified Object.
 java.lang.Object parseObject(java.lang.String source, int index)
          Parses the text starting at the specified index and converts it into an Object of the appropriate type.
 java.lang.String toString()
          String summary.
 
Methods inherited from class org.progeeks.meta.format.AbstractPropertyFormat
format, parseObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultPropertyFormat

public DefaultPropertyFormat()
Creates a property formatter without a specified type. This will convert everything to strings for the format() method. The parseObject() method will throw an unsupported operation exception.


DefaultPropertyFormat

public DefaultPropertyFormat(java.lang.Class type)
Creates a property formatter that will convert objects to string for the format method and attempt to instantiate an object of the specified type for the parseObject() method.

Method Detail

format

public java.lang.String format(java.lang.Object obj)
Returns the formatted String for the specified Object.

Specified by:
format in interface PropertyFormat
Specified by:
format in class AbstractPropertyFormat

format

public java.lang.String format(MetaObject obj)
Returns the formatted String for the specified MetaObject.


parseObject

public java.lang.Object parseObject(java.lang.String source,
                                    int index)
Parses the text starting at the specified index and converts it into an Object of the appropriate type. If this method is not supported then an UnsupportedOperationException will be thrown.

Specified by:
parseObject in interface PropertyFormat
Specified by:
parseObject in class AbstractPropertyFormat

toString

public java.lang.String toString()
String summary.

Overrides:
toString in class java.lang.Object


Copyright © 2002-2003 Paul Speed. All Rights Reserved.