类com.sun.javadoc.AnnotationTypeDoc源码实例Demo

下面列出了怎么用com.sun.javadoc.AnnotationTypeDoc的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: xml-doclet   文件: Parser.java
/**
 * Parse an annotation.
 * 
 * @param annotationTypeDoc
 *            A AnnotationTypeDoc instance
 * @return the annotation node
 */
protected Annotation parseAnnotationTypeDoc(AnnotationTypeDoc annotationTypeDoc) {
	Annotation annotationNode = objectFactory.createAnnotation();
	annotationNode.setName(annotationTypeDoc.name());
	annotationNode.setQualified(annotationTypeDoc.qualifiedName());
	String comment = annotationTypeDoc.commentText();
	if (comment.length() > 0) {
		annotationNode.setComment(comment);
	}
	annotationNode.setIncluded(annotationTypeDoc.isIncluded());
	annotationNode.setScope(parseScope(annotationTypeDoc));

	for (AnnotationTypeElementDoc annotationTypeElementDoc : annotationTypeDoc.elements()) {
		annotationNode.getElement().add(parseAnnotationTypeElementDoc(annotationTypeElementDoc));
	}

	for (AnnotationDesc annotationDesc : annotationTypeDoc.annotations()) {
		annotationNode.getAnnotation().add(parseAnnotationDesc(annotationDesc, annotationTypeDoc.qualifiedName()));
	}

	for (Tag tag : annotationTypeDoc.tags()) {
		annotationNode.getTag().add(parseTag(tag));
	}

	return annotationNode;
}
 
源代码2 项目: PrivacyStreams   文件: PSOperatorWrapperDoc.java
public static PSOperatorWrapperDoc build(ClassDoc classDoc) {
    AnnotationDesc[] annotations = classDoc.annotations();
    for (AnnotationDesc annotation : annotations) {
        AnnotationTypeDoc annotationType = annotation.annotationType();
        if (Consts.OPERATOR_WRAPPER_ANNOTATION.equals(annotationType.toString())) {
            return new PSOperatorWrapperDoc(classDoc);
        }
    }
    return null;
}
 
源代码3 项目: PrivacyStreams   文件: PSPipelineDoc.java
public static PSPipelineDoc build(ClassDoc classDoc, MethodDoc methodDoc) {
    AnnotationDesc[] annotations = methodDoc.annotations();
    for (AnnotationDesc annotation : annotations) {
        AnnotationTypeDoc annotationType = annotation.annotationType();
        if (Consts.TRANSFORMATION_ANNOTATION.equals(annotationType.toString())) {
            return new PSPipelineDoc(classDoc, methodDoc, annotation, TYPE_TRANSFORMATION);
        }
        else if (Consts.ACTION_ANNOTATION.equals(annotationType.toString())) {
            return new PSPipelineDoc(classDoc, methodDoc, annotation, TYPE_ACTION);
        }
    }
    return null;
}
 
源代码4 项目: PrivacyStreams   文件: PSItemFieldDoc.java
public static PSItemFieldDoc build(PSItemDoc psItemDoc, FieldDoc fieldDoc) {
    AnnotationDesc[] annotations = fieldDoc.annotations();
    for (AnnotationDesc annotation : annotations) {
        AnnotationTypeDoc annotationType = annotation.annotationType();
        if (Consts.ITEM_FIELD_ANNOTATION.equals(annotationType.toString())) {
            return new PSItemFieldDoc(psItemDoc, fieldDoc, annotation);
        }
    }
    return null;
}
 
源代码5 项目: PrivacyStreams   文件: PSItemDoc.java
public static boolean isValidPSItem(ClassDoc classDoc) {
    AnnotationDesc[] annotations = classDoc.annotations();
    for (AnnotationDesc annotation : annotations) {
        AnnotationTypeDoc annotationType = annotation.annotationType();
        if (Consts.ITEM_ANNOTATION.equals(annotationType.toString())) {
            return true;
        }
    }
    return false;
}
 
源代码6 项目: sarl   文件: ProgrammaticWrappingProxyInstaller.java
@Override
public AnnotationTypeDoc wrap(AnnotationTypeDoc source) {
	if (source == null || source instanceof Proxy<?> || !(source instanceof AnnotationTypeDocImpl)) {
		return source;
	}
	return new AnnotationTypeDocWrapper((AnnotationTypeDocImpl) source);
}
 
