当前位置: 首页>>代码示例>>Java>>正文


Java IntegerMemberValue类代码示例

本文整理汇总了Java中javassist.bytecode.annotation.IntegerMemberValue的典型用法代码示例。如果您正苦于以下问题:Java IntegerMemberValue类的具体用法?Java IntegerMemberValue怎么用?Java IntegerMemberValue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IntegerMemberValue类属于javassist.bytecode.annotation包,在下文中一共展示了IntegerMemberValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCloneAnnotationsAttribute

import javassist.bytecode.annotation.IntegerMemberValue; //导入依赖的package包/类
@Test
public void testCloneAnnotationsAttribute() {
	CtClass clz = ClassPool.getDefault().makeClass(
			"testCloneAnnotationsAttribute");
	CtMethod ctmethod = addNewMethod(
			clz,
			"origMethod");
	AnnotationsAttribute attr = annotateMethod(
			ctmethod,
			"origAnno",
			135);

	AnnotationsAttribute clonedAttr = JavassistUtils.cloneAnnotationsAttribute(
			ctmethod.getMethodInfo().getConstPool(),
			attr,
			java.lang.annotation.ElementType.METHOD);

	Assert.assertEquals(
			135,
			((IntegerMemberValue) clonedAttr.getAnnotation(
					"java.lang.Integer").getMemberValue(
					"origAnno")).getValue());
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:24,代码来源:JavassistUtilsTest.java

示例2: annotateMethod

import javassist.bytecode.annotation.IntegerMemberValue; //导入依赖的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

示例3: annotateField

import javassist.bytecode.annotation.IntegerMemberValue; //导入依赖的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

示例4: createMemberValue

import javassist.bytecode.annotation.IntegerMemberValue; //导入依赖的package包/类
private static MemberValue createMemberValue(ConstPool cp, CtClass type, Object value) throws NotFoundException {
    MemberValue memberValue = javassist.bytecode.annotation.Annotation.createMemberValue(cp, type);
    if (memberValue instanceof BooleanMemberValue)
        ((BooleanMemberValue) memberValue).setValue((Boolean) value);
    else if (memberValue instanceof ByteMemberValue)
        ((ByteMemberValue) memberValue).setValue((Byte) value);
    else if (memberValue instanceof CharMemberValue)
        ((CharMemberValue) memberValue).setValue((Character) value);
    else if (memberValue instanceof ShortMemberValue)
        ((ShortMemberValue) memberValue).setValue((Short) value);
    else if (memberValue instanceof IntegerMemberValue)
        ((IntegerMemberValue) memberValue).setValue((Integer) value);
    else if (memberValue instanceof LongMemberValue)
        ((LongMemberValue) memberValue).setValue((Long) value);
    else if (memberValue instanceof FloatMemberValue)
        ((FloatMemberValue) memberValue).setValue((Float) value);
    else if (memberValue instanceof DoubleMemberValue)
        ((DoubleMemberValue) memberValue).setValue((Double) value);
    else if (memberValue instanceof ClassMemberValue)
        ((ClassMemberValue) memberValue).setValue(((Class<?>)value).getName());
    else if (memberValue instanceof StringMemberValue)
        ((StringMemberValue) memberValue).setValue((String) value);
    else if (memberValue instanceof EnumMemberValue) 
        ((EnumMemberValue) memberValue).setValue(((Enum<?>) value).name());
    /* else if (memberValue instanceof AnnotationMemberValue) */
    else if (memberValue instanceof ArrayMemberValue) {
        CtClass arrayType = type.getComponentType();
        int len = Array.getLength(value);
        MemberValue[] members = new MemberValue[len];
        for (int i = 0; i < len; i ++) {
            members[i] = createMemberValue(cp, arrayType, Array.get(value, i));
        }
        ((ArrayMemberValue) memberValue).setValue(members);
    }
    return memberValue;
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:37,代码来源:JValidator.java

示例5: createMemberValue

import javassist.bytecode.annotation.IntegerMemberValue; //导入依赖的package包/类
private static MemberValue createMemberValue(ConstPool cp, CtClass type, Object value) throws NotFoundException {
    MemberValue memberValue = javassist.bytecode.annotation.Annotation.createMemberValue(cp, type);
    if (memberValue instanceof BooleanMemberValue)
        ((BooleanMemberValue) memberValue).setValue((Boolean) value);
    else if (memberValue instanceof ByteMemberValue)
        ((ByteMemberValue) memberValue).setValue((Byte) value);
    else if (memberValue instanceof CharMemberValue)
        ((CharMemberValue) memberValue).setValue((Character) value);
    else if (memberValue instanceof ShortMemberValue)
        ((ShortMemberValue) memberValue).setValue((Short) value);
    else if (memberValue instanceof IntegerMemberValue)
        ((IntegerMemberValue) memberValue).setValue((Integer) value);
    else if (memberValue instanceof LongMemberValue)
        ((LongMemberValue) memberValue).setValue((Long) value);
    else if (memberValue instanceof FloatMemberValue)
        ((FloatMemberValue) memberValue).setValue((Float) value);
    else if (memberValue instanceof DoubleMemberValue)
        ((DoubleMemberValue) memberValue).setValue((Double) value);
    else if (memberValue instanceof ClassMemberValue)
        ((ClassMemberValue) memberValue).setValue(((Class<?>) value).getName());
    else if (memberValue instanceof StringMemberValue)
        ((StringMemberValue) memberValue).setValue((String) value);
    else if (memberValue instanceof EnumMemberValue)
        ((EnumMemberValue) memberValue).setValue(((Enum<?>) value).name());
    /* else if (memberValue instanceof AnnotationMemberValue) */
    else if (memberValue instanceof ArrayMemberValue) {
        CtClass arrayType = type.getComponentType();
        int len = Array.getLength(value);
        MemberValue[] members = new MemberValue[len];
        for (int i = 0; i < len; i++) {
            members[i] = createMemberValue(cp, arrayType, Array.get(value, i));
        }
        ((ArrayMemberValue) memberValue).setValue(members);
    }
    return memberValue;
}
 
开发者ID:tiglabs,项目名称:jsf-sdk,代码行数:37,代码来源:Jsr303Validator.java

示例6: createMemberValue

import javassist.bytecode.annotation.IntegerMemberValue; //导入依赖的package包/类
private static MemberValue createMemberValue(ConstPool cp, CtClass type, Object value) throws NotFoundException {
	MemberValue memberValue = javassist.bytecode.annotation.Annotation.createMemberValue(cp, type);
	if (memberValue instanceof BooleanMemberValue)
		((BooleanMemberValue) memberValue).setValue((Boolean) value);
	else if (memberValue instanceof ByteMemberValue)
		((ByteMemberValue) memberValue).setValue((Byte) value);
	else if (memberValue instanceof CharMemberValue)
		((CharMemberValue) memberValue).setValue((Character) value);
	else if (memberValue instanceof ShortMemberValue)
		((ShortMemberValue) memberValue).setValue((Short) value);
	else if (memberValue instanceof IntegerMemberValue)
		((IntegerMemberValue) memberValue).setValue((Integer) value);
	else if (memberValue instanceof LongMemberValue)
		((LongMemberValue) memberValue).setValue((Long) value);
	else if (memberValue instanceof FloatMemberValue)
		((FloatMemberValue) memberValue).setValue((Float) value);
	else if (memberValue instanceof DoubleMemberValue)
		((DoubleMemberValue) memberValue).setValue((Double) value);
	else if (memberValue instanceof ClassMemberValue)
		((ClassMemberValue) memberValue).setValue(((Class<?>) value).getName());
	else if (memberValue instanceof StringMemberValue)
		((StringMemberValue) memberValue).setValue((String) value);
	else if (memberValue instanceof EnumMemberValue)
		((EnumMemberValue) memberValue).setValue(((Enum<?>) value).name());
	/* else if (memberValue instanceof AnnotationMemberValue) */
	else if (memberValue instanceof ArrayMemberValue) {
		CtClass arrayType = type.getComponentType();
		int len = Array.getLength(value);
		MemberValue[] members = new MemberValue[len];
		for (int i = 0; i < len; i++) {
			members[i] = createMemberValue(cp, arrayType, Array.get(value, i));
		}
		((ArrayMemberValue) memberValue).setValue(members);
	}
	return memberValue;
}
 
开发者ID:nince-wyj,项目名称:jahhan,代码行数:37,代码来源:JValidator.java

示例7: gecco

import javassist.bytecode.annotation.IntegerMemberValue; //导入依赖的package包/类
@Override
public JavassistDynamicBean gecco(String[] matchUrl, String downloader, int timeout, String... pipelines) {
	AnnotationsAttribute attr = new AnnotationsAttribute(cpool, AnnotationsAttribute.visibleTag);

	Annotation annot = new Annotation(Gecco.class.getName(), cpool);
	// matchUrl
	//annot.addMemberValue("matchUrl", new StringMemberValue(matchUrl, cpool));
	ArrayMemberValue arrayMemberValueMatchUrl = new ArrayMemberValue(cpool);
	MemberValue[] elementMatchUrls = new StringMemberValue[matchUrl.length];
	for (int i = 0; i < matchUrl.length; i++) {
		elementMatchUrls[i] = new StringMemberValue(matchUrl[i], cpool);
	}
	arrayMemberValueMatchUrl.setValue(elementMatchUrls);
	annot.addMemberValue("matchUrl", arrayMemberValueMatchUrl);
	
	
	// downloader
	annot.addMemberValue("downloader", new StringMemberValue(downloader, cpool));
	// timeout
	annot.addMemberValue("timeout", new IntegerMemberValue(cpool, timeout));
	// pipelines
	ArrayMemberValue arrayMemberValue = new ArrayMemberValue(cpool);
	MemberValue[] elements = new StringMemberValue[pipelines.length];
	for (int i = 0; i < pipelines.length; i++) {
		elements[i] = new StringMemberValue(pipelines[i], cpool);
	}
	arrayMemberValue.setValue(elements);
	annot.addMemberValue("pipelines", arrayMemberValue);

	attr.addAnnotation(annot);
	cfile.addAttribute(attr);
	return this;
}
 
开发者ID:xtuhcy,项目名称:gecco,代码行数:34,代码来源:JavassistDynamicBean.java

示例8: testCopyClassAnnontations

import javassist.bytecode.annotation.IntegerMemberValue; //导入依赖的package包/类
@Test
public void testCopyClassAnnontations() {
	CtClass fromClass = ClassPool.getDefault().makeClass(
			"fromClass");
	CtClass toClass = ClassPool.getDefault().makeClass(
			"toClass");

	// Create class annotations
	ConstPool fromPool = fromClass.getClassFile().getConstPool();
	AnnotationsAttribute attr = new AnnotationsAttribute(
			fromPool,
			AnnotationsAttribute.visibleTag);
	Annotation anno = new Annotation(
			"java.lang.Integer",
			fromPool);
	anno.addMemberValue(
			"copyClassName",
			new IntegerMemberValue(
					fromPool,
					246));
	attr.addAnnotation(anno);
	fromClass.getClassFile().addAttribute(
			attr);

	JavassistUtils.copyClassAnnotations(
			fromClass,
			toClass);

	Annotation toAnno = ((AnnotationsAttribute) toClass.getClassFile().getAttribute(
			AnnotationsAttribute.visibleTag)).getAnnotation("java.lang.Integer");

	Assert.assertEquals(
			246,
			((IntegerMemberValue) toAnno.getMemberValue("copyClassName")).getValue());
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:36,代码来源:JavassistUtilsTest.java

示例9: testGenerateEmptyClass

import javassist.bytecode.annotation.IntegerMemberValue; //导入依赖的package包/类
@Test
public void testGenerateEmptyClass() {
	CtClass emptyClass = JavassistUtils.generateEmptyClass();
	CtClass anotherEmptyClass = JavassistUtils.generateEmptyClass();

	Assert.assertFalse(emptyClass.equals(anotherEmptyClass));

	// test empty class works as expected
	CtMethod method = addNewMethod(
			emptyClass,
			"a");
	annotateMethod(
			method,
			"abc",
			7);
	CtField field = addNewField(
			emptyClass,
			"d");
	annotateField(
			field,
			"def",
			9);

	Assert.assertEquals(
			7,
			((IntegerMemberValue) ((AnnotationsAttribute) method.getMethodInfo().getAttribute(
					AnnotationsAttribute.visibleTag)).getAnnotation(
					"java.lang.Integer").getMemberValue(
					"abc")).getValue());

	Assert.assertEquals(
			9,
			((IntegerMemberValue) ((AnnotationsAttribute) field.getFieldInfo().getAttribute(
					AnnotationsAttribute.visibleTag)).getAnnotation(
					"java.lang.Integer").getMemberValue(
					"def")).getValue());
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:38,代码来源:JavassistUtilsTest.java

示例10: getOkResponseAnnotation

import javassist.bytecode.annotation.IntegerMemberValue; //导入依赖的package包/类
/**
 * Returns the 200 ok response annotation
 * 
 * @param responseClass
 * @return
 */
protected Annotation getOkResponseAnnotation(Class<?> responseClass) {
	ConstPool constPool = ctClass.getClassFile().getConstPool();
	Annotation annotation = new Annotation(ApiResponse.class.getCanonicalName(), constPool);
	IntegerMemberValue code = new IntegerMemberValue(constPool);
	code.setValue(Response.Status.OK.getStatusCode());
	annotation.addMemberValue("code", code);
	annotation.addMemberValue("message", new StringMemberValue(Response.Status.OK.getReasonPhrase(), constPool));
	annotation.addMemberValue("response", new ClassMemberValue(responseClass.getCanonicalName(), constPool));
	return annotation;
}
 
开发者ID:minnal,项目名称:minnal,代码行数:17,代码来源:AbstractMethodCreator.java

示例11: getNotFoundResponseAnnotation

import javassist.bytecode.annotation.IntegerMemberValue; //导入依赖的package包/类
/**
 * Returns the 404 not found response annotation
 * 
 * @param responseClass
 * @return
 */
protected Annotation getNotFoundResponseAnnotation() {
	ConstPool constPool = ctClass.getClassFile().getConstPool();
	Annotation annotation = new Annotation(ApiResponse.class.getCanonicalName(), constPool);
	IntegerMemberValue code = new IntegerMemberValue(constPool);
	code.setValue(Response.Status.NOT_FOUND.getStatusCode());
	annotation.addMemberValue("code", code);
	annotation.addMemberValue("message", new StringMemberValue(Response.Status.NOT_FOUND.getReasonPhrase(), constPool));
	return annotation;
}
 
开发者ID:minnal,项目名称:minnal,代码行数:16,代码来源:AbstractMethodCreator.java

示例12: getNoContentResponseAnnotation

import javassist.bytecode.annotation.IntegerMemberValue; //导入依赖的package包/类
/**
 * Returns the 204 no content response annotation
 * 
 * @param responseClass
 * @return
 */
protected Annotation getNoContentResponseAnnotation() {
	ConstPool constPool = ctClass.getClassFile().getConstPool();
	Annotation annotation = new Annotation(ApiResponse.class.getCanonicalName(), constPool);
	IntegerMemberValue code = new IntegerMemberValue(constPool);
	code.setValue(Response.Status.NO_CONTENT.getStatusCode());
	annotation.addMemberValue("code", code);
	annotation.addMemberValue("message", new StringMemberValue(Response.Status.NO_CONTENT.getReasonPhrase(), constPool));
	return annotation;
}
 
开发者ID:minnal,项目名称:minnal,代码行数:16,代码来源:AbstractMethodCreator.java

示例13: getBadRequestResponseAnnotation

import javassist.bytecode.annotation.IntegerMemberValue; //导入依赖的package包/类
/**
 * Returns the 400 bad request response annotation
 * 
 * @param responseClass
 * @return
 */
protected Annotation getBadRequestResponseAnnotation() {
	ConstPool constPool = ctClass.getClassFile().getConstPool();
	Annotation annotation = new Annotation(ApiResponse.class.getCanonicalName(), constPool);
	IntegerMemberValue code = new IntegerMemberValue(constPool);
	code.setValue(Response.Status.BAD_REQUEST.getStatusCode());
	annotation.addMemberValue("code", code);
	annotation.addMemberValue("message", new StringMemberValue(Response.Status.BAD_REQUEST.getReasonPhrase(), constPool));
	return annotation;
}
 
开发者ID:minnal,项目名称:minnal,代码行数:16,代码来源:AbstractMethodCreator.java

示例14: visitIntegerMemberValue

import javassist.bytecode.annotation.IntegerMemberValue; //导入依赖的package包/类
@Override
public void visitIntegerMemberValue(IntegerMemberValue node) {
  values.add(String.valueOf(node.getValue()));
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:5,代码来源:ClassPathScanner.java

示例15: visitIntegerMemberValue

import javassist.bytecode.annotation.IntegerMemberValue; //导入依赖的package包/类
@Override
public void visitIntegerMemberValue(IntegerMemberValue node) {

}
 
开发者ID:aschattney,项目名称:annotated-mvp,代码行数:5,代码来源:ByteCodeProcessor.java


注:本文中的javassist.bytecode.annotation.IntegerMemberValue类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。