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


Java ArrayMemberValue.setValue方法代码示例

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


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

示例1: getEntityListeners

import javassist.bytecode.annotation.ArrayMemberValue; //导入方法依赖的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.ArrayMemberValue; //导入方法依赖的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.ArrayMemberValue; //导入方法依赖的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.ArrayMemberValue; //导入方法依赖的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: removeValue

import javassist.bytecode.annotation.ArrayMemberValue; //导入方法依赖的package包/类
static
private void removeValue(ArrayMemberValue memberValue, String value){
	List<MemberValue> values = new ArrayList<>(Arrays.asList(memberValue.getValue()));

	boolean removed = false;

	Iterator<MemberValue> it = values.iterator();
	while(it.hasNext()){
		StringMemberValue stringValue = (StringMemberValue)it.next();

		if((value).equals(stringValue.getValue())){
			it.remove();

			removed = true;
		}
	}

	if(!removed){
		throw new RuntimeException(value + " not in " + values);
	}

	memberValue.setValue(values.toArray(new MemberValue[values.size()]));
}
 
开发者ID:jpmml,项目名称:jpmml-model,代码行数:24,代码来源:TransformationUtil.java

示例6: addEndpointMapping

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

示例7: getApiParamAnnotations

import javassist.bytecode.annotation.ArrayMemberValue; //导入方法依赖的package包/类
/**
 * Returns the api parameter annotations
 * 
 * @return
 */
protected Annotation getApiParamAnnotations() {
	Annotation implicitParams = new Annotation(ApiImplicitParams.class.getCanonicalName(), ctClass.getClassFile().getConstPool());
	List<AnnotationMemberValue> annotationMemberValues = new ArrayList<AnnotationMemberValue>();
	List<Annotation> annotations = Lists.newArrayList();
	annotations.addAll(getApiPathParamAnnotations());
	annotations.addAll(getApiQueryParamAnnotations());
	annotations.addAll(getApiAdditionalParamAnnotations());
	for (Annotation annotation : annotations) {
		annotationMemberValues.add(new AnnotationMemberValue(annotation, ctClass.getClassFile().getConstPool()));
	}
	ArrayMemberValue values = new ArrayMemberValue(ctClass.getClassFile().getConstPool());
	values.setValue(annotationMemberValues.toArray(new AnnotationMemberValue[0]));
	implicitParams.addMemberValue("value", values);
	return implicitParams;
}
 
开发者ID:minnal,项目名称:minnal,代码行数:21,代码来源:AbstractMethodCreator.java

示例8: getSecurityAnnotation

import javassist.bytecode.annotation.ArrayMemberValue; //导入方法依赖的package包/类
/**
 * Returns the security annotation
 * 
 * @return
 */
protected Annotation getSecurityAnnotation() {
	Set<String> permissions = getPermissions();
	if (permissions == null || permissions.isEmpty()) {
		return null;
	}
	
	Annotation rolesAllowed = new Annotation(RolesAllowed.class.getCanonicalName(), ctClass.getClassFile().getConstPool());
	ArrayMemberValue values = new ArrayMemberValue(ctClass.getClassFile().getConstPool());
	List<StringMemberValue> memberValues = new ArrayList<StringMemberValue>();
	for (String permission : permissions) {
		memberValues.add(new StringMemberValue(permission, ctClass.getClassFile().getConstPool()));
	}
	values.setValue(memberValues.toArray(new StringMemberValue[0]));
	rolesAllowed.addMemberValue("value", values);
	return rolesAllowed;
}
 
开发者ID:minnal,项目名称:minnal,代码行数:22,代码来源:AbstractMethodCreator.java

示例9: getAuthors

import javassist.bytecode.annotation.ArrayMemberValue; //导入方法依赖的package包/类
public ArrayMemberValue getAuthors(OsmiumMetaContainer meta, ConstPool cpool) {
	ArrayMemberValue arrayMember = new ArrayMemberValue(cpool);
	String[] authors = meta.getAuthors();
	MemberValue[] elements = new MemberValue[authors.length];
	for (int i = 0; i < authors.length; i++) {
		elements[i] = new StringMemberValue(authors[i], cpool);
	}
	arrayMember.setValue(elements);
	return arrayMember;
}
 
开发者ID:kmecpp,项目名称:Osmium,代码行数:11,代码来源:OsmiumPluginProcessor.java

示例10: getDependencies

import javassist.bytecode.annotation.ArrayMemberValue; //导入方法依赖的package包/类
public ArrayMemberValue getDependencies(OsmiumMetaContainer meta, ConstPool cpool) {
	ArrayMemberValue arrayMember = new ArrayMemberValue(cpool);
	String[] dependencies = meta.getDependencies();
	MemberValue[] elements = new MemberValue[dependencies.length];
	for (int i = 0; i < dependencies.length; i++) {
		elements[i] = new StringMemberValue(dependencies[i], cpool);
	}
	arrayMember.setValue(elements);
	return arrayMember;
}
 
开发者ID:kmecpp,项目名称:Osmium,代码行数:11,代码来源:OsmiumPluginProcessor.java

