當前位置: 首頁>>代碼示例>>Java>>正文


Java Annotation.addMemberValue方法代碼示例

本文整理匯總了Java中javassist.bytecode.annotation.Annotation.addMemberValue方法的典型用法代碼示例。如果您正苦於以下問題:Java Annotation.addMemberValue方法的具體用法?Java Annotation.addMemberValue怎麽用?Java Annotation.addMemberValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javassist.bytecode.annotation.Annotation的用法示例。


在下文中一共展示了Annotation.addMemberValue方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getEntityListeners

import javassist.bytecode.annotation.Annotation; //導入方法依賴的package包/類
protected Annotation getEntityListeners(ConstPool constantPool, Annotation existingEntityListeners, Annotation templateEntityListeners) {
    Annotation listeners = new Annotation(EntityListeners.class.getName(), constantPool);
    ArrayMemberValue listenerArray = new ArrayMemberValue(constantPool);
    Set<MemberValue> listenerMemberValues = new HashSet<MemberValue>();
    {
        ArrayMemberValue templateListenerValues = (ArrayMemberValue) templateEntityListeners.getMemberValue("value");
        listenerMemberValues.addAll(Arrays.asList(templateListenerValues.getValue()));
        logger.debug("Adding template values to new EntityListeners");
    }
    if (existingEntityListeners != null) {
        ArrayMemberValue oldListenerValues = (ArrayMemberValue) existingEntityListeners.getMemberValue("value");
        listenerMemberValues.addAll(Arrays.asList(oldListenerValues.getValue()));
        logger.debug("Adding previous values to new EntityListeners");
    }
    listenerArray.setValue(listenerMemberValues.toArray(new MemberValue[listenerMemberValues.size()]));
    listeners.addMemberValue("value", listenerArray);

    return listeners;

}
 
開發者ID:passion1014,項目名稱:metaworks_framework,代碼行數:21,代碼來源:DirectCopyClassTransformer.java

示例2: addAnnotation

import javassist.bytecode.annotation.Annotation; //導入方法依賴的package包/類
public void addAnnotation(Class<?> type, Class<?>... values) {
	ClassFile cf = cc.getClassFile();
	ConstPool cp = cf.getConstPool();
	ClassMemberValue[] elements = new ClassMemberValue[values.length];
	for (int i = 0; i < values.length; i++) {
		elements[i] = cb.createClassMemberValue(values[i], cp);
	}
	ArrayMemberValue value = new ArrayMemberValue(cp);
	value.setValue(elements);
	AnnotationsAttribute ai = (AnnotationsAttribute) cf
			.getAttribute(visibleTag);
	if (ai == null) {
		ai = new AnnotationsAttribute(cp, visibleTag);
		cf.addAttribute(ai);
	}
	try {
		Annotation annotation = new Annotation(cp, get(type));
		annotation.addMemberValue("value", value);
		ai.addAnnotation(annotation);
	} catch (NotFoundException e) {
		throw new AssertionError(e);
	}
}
 
開發者ID:anno4j,項目名稱:anno4j,代碼行數:24,代碼來源:ClassTemplate.java

示例3: href

import javassist.bytecode.annotation.Annotation; //導入方法依賴的package包/類
@Override
public DynamicField href(boolean click, String... value) {
	Annotation annot = new Annotation(Href.class.getName(), cpool);
       annot.addMemberValue("click", new BooleanMemberValue(click, cpool));
       
       ArrayMemberValue arrayMemberValue = new ArrayMemberValue(cpool);
       MemberValue[] memberValues = new StringMemberValue[value.length];
       for(int i = 0; i < value.length; i++) {
       	memberValues[i] = new StringMemberValue(value[i], cpool);
       }
       arrayMemberValue.setValue(memberValues);
       annot.addMemberValue("value", arrayMemberValue);
       
       attr.addAnnotation(annot);
	return this;
}
 
開發者ID:xtuhcy,項目名稱:gecco,代碼行數:17,代碼來源:JavassistDynamicField.java

示例4: image

import javassist.bytecode.annotation.Annotation; //導入方法依賴的package包/類
@Override
public DynamicField image(String download, String... value) {
	Annotation annot = new Annotation(Image.class.getName(), cpool);
       annot.addMemberValue("download", new StringMemberValue(download, cpool));
       
       ArrayMemberValue arrayMemberValue = new ArrayMemberValue(cpool);
       MemberValue[] memberValues = new StringMemberValue[value.length];
       for(int i = 0; i < value.length; i++) {
       	memberValues[i] = new StringMemberValue(value[i], cpool);
       }
       arrayMemberValue.setValue(memberValues);
       annot.addMemberValue("value", arrayMemberValue);
       
       attr.addAnnotation(annot);
	return this;
}
 
