com.amazon.carbonado.raw
Class GenericStorableCodecFactory

java.lang.Object
  extended by com.amazon.carbonado.raw.GenericStorableCodecFactory
All Implemented Interfaces:
StorableCodecFactory
Direct Known Subclasses:
CompressedStorableCodecFactory

public class GenericStorableCodecFactory
extends Object
implements StorableCodecFactory

Factory for generic codec that supports any kind of storable by auto-generating and caching storable implementations.

Author:
Brian S O'Neill

Constructor Summary
GenericStorableCodecFactory()
           
 
Method Summary
<S extends Storable>
GenericStorableCodec<S>
createCodec(Class<S> type, StorableIndex pkIndex, boolean isMaster, Layout layout)
           
<S extends Storable>
GenericStorableCodec<S>
createCodec(Class<S> type, StorableIndex pkIndex, boolean isMaster, Layout layout, RawSupport support)
           
protected
<S extends Storable>
GenericEncodingStrategy<S>
createStrategy(Class<S> type, StorableIndex<S> pkIndex)
          Override to return a different EncodingStrategy.
protected
<S extends Storable>
GenericEncodingStrategy<S>
createStrategy(Class<S> type, StorableIndex<S> pkIndex, LayoutOptions options)
          Override to return a different EncodingStrategy.
 LayoutOptions getLayoutOptions(Class<? extends Storable> type)
          Returns null.
 String getStorageName(Class<? extends Storable> type)
          Returns null to let repository decide what the name should be.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericStorableCodecFactory

public GenericStorableCodecFactory()
Method Detail

getStorageName

public String getStorageName(Class<? extends Storable> type)
                      throws SupportException
Returns null to let repository decide what the name should be.

Specified by:
getStorageName in interface StorableCodecFactory
Throws:
SupportException - if type is not supported

getLayoutOptions

public LayoutOptions getLayoutOptions(Class<? extends Storable> type)
Returns null.

Specified by:
getLayoutOptions in interface StorableCodecFactory

createCodec

public <S extends Storable> GenericStorableCodec<S> createCodec(Class<S> type,
                                                                StorableIndex pkIndex,
                                                                boolean isMaster,
                                                                Layout layout)
                                                     throws SupportException
Specified by:
createCodec in interface StorableCodecFactory
Parameters:
type - type of storable to create codec for
pkIndex - suggested index for primary key (optional)
isMaster - when true, version properties and sequences are managed
layout - when non-null, encode a storable layout generation value in one or four bytes. Generation 0..127 is encoded in one byte, and 128..max is encoded in four bytes, with the most significant bit set.
Throws:
SupportException - if type is not supported

createCodec

public <S extends Storable> GenericStorableCodec<S> createCodec(Class<S> type,
                                                                StorableIndex pkIndex,
                                                                boolean isMaster,
                                                                Layout layout,
                                                                RawSupport support)
                                                     throws SupportException
Specified by:
createCodec in interface StorableCodecFactory
Parameters:
type - type of storable to create codec for
pkIndex - suggested index for primary key (optional)
isMaster - when true, version properties and sequences are managed
layout - when non-null, encode a storable layout generation value in one or four bytes. Generation 0..127 is encoded in one byte, and 128..max is encoded in four bytes, with the most significant bit set.
support - binds generated storable with a storage layer
Throws:
SupportException - if type is not supported
Since:
1.2

createStrategy

protected <S extends Storable> GenericEncodingStrategy<S> createStrategy(Class<S> type,
                                                                         StorableIndex<S> pkIndex)
                                                              throws SupportException
Override to return a different EncodingStrategy.

Parameters:
type - type of Storable to generate code for
pkIndex - specifies sequence and ordering of key properties (optional)
Throws:
SupportException

createStrategy

protected <S extends Storable> GenericEncodingStrategy<S> createStrategy(Class<S> type,
                                                                         StorableIndex<S> pkIndex,
                                                                         LayoutOptions options)
                                                              throws SupportException
Override to return a different EncodingStrategy.

Parameters:
type - type of Storable to generate code for
pkIndex - specifies sequence and ordering of key properties (optional)
options - additional layout options (optional)
Throws:
SupportException
Since:
1.2.1


Copyright © 2006-2009 Amazon Technologies, Inc.. All Rights Reserved.