源代码7 项目: sarl   文件: ProgrammaticWrappingProxyInstaller.java
/** Wrap a annotation type doc.
 *
 * @param source the source
 * @return the wrapper.
 */
public AnnotationTypeDoc[] wrap(AnnotationTypeDoc[] source) {
	if (source == null) {
		return null;
	}
	final List<AnnotationTypeDoc> list = new ArrayList<>();
	for (final AnnotationTypeDoc element : source) {
		if (isIncluded(element)) {
			list.add(wrap(element));
		}
	}
	return Utils.toArray(source, list);
}
 
源代码8 项目: xml-doclet   文件: Parser.java
/**
 * The entry point into parsing the javadoc.
 * 
 * @param rootDoc
 *            The RootDoc intstance obtained via the doclet API
 * @return The root node, containing everything parsed from javadoc doclet
 */
public Root parseRootDoc(RootDoc rootDoc) {
	Root rootNode = objectFactory.createRoot();

	for (ClassDoc classDoc : rootDoc.classes()) {
		PackageDoc packageDoc = classDoc.containingPackage();

		Package packageNode = packages.get(packageDoc.name());
		if (packageNode == null) {
			packageNode = parsePackage(packageDoc);
			packages.put(packageDoc.name(), packageNode);
			rootNode.getPackage().add(packageNode);
		}

		if (classDoc instanceof AnnotationTypeDoc) {
			packageNode.getAnnotation().add(parseAnnotationTypeDoc((AnnotationTypeDoc) classDoc));
		} else if (classDoc.isEnum()) {
			packageNode.getEnum().add(parseEnum(classDoc));
		} else if (classDoc.isInterface()) {
			packageNode.getInterface().add(parseInterface(classDoc));
		} else {
			packageNode.getClazz().add(parseClass(classDoc));
		}
	}

	return rootNode;
}
 
源代码9 项目: hadoop   文件: RootDocProcessor.java
@Override
   public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable {
     String methodName = method.getName();
     if (target instanceof Doc) {
if (methodName.equals("isIncluded")) {
  Doc doc = (Doc) target;
  return !exclude(doc) && doc.isIncluded();
}
if (target instanceof RootDoc) {
  if (methodName.equals("classes")) {
    return filter(((RootDoc) target).classes(), ClassDoc.class);
  } else if (methodName.equals("specifiedClasses")) {
    return filter(((RootDoc) target).specifiedClasses(), ClassDoc.class);
  } else if (methodName.equals("specifiedPackages")) {
    return filter(((RootDoc) target).specifiedPackages(), PackageDoc.class);
  }
} else if (target instanceof ClassDoc) {
  if (isFiltered(args)) {
    if (methodName.equals("methods")) {
      return filter(((ClassDoc) target).methods(true), MethodDoc.class);
    } else if (methodName.equals("fields")) {
      return filter(((ClassDoc) target).fields(true), FieldDoc.class);
    } else if (methodName.equals("innerClasses")) {
      return filter(((ClassDoc) target).innerClasses(true),
	  ClassDoc.class);
    } else if (methodName.equals("constructors")) {
      return filter(((ClassDoc) target).constructors(true),
	  ConstructorDoc.class);
    }
  }
} else if (target instanceof PackageDoc) {
  if (methodName.equals("allClasses")) {
    if (isFiltered(args)) {
      return filter(((PackageDoc) target).allClasses(true),
	ClassDoc.class);
    } else {
      return filter(((PackageDoc) target).allClasses(), ClassDoc.class);  
    }
  } else if (methodName.equals("annotationTypes")) {
    return filter(((PackageDoc) target).annotationTypes(),
	AnnotationTypeDoc.class);
  } else if (methodName.equals("enums")) {
    return filter(((PackageDoc) target).enums(),
	ClassDoc.class);
  } else if (methodName.equals("errors")) {
    return filter(((PackageDoc) target).errors(),
	ClassDoc.class);
  } else if (methodName.equals("exceptions")) {
    return filter(((PackageDoc) target).exceptions(),
	ClassDoc.class);
  } else if (methodName.equals("interfaces")) {
    return filter(((PackageDoc) target).interfaces(),
	ClassDoc.class);
  } else if (methodName.equals("ordinaryClasses")) {
    return filter(((PackageDoc) target).ordinaryClasses(),
	ClassDoc.class);
  }
}
     }

     if (args != null) {
if (methodName.equals("compareTo") || methodName.equals("equals")
    || methodName.equals("overrides")
    || methodName.equals("subclassOf")) {
  args[0] = unwrap(args[0]);
}
     }
     try {
return process(method.invoke(target, args), method.getReturnType());
     } catch (InvocationTargetException e) {
throw e.getTargetException();
     }
   }
 
