public class GenericEncodingStrategy<S extends Storable>
extends java.lang.Object
Note: subclasses must override and specialize the hashCode and equals
 methods. Failure to do so interferes with StorableCodecFactory's
 generated code cache.
| Constructor and Description | 
|---|
| GenericEncodingStrategy(java.lang.Class<S> type,
                       StorableIndex<S> pkIndex) | 
| GenericEncodingStrategy(java.lang.Class<S> type,
                       StorableIndex<S> pkIndex,
                       int keyPrefixPadding,
                       int keySuffixPadding,
                       int dataPrefixPadding,
                       int dataSuffixPadding) | 
| Modifier and Type | Method and Description | 
|---|---|
| void | buildDataDecoding(org.cojen.classfile.CodeAssembler assembler,
                 StorableProperty<S>[] properties,
                 org.cojen.classfile.LocalVariable instanceVar,
                 java.lang.Class<?> adapterInstanceClass,
                 boolean useWriteMethods,
                 int generation,
                 org.cojen.classfile.Label altGenerationHandler,
                 org.cojen.classfile.LocalVariable encodedVar)Generates bytecode instructions to decode properties. | 
| org.cojen.classfile.LocalVariable | buildDataEncoding(org.cojen.classfile.CodeAssembler assembler,
                 StorableProperty<S>[] properties,
                 org.cojen.classfile.LocalVariable instanceVar,
                 java.lang.Class<?> adapterInstanceClass,
                 boolean useReadMethods,
                 int generation)Generates bytecode instructions to encode properties. | 
| void | buildKeyDecoding(org.cojen.classfile.CodeAssembler assembler,
                OrderedProperty<S>[] properties,
                org.cojen.classfile.LocalVariable instanceVar,
                java.lang.Class<?> adapterInstanceClass,
                boolean useWriteMethods,
                org.cojen.classfile.LocalVariable encodedVar)Generates bytecode instructions to decode properties. | 
| org.cojen.classfile.LocalVariable | buildKeyEncoding(org.cojen.classfile.CodeAssembler assembler,
                OrderedProperty<S>[] properties,
                org.cojen.classfile.LocalVariable instanceVar,
                java.lang.Class<?> adapterInstanceClass,
                boolean useReadMethods,
                org.cojen.classfile.LocalVariable partialStartVar,
                org.cojen.classfile.LocalVariable partialEndVar)Generates bytecode instructions to encode properties. | 
| void | buildSerialDecoding(org.cojen.classfile.CodeAssembler assembler,
                   StorableProperty<S>[] properties,
                   org.cojen.classfile.LocalVariable encodedVar)Generates bytecode instructions to decode properties and their states. | 
| org.cojen.classfile.LocalVariable | buildSerialEncoding(org.cojen.classfile.CodeAssembler assembler,
                   StorableProperty<S>[] properties)Generates bytecode instructions to encode properties and their
 states. | 
| protected StorablePropertyInfo | checkSupport(StorableProperty<S> property) | 
| protected StorablePropertyInfo[] | checkSupport(StorableProperty<S>[] properties) | 
| boolean | equals(java.lang.Object obj) | 
| protected void | extraDataDecoding(org.cojen.classfile.CodeAssembler a,
                 org.cojen.classfile.LocalVariable dataVar,
                 int prefix,
                 int suffix)Second phase decoding, which does nothing by default. | 
| protected void | extraDataEncoding(org.cojen.classfile.CodeAssembler a,
                 org.cojen.classfile.LocalVariable dataVar,
                 int prefix,
                 int suffix)Second phase encoding, which does nothing by default. | 
| protected StorableProperty<S>[] | gatherAllDataProperties()Returns all non-derived data properties for storable. | 
| protected OrderedProperty<S>[] | gatherAllKeyProperties()Returns all key properties as ordered properties, possibly with
 unspecified directions. | 
| protected StorableProperty<S>[] | gatherAllProperties()Returns all non-join, non-derived properties for storable. | 
| int | getConstantKeyPrefixLength()Returns amount of prefix key bytes that encoding strategy instance
 produces which are always the same. | 
| int | getDataPrefixPadding() | 
| int | getDataSuffixPadding() | 
| int | getKeyPrefixPadding() | 
| int | getKeySuffixPadding() | 
| protected StorableIndex<S> | getPrimaryKeyIndex()Returns all key properties in the form of an index. | 
| java.lang.Class<S> | getType()Returns the type of Storable that code is generated for. | 
| int | hashCode() | 
| boolean | isSupported(java.lang.Class<?> propertyType)Returns true if the type of the given property type is supported. | 
| boolean | isSupported(org.cojen.classfile.TypeDesc propertyType)Returns true if the type of the given property type is supported. | 
| protected boolean | loadPropertyValue(org.cojen.classfile.CodeAssembler a,
                 StorablePropertyInfo info,
                 int ordinal,
                 boolean useReadMethod,
                 org.cojen.classfile.LocalVariable instanceVar,
                 java.lang.Class<?> adapterInstanceClass,
                 org.cojen.classfile.LocalVariable partialStartVar)Generates code to load a property value onto the operand stack. | 
