List of usage examples for org.objectweb.asm MethodVisitor visitLabel
public void visitLabel(final Label label)
From source file:ldapbeans.bean.LdapBeanClassManager.java
License:LGPL
/** * Generate a method of the generated class * /*from w ww . j ava2 s . co m*/ * @param p_ClassWriter * The {@link ClassWriter} of the generated class * @param p_ClassName * The name of the class * @param p_Method * the method to generate * @param p_MethodDescriptor * The method descriptor */ private void generateMethodEquals(ClassWriter p_ClassWriter, String p_ClassName, Method p_Method, String p_MethodDescriptor) { MethodVisitor mv = p_ClassWriter.visitMethod(ACC_PUBLIC, "equals", "(Ljava/lang/Object;)Z", null, null); mv.visitCode(); mv.visitVarInsn(ALOAD, 1); mv.visitTypeInsn(INSTANCEOF, "ldapbeans/bean/LdapBean"); Label l0 = new Label(); mv.visitJumpInsn(IFEQ, l0); mv.visitVarInsn(ALOAD, 1); Label l1 = new Label(); mv.visitJumpInsn(IFNULL, l1); mv.visitVarInsn(ALOAD, 0); mv.visitMethodInsn(INVOKEINTERFACE, "ldapbeans/bean/LdapBean", "getDN", "()Ljava/lang/String;"); mv.visitVarInsn(ALOAD, 1); mv.visitTypeInsn(CHECKCAST, "ldapbeans/bean/LdapBean"); mv.visitMethodInsn(INVOKEINTERFACE, "ldapbeans/bean/LdapBean", "getDN", "()Ljava/lang/String;"); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z"); mv.visitJumpInsn(IFEQ, l1); mv.visitInsn(ICONST_1); mv.visitInsn(IRETURN); mv.visitLabel(l1); mv.visitInsn(ICONST_0); mv.visitInsn(IRETURN); mv.visitLabel(l0); mv.visitInsn(ICONST_0); mv.visitInsn(IRETURN); mv.visitMaxs(0, 0); mv.visitEnd(); }
From source file:ldapbeans.bean.LdapBeanClassManager.java
License:LGPL
/** * Generate a method of the generated class * /*ww w.java 2s. c o m*/ * @param p_MethodVisitor * The {@link MethodVisitor} of the generated method * @param p_ClassName * The name of the class * @param p_Method * the generated method * @param p_StartIndex * First index of the stack after parameters * @param p_LdapAttribute * The LdapAttribute that will be used for generating the method */ private void generateMethodSetterInitializeAttribute(MethodVisitor p_MethodVisitor, String p_ClassName, Method p_Method, int p_StartIndex, LdapAttribute p_LdapAttribute) { MethodVisitor mv = p_MethodVisitor; String attributeName = p_LdapAttribute.value(); // Attributes attributes = m_LdapObject.getAttributes(); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, INTERNAL_PACKAGE_NAME + '/' + p_ClassName, "m_LdapObject", "Lldapbeans/bean/LdapObject;"); mv.visitMethodInsn(INVOKEVIRTUAL, "ldapbeans/bean/LdapObject", "getAttributes", "()Ljavax/naming/directory/Attributes;"); mv.visitVarInsn(ASTORE, p_StartIndex + 2); // Attribute attribute = attributes.get("attributeName"); mv.visitVarInsn(ALOAD, p_StartIndex + 2); mv.visitLdcInsn(attributeName); mv.visitMethodInsn(INVOKEINTERFACE, "javax/naming/directory/Attributes", "get", "(Ljava/lang/String;)Ljavax/naming/directory/Attribute;"); mv.visitVarInsn(ASTORE, p_StartIndex + 3); // if (attribute == null) { mv.visitVarInsn(ALOAD, p_StartIndex + 3); Label l0 = new Label(); mv.visitJumpInsn(IFNONNULL, l0); // attribute = new BasicAttribute("attributeName"); mv.visitTypeInsn(NEW, "javax/naming/directory/BasicAttribute"); mv.visitInsn(DUP); mv.visitLdcInsn(attributeName); mv.visitMethodInsn(INVOKESPECIAL, "javax/naming/directory/BasicAttribute", "<init>", "(Ljava/lang/String;)V"); mv.visitVarInsn(ASTORE, p_StartIndex + 3); // attributes.put(attribute); mv.visitVarInsn(ALOAD, p_StartIndex + 2); mv.visitVarInsn(ALOAD, p_StartIndex + 3); mv.visitMethodInsn(INVOKEINTERFACE, "javax/naming/directory/Attributes", "put", "(Ljavax/naming/directory/Attribute;)" + "Ljavax/naming/directory/Attribute;"); mv.visitInsn(POP); if (!p_Method.getName().startsWith("add")) { /* * If method is not an adder (but a simple setter), attribute has to * be cleared */ // } else { Label l1 = new Label(); mv.visitJumpInsn(GOTO, l1); mv.visitLabel(l0); // attribute.clear(); mv.visitVarInsn(ALOAD, p_StartIndex + 3); mv.visitMethodInsn(INVOKEINTERFACE, "javax/naming/directory/Attribute", "clear", "()V"); // } mv.visitLabel(l1); } else { // } mv.visitLabel(l0); } }
From source file:ldapbeans.bean.LdapBeanClassManager.java
License:LGPL
/** * Generate a portion of a method of the generated class * /* w ww . j a v a 2 s . c o m*/ * @param p_MethodVisitor * The {@link MethodVisitor} of the generated method * @param p_ClassName * The name of the class * @param p_Method * the generated method * @param p_ParamIndex * index of the parameter to convert * @param p_StartIndex * first index of the stack after parameters * @param p_LdapAttribute * The LdapAttribute that will be used for generating the method * @param p_ParameterType * The type of the parameter */ private void generateMethodSetterAssignValue(MethodVisitor p_MethodVisitor, String p_ClassName, Method p_Method, int p_ParamIndex, int p_StartIndex, LdapAttribute p_LdapAttribute, Class<?> p_ParameterType) { MethodVisitor mv = p_MethodVisitor; int paramStackIndex = getStackIndexOfParameter(p_Method, p_ParamIndex); ConvertAttribute annotation = getConvertAttributeAnnotation(p_Method)[p_ParamIndex]; if (Collection.class.isAssignableFrom(p_ParameterType)) { /* * The parameter is a collection, each element of the collection * will be added */ // Iterator it = p_AttributeValue.iterator(); mv.visitVarInsn(ALOAD, paramStackIndex); mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Collection", "iterator", "()Ljava/util/Iterator;"); mv.visitVarInsn(ASTORE, p_StartIndex + 5); // while(it.hasNext()) { Label l2 = new Label(); mv.visitLabel(l2); mv.visitVarInsn(ALOAD, p_StartIndex + 5); mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Iterator", "hasNext", "()Z"); Label l3 = new Label(); mv.visitJumpInsn(IFEQ, l3); // Object value = it.next(); mv.visitVarInsn(ALOAD, p_StartIndex + 5); mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Iterator", "next", "()Ljava/lang/Object;"); mv.visitVarInsn(ASTORE, p_StartIndex + 4); // convert value to String // TODO : Find another way to convert object generateMethodSetterAssignValueConvert(mv, p_ClassName, p_Method, p_StartIndex + 4, p_StartIndex, p_LdapAttribute, annotation, Object.class); generateMethodSetterAssignValueToTempArray(mv, p_ClassName, p_Method, p_StartIndex + 4, p_StartIndex); // } mv.visitJumpInsn(GOTO, l2); mv.visitLabel(l3); } else if (p_ParameterType.isArray()) { // TODO // int i=0; mv.visitInsn(ICONST_0); mv.visitVarInsn(ISTORE, p_StartIndex + 5); // while(i<values.length) { Label l0 = new Label(); Label l1 = new Label(); mv.visitLabel(l0); mv.visitVarInsn(ILOAD, p_StartIndex + 5); mv.visitVarInsn(ALOAD, paramStackIndex); mv.visitInsn(ARRAYLENGTH); mv.visitJumpInsn(IF_ICMPGE, l1); // value = values[i]; mv.visitVarInsn(ALOAD, paramStackIndex); mv.visitVarInsn(ILOAD, p_StartIndex + 1); mv.visitInsn(AALOAD); mv.visitVarInsn(ASTORE, p_StartIndex + 4); // convert value to String generateMethodSetterAssignValueConvert(mv, p_ClassName, p_Method, p_StartIndex + 4, p_StartIndex, p_LdapAttribute, annotation, p_ParameterType.getComponentType()); generateMethodSetterAssignValueToTempArray(mv, p_ClassName, p_Method, p_StartIndex + 4, p_StartIndex); // i++; mv.visitIincInsn(p_StartIndex + 5, 1); // } mv.visitJumpInsn(GOTO, l0); mv.visitLabel(l1); } else { generateMethodSetterAssignValueConvert(mv, p_ClassName, p_Method, paramStackIndex, p_StartIndex, p_LdapAttribute, annotation, p_ParameterType); generateMethodSetterAssignValueToTempArray(mv, p_ClassName, p_Method, p_StartIndex + 4, p_StartIndex); } }
From source file:ldapbeans.bean.LdapBeanClassManager.java
License:LGPL
/** * Generate a method of the generated class * /*ww w . j a v a 2 s . c o m*/ * @param p_MethodVisitor * The {@link MethodVisitor} of the generated method * @param p_ClassName * The name of the class * @param p_Method * the generated method * @param p_StartIndex * First index of the stack after parameters * @param p_LdapAttribute * LdapAttribute of the generated method */ private void generateMethodSetterAssignResult(MethodVisitor p_MethodVisitor, String p_ClassName, Method p_Method, int p_StartIndex, LdapAttribute p_LdapAttribute) { MethodVisitor mv = p_MethodVisitor; if (p_LdapAttribute.pattern().length() == 0) { // int i=0; mv.visitInsn(ICONST_0); mv.visitVarInsn(ISTORE, p_StartIndex + 1); // { Label l0 = new Label(); mv.visitJumpInsn(GOTO, l0); Label l1 = new Label(); mv.visitLabel(l1); mv.visitVarInsn(ALOAD, p_StartIndex + 3); // value = tempValues[i]; mv.visitVarInsn(ALOAD, p_StartIndex); mv.visitVarInsn(ILOAD, p_StartIndex + 1); mv.visitInsn(AALOAD); // attribute.add(value); mv.visitMethodInsn(INVOKEINTERFACE, "javax/naming/directory/Attribute", "add", "(Ljava/lang/Object;)Z"); mv.visitInsn(POP); // i++ mv.visitIincInsn(p_StartIndex + 1, 1); // } mv.visitLabel(l0); // i < tempValues.length mv.visitVarInsn(ILOAD, p_StartIndex + 1); mv.visitVarInsn(ALOAD, p_StartIndex); mv.visitInsn(ARRAYLENGTH); mv.visitJumpInsn(IF_ICMPLT, l1); } else { mv.visitVarInsn(ALOAD, p_StartIndex + 3); mv.visitLdcInsn(p_LdapAttribute.pattern()); mv.visitVarInsn(ALOAD, p_StartIndex); mv.visitMethodInsn(INVOKESTATIC, "ldapbeans/util/StringUtil", "format", "(Ljava/lang/String;[Ljava/lang/Object;)" + "Ljava/lang/String;"); // attribute.add(value); mv.visitMethodInsn(INVOKEINTERFACE, "javax/naming/directory/Attribute", "add", "(Ljava/lang/Object;)Z"); mv.visitInsn(POP); } }
From source file:ldapbeans.bean.LdapBeanClassManager.java
License:LGPL
/** * Generate a portion of a method of the generated class * /*from w w w . ja v a2s. c o m*/ * @param p_MethodVisitor * The {@link MethodVisitor} of the generated method * @param p_ObjectStackIndex * index of the object to convert in the stack * @param p_StartIndex * first index of the stack after parameters * @param p_LdapAttribute * The LdapAttribute that will be used for generating the method * @param p_OriginalType * The type before conversion */ private void generateMethodSetterAssignValueConvertBoolean(MethodVisitor p_MethodVisitor, int p_ObjectStackIndex, int p_StartIndex, LdapAttribute p_LdapAttribute, Class<?> p_OriginalType) { MethodVisitor mv = p_MethodVisitor; if (Boolean.class.equals(p_OriginalType)) { mv.visitVarInsn(ALOAD, p_ObjectStackIndex); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Boolean", "booleanValue", "()Z"); } else { mv.visitVarInsn(ILOAD, p_ObjectStackIndex); } Label l2 = new Label(); mv.visitJumpInsn(IFEQ, l2); mv.visitLdcInsn(p_LdapAttribute.trueValue()[0]); Label l3 = new Label(); mv.visitJumpInsn(GOTO, l3); mv.visitLabel(l2); mv.visitLdcInsn(p_LdapAttribute.falseValue()[0]); mv.visitLabel(l3); mv.visitVarInsn(ASTORE, p_StartIndex + 4); }
From source file:ldapbeans.bean.LdapBeanClassManager.java
License:LGPL
/** * Generate a method of the generated class * /*from w w w . ja va 2s .co m*/ * @param p_MethodVisitor * The {@link MethodVisitor} of the generated method * @param p_ClassName * The name of the class * @param p_LdapAttribute * The LdapAttribute that will be used for generating the method * @param p_ReturnType * The type of the result */ private void generateMethodGetterLdapValue(MethodVisitor p_MethodVisitor, String p_ClassName, LdapAttribute p_LdapAttribute, Class<?> p_ReturnType) { MethodVisitor mv = p_MethodVisitor; String attributeName = p_LdapAttribute.value(); Label l0 = new Label(); Label l1 = new Label(); Label l2 = new Label(); mv.visitTryCatchBlock(l0, l1, l2, "javax/naming/NamingException"); // Attributes attributes = m_LdapObject.getAttributes(); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, INTERNAL_PACKAGE_NAME + '/' + p_ClassName, "m_LdapObject", "Lldapbeans/bean/LdapObject;"); mv.visitMethodInsn(INVOKEVIRTUAL, "ldapbeans/bean/LdapObject", "getAttributes", "()Ljavax/naming/directory/Attributes;"); mv.visitVarInsn(ASTORE, 3); // Attribute attribute = attributes.get("attributeName"); mv.visitVarInsn(ALOAD, 3); mv.visitLdcInsn(attributeName); mv.visitMethodInsn(INVOKEINTERFACE, "javax/naming/directory/Attributes", "get", "(Ljava/lang/String;)Ljavax/naming/directory/Attribute;"); mv.visitVarInsn(ASTORE, 4); // try { mv.visitLabel(l0); // if (attribute != null) { Label l3 = new Label(); mv.visitVarInsn(ALOAD, 4); mv.visitJumpInsn(IFNULL, l3); generateMethodGetterAssignResult(mv, p_ClassName, p_LdapAttribute, p_ReturnType); // } mv.visitLabel(l1); mv.visitJumpInsn(GOTO, l3); // } catch(NamingException e) { mv.visitLabel(l2); mv.visitVarInsn(ASTORE, 5); // throw new IllegalArgumentException() // TODO: change the message generateThrowingIllegalArgumentException(p_MethodVisitor, "Error when trying to get value"); // } mv.visitLabel(l3); }
From source file:ldapbeans.bean.LdapBeanClassManager.java
License:LGPL
/** * Generate a portion of a method of the generated class * // w w w .ja v a 2 s. c om * @param p_MethodVisitor * The {@link MethodVisitor} of the generated method * @param p_ClassName * Name of the generated class * @param p_LdapAttribute * The LdapAttribute that will be used for generating the method * @param p_ReturnType * The type of the result */ private void generateMethodGetterAssignResultCollection(MethodVisitor p_MethodVisitor, String p_ClassName, LdapAttribute p_LdapAttribute, Class<?> p_ReturnType) { MethodVisitor mv = p_MethodVisitor; // NamingEnumeration<?> enumeration = attribute.getAll(); mv.visitVarInsn(ALOAD, 4); mv.visitMethodInsn(INVOKEINTERFACE, "javax/naming/directory/Attribute", "getAll", "()Ljavax/naming/NamingEnumeration;"); mv.visitVarInsn(ASTORE, 5); // result = new [Collection](attribute.size()); generateMethodGetterInitializeResult(p_MethodVisitor, p_ReturnType); // while (enumeration.hasMoreElements()) { Label l4 = new Label(); mv.visitLabel(l4); mv.visitVarInsn(ALOAD, 5); mv.visitMethodInsn(INVOKEINTERFACE, "javax/naming/NamingEnumeration", "hasMoreElements", "()Z"); Label l5 = new Label(); mv.visitJumpInsn(IFEQ, l5); // result.add(enumeration.nextElement()); mv.visitVarInsn(ALOAD, 5); mv.visitMethodInsn(INVOKEINTERFACE, "javax/naming/NamingEnumeration", "nextElement", "()Ljava/lang/Object;"); mv.visitVarInsn(ASTORE, 6); generateConvert(p_MethodVisitor, p_ClassName, p_LdapAttribute, p_LdapAttribute.componentType(), 6, 7); mv.visitVarInsn(ALOAD, 1); mv.visitVarInsn(ALOAD, 7); mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Collection", "add", "(Ljava/lang/Object;)Z"); mv.visitInsn(POP); // } mv.visitJumpInsn(GOTO, l4); mv.visitLabel(l5); // enumeration.close(); mv.visitVarInsn(ALOAD, 5); mv.visitMethodInsn(INVOKEINTERFACE, "javax/naming/NamingEnumeration", "close", "()V"); }
From source file:ldapbeans.bean.LdapBeanClassManager.java
License:LGPL
/** * Generate a portion of a method of the generated class * //from www . j a v a 2 s. c o m * @param p_MethodVisitor * The {@link MethodVisitor} of the generated method * @param p_ClassName * Name of the generated class * @param p_LdapAttribute * The LdapAttribute that will be used for generating the method * @param p_ReturnType * The type of the result */ private void generateMethodGetterAssignResultArray(MethodVisitor p_MethodVisitor, String p_ClassName, LdapAttribute p_LdapAttribute, Class<?> p_ReturnType) { MethodVisitor mv = p_MethodVisitor; // NamingEnumeration<?> enumeration = attribute.getAll(); mv.visitVarInsn(ALOAD, 4); mv.visitMethodInsn(INVOKEINTERFACE, "javax/naming/directory/Attribute", "getAll", "()Ljavax/naming/NamingEnumeration;"); mv.visitVarInsn(ASTORE, 5); // result = new Object[attribute.size()]; generateMethodGetterInitializeResult(p_MethodVisitor, p_ReturnType); // int i = 0; mv.visitInsn(ICONST_0); mv.visitVarInsn(ISTORE, 6); // while (enumeration.hasMoreElements()) { Label l4 = new Label(); mv.visitLabel(l4); mv.visitVarInsn(ALOAD, 5); mv.visitMethodInsn(INVOKEINTERFACE, "javax/naming/NamingEnumeration", "hasMoreElements", "()Z"); Label l5 = new Label(); mv.visitJumpInsn(IFEQ, l5); // tmp = enumeration.nextElement(); mv.visitVarInsn(ALOAD, 5); mv.visitMethodInsn(INVOKEINTERFACE, "javax/naming/NamingEnumeration", "nextElement", "()Ljava/lang/Object;"); mv.visitVarInsn(ASTORE, 7); generateConvert(p_MethodVisitor, p_ClassName, p_LdapAttribute, p_ReturnType.getComponentType(), 7, 8); // result[i++] = tmp; mv.visitVarInsn(ALOAD, 1); mv.visitVarInsn(ILOAD, 6); mv.visitIincInsn(6, 1); mv.visitVarInsn(ALOAD, 8); mv.visitInsn(AASTORE); // } mv.visitJumpInsn(GOTO, l4); mv.visitLabel(l5); // enumeration.close(); mv.visitVarInsn(ALOAD, 5); mv.visitMethodInsn(INVOKEINTERFACE, "javax/naming/NamingEnumeration", "close", "()V"); }
From source file:ldapbeans.bean.LdapBeanClassManager.java
License:LGPL
/** * Generate code to convert ldapAttribute witch is on the to of the stack to * the type of the result/*from w w w. ja va2 s . c om*/ * * @param p_MethodVisitor * The {@link MethodVisitor} of the generated method * @param p_ClassName * Name of the generated class * @param p_LdapAttribute * The LdapAttribute that will be used for generating the method * @param p_ReturnType * The type of the result * @param p_Object * Index of the object to convert on the stack * @param p_Result * Index of the converted object on the stack */ private void generateConvert(MethodVisitor p_MethodVisitor, String p_ClassName, LdapAttribute p_LdapAttribute, Class<?> p_ReturnType, int p_Object, int p_Result) { MethodVisitor mv = p_MethodVisitor; Label l0 = new Label(); Label l1 = new Label(); if (p_ReturnType != null) { // if(value != null) { mv.visitVarInsn(ALOAD, p_Object); mv.visitJumpInsn(IFNULL, l0); if (String.class.isAssignableFrom(p_ReturnType)) { generateConvertToString(p_MethodVisitor, p_ClassName, p_ReturnType, p_Object, p_Result); } else if (LdapBean.class.isAssignableFrom(p_ReturnType)) { generateConvertToLdapBean(p_MethodVisitor, p_ClassName, p_LdapAttribute, p_ReturnType, p_Object, p_Result); } else if (boolean.class.isAssignableFrom(p_ReturnType) || Boolean.class.isAssignableFrom(p_ReturnType)) { generateConvertToBoolean(p_MethodVisitor, p_ClassName, p_LdapAttribute, p_ReturnType, p_Object, p_Result); } else if (Number.class.isAssignableFrom(p_ReturnType)) { generateConvertToNumber(p_MethodVisitor, p_ClassName, p_LdapAttribute, p_ReturnType, p_Object, p_Result); } else if (p_ReturnType.isPrimitive()) { generateConvertToPrimitive(p_MethodVisitor, p_ClassName, p_LdapAttribute, p_ReturnType, p_Object, p_Result); } else if (Character.class.isAssignableFrom(p_ReturnType)) { // result = Character.valueOf(object.toString().charAt(0)); mv.visitVarInsn(ALOAD, p_Object); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Object", "toString", "()Ljava/lang/String;"); mv.visitInsn(ICONST_0); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "charAt", "(I)C"); mv.visitMethodInsn(INVOKESTATIC, "java/lang/Character", "valueOf", "(C)Ljava/lang/Character;"); mv.visitVarInsn(ASTORE, p_Result); } else { mv.visitVarInsn(ALOAD, p_Object); mv.visitVarInsn(ASTORE, p_Result); } // } else { mv.visitJumpInsn(GOTO, l1); mv.visitLabel(l0); // result = null; generateDefaultValue(p_MethodVisitor, p_ReturnType, p_Result); // } mv.visitLabel(l1); } else { generateConvertToLdapBean(p_MethodVisitor, p_ClassName, p_LdapAttribute, null, p_Object, p_Result); } }
From source file:ldapbeans.bean.LdapBeanClassManager.java
License:LGPL
/** * Generate code to convert ldapAttribute witch is on the top of the stack * to LdapBean/*from w w w .j a va 2 s.c o m*/ * * @param p_MethodVisitor * The {@link MethodVisitor} of the generated method * @param p_ClassName * Name of the generated class * @param p_LdapAttribute * The LdapAttribute that will be used for generating the method * @param p_ReturnType * The type of the result * @param p_Object * Index of the object to convert on the stack * @param p_Result * Index of the converted object on the stack */ private void generateConvertToLdapBean(MethodVisitor p_MethodVisitor, String p_ClassName, LdapAttribute p_LdapAttribute, Class<?> p_ReturnType, int p_Object, int p_Result) { MethodVisitor mv = p_MethodVisitor; Label l1 = new Label(); Label l0 = new Label(); // if(object == null) { mv.visitVarInsn(ALOAD, p_Object); mv.visitJumpInsn(IFNULL, l0); // result = m_LdapBeanManager.searchFirst(p_ReturnType, // "search_filter"); mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, INTERNAL_PACKAGE_NAME + '/' + p_ClassName, "m_LdapBeanManager", "Lldapbeans/bean/LdapBeanManager;"); if (p_ReturnType != null) { mv.visitLdcInsn(Type.getType(p_ReturnType)); } else { mv.visitInsn(ACONST_NULL); } if (p_LdapAttribute.search().length() == 0) { mv.visitVarInsn(ALOAD, p_Object); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Object", "toString", "()Ljava/lang/String;"); mv.visitMethodInsn(INVOKEVIRTUAL, "ldapbeans/bean/LdapBeanManager", "findByDn", "(Ljava/lang/Class;Ljava/lang/String;)" + "Lldapbeans/bean/LdapBean;"); } else { mv.visitLdcInsn(p_LdapAttribute.search()); if (p_LdapAttribute.pattern().length() != 0) { // regExpGroup = StringUtil.getRegexpGroup(object.toString(), // pattern) mv.visitVarInsn(ALOAD, p_Object); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Object", "toString", "()Ljava/lang/String;"); mv.visitLdcInsn(p_LdapAttribute.pattern()); mv.visitMethodInsn(INVOKESTATIC, "ldapbeans/util/StringUtil", "getRegexpGroup", "(Ljava/lang/String;Ljava/lang/String;)" + "[Ljava/lang/String;"); } else { // regExpGroup = new Object[] { object } mv.visitInsn(ICONST_1); mv.visitTypeInsn(ANEWARRAY, "java/lang/Object"); mv.visitInsn(DUP); mv.visitInsn(ICONST_0); mv.visitVarInsn(ALOAD, p_Object); mv.visitInsn(AASTORE); } // searchFilter = StringUtil.format("search_filter", regExpGroup); mv.visitMethodInsn(INVOKESTATIC, "ldapbeans/util/StringUtil", "format", "(Ljava/lang/String;[Ljava/lang/Object;)" + "Ljava/lang/String;"); // result = m_LdapBeanManager.searchFirst(foo.class, searchFilter); mv.visitMethodInsn(INVOKEVIRTUAL, "ldapbeans/bean/LdapBeanManager", "searchFirst", "(Ljava/lang/Class;Ljava/lang/String;)" + "Lldapbeans/bean/LdapBean;"); } mv.visitVarInsn(ASTORE, p_Result); // } else { mv.visitJumpInsn(GOTO, l1); mv.visitLabel(l0); // result = null; mv.visitInsn(ACONST_NULL); mv.visitVarInsn(ASTORE, p_Result); // } mv.visitLabel(l1); }