開發者ID:xtuhcy,項目名稱:gecco,代碼行數:17,代碼來源:JavassistDynamicField.java

示例5: addMimicAnnotation

import javassist.bytecode.annotation.Annotation; //導入方法依賴的package包/類
private void addMimicAnnotation(CtClass dst, String sourceClassName,
        boolean isMimicingInterfaces, boolean isMimicingFields,
        boolean isMimicingConstructors, boolean isMimicingMethods) {
    ClassFile cf = dst.getClassFile();
    ConstPool cp = cf.getConstPool();
    AnnotationsAttribute attr = new AnnotationsAttribute(cp,
            AnnotationsAttribute.visibleTag);

    Annotation a = new Annotation(Mimic.class.getName(), cp);
    a.addMemberValue("sourceClass", new ClassMemberValue(sourceClassName,
            cp));
    a.addMemberValue("isMimicingInterfaces", new BooleanMemberValue(
            isMimicingInterfaces, cp));
    a.addMemberValue("isMimicingFields", new BooleanMemberValue(
            isMimicingFields, cp));
    a.addMemberValue("isMimicingConstructors", new BooleanMemberValue(
            isMimicingConstructors, cp));
    a.addMemberValue("isMimicingMethods", new BooleanMemberValue(
            isMimicingMethods, cp));
    attr.setAnnotation(a);
    cf.addAttribute(attr);
    cf.setVersionToJava5();
}
 
開發者ID:stephanenicolas,項目名稱:mimic,代碼行數:24,代碼來源:MimicProcessorTest.java

示例6: createJavassistAnnotation

import javassist.bytecode.annotation.Annotation; //導入方法依賴的package包/類
public static Annotation createJavassistAnnotation(ConstPool constpool,
		java.lang.annotation.Annotation annotation)
		throws CannotBuildClassException {

	Annotation annotationCopy = new Annotation(annotation.annotationType()
			.getName(), constpool);
	for (Method m : annotation.annotationType().getDeclaredMethods()) {
		try {
			Object value = m.invoke(annotation);
			annotationCopy.addMemberValue(m.getName(),
					JavassistUtils.createMemberValue(value, constpool));
		} catch (IllegalAccessException | IllegalArgumentException
				| InvocationTargetException e) {
			e.printStackTrace();
			throw new CannotBuildClassException(
					"Could not copy info from annotation "
							+ annotation.annotationType().getName());
		}
	}
	return annotationCopy;
}
 
開發者ID:qzagarese,項目名稱:hyaline-dto,代碼行數:22,代碼來源:JavassistUtils.java

示例7: addEndpointMapping

import javassist.bytecode.annotation.Annotation; //導入方法依賴的package包/類
@Override
protected void addEndpointMapping(CtMethod ctMethod, String method, String request) {
	MethodInfo methodInfo = ctMethod.getMethodInfo();
	ConstPool constPool = methodInfo.getConstPool();

	AnnotationsAttribute attr = new AnnotationsAttribute(constPool, AnnotationsAttribute.visibleTag);
	Annotation requestMapping = new Annotation(RequestMapping.class.getName(), constPool);

	ArrayMemberValue valueVals = new ArrayMemberValue(constPool);
	StringMemberValue valueVal = new StringMemberValue(constPool);
	valueVal.setValue(request);
	valueVals.setValue(new MemberValue[]{valueVal});

	requestMapping.addMemberValue("value", valueVals);

	ArrayMemberValue methodVals = new ArrayMemberValue(constPool);
	EnumMemberValue methodVal = new EnumMemberValue(constPool);
	methodVal.setType(RequestMethod.class.getName());
	methodVal.setValue(method);
	methodVals.setValue(new MemberValue[]{methodVal});

	requestMapping.addMemberValue("method", methodVals);
	attr.addAnnotation(requestMapping);
	methodInfo.addAttribute(attr);
}
 
開發者ID:statefulj,項目名稱:statefulj,代碼行數:26,代碼來源:SpringMVCBinder.java

示例8: addClassAnnotation

