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


Java ArrayMemberValue类代码示例

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


ArrayMemberValue类属于javassist.bytecode.annotation包,在下文中一共展示了ArrayMemberValue类的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: getExistingXmlJavaTypeAdapters

import javassist.bytecode.annotation.ArrayMemberValue; //导入依赖的package包/类
/**
 * A narrow-purpose helper method that accepts an {@link
 * ArrayMemberValue} parameter whose value is (semantically) the
 * return value of the {@link XmlJavaTypeAdapters#value()}
 * annotation attribute, and returns a {@link Map} of {@link
 * Annotation} objects representing {@link XmlJavaTypeAdapter}
 * annotations indexed by the {@linkplain XmlJavaTypeAdapter#type()
 * types} that each of them governs.
 *
 * <p>This method never returns {@code null}.</p>
 *
 * @param adaptersHolder the {@link ArrayMemberValue} that resulted
 * from calling {@link Annotation#getMemberValue(String)
 * Annotation#getMemberValue("value")} on an {@link Annotation} that
 * is Javassist's representation of the {@link XmlJavaTypeAdapters}
 * annotation.  This parameter may be {@code null}.
 *
 * @return a {@link Map} of {@link Annotation} objects representing
 * {@link XmlJavaTypeAdapter} annotations indexed by the {@linkplain
 * XmlJavaTypeAdapter#type() types} that each of them governs; never
 * {@code null}
 */
private static final Map<String, Annotation> getExistingXmlJavaTypeAdapters(final ArrayMemberValue adaptersHolder) {
  // Build a Map indexing existing @XmlJavaTypeAdapter annotations
  // by the types that they govern.
  final Map<String, Annotation> xmlJavaTypeAdapters = new HashMap<String, Annotation>();
  if (adaptersHolder != null) {
    final MemberValue[] rawMemberValue = adaptersHolder.getValue();
    if (rawMemberValue != null && rawMemberValue.length > 0) {
      for (final MemberValue mv : rawMemberValue) {
        if (mv instanceof AnnotationMemberValue) {
          final Annotation xmlJavaTypeAdapter = ((AnnotationMemberValue)mv).getValue();
          if (xmlJavaTypeAdapter != null && XmlJavaTypeAdapter.class.getName().equals(xmlJavaTypeAdapter.getTypeName())) {
            final ClassMemberValue typeHolder = (ClassMemberValue)xmlJavaTypeAdapter.getMemberValue("type");
            if (typeHolder != null) {
              final String interfaceTypeName = typeHolder.getValue();
              if (interfaceTypeName != null) {
                xmlJavaTypeAdapters.put(interfaceTypeName, xmlJavaTypeAdapter);
              }
            }
          }
        }
      }
    }
  }
  return xmlJavaTypeAdapters;
}
 
开发者ID:ljnelson,项目名称:jaxb-tools,代码行数:48,代码来源:PackageInfoModifier.java

示例10: createMemberValue

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

示例11: createMemberValue

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

示例12: 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

示例13: 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

示例14: createMemberValue

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

示例15: equals

import javassist.bytecode.annotation.ArrayMemberValue; //导入依赖的package包/类
private boolean equals(CtMethod cm, String name, CtClass[] parameters)
		throws NotFoundException {
	if (!cm.getName().equals(name))
		return false;
	if (Arrays.equals(cm.getParameterTypes(), parameters))
		return true;
	if (cm.getParameterTypes().length != 1)
		return false;
	MethodInfo mi = cm.getMethodInfo();
	AnnotationsAttribute ainfo = (AnnotationsAttribute) mi
			.getAttribute(AnnotationsAttribute.invisibleTag);
	if (ainfo == null)
		return false;
	Annotation[] anno = ainfo.getAnnotations();
	if (anno == null)
		return false;
	String typeName = ParameterTypes.class.getName();
	for (int i = 0; i < anno.length; i++) {
		if (anno[i].getTypeName().equals(typeName)) {
			ArrayMemberValue mv = (ArrayMemberValue) anno[i]
					.getMemberValue("value");
			MemberValue[] mvalues = mv.getValue();
			if (mvalues.length != parameters.length)
				return false;
			for (int j = 0; j < mvalues.length; j++) {
				ClassMemberValue cmv = (ClassMemberValue) mvalues[j];
				if (!parameters[j].getName().equals(cmv.getValue()))
					return false;
			}
			return true;
		}
	}
	return false;
}
 
开发者ID:anno4j,项目名称:anno4j,代码行数:35,代码来源:ClassTemplate.java


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