| protected boolean | loadPropertyValue(org.cojen.classfile.LocalVariable[] stashedProperties,
                 java.lang.Boolean[] stashedFromInstances,
                 org.cojen.classfile.CodeAssembler a,
                 StorablePropertyInfo info,
                 int ordinal,
                 boolean useReadMethod,
                 org.cojen.classfile.LocalVariable instanceVar,
                 java.lang.Class<?> adapterInstanceClass,
                 org.cojen.classfile.LocalVariable partialStartVar)Generates code to load a property value onto the operand stack. | 
| protected void | pushDecodingInstanceVar(org.cojen.classfile.CodeAssembler a,
                       int ordinal,
                       org.cojen.classfile.LocalVariable instanceVar)Push decoding instanceVar to stack in preparation to calling
 storePropertyValue. | 
| protected void | pushRawSupport(org.cojen.classfile.CodeAssembler a,
              org.cojen.classfile.LocalVariable instanceVar)Generates code to push RawSupport instance to the stack. | 
| protected void | storePropertyValue(org.cojen.classfile.CodeAssembler a,
                  StorablePropertyInfo info,
                  boolean useWriteMethod,
                  org.cojen.classfile.LocalVariable instanceVar,
                  java.lang.Class<?> adapterInstanceClass)Generates code to store a property value into an instance which is
 already on the operand stack. | 
public GenericEncodingStrategy(java.lang.Class<S> type, StorableIndex<S> pkIndex)
type - type of Storable to generate code forpkIndex - specifies sequence and ordering of key properties (optional)public GenericEncodingStrategy(java.lang.Class<S> type, StorableIndex<S> pkIndex, int keyPrefixPadding, int keySuffixPadding, int dataPrefixPadding, int dataSuffixPadding)
type - type of Storable to generate code forpkIndex - specifies sequence and ordering of key properties (optional)keyPrefixPadding - amount of padding bytes at start of keyskeySuffixPadding - amount of padding bytes at end of keysdataPrefixPadding - amount of padding bytes at start of data valuesdataSuffixPadding - amount of padding bytes at end of data valuespublic org.cojen.classfile.LocalVariable buildKeyEncoding(org.cojen.classfile.CodeAssembler assembler,
                                                 OrderedProperty<S>[] properties,
                                                 org.cojen.classfile.LocalVariable instanceVar,
                                                 java.lang.Class<?> adapterInstanceClass,
                                                 boolean useReadMethods,
                                                 org.cojen.classfile.LocalVariable partialStartVar,
                                                 org.cojen.classfile.LocalVariable partialEndVar)
                                                   throws SupportException
Note: if a partialStartVar is provided and this strategy has a key prefix, the prefix is allocated only if the runtime value of partialStartVar is zero. Likewise, if a partialEndVar is provided and this strategy has a key suffix, the suffix is allocated only of the runtime value of partialEndVar is one less than the property count.
assembler - code assembler to receive bytecode instructionsproperties - specific properties to encode, defaults to all key
 properties if nullinstanceVar - local variable referencing Storable instance,
 defaults to "this" if null. If variable type is an Object array, then
 property values are read from the runtime value of this array instead
 of a Storable instance.adapterInstanceClass - class containing static references to
 adapter instances - defaults to instanceVaruseReadMethods - when true, access properties by public read
 methods instead of protected fields - should be used if class being
 generated doesn't have access to these fieldspartialStartVar - optional variable for supporting partial key
 generation. It must be an int, whose runtime value must be less than the
 properties array length. It marks the range start of the partial
 property range.partialEndVar - optional variable for supporting partial key
 generation. It must be an int, whose runtime value must be less than or
 equal to the properties array length. It marks the range end (exclusive)
 of the partial property range.SupportException - if any property type is not supportedjava.lang.IllegalArgumentException - if assembler is null, or if instanceVar
 is not the correct instance type, or if partial variable types are not
 intspublic void buildKeyDecoding(org.cojen.classfile.CodeAssembler assembler,
                    OrderedProperty<S>[] properties,
                    org.cojen.classfile.LocalVariable instanceVar,
                    java.lang.Class<?> adapterInstanceClass,
                    boolean useWriteMethods,
                    org.cojen.classfile.LocalVariable encodedVar)
                      throws SupportException