import javassist.bytecode.annotation.Annotation; //導入方法依賴的package包/類
public static void addClassAnnotation(CtClass clazz, Class<?> annotationClass, Object... values) {
	ClassFile ccFile = clazz.getClassFile();
	ConstPool constPool = ccFile.getConstPool();
	AnnotationsAttribute attr = getAnnotationsAttribute(ccFile);
	Annotation annot = new Annotation(annotationClass.getName(), constPool);
	
	for(int i = 0; i < values.length; i = i + 2) {
		String valueName = (String)values[i];
		Object value = values[i+1];
		if (valueName != null && value != null) {
			MemberValue memberValue = createMemberValue(constPool, value);
			annot.addMemberValue(valueName, memberValue);
		}
	}
	
	attr.addAnnotation(annot);
}
 
開發者ID:statefulj,項目名稱:statefulj,代碼行數:18,代碼來源:JavassistUtils.java

示例9: addIdParameter

import javassist.bytecode.annotation.Annotation; //導入方法依賴的package包/類
protected Annotation[] addIdParameter(
		CtMethod ctMethod, 
		Class<?> idType,
		ClassPool cp) throws NotFoundException, CannotCompileException {
	// Clone the parameter Class
	//
	CtClass ctParm = cp.get(idType.getName());
	
	// Add the parameter to the method
	//
	ctMethod.addParameter(ctParm);
	
	// Add the Parameter Annotations to the Method
	//
	MethodInfo methodInfo = ctMethod.getMethodInfo();
	ConstPool constPool = methodInfo.getConstPool();
	Annotation annot = new Annotation(getPathAnnotationClass().getName(), constPool);
	
	StringMemberValue valueVal = new StringMemberValue("id", constPool); 
	annot.addMemberValue("value", valueVal);
	
	return new Annotation[]{ annot };
}
 
開發者ID:statefulj,項目名稱:statefulj,代碼行數:24,代碼來源:AbstractRestfulBinder.java

示例10: annotateMethod

import javassist.bytecode.annotation.Annotation; //導入方法依賴的package包/類
private AnnotationsAttribute annotateMethod(
		CtMethod ctmethod,
		String annotationName,
		int annotationValue ) {
	AnnotationsAttribute attr = new AnnotationsAttribute(
			ctmethod.getMethodInfo().getConstPool(),
			AnnotationsAttribute.visibleTag);
	Annotation anno = new Annotation(
			"java.lang.Integer",
			ctmethod.getMethodInfo().getConstPool());
	anno.addMemberValue(
			annotationName,
			new IntegerMemberValue(
					ctmethod.getMethodInfo().getConstPool(),
					annotationValue));
	attr.addAnnotation(anno);

	ctmethod.getMethodInfo().addAttribute(
			attr);

	return attr;
}
 
開發者ID:locationtech,項目名稱:geowave,代碼行數:23,代碼來源:JavassistUtilsTest.java

示例11: annotateField

import javassist.bytecode.annotation.Annotation; //導入方法依賴的package包/類
private void annotateField(
		CtField ctfield,
		String annotationName,
		int annotationValue ) {
	AnnotationsAttribute attr = new AnnotationsAttribute(
			ctfield.getFieldInfo().getConstPool(),
			AnnotationsAttribute.visibleTag);
	Annotation anno = new Annotation(
			"java.lang.Integer",
			ctfield.getFieldInfo().getConstPool());
	anno.addMemberValue(
			annotationName,
			new IntegerMemberValue(
					ctfield.getFieldInfo().getConstPool(),
					annotationValue));
	attr.addAnnotation(anno);

	ctfield.getFieldInfo().addAttribute(
			attr);
}
 
開發者ID:locationtech,項目名稱:geowave,代碼行數:21,代碼來源:JavassistUtilsTest.java

示例12: copyAnnotation

import javassist.bytecode.annotation.Annotation; //導入方法依賴的package包/類
/**
 * @param classPool class pool to use
 * @param constPool constants pool
 * @param ann       annotation to copy
 * @return javassist annotation object (copy of original annotation)
 * @throws Exception on errors
 */
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
public static Annotation copyAnnotation(final ClassPool classPool, final ConstPool constPool,
                                        final java.lang.annotation.Annotation ann) throws Exception {
    final Class<? extends java.lang.annotation.Annotation> annotationType = ann.annotationType();
    final Annotation copy = new Annotation(annotationType.getName(), constPool);
    final Method[] methods = annotationType.getDeclaredMethods();
    for (final Method method : methods) {
        final CtClass ctType = classPool.get(method.getReturnType().getName());
        final MemberValue memberValue = Annotation.createMemberValue(constPool, ctType);
        final Object value = method.invoke(ann);
        memberValue.accept(new AnnotationMemberValueVisitor(classPool, constPool, value));
        copy.addMemberValue(method.getName(), memberValue);
    }
    return copy;
}
 
