org.datanucleus.enhancer.asm.primarykey
Class PrimaryKeyGenerator

java.lang.Object
  extended by org.datanucleus.enhancer.asm.primarykey.PrimaryKeyGenerator

public class PrimaryKeyGenerator
extends java.lang.Object

Class to handle the generation of a PK class for a persistable class. The primary key class is generated as its own class, rather than as an inner class of the original class.


Field Summary
protected static org.datanucleus.util.Localiser LOCALISER
          Localisation of messages
 
Constructor Summary
PrimaryKeyGenerator(org.datanucleus.metadata.AbstractClassMetaData cmd, ASMClassEnhancer enhancer)
          Constructor for a PK generator for the specified class.
 
Method Summary
protected  void addDefaultConstructor(org.objectweb.asm.ClassWriter cw)
          Method to add an empty default constructor.
protected  void addFields(org.objectweb.asm.ClassWriter cw)
          Method to add fields to match the PK fields of the persistable class
protected  void addMethodEquals(org.objectweb.asm.ClassWriter cw)
          Method to add an equals() method.
protected  void addMethodHashCode(org.objectweb.asm.ClassWriter cw)
          Method to add a hashCode() method.
protected  void addMethodToString(org.objectweb.asm.ClassWriter cw)
          Method to add a toString() method.
protected  void addStringConstructor(org.objectweb.asm.ClassWriter cw)
          Method to add a constructor taking in a String.
 byte[] generate()
          Method to generate the primary key class.
protected  java.lang.String getTypeNameForField(org.datanucleus.metadata.AbstractMemberMetaData mmd)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCALISER

protected static org.datanucleus.util.Localiser LOCALISER
Localisation of messages

Constructor Detail

PrimaryKeyGenerator

public PrimaryKeyGenerator(org.datanucleus.metadata.AbstractClassMetaData cmd,
                           ASMClassEnhancer enhancer)
Constructor for a PK generator for the specified class.

Parameters:
cmd - Metadata for the class that needs a primary key class
enhancer - The enhancer being used
Method Detail

generate

public byte[] generate()
Method to generate the primary key class.

Returns:
The bytes for this pk class

addFields

protected void addFields(org.objectweb.asm.ClassWriter cw)
Method to add fields to match the PK fields of the persistable class

Parameters:
cw - The ClassWriter to use

getTypeNameForField

protected java.lang.String getTypeNameForField(org.datanucleus.metadata.AbstractMemberMetaData mmd)

addDefaultConstructor

protected void addDefaultConstructor(org.objectweb.asm.ClassWriter cw)
Method to add an empty default constructor.

Parameters:
cw - The ClassWriter to use

addStringConstructor

protected void addStringConstructor(org.objectweb.asm.ClassWriter cw)
Method to add a constructor taking in a String.

Parameters:
cw - The ClassWriter to use

addMethodToString

protected void addMethodToString(org.objectweb.asm.ClassWriter cw)
Method to add a toString() method.

Parameters:
cw - The ClassWriter to use

addMethodEquals

protected void addMethodEquals(org.objectweb.asm.ClassWriter cw)
Method to add an equals() method.

Parameters:
cw - The ClassWriter to use

addMethodHashCode

protected void addMethodHashCode(org.objectweb.asm.ClassWriter cw)
Method to add a hashCode() method.

Parameters:
cw - The ClassWriter to use


Copyright © 2011. All Rights Reserved.