本文整理汇总了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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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()]));
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
}
}