本文整理匯總了Java中com.sun.javadoc.AnnotationDesc類的典型用法代碼示例。如果您正苦於以下問題:Java AnnotationDesc類的具體用法?Java AnnotationDesc怎麽用?Java AnnotationDesc使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
AnnotationDesc類屬於com.sun.javadoc包,在下文中一共展示了AnnotationDesc類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: processAnnotations
import com.sun.javadoc.AnnotationDesc; //導入依賴的package包/類
protected void processAnnotations(AnnotationDesc annotation, APIParameter apiParameter) {
if (annotation.annotationType().qualifiedName().startsWith("org.springframework.web.bind.annotation.")) {
for (ElementValuePair pair : annotation.elementValues()) {
if (pair.element().name().equals("value") || pair.element().name().equals("name")) {
if (pair.value() != null) {
apiParameter.setName(pair.value().toString().replace("\"", ""));
}
}
if (pair.element().name().equals("required")) {
if (pair.value().value().equals(true)) {
apiParameter.setParameterOccurs(ParameterOccurs.REQUIRED);
} else {
apiParameter.setParameterOccurs(ParameterOccurs.OPTIONAL);
}
}
}
}
}
示例2: isDubboService
import com.sun.javadoc.AnnotationDesc; //導入依賴的package包/類
protected boolean isDubboService(ClassDoc classDoc) {
AnnotationDesc[] annotations = classDoc.annotations();
for (int i = 0; i < annotations.length; i++) {
if (annotations[i].annotationType().qualifiedTypeName().equals("com.alibaba.dubbo.config.annotation.Service")) {
AnnotationDesc.ElementValuePair[] elementValuePairs = annotations[i].elementValues();
for (AnnotationDesc.ElementValuePair elementValuePair : elementValuePairs) {
if("protocol".equals(elementValuePair.element().name())
&& "http".equals(protocolMap.get(elementValuePair.value().toString().replace("\"", "")))) {
return false;
}
}
return true;
}
}
return false;
}
示例3: parseRequestMapping
import com.sun.javadoc.AnnotationDesc; //導入依賴的package包/類
@Override
protected RequestMapping parseRequestMapping(MethodDoc method) {
RequestMapping mapping = new RequestMapping();
mapping.setContainerName(method.containingClass().simpleTypeName());
AnnotationDesc[] annotations = method.annotations();
String url = method.toString().replaceFirst(
method.containingClass().qualifiedName() + ".", "");
for (int i = 0; i < annotations.length; i++) {
if (annotations[i].annotationType().name().equals("WebMethod")) {
for (ElementValuePair p : annotations[i].elementValues()) {
if (p.element().name().equals("operationName")) {
url = url.replace(method.name(), p.value().value()
.toString().replace("\"", ""));
}
}
}
}
mapping.setUrl(url);
mapping.setTooltip(method.containingClass().simpleTypeName());
mapping.setContainerName(method.containingClass().simpleTypeName());
return mapping;
}
示例4: getExportedPackage
import com.sun.javadoc.AnnotationDesc; //導入依賴的package包/類
private String getExportedPackage(ClassDoc clz) {
if (clz == null) {
return "";
}
PackageDoc cpkg = clz.containingPackage();
String pkg = cpkg == null ? "" : (cpkg.name());
for (AnnotationDesc a : clz.annotations()) {
if (a.annotationType().name().equals("ExportPackage")) {
for (AnnotationDesc.ElementValuePair p : a.elementValues()) {
pkg = p.value().toString();
break;
}
}
}
pkg = pkg.replaceAll("\"", "");
return pkg;
}
示例5: filterClasses
import com.sun.javadoc.AnnotationDesc; //導入依賴的package包/類
/**
* Utility to filter a set of classes based on annotations. This method
* will filter the given list of classes based on whether any of the
* annotations given in the types argument are present. This looks only
* at the class name of the annotation, not the fully-qualified name.
* @param orig the original set of classes to filter
* @param types the types of annotations to accept
* @return the filtered list of classes
*/
protected static ClassDoc[] filterClasses(ClassDoc[] orig, String... types) {
if (types == null || types.length == 0) {
return new ClassDoc[0];
}
List<String> in = Arrays.asList(types);
List<ClassDoc> out = new ArrayList<ClassDoc>();
for (ClassDoc classDoc : orig) {
for (AnnotationDesc annotation : classDoc.annotations()) {
if (in.contains(annotation.annotationType().name())) {
out.add(classDoc);
break;
}
}
}
return out.toArray(new ClassDoc[0]);
}
示例6: getAnnotationString
import com.sun.javadoc.AnnotationDesc; //導入依賴的package包/類
public String getAnnotationString(AnnotationDesc annot)
{
String result = "<span class='annotation'>";
String link = getItemLink(annot.annotationType());
result += link == null ? "@" + annot.annotationType().qualifiedName() : "<a href='" + link + "'>@" + annot.annotationType().name() + "</a>";
AnnotationDesc.ElementValuePair[] pairs = annot.elementValues();
if (pairs.length > 0)
{
result += " (";
for (int i = 0; i != pairs.length; i++)
{
if (i > 0)
{
result += ", ";
}
AnnotationDesc.ElementValuePair pair = pairs[i];
String link2 = getItemLink(pair.element().containingClass());
result += link2 == null ? pair.element().qualifiedName() : "<a href='" + link2 + "#" + getSignature(pair.element()) + "'>" + pair.element().name() + "</a>";
result += "=" + formatValue(pair.value());
}
result += ")";
}
return result + "</span>";
}
示例7: extractQueryParams
import com.sun.javadoc.AnnotationDesc; //導入依賴的package包/類
private void extractQueryParams(MethodDoc method, RestMethod restMethod)
{
Parameter[] params = method.parameters();
for (Parameter param : params)
{
AnnotationDesc queryParamAnnotation = getAnnotation(param.annotations(), "QueryParam");
if (queryParamAnnotation != null)
{
RestDocItem di = new RestDocItem();
di.setName(stripQuotes(queryParamAnnotation.elementValues()[0].value().toString()));
di.setComment(getParamComment(method.paramTags(), param.name()));
restMethod.getQueryParams().add(di);
}
}
}
示例8: extractPathParams
import com.sun.javadoc.AnnotationDesc; //導入依賴的package包/類
private void extractPathParams(MethodDoc method, RestMethod restMethod)
{
Parameter[] params = method.parameters();
for (Parameter param : params)
{
AnnotationDesc queryParamAnnotation = getAnnotation(param.annotations(), "PathParam");
if (queryParamAnnotation != null)
{
RestDocItem di = new RestDocItem();
di.setName(stripQuotes(queryParamAnnotation.elementValues()[0].value().toString()));
di.setComment(getParamComment(method.paramTags(), param.name()));
restMethod.getPathParams().add(di);
}
}
}
示例9: build
import com.sun.javadoc.AnnotationDesc; //導入依賴的package包/類
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;
}
示例10: build
import com.sun.javadoc.AnnotationDesc; //導入依賴的package包/類
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;
}
示例11: PSItemFieldDoc
import com.sun.javadoc.AnnotationDesc; //導入依賴的package包/類
private PSItemFieldDoc(PSItemDoc psItemDoc, FieldDoc fieldDoc, AnnotationDesc annotation) {
this.psItemDoc = psItemDoc;
this.reference = fieldDoc.name();
this.name = fieldDoc.constantValue().toString();
this.description = fieldDoc.commentText().replace('\n', ' ');
for (AnnotationDesc.ElementValuePair elementValuePair : annotation.elementValues()) {
if ("type".equals(elementValuePair.element().name())) {
Object typeValue = elementValuePair.value().value();
this.type = (Type) typeValue;
}
}
}
示例12: build
import com.sun.javadoc.AnnotationDesc; //導入依賴的package包/類
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;
}
示例13: isValidPSItem
import com.sun.javadoc.AnnotationDesc; //導入依賴的package包/類
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;
}
示例14: isProgramElementDocAnnotatedWith
import com.sun.javadoc.AnnotationDesc; //導入依賴的package包/類
protected boolean isProgramElementDocAnnotatedWith(ProgramElementDoc elementDoc, String annotation) {
AnnotationDesc[] annotations = elementDoc.annotations();
for (int i = 0; i < annotations.length; i++) {
if (annotations[i].annotationType().qualifiedTypeName().equals(annotation)) {
return true;
}
}
return false;
}
示例15: getFieldValidatorDesc
import com.sun.javadoc.AnnotationDesc; //導入依賴的package包/類
protected String getFieldValidatorDesc(FieldDoc fieldDoc) {
StringBuilder strBuilder = new StringBuilder();
for (AnnotationDesc annotationDesc : fieldDoc.annotations()) {
if (annotationDesc.annotationType().qualifiedTypeName().startsWith("org.hibernate.validator.constraints")
|| annotationDesc.annotationType().qualifiedTypeName().startsWith("javax.validation.constraints")
|| annotationDesc.annotationType().qualifiedTypeName().startsWith("lombok.NonNull")) {
strBuilder.append("@");
strBuilder.append(annotationDesc.annotationType().name());
if (annotationDesc.elementValues().length > 0) {
strBuilder.append("(");
boolean isFirstElement = true;
for (AnnotationDesc.ElementValuePair elementValuePair : annotationDesc.elementValues()) {
if (!isFirstElement) {
strBuilder.append(",");
}
strBuilder.append(elementValuePair.element().name());
strBuilder.append("=");
strBuilder.append(
net.winroad.wrdoclet.utils.Util.decodeUnicode(elementValuePair.value().toString()));
isFirstElement = false;
}
strBuilder.append(")");
}
strBuilder.append(" ");
}
}
return strBuilder.toString();
}