Java 类com.sun.javadoc.AnnotationValue 实例源码

项目:xmldoclet    文件:XMLDoclet.java   
/**
 *
 * @return an "value" or "array" XML node for the annotation value.
 */
private static XMLNode toAnnotationValueNode(AnnotationValue value) {
  if (value == null) return null;
  XMLNode node = null;
  Object o = value.value();
  Class<?> c = o.getClass();
  if (c.isArray()) {
    node = new XMLNode("array");
    Object[]a = (Object[])o;
    for (Object i : a) {
      if (i instanceof AnnotationValue) {
        node.child(toAnnotationValueNode((AnnotationValue)i));
      } else {
        System.err.println("Unexpected annotation value type"+i);
      }
    }
  } else {
    node = new XMLNode("value");
    node.attribute("type", getAnnotationValueType(o));
    node.attribute("value", o.toString());
  }

  return node;
}
项目:bazooka-wo-xmldoclet    文件:XMLDoclet.java   
/**
 *
 * @return an "value" or "array" XML node for the annotation value.
 */
private static XMLNode toAnnotationValueNode(AnnotationValue value) {
  if (value == null) return null;
  XMLNode node = null;
  Object o = value.value();
  Class<?> c = o.getClass();
  if (c.isArray()) {
    node = new XMLNode("array");
    Object[]a = (Object[])o;
    for (Object i : a) {
      if (i instanceof AnnotationValue) {
        node.child(toAnnotationValueNode((AnnotationValue)i));
      } else {
        System.err.println("Unexpected annotation value type"+i);
      }
    }
  } else {
    node = new XMLNode("value");
    node.attribute("type", getAnnotationValueType(o));
    node.attribute("value", o.toString());
  }

  return node;
}
项目:maxur-ldoc    文件:SubDomain.java   
private static List<LinkModel> makeByLinks(final AnnotationDesc desc) {
    final ArrayList<LinkModel> result = new ArrayList<>();
    for (AnnotationDesc.ElementValuePair member : desc.elementValues())
        if ("value".equals(member.element().name())) {
            Arrays.stream((AnnotationValue[]) member.value().value())
                .map(AnnotationValue::value)
                .map(AnnotationDesc.class::cast)
                .forEach(ad -> result.add(new LinkModel(ad)));

        }
    return result;
}
项目:azuki-doclet-jaxrs    文件:JAXRSDocletParser.java   
private Set<String> getProducesValue(final AnnotationDesc[] annotations) {
    Set<String> result = new HashSet<String>();
    AnnotationDesc annotation = DocletUtility.findAnnotation(annotations, Produces.class);
    if (null != annotation) {
        AnnotationValue[] values = (AnnotationValue[]) DocletUtility.getAnnotationValue(annotation);
        if (null != values) {
            for (AnnotationValue value : values) {
                result.add(value.value().toString());
            }
        }
    }
    return result;
}
项目:azuki-doclet-jaxrs    文件:JAXRSDocletParser.java   
private Set<String> getConsumesValue(final AnnotationDesc[] annotations) {
    Set<String> result = new HashSet<String>();
    AnnotationDesc annotation = DocletUtility.findAnnotation(annotations, Consumes.class);
    if (null != annotation) {
        AnnotationValue[] values = (AnnotationValue[]) DocletUtility.getAnnotationValue(annotation);
        if (null != values) {
            for (AnnotationValue value : values) {
                result.add(value.value().toString());
            }
        }
    }
    return result;
}
项目:javadoc-json-doclet    文件:JsonDoclet.java   
/**
 * @return the full JSON for the given annotation type
 */
protected JSONObject processAnnotationValue(AnnotationValue annoValue) {

    if (annoValue == null) {
        return null;
    }

    JSONObject retMe = new JSONObject();
    retMe.put( "toString", annoValue.toString() );

    return retMe;
}
项目:rest-doclet    文件:AnnotationUtils.java   
private static List<String> resolveAnnotationValue(AnnotationValue value) {
    List<String> retVal = new ArrayList<String>();
    /**
     * TODO using recursion here is probably flawed.
     */
    if (value.value() instanceof AnnotationValue[])
        for (AnnotationValue annotationValue : (AnnotationValue[])value.value())
            retVal.addAll(resolveAnnotationValue(annotationValue));
    else {
        retVal.add(value.value().toString());

    }

    return retVal;
}
项目:xml-doclet    文件:Parser.java   
/**
 * Parse the elements of an annotation
 * 
 * @param element
 *            A AnnotationTypeElementDoc instance
 * @return the annotation element node
 */
protected AnnotationElement parseAnnotationTypeElementDoc(AnnotationTypeElementDoc annotationTypeElementDoc) {
  AnnotationElement annotationElementNode = objectFactory.createAnnotationElement();
  annotationElementNode.setName(annotationTypeElementDoc.name());
  annotationElementNode.setIdentifier(parseIdentifier((Doc) annotationTypeElementDoc));
  annotationElementNode.setId(annotationTypeElementDoc.name());
  annotationElementNode.setFull(annotationTypeElementDoc.qualifiedName());
  annotationElementNode.setComment(parseComment(annotationTypeElementDoc));

  AnnotationValue value = annotationTypeElementDoc.defaultValue();
  if (value != null) {
    annotationElementNode.setDefault(value.toString());
  }

  Tag[] tags;
  SeeTag[] seeTags;

  tags = annotationTypeElementDoc.tags("@deprecated");
  if (tags.length > 0) {
    annotationElementNode.setDeprecated(parseComment(tags[0]));
  }

  tags = annotationTypeElementDoc.tags("@since");
  if (tags.length > 0) {
    annotationElementNode.setSince(tags[0].text());
  }

  tags = annotationTypeElementDoc.tags("@version");
  if (tags.length > 0) {
    annotationElementNode.setVersion(tags[0].text());
  }

  Return returnNode = objectFactory.createReturn();

  tags = annotationTypeElementDoc.tags("@return");
  if (tags.length > 0) {
    returnNode.setComment(parseComment(tags[0]));
  }

  returnNode.setType(parseTypeInfo(annotationTypeElementDoc.returnType()));

  annotationElementNode.setReturn(returnNode);

  seeTags = annotationTypeElementDoc.seeTags();
  for (int i = 0; i < seeTags.length; i++) {
    annotationElementNode.getLink().add(parseLink(seeTags[i]));
  }

  return annotationElementNode;
}