assembler - code assembler to receive bytecode instructionsproperties - specific properties to decode, defaults to all key
 properties if nullinstanceVar - local variable referencing Storable instance,
 defaults to "this" if null. If variable type is an Object array, then
 property values are placed into the runtime value of this array instead
 of a Storable instance.adapterInstanceClass - class containing static references to
 adapter instances - defaults to instanceVaruseWriteMethods - when true, set properties by public write
 methods instead of protected fields - should be used if class being
 generated doesn't have access to these fieldsencodedVar - required variable, which must be a byte array. At
 runtime, it references an encoded key.SupportException - if any property type is not supportedjava.lang.IllegalArgumentException - if assembler is null, or if instanceVar
 is not the correct instance type, or if encodedVar is not a byte arraypublic org.cojen.classfile.LocalVariable buildDataEncoding(org.cojen.classfile.CodeAssembler assembler,
                                                  StorableProperty<S>[] properties,
                                                  org.cojen.classfile.LocalVariable instanceVar,
                                                  java.lang.Class<?> adapterInstanceClass,
                                                  boolean useReadMethods,
                                                  int generation)
                                                    throws SupportException
assembler - code assembler to receive bytecode instructionsproperties - specific properties to encode, defaults to all non-key
 properties if nullinstanceVar - local variable referencing Storable instance,
 defaults to "this" if null. If variable type is an Object array, then
 property values are read from the runtime value of this array instead
 of a Storable instance.adapterInstanceClass - class containing static references to
 adapter instances - defaults to instanceVaruseReadMethods - when true, access properties by public read
 methods instead of protected fieldsgeneration - when non-negative, write 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.SupportException - if any property type is not supportedjava.lang.IllegalArgumentException - if assembler is null, or if instanceVar
 is not the correct instance typepublic void buildDataDecoding(org.cojen.classfile.CodeAssembler assembler,
                     StorableProperty<S>[] properties,
                     org.cojen.classfile.LocalVariable instanceVar,
                     java.lang.Class<?> adapterInstanceClass,
                     boolean useWriteMethods,
                     int generation,
                     org.cojen.classfile.Label altGenerationHandler,
                     org.cojen.classfile.LocalVariable encodedVar)
                       throws SupportException
assembler - code assembler to receive bytecode instructionsproperties - specific properties to decode, defaults to all non-key
 properties if nullinstanceVar - local variable referencing Storable instance,
 defaults to "this" if null. If variable type is an Object array, then
 property values are placed into the runtime value of this array instead
 of a Storable instance.adapterInstanceClass - class containing static references to
 adapter instances - defaults to instanceVaruseWriteMethods - when true, set properties by public write
 methods instead of protected fields - should be used if class being
 generated doesn't have access to these fieldsgeneration - when non-negative, decoder expects a storable layout
 generation value to match this value. Otherwise, it throws a
 CorruptEncodingException.altGenerationHandler - if non-null and a generation is provided,
 this label defines an alternate generation handler. It is executed
 instead of throwing a CorruptEncodingException if the generation doesn't
 match. The actual generation is available on the top of the stack for
 the handler to consume.encodedVar - required variable, which must be a byte array. At
 runtime, it references encoded data.SupportException - if any property type is not supportedjava.lang.IllegalArgumentException - if assembler is null, or if instanceVar
 is not the correct instance type, or if encodedVar is not a byte arraypublic org.cojen.classfile.LocalVariable buildSerialEncoding(org.cojen.classfile.CodeAssembler assembler,
                                                    StorableProperty<S>[] properties)
                                                      throws SupportException
assembler - code assembler to receive bytecode instructionsproperties - specific properties to decode, defaults to all
 properties if nullSupportException - if any property type is not supportedpublic void buildSerialDecoding(org.cojen.classfile.CodeAssembler assembler,
                       StorableProperty<S>[] properties,
                       org.cojen.classfile.LocalVariable encodedVar)
                         throws SupportException
assembler - code assembler to receive bytecode instructionsproperties - specific properties to decode, defaults to all
 properties if nullencodedVar - required variable, which must be a byte array. At
 runtime, it references encoded data.SupportException - if any property type is not supportedjava.lang.IllegalArgumentException - if encodedVar is not a byte arraypublic final java.lang.Class<S> getType()
