org.joda.beans.ser
Class DefaultDeserializer

java.lang.Object
  extended by org.joda.beans.ser.DefaultDeserializer
All Implemented Interfaces:
SerDeserializer

public class DefaultDeserializer
extends Object
implements SerDeserializer

Default deserializer that expects the input to match the current classpath beans.

This uses the standard MetaBean, MetaProperty and BeanBuilder.

Implementations must be thread-safe singletons.


Field Summary
static SerDeserializer INSTANCE
          Singleton.
 
Constructor Summary
protected DefaultDeserializer()
          Creates an instance.
 
Method Summary
 Object build(Class<?> beanType, BeanBuilder<?> builder)
          Builds the resulting object.
 BeanBuilder<?> createBuilder(Class<?> beanType, MetaBean metaBean)
          Creates the stateful builder that captures state as the parse progresses.
 MetaBean findMetaBean(Class<?> beanType)
          Lookup the meta-bean for the speecified type.
 MetaProperty<?> findMetaProperty(Class<?> beanType, MetaBean metaBean, String propertyName)
          Lookup the meta-property for the specified property name.
 void setValue(BeanBuilder<?> builder, MetaProperty<?> metaProp, Object value)
          Sets the parsed value into the builder.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INSTANCE

public static final SerDeserializer INSTANCE
Singleton.

Constructor Detail

DefaultDeserializer

protected DefaultDeserializer()
Creates an instance.

Method Detail

findMetaBean

public MetaBean findMetaBean(Class<?> beanType)
Description copied from interface: SerDeserializer
Lookup the meta-bean for the speecified type.

If the type is not a bean, then null may be returned.

Specified by:
findMetaBean in interface SerDeserializer
Parameters:
beanType - the type being processed, not null
Returns:
the meta-bean, null if not a bean type

createBuilder

public BeanBuilder<?> createBuilder(Class<?> beanType,
                                    MetaBean metaBean)
Description copied from interface: SerDeserializer
Creates the stateful builder that captures state as the parse progresses.

This is normally a BeanBuilder however any type may be returned.

Specified by:
createBuilder in interface SerDeserializer
Parameters:
beanType - the type being processed, not null
metaBean - the meta-bean, null if not a bean type
Returns:
the builder, null if not interested in the parse progress

findMetaProperty

public MetaProperty<?> findMetaProperty(Class<?> beanType,
                                        MetaBean metaBean,
                                        String propertyName)
Description copied from interface: SerDeserializer
Lookup the meta-property for the specified property name.

Return null if a property has been deleted, which will cause the parser to discard the property.

Return a non-null meta-property to parse the property. If the property was renamed, or had a type change, then the meta-property should match the property as originally stored.

Specified by:
findMetaProperty in interface SerDeserializer
Parameters:
beanType - the type being processed, not null
metaBean - the meta-bean, null if not a bean type
propertyName - the property name being parsed, not null
Returns:
the meta-property, null to ignore the property

setValue

public void setValue(BeanBuilder<?> builder,
                     MetaProperty<?> metaProp,
                     Object value)
Description copied from interface: SerDeserializer
Sets the parsed value into the builder.

Specified by:
setValue in interface SerDeserializer
Parameters:
builder - the builder, null if not interested in the parse progress
metaProp - the meta-property, not null
value - the parsed value, may be null

build

public Object build(Class<?> beanType,
                    BeanBuilder<?> builder)
Description copied from interface: SerDeserializer
Builds the resulting object.

This method finishes the builder and returns the final object. The migrator could validate or manipulate data here once all data is parsed, for example to default a missing field.

Specified by:
build in interface SerDeserializer
Parameters:
beanType - the type being processed, not null
builder - the builder, null if not interested in the parse progress
Returns:
the final built object, may be null

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2007–2015 Joda.org. All rights reserved.