開發者ID:xvik,項目名稱:guice-ext-annotations,代碼行數:23,代碼來源:JavassistUtils.java

示例13: xmlRootElement

import javassist.bytecode.annotation.Annotation; //導入方法依賴的package包/類
/**
 * Create new <tt>XmlRootElement</tt> annotation.
 * @param file Javassist file to work with
 * @param name Name of root element
 * @return The annotation
 */
private static Annotation xmlRootElement(final ClassFile file,
    final String name) {
    final AnnotationsAttribute attribute = AnnotationsAttribute.class.cast(
        file.getAttribute(AnnotationsAttribute.visibleTag)
    );
    final Annotation annotation = attribute.getAnnotation(
        XmlRootElement.class.getName()
    );
    annotation.addMemberValue(
        "name",
        new StringMemberValue(name, file.getConstPool())
    );
    Logger.debug(
        JaxbGroup.class,
        "#xmlRootElement(.., '%s'): annotation created",
        name
    );
    return annotation;
}
 
開發者ID:yegor256,項目名稱:rexsl,代碼行數:26,代碼來源:JaxbGroup.java

示例14: addParamAnnotations

import javassist.bytecode.annotation.Annotation; //導入方法依賴的package包/類
@Override
protected void addParamAnnotations(CtMethod ctMethod) {
	Annotation[][] annotations = new Annotation[4][1];
	Annotation headersParam = new Annotation(Context.class.getCanonicalName(), ctMethod.getMethodInfo().getConstPool());
	annotations[0][0] = headersParam;
	Annotation uriInfoParam = new Annotation(Context.class.getCanonicalName(), ctMethod.getMethodInfo().getConstPool());
	annotations[1][0] = uriInfoParam;
	Annotation providersParam = new Annotation(Context.class.getCanonicalName(), ctMethod.getMethodInfo().getConstPool());
	annotations[2][0] = providersParam;
	Annotation apiParam = new Annotation(ApiParam.class.getCanonicalName(), ctMethod.getMethodInfo().getConstPool());
	apiParam.addMemberValue("name", new StringMemberValue("body", ctMethod.getMethodInfo().getConstPool()));
	apiParam.addMemberValue("access", new StringMemberValue("internal", ctMethod.getMethodInfo().getConstPool()));
	apiParam.addMemberValue("paramType", new StringMemberValue("body", ctMethod.getMethodInfo().getConstPool()));
	annotations[3][0] = apiParam;
	JavassistUtils.addParameterAnnotation(ctMethod, annotations);
}
 
開發者ID:minnal,項目名稱:minnal,代碼行數:17,代碼來源:CreateMethodCreator.java

示例15: getApiPathParamAnnotations

import javassist.bytecode.annotation.Annotation; //導入方法依賴的package包/類
/**
 * Returns the api path parameter annotations
 * 
 * @return
 */
protected List<Annotation> getApiPathParamAnnotations() {
	List<Annotation> annotations = new ArrayList<Annotation>();
	List<String> parameters = getRoutePattern().getParameterNames();
	for (int i = 0; i < parameters.size(); i++) {
		Annotation annotation = new Annotation(ApiImplicitParam.class.getCanonicalName(), ctClass.getClassFile().getConstPool());
		annotation.addMemberValue("name", new StringMemberValue(parameters.get(i), ctClass.getClassFile().getConstPool()));
		annotation.addMemberValue("paramType", new StringMemberValue("path", ctClass.getClassFile().getConstPool()));
		annotation.addMemberValue("dataType", new StringMemberValue(String.class.getCanonicalName(), ctClass.getClassFile().getConstPool()));
		annotation.addMemberValue("value", new StringMemberValue("The " + getResourcePath().getNodePath().get(i).getEntityMetaData().getName() + " identifier", ctClass.getClassFile().getConstPool()));
		annotation.addMemberValue("required", new BooleanMemberValue(true, ctClass.getClassFile().getConstPool()));
		if (i == parameters.size() - 1) {
			annotation.addMemberValue("allowMultiple", new BooleanMemberValue(true, ctClass.getClassFile().getConstPool()));
		}
		annotations.add(annotation);
	}
	return annotations;
}
 
開發者ID:minnal,項目名稱:minnal,代碼行數:23,代碼來源:AbstractMethodCreator.java


注:本文中的javassist.bytecode.annotation.Annotation.addMemberValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。