public boolean isSupported(java.lang.Class<?> propertyType)
public boolean isSupported(org.cojen.classfile.TypeDesc propertyType)
public int getKeyPrefixPadding()
public int getKeySuffixPadding()
public int getDataPrefixPadding()
public int getDataSuffixPadding()
public int getConstantKeyPrefixLength()
public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectprotected StorableIndex<S> getPrimaryKeyIndex()
protected OrderedProperty<S>[] gatherAllKeyProperties()
protected StorableProperty<S>[] gatherAllDataProperties()
protected StorableProperty<S>[] gatherAllProperties()
protected StorablePropertyInfo checkSupport(StorableProperty<S> property) throws SupportException
SupportExceptionprotected StorablePropertyInfo[] checkSupport(StorableProperty<S>[] properties) throws SupportException
SupportExceptionprotected void extraDataEncoding(org.cojen.classfile.CodeAssembler a,
                     org.cojen.classfile.LocalVariable dataVar,
                     int prefix,
                     int suffix)
dataVar - local variable referencing a byte array with dataprefix - prefix of byte array to preservesuffix - suffix of byte array to preserveprotected void extraDataDecoding(org.cojen.classfile.CodeAssembler a,
                     org.cojen.classfile.LocalVariable dataVar,
                     int prefix,
                     int suffix)
dataVar - local variable referencing a byte array with dataprotected boolean loadPropertyValue(org.cojen.classfile.LocalVariable[] stashedProperties,
                        java.lang.Boolean[] stashedFromInstances,
                        org.cojen.classfile.CodeAssembler a,
                        StorablePropertyInfo info,
                        int ordinal,
                        boolean useReadMethod,
                        org.cojen.classfile.LocalVariable instanceVar,
                        java.lang.Class<?> adapterInstanceClass,
                        org.cojen.classfile.LocalVariable partialStartVar)
info - info for property to loadordinal - zero-based property ordinal, used only if instanceVar
 refers to an object array.useReadMethod - when true, access property by public read method
 instead of protected fieldinstanceVar - local variable referencing Storable instance,
 defaults to "this" if null. If variable type is an Object array, then
 property values are read from the runtime value of this array instead
 of a Storable instance.adapterInstanceClass - class containing static references to
 adapter instances - defaults to instanceVarpartialStartVar - optional variable for supporting partial key
 generation. It must be an int, whose runtime value must be less than the
 properties array length. It marks the range start of the partial
 property range.protected boolean loadPropertyValue(org.cojen.classfile.CodeAssembler a,
                        StorablePropertyInfo info,
                        int ordinal,
                        boolean useReadMethod,
                        org.cojen.classfile.LocalVariable instanceVar,
                        java.lang.Class<?> adapterInstanceClass,
                        org.cojen.classfile.LocalVariable partialStartVar)
info - info for property to loadordinal - zero-based property ordinal, used only if instanceVar
 refers to an object array.useReadMethod - when true, access property by public read method
 instead of protected fieldinstanceVar - local variable referencing Storable instance,
 defaults to "this" if null. If variable type is an Object array, then
 property values are read from the runtime value of this array instead
 of a Storable instance.adapterInstanceClass - class containing static references to
 adapter instances - defaults to instanceVarpartialStartVar - optional variable for supporting partial key
 generation. It must be an int, whose runtime value must be less than the
 properties array length. It marks the range start of the partial
 property range.protected void pushRawSupport(org.cojen.classfile.CodeAssembler a,
                  org.cojen.classfile.LocalVariable instanceVar)
                       throws SupportException
instanceVar - Storable instance or array of property values. Null
 is storable instance of "this".SupportExceptionprotected void pushDecodingInstanceVar(org.cojen.classfile.CodeAssembler a,
                           int ordinal,
                           org.cojen.classfile.LocalVariable instanceVar)
ordinal - zero-based property ordinal, used only if instanceVar
 refers to an object array.instanceVar - local variable referencing Storable instance,
 defaults to "this" if null. If variable type is an Object array, then
 property values are written to the runtime value of this array instead
 of a Storable instance.storePropertyValueprotected void storePropertyValue(org.cojen.classfile.CodeAssembler a,
                      StorablePropertyInfo info,
                      boolean useWriteMethod,
                      org.cojen.classfile.LocalVariable instanceVar,
                      java.lang.Class<?> adapterInstanceClass)
info - info for property to store touseWriteMethod - when true, set property by public write method
 instead of protected fieldinstanceVar - local variable referencing Storable instance,
 defaults to "this" if null. If variable type is an Object array, then
 property values are written to the runtime value of this array instead
 of a Storable instance.adapterInstanceClass - class containing static references to
 adapter instances - defaults to instanceVarpushDecodingInstanceVarCopyright © 2006-2013 Amazon Technologies, Inc.. All Rights Reserved.