當前位置: 首頁>>代碼示例>>Java>>正文


Java Name.toString方法代碼示例

本文整理匯總了Java中javax.lang.model.element.Name.toString方法的典型用法代碼示例。如果您正苦於以下問題:Java Name.toString方法的具體用法?Java Name.toString怎麽用?Java Name.toString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.lang.model.element.Name的用法示例。


在下文中一共展示了Name.toString方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: target2String

import javax.lang.model.element.Name; //導入方法依賴的package包/類
public static String target2String(TypeElement target) {
    final Name qualifiedName = target.getQualifiedName(); //#130759
    if (qualifiedName == null) {
        Logger.getLogger(Utilities.class.getName()).warning("Target qualified name could not be resolved."); //NOI18N
        return ""; //NOI18N
    } else {
        String qnString = qualifiedName.toString();
        if (qnString.length() == 0) {
            //probably an anonymous class
            qnString = target.asType().toString();
        }

        try {
            qnString = XMLUtil.toElementContent(qnString);
        } catch (CharConversionException ex) {
            Logger.getLogger(Utilities.class.getName()).log(Level.FINE, null, ex);
        }

        return qnString;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:Utilities.java

示例2: extractClass

import javax.lang.model.element.Name; //導入方法依賴的package包/類
/** Extract reflection Class<?> information from type element. */
@NonNull
public static Class<?> extractClass(@NonNull final TypeElement te) throws ClassNotFoundException {
    final Name name;

    if (te instanceof Symbol.ClassSymbol) {
        final Symbol.ClassSymbol cs = (Symbol.ClassSymbol) te;

        // this method is more accurate for nested classes
        name = cs.flatName();
    } else {
        name = te.getQualifiedName();
    }

    final String className = name.toString();

    try {
        return Class.forName(className).asSubclass(Annotation.class);
    } catch (ClassNotFoundException ex) {
        // it can be sub-type, try another approach bellow
    }

    final int dot = className.lastIndexOf(".");
    final String innerFix2 = className.substring(0, dot) + "$" + className.substring(dot + 1);
    return Class.forName(innerFix2).asSubclass(Annotation.class);
}
 
開發者ID:OleksandrKucherenko,項目名稱:autoproxy,代碼行數:27,代碼來源:CommonClassGenerator.java

示例3: addUnresolvableImport

import javax.lang.model.element.Name; //導入方法依賴的package包/類
private void addUnresolvableImport(Name name, ImportTree imp) {
    String key = name.toString();

    Collection<ImportTree> l = simpleName2UnresolvableImports.get(key);

    if (l == null) {
        simpleName2UnresolvableImports.put(key, l = new LinkedList<ImportTree>());
    }

    l.add(imp);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:12,代碼來源:UnusedImports.java

示例4: handleIdentifier

import javax.lang.model.element.Name; //導入方法依賴的package包/類
private void handleIdentifier(Tree node, Name id) {
    TreeMaker mk = copy.getTreeMaker();
    String nn = id.toString();
    if (nn.equals(name)) {
        Element res = copy.getTrees().getElement(getCurrentPath());
        if (res != null && res == shadowed) {
            if (res.getModifiers().contains(Modifier.STATIC)) {
                copy.rewrite(node, 
                        mk.MemberSelect(
                            mk.Identifier(shadowedGate), // NOI18N
                            res.getSimpleName().toString()
                        )
                );
            } else if (shadowedGate == target) {
                copy.rewrite(node, 
                        mk.MemberSelect(
                            mk.MemberSelect(mk.Identifier(target), "super"), // NOI18N
                            res.getSimpleName().toString()
                        )
                );
            } else {
                copy.rewrite(node, 
                        mk.MemberSelect(
                            mk.MemberSelect(mk.Identifier(shadowedGate), "this"), // NOI18N
                            res.getSimpleName().toString()
                        )
                );
            }
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:32,代碼來源:ReferenceTransformer.java

示例5: extractCommandNames

import javax.lang.model.element.Name; //導入方法依賴的package包/類
private List<String> extractCommandNames(Name elementName, String[] commandNames) {
    if (commandNames.length == 0) {
        String className = elementName.toString();
        StringBuilder builder = new StringBuilder()
                .append(Character.toLowerCase(className.charAt(0)))
                .append(className.substring(1, className.length()));

        return Collections.singletonList(builder.toString());
    }
    return Arrays.asList(commandNames);
}
 
開發者ID:jeeshell,項目名稱:je2sh,代碼行數:12,代碼來源:CommandProcessor.java

示例6: parseBindView

import javax.lang.model.element.Name; //導入方法依賴的package包/類
private void parseBindView(Element element, Map<TypeElement, BindingSet.Builder> builderMap,
    Set<TypeElement> erasedTargetNames) {
  TypeElement enclosingElement = (TypeElement) element.getEnclosingElement();

  // Start by verifying common generated code restrictions.
  boolean hasError = isInaccessibleViaGeneratedCode(BindView.class, "fields", element)
      || isBindingInWrongPackage(BindView.class, element);

  // Verify that the target type extends from View.
  TypeMirror elementType = element.asType();
  if (elementType.getKind() == TypeKind.TYPEVAR) {
    TypeVariable typeVariable = (TypeVariable) elementType;
    elementType = typeVariable.getUpperBound();
  }
  Name qualifiedName = enclosingElement.getQualifiedName();
  Name simpleName = element.getSimpleName();
  if (!isSubtypeOfType(elementType, VIEW_TYPE) && !isInterface(elementType)) {
    if (elementType.getKind() == TypeKind.ERROR) {
      note(element, "@%s field with unresolved type (%s) "
              + "must elsewhere be generated as a View or interface. (%s.%s)",
          BindView.class.getSimpleName(), elementType, qualifiedName, simpleName);
    } else {
      error(element, "@%s fields must extend from View or be an interface. (%s.%s)",
          BindView.class.getSimpleName(), qualifiedName, simpleName);
      hasError = true;
    }
  }

  if (hasError) {
    return;
  }

  // Assemble information on the field.
  int id = element.getAnnotation(BindView.class).value();

  BindingSet.Builder builder = builderMap.get(enclosingElement);
  QualifiedId qualifiedId = elementToQualifiedId(element, id);
  if (builder != null) {
    String existingBindingName = builder.findExistingBindingName(getId(qualifiedId));
    if (existingBindingName != null) {
      error(element, "Attempt to use @%s for an already bound ID %d on '%s'. (%s.%s)",
          BindView.class.getSimpleName(), id, existingBindingName,
          enclosingElement.getQualifiedName(), element.getSimpleName());
      return;
    }
  } else {
    builder = getOrCreateBindingBuilder(builderMap, enclosingElement);
  }

  String name = simpleName.toString();
  TypeName type = TypeName.get(elementType);
  boolean required = isFieldRequired(element);

  builder.addField(getId(qualifiedId), new FieldViewBinding(name, type, required));

  // Add the type-erased version to the valid binding targets set.
  erasedTargetNames.add(enclosingElement);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:59,代碼來源:ButterKnifeProcessor.java

示例7: getAnnotationQualifiedName

import javax.lang.model.element.Name; //導入方法依賴的package包/類
public static String getAnnotationQualifiedName(AnnotationMirror annotationMirror) {
    DeclaredType annotationDeclaredType = annotationMirror.getAnnotationType();
    TypeElement annotationTypeElement = (TypeElement) annotationDeclaredType.asElement();
    Name name = annotationTypeElement.getQualifiedName();
    return name.toString();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:7,代碼來源:JpaControllerUtil.java

示例8: getOperationName

import javax.lang.model.element.Name; //導入方法依賴的package包/類
@Override
public String getOperationName(Name messageName) {
    return messageName != null ? messageName.toString() : null;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:5,代碼來源:WebServiceAp.java

示例9: parseBindView

import javax.lang.model.element.Name; //導入方法依賴的package包/類
private void parseBindView(Element element, Map<TypeElement, BindingSet.Builder> builderMap,
      Set<TypeElement> erasedTargetNames) {
    TypeElement enclosingElement = (TypeElement) element.getEnclosingElement();

    // Start by verifying common generated code restrictions.
    boolean hasError = isInaccessibleViaGeneratedCode(BindView.class, "fields", element)
        || isBindingInWrongPackage(BindView.class, element);

    // Verify that the target type extends from View.
    TypeMirror elementType = element.asType();
    if (elementType.getKind() == TypeKind.TYPEVAR) {
      TypeVariable typeVariable = (TypeVariable) elementType;
      elementType = typeVariable.getUpperBound();
    }
    Name qualifiedName = enclosingElement.getQualifiedName();
    Name simpleName = element.getSimpleName();
    if (!isSubtypeOfType(elementType, VIEW_TYPE) && !isInterface(elementType)) {
      if (elementType.getKind() == TypeKind.ERROR) {
        note(element, "@%s field with unresolved type (%s) "
                + "must elsewhere be generated as a View or interface. (%s.%s)",
            BindView.class.getSimpleName(), elementType, qualifiedName, simpleName);
      } else {
        error(element, "@%s fields must extend from View or be an interface. (%s.%s)",
            BindView.class.getSimpleName(), qualifiedName, simpleName);
        hasError = true;
      }
    }

    if (hasError) {
      return;
    }

    // Assemble information on the field.
    int id = element.getAnnotation(BindView.class).value();
    int parentId = element.getAnnotation(BindView.class).parentId();

    BindingSet.Builder builder = builderMap.get(enclosingElement);
    QualifiedId qualifiedId = elementToQualifiedId(element, id);
    if (builder != null) {
//      String existingBindingName = builder.findExistingBindingName(getId(qualifiedId));
//      if (existingBindingName != null) {
//        error(element, "Attempt to use @%s for an already bound ID %d on '%s'. (%s.%s)",
//            BindView.class.getSimpleName(), id, existingBindingName,
//            enclosingElement.getQualifiedName(), element.getSimpleName());
//        return;
//      }
    } else {
      builder = createBindingBuilder(builderMap, enclosingElement);
    }

    String name = simpleName.toString();
    TypeName type = TypeName.get(elementType);
    boolean required = isFieldRequired(element);

    builder.addField(getId(qualifiedId), new FieldViewBinding(name, type, required, parentId));

    // Add the type-erased version to the valid binding targets set.
    erasedTargetNames.add(enclosingElement);
  }
 
開發者ID:qq542391099,項目名稱:butterknife-parent,代碼行數:60,代碼來源:ButterKnifeProcessor.java


注:本文中的javax.lang.model.element.Name.toString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。