/** * Set the annotation value of this property by importing the given * annotation from another instance. */ private Annotation setValue(Value val, Annotation o) { Annotation anno = new Annotation(this); anno.setType(o.getTypeName()); anno.setProperties(o.getProperties()); val.index = -1; val.index2 = -1; val.value = anno; val.type = null; return anno; }
/** * Set the annotation properties. This method is useful when * importing properties from another instance. */ public void setProperties(Property[] props) { clearProperties(); if (props != null) for (int i = 0; i < props.length; i++) addProperty(props[i]); }
/** * The bytecode for the type of this annotation. */ public BCClass getTypeBC() { return getProject().loadClass(getTypeName(), getClassLoader()); }
/** * Set this property value to a new annotation of the given type, * returning the annotation for manipulation. */ public Annotation newAnnotationValue(String type) { Annotation anno = new Annotation(this); anno.setType(type); _values = null; _value.index = -1; _value.index2 = -1; _value.value = anno; _value.type = null; return anno; }
/** * Import an annotation from another instance. * * @return the newly added annotation */ public Annotation addAnnotation(Annotation an) { Annotation anno = addAnnotation(an.getTypeName()); anno.setProperties(an.getProperties()); return anno; }
/** * This annotation's type. */ public void setType(String type) { type = getProject().getNameCache().getInternalForm(type, true); _typeIndex = getPool().findUTF8Entry(type, true); }
void read(DataInput in, int length) throws IOException { _annotations.clear(); int annos = in.readUnsignedShort(); Annotation anno; for (int i = 0; i < annos; i++) { anno = new Annotation(this); anno.read(in); _annotations.add(anno); } }
/** * The {@link Class} object for this annotation's type. */ public Class getType() { return Strings.toClass(getTypeName(), getClassLoader()); }
public void enterAnnotation(Annotation obj) { openBlock("Annotation"); println("type=" + obj.getTypeIndex() + " <" + obj.getTypeName() + ">"); }
/** * Return the length of the given value. */ private int getLength(Value val) { if (val.index2 != -1) return 5; // tag + enum type + enum name if (val.index != -1) return 3; // tag + constant or class return 1 + ((Annotation) val.value).getLength(); // tag + anno }
private void printAnnotationPropertyValue(Object obj) { if (obj == null) println("value=null"); else if (obj instanceof Annotation) { _out.print(_prefix); _out.print("value="); ((Annotation) obj).acceptVisit(this); } else println("value=(" + obj.getClass().getName() + ") " + obj); }
/** * Import a property from another instance. * * @return the newly added property */ public Property addProperty(Property p) { Property prop = addProperty(p.getName()); prop.setValue(p.getValue()); return prop; }
public Project getProject() { return _owner.getProject(); }
public ConstantPool getPool() { return _owner.getPool(); }
public ClassLoader getClassLoader() { return _owner.getClassLoader(); }
void read(DataInput in) throws IOException { _typeIndex = in.readUnsignedShort(); clearProperties(); int props = in.readUnsignedShort(); if (props > 0) { if (_properties == null) _properties = new ArrayList(props); Property prop; for (int i = 0; i < props; i++) { prop = new Property(this); prop.read(in); _properties.add(prop); } } }
/** * Set this property value to a new annotation of the given type, * returning the annotation for manipulation. */ public Annotation newAnnotationValue(String type) { Annotation anno = new Annotation(this); anno.setType(type); _values = null; _value.index = -1; _value.index2 = -1; _value.value = anno; _value.type = null; return anno; }
/** * Import an annotation from another instance. * * @return the newly added annotation */ public Annotation addAnnotation(Annotation an) { Annotation anno = addAnnotation(an.getTypeName()); anno.setProperties(an.getProperties()); return anno; }
/** * This annotation's type. */ public void setType(String type) { type = getProject().getNameCache().getInternalForm(type, true); _typeIndex = getPool().findUTF8Entry(type, true); }
void read(DataInput in, int length) throws IOException { _annotations.clear(); int annos = in.readUnsignedShort(); Annotation anno; for (int i = 0; i < annos; i++) { anno = new Annotation(this); anno.read(in); _annotations.add(anno); } }