示例11: gecco

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

示例12: getApiResponsesAnnotation

import javassist.bytecode.annotation.ArrayMemberValue; //导入方法依赖的package包/类
protected Annotation getApiResponsesAnnotation() {
	Annotation apiResponses = new Annotation(ApiResponses.class.getCanonicalName(), ctClass.getClassFile().getConstPool());
	ArrayMemberValue values = new ArrayMemberValue(ctClass.getClassFile().getConstPool());
	List<AnnotationMemberValue> memberValues = new ArrayList<AnnotationMemberValue>();
	for (Annotation annotation : getApiResponseAnnotations()) {
		memberValues.add(new AnnotationMemberValue(annotation, ctClass.getClassFile().getConstPool()));
	}
	values.setValue(memberValues.toArray(new AnnotationMemberValue[0]));
	apiResponses.addMemberValue("value", values);
	return apiResponses;
}
 
开发者ID:minnal,项目名称:minnal,代码行数:12,代码来源:AbstractMethodCreator.java

示例13: getProducesAnnotation

import javassist.bytecode.annotation.ArrayMemberValue; //导入方法依赖的package包/类
protected Annotation getProducesAnnotation() {
	Annotation annotation = new Annotation(Produces.class.getCanonicalName(), getCtClass().getClassFile().getConstPool());
	ArrayMemberValue values = new ArrayMemberValue(getCtClass().getClassFile().getConstPool());
	StringMemberValue json = new StringMemberValue(MediaType.APPLICATION_JSON, getCtClass().getClassFile().getConstPool());
	StringMemberValue xml = new StringMemberValue(MediaType.APPLICATION_XML, getCtClass().getClassFile().getConstPool());
	values.setValue(new StringMemberValue[]{json, xml});
	annotation.addMemberValue("value", values);
	return annotation;
}
 
开发者ID:minnal,项目名称:minnal,代码行数:10,代码来源:AbstractMethodCreator.java

示例14: xmlSeeAlso

import javassist.bytecode.annotation.ArrayMemberValue; //导入方法依赖的package包/类
/**
 * Create new <tt>XmlSeeAlso</tt> annotation.
 * @param file Javassist file to work with
 * @param types The class to refer to
 * @return The annotation
 */
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
private static Annotation xmlSeeAlso(final ClassFile file,
    final Collection<Class<?>> types) {
    final Annotation annotation = new Annotation(
        XmlSeeAlso.class.getName(),
        file.getConstPool()
    );
    final ArrayMemberValue member = new ArrayMemberValue(
        file.getConstPool()
    );
    final ClassMemberValue[] values = new ClassMemberValue[types.size()];
    int pos = 0;
    for (final Class<?> type : types) {
        values[pos] = new ClassMemberValue(
            type.getName(),
            file.getConstPool()
        );
        pos += 1;
    }
    member.setValue(values);
    annotation.addMemberValue("value", member);
    Logger.debug(
        JaxbGroup.class,
        "#xmlSeeAlso(.., %d classes): annotation created",
        types.size()
    );
    return annotation;
}
 
开发者ID:yegor256,项目名称:rexsl,代码行数:35,代码来源:JaxbGroup.java

示例15: overrideParameterPrefixes

import javassist.bytecode.annotation.ArrayMemberValue; //导入方法依赖的package包/类
/**
 * Iterate the annotations, look for a 'names' parameter, and override it to
 * prepend the given prefix.
 * 
 * @param field
 * @param prefix
 */
private void overrideParameterPrefixes(
		CtField field,
		String[] names ) {

	// This is the JCommander package name
	String packageName = JCommander.class.getPackage().getName();

	AnnotationsAttribute fieldAttributes = (AnnotationsAttribute) field.getFieldInfo().getAttribute(
			AnnotationsAttribute.visibleTag);

	// Look for annotations that have a 'names' attribute, and whose package
	// starts with the expected JCommander package.
	for (Annotation annotation : fieldAttributes.getAnnotations()) {
		if (annotation.getTypeName().startsWith(
				packageName)) {
			// See if it has a 'names' member variable.
			MemberValue namesMember = annotation.getMemberValue(NAMES_MEMBER);

			// We have a names member!!!
			if (namesMember != null) {
				ArrayMemberValue arrayNamesMember = (ArrayMemberValue) namesMember;

				// Iterate and transform each item in 'names()' list and
				// transform it.
				MemberValue[] newMemberValues = new MemberValue[names.length];
				for (int i = 0; i < names.length; i++) {
					newMemberValues[i] = new StringMemberValue(
							names[i],
							field.getFieldInfo2().getConstPool());
				}

				// Override the member values in nameMember with the new
				// one's we've generated
				arrayNamesMember.setValue(newMemberValues);

				// This is KEY! For some reason, the existing annotation
				// will not be modified unless
				// you call 'setAnnotation' here. I'm guessing
				// 'getAnnotation()' creates a copy.
				fieldAttributes.setAnnotation(annotation);

				// Finished processing names.
				break;
			}
		}
	}
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:55,代码来源:JCommanderTranslationMap.java


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