// if (key instanceof String)
// return new oidType(getClass(), (String)key);
// else
// return new oidType(getClass(), (oidKeyType)key);
// }
ObjectType oidType;
ObjectType oidKeyType;
if (oidClassName.equals(ClassEnhancer.CN_StringIdentity))
{
oidType = BCELClassEnhancer.OT_StringIdentity;
oidKeyType = Type.STRING;
}
else if (oidClassName.equals(ClassEnhancer.CN_LongIdentity))
{
oidType = BCELClassEnhancer.OT_LongIdentity;
oidKeyType = new ObjectType(Long.class.getName());
}
else if (oidClassName.equals(ClassEnhancer.CN_IntIdentity))
{
oidType = BCELClassEnhancer.OT_IntIdentity;
oidKeyType = new ObjectType(Integer.class.getName());
}
else if (oidClassName.equals(ClassEnhancer.CN_ShortIdentity))
{
oidType = BCELClassEnhancer.OT_ShortIdentity;
oidKeyType = new ObjectType(Short.class.getName());
}
else if (oidClassName.equals(ClassEnhancer.CN_ByteIdentity))
{
oidType = BCELClassEnhancer.OT_ByteIdentity;
oidKeyType = new ObjectType(Byte.class.getName());
}
else if (oidClassName.equals(ClassEnhancer.CN_CharIdentity))
{
oidType = BCELClassEnhancer.OT_CharIdentity;
oidKeyType = new ObjectType(Long.class.getName());
}
else
{
oidType = BCELClassEnhancer.OT_ObjectIdentity;
oidKeyType = new ObjectType(Object.class.getName());
}
il.append(InstructionConstants.ALOAD_1);
BranchInstruction checkKeyIsNull = new IFNONNULL(null);
il.append(checkKeyIsNull);
createThrowException(ClassEnhancer.CN_IllegalArgumentException, "key is null");
checkKeyIsNull.setTarget(il.append(InstructionConstants.ALOAD_1));
il.append(factory.createInstanceOf(Type.STRING));
il.append(InstructionConstants.ICONST_1);
BranchInstruction isInstanceof = new IF_ICMPEQ(null);
il.append(isInstanceof);
// new oidType(getClass(), (oidKeyType)key);
il.append(factory.createNew(oidType));
il.append(InstructionConstants.DUP);
il.append(InstructionConstants.ALOAD_0);
il.append(factory.createInvoke("java.lang.Object", "getClass", BCELClassEnhancer.OT_CLASS, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
il.append(InstructionConstants.ALOAD_1);
il.append(factory.createCheckCast(oidKeyType));
il.append(factory.createInvoke(oidType.getClassName(), Constants.CONSTRUCTOR_NAME, Type.VOID,
new Type[] { BCELClassEnhancer.OT_CLASS, oidKeyType }, Constants.INVOKESPECIAL));
// "return"
il.append(InstructionFactory.createReturn(Type.OBJECT));
// "new oidType(getClass(), (String)key);"
isInstanceof.setTarget(il.append(factory.createNew(oidType)));
il.append(InstructionConstants.DUP);
il.append(InstructionConstants.ALOAD_0);
il.append(factory.createInvoke("java.lang.Object", "getClass", BCELClassEnhancer.OT_CLASS, Type.NO_ARGS, Constants.INVOKEVIRTUAL));
il.append(InstructionConstants.ALOAD_1);
il.append(factory.createCheckCast(Type.STRING));
il.append(factory.createInvoke(oidType.getClassName(), Constants.CONSTRUCTOR_NAME, Type.VOID,
new Type[] { BCELClassEnhancer.OT_CLASS, Type.STRING }, Constants.INVOKESPECIAL));
// "return"
il.append(InstructionFactory.createReturn(Type.OBJECT));
}
// Users Application Identity class
else if (oidClassName != null && oidClassName.length() > 0)
{
// Creates the following method
// public Object jdoNewObjectIdInstance(Object key)
// {
// return new oidType((String)key);
// }
ObjectType objectIdClassType = new ObjectType(oidClassName);
il.append(factory.createNew(objectIdClassType));
il.append(InstructionConstants.DUP);
il.append(InstructionConstants.ALOAD_1);
il.append(factory.createCheckCast(Type.STRING));
il.append(factory.createInvoke(oidClassName, Constants.CONSTRUCTOR_NAME, Type.VOID,