源代码10 项目: big-c   文件: RootDocProcessor.java
@Override
   public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable {
     String methodName = method.getName();
     if (target instanceof Doc) {
if (methodName.equals("isIncluded")) {
  Doc doc = (Doc) target;
  return !exclude(doc) && doc.isIncluded();
}
if (target instanceof RootDoc) {
  if (methodName.equals("classes")) {
    return filter(((RootDoc) target).classes(), ClassDoc.class);
  } else if (methodName.equals("specifiedClasses")) {
    return filter(((RootDoc) target).specifiedClasses(), ClassDoc.class);
  } else if (methodName.equals("specifiedPackages")) {
    return filter(((RootDoc) target).specifiedPackages(), PackageDoc.class);
  }
} else if (target instanceof ClassDoc) {
  if (isFiltered(args)) {
    if (methodName.equals("methods")) {
      return filter(((ClassDoc) target).methods(true), MethodDoc.class);
    } else if (methodName.equals("fields")) {
      return filter(((ClassDoc) target).fields(true), FieldDoc.class);
    } else if (methodName.equals("innerClasses")) {
      return filter(((ClassDoc) target).innerClasses(true),
	  ClassDoc.class);
    } else if (methodName.equals("constructors")) {
      return filter(((ClassDoc) target).constructors(true),
	  ConstructorDoc.class);
    }
  }
} else if (target instanceof PackageDoc) {
  if (methodName.equals("allClasses")) {
    if (isFiltered(args)) {
      return filter(((PackageDoc) target).allClasses(true),
	ClassDoc.class);
    } else {
      return filter(((PackageDoc) target).allClasses(), ClassDoc.class);  
    }
  } else if (methodName.equals("annotationTypes")) {
    return filter(((PackageDoc) target).annotationTypes(),
	AnnotationTypeDoc.class);
  } else if (methodName.equals("enums")) {
    return filter(((PackageDoc) target).enums(),
	ClassDoc.class);
  } else if (methodName.equals("errors")) {
    return filter(((PackageDoc) target).errors(),
	ClassDoc.class);
  } else if (methodName.equals("exceptions")) {
    return filter(((PackageDoc) target).exceptions(),
	ClassDoc.class);
  } else if (methodName.equals("interfaces")) {
    return filter(((PackageDoc) target).interfaces(),
	ClassDoc.class);
  } else if (methodName.equals("ordinaryClasses")) {
    return filter(((PackageDoc) target).ordinaryClasses(),
	ClassDoc.class);
  }
}
     }

     if (args != null) {
if (methodName.equals("compareTo") || methodName.equals("equals")
    || methodName.equals("overrides")
    || methodName.equals("subclassOf")) {
  args[0] = unwrap(args[0]);
}
     }
     try {
return process(method.invoke(target, args), method.getReturnType());
     } catch (InvocationTargetException e) {
throw e.getTargetException();
     }
   }
 
源代码11 项目: sarl   文件: NoProxyInstaller.java
@Override
public AnnotationTypeDoc wrap(AnnotationTypeDoc obj) {
	return obj;
}
 
源代码12 项目: sarl   文件: JreProxyInstaller.java
@Override
public AnnotationTypeDoc wrap(AnnotationTypeDoc obj) {
	return (AnnotationTypeDoc) wrap((Object) obj);
}
 
源代码13 项目: sarl   文件: ProgrammaticWrappingProxyInstaller.java
@Override
public AnnotationTypeDoc asAnnotationTypeDoc() {
	return wrap(this.delegate.asAnnotationTypeDoc());
}
 
源代码14 项目: sarl   文件: ProgrammaticWrappingProxyInstaller.java
@Override
public AnnotationTypeDoc[] annotationTypes() {
	return wrap(this.delegate.annotationTypes());
}
 
源代码15 项目: sarl   文件: ProgrammaticWrappingProxyInstaller.java
@Override
public AnnotationTypeDoc asAnnotationTypeDoc() {
	return wrap(this.delegate.asAnnotationTypeDoc());
}
 
源代码16 项目: sarl   文件: SarlWriterFactory.java
@Override
public AnnotationTypeWriter getAnnotationTypeWriter(AnnotationTypeDoc annotationType, Type prevType, Type nextType)
		throws Exception {
	return new SarlAnnotationTypeWriter(this.configuration, annotationType, prevType, nextType);
}
 
源代码17 项目: xml-doclet   文件: Parser.java
/**
 * Parses annotation instances of an annotable program element
 * 
 * @param annotationDesc
 *            annotationDesc
 * @param programElement
 *            programElement
 * @return representation of annotations
 */
protected AnnotationInstance parseAnnotationDesc(AnnotationDesc annotationDesc, String programElement) {
	AnnotationInstance annotationInstanceNode = objectFactory.createAnnotationInstance();

	try {
		AnnotationTypeDoc annotTypeInfo = annotationDesc.annotationType();
		annotationInstanceNode.setName(annotTypeInfo.name());
		annotationInstanceNode.setQualified(annotTypeInfo.qualifiedTypeName());
	} catch (ClassCastException castException) {
		log.error("Unable to obtain type data about an annotation found on: " + programElement);
		log.error("Add to the classpath the class/jar that defines this annotation.");
	}

	for (AnnotationDesc.ElementValuePair elementValuesPair : annotationDesc.elementValues()) {
		AnnotationArgument annotationArgumentNode = objectFactory.createAnnotationArgument();
		annotationArgumentNode.setName(elementValuesPair.element().name());

		Type annotationArgumentType = elementValuesPair.element().returnType();
		annotationArgumentNode.setType(parseTypeInfo(annotationArgumentType));
		annotationArgumentNode.setPrimitive(annotationArgumentType.isPrimitive());
		annotationArgumentNode.setArray(annotationArgumentType.dimension().length() > 0);

		Object objValue = elementValuesPair.value().value();
		if (objValue instanceof AnnotationValue[]) {
			for (AnnotationValue annotationValue : (AnnotationValue[]) objValue) {
			    if (annotationValue.value() instanceof AnnotationDesc) {
                       AnnotationDesc annoDesc = (AnnotationDesc) annotationValue.value();
                       annotationArgumentNode.getAnnotation().add(parseAnnotationDesc(annoDesc, programElement));
                   } else {
                       annotationArgumentNode.getValue().add(annotationValue.value().toString());
                   }
			}
		} else if (objValue instanceof FieldDoc) {
			annotationArgumentNode.getValue().add(((FieldDoc) objValue).name());
		} else if (objValue instanceof ClassDoc) {
			annotationArgumentNode.getValue().add(((ClassDoc) objValue).qualifiedTypeName());
		} else {
			annotationArgumentNode.getValue().add(objValue.toString());
		}
		annotationInstanceNode.getArgument().add(annotationArgumentNode);
	}

	return annotationInstanceNode;
}
 
源代码18 项目: sarl   文件: ProxyInstaller.java
/** Wrap the given annotation type documentation.
 *
 * @param obj the document to filter.
 * @return the filtered {@code obj}.
 */
AnnotationTypeDoc wrap(AnnotationTypeDoc obj);
 
源代码19 项目: sarl   文件: SarlAnnotationTypeWriter.java
/** Constructor.
 * @param configuration the configuration.
 * @param annotationType the type.
 * @param prevType the previous type.
 * @param nextType the next type.
 * @throws Exception in case of error.
 */
public SarlAnnotationTypeWriter(ConfigurationImpl configuration, AnnotationTypeDoc annotationType, Type prevType,
		Type nextType) throws Exception {
	super(configuration, annotationType, prevType, nextType);
}