Package com.android.dx.rop.annotation

Examples of com.android.dx.rop.annotation.Annotation


     * @param attribs {@code non-null;} the attributes list to search in
     * @return {@code non-null;} the set of annotations, which may be empty
     */
    public static Annotations getAnnotations(AttributeList attribs) {
        Annotations result = getAnnotations0(attribs);
        Annotation signature = getSignature(attribs);

        if (signature != null) {
            result = Annotations.combine(result, signature);
        }

View Full Code Here


    public static Annotations getClassAnnotations(DirectClassFile cf,
            CfOptions args) {
        CstType thisClass = cf.getThisClass();
        AttributeList attribs = cf.getAttributes();
        Annotations result = getAnnotations(attribs);
        Annotation enclosingMethod = translateEnclosingMethod(attribs);

        try {
            Annotations innerClassAnnotations =
                translateInnerClasses(thisClass, attribs,
                        enclosingMethod == null);
            if (innerClassAnnotations != null) {
                result = Annotations.combine(result, innerClassAnnotations);
            }
        } catch (Warning warn) {
            args.warn.println("warning: " + warn.getMessage());
        }

        if (enclosingMethod != null) {
            result = Annotations.combine(result, enclosingMethod);
        }

        if (AccessFlags.isAnnotation(cf.getAccessFlags())) {
            Annotation annotationDefault =
                translateAnnotationDefaults(cf);
            if (annotationDefault != null) {
                result = Annotations.combine(result, annotationDefault);
            }
        }
View Full Code Here

    public static Annotations getMethodAnnotations(Method method) {
        Annotations result = getAnnotations(method.getAttributes());
        TypeList exceptions = getExceptions(method);

        if (exceptions.size() != 0) {
            Annotation throwsAnnotation =
                AnnotationUtils.makeThrows(exceptions);
            result = Annotations.combine(result, throwsAnnotation);
        }

        return result;
View Full Code Here

     */
    private static Annotation translateAnnotationDefaults(DirectClassFile cf) {
        CstType thisClass = cf.getThisClass();
        MethodList methods = cf.getMethods();
        int sz = methods.size();
        Annotation result =
            new Annotation(thisClass, AnnotationVisibility.EMBEDDED);
        boolean any = false;

        for (int i = 0; i < sz; i++) {
            Method one = methods.get(i);
            AttributeList attribs = one.getAttributes();
            AttAnnotationDefault oneDefault = (AttAnnotationDefault)
                attribs.findFirst(AttAnnotationDefault.ATTRIBUTE_NAME);

            if (oneDefault != null) {
                NameValuePair pair = new NameValuePair(
                        one.getNat().getName(),
                        oneDefault.getValue());
                result.add(pair);
                any = true;
            }
        }

        if (! any) {
            return null;
        }

        result.setImmutable();
        return AnnotationUtils.makeAnnotationDefault(result);
    }
View Full Code Here

    boolean skeletonOnly= hasAnnotation(directClassFile.getAttributes(), XMLVMSkeletonOnly.class);
    if (skeletonOnly)
    {
      classElement.setAttribute("skeletonOnly", "true");

      Annotation skeletonAnnotation= getAnnotation(directClassFile.getAttributes(), XMLVMSkeletonOnly.class);
      for (NameValuePair pair : skeletonAnnotation.getNameValuePairs())
      {
        if (pair.getName().getString().equals("references"))
        {
          CstArray.List clazzArrayList= ((CstArray) pair.getValue()).getList();
          for (int i= 0; i < clazzArrayList.size(); i++)
          {
            addReference(referencedTypes, ((CstType) clazzArrayList.get(i)).toHuman(), ReferenceKind.USAGE);
          }
        }
      }
    }

    Annotation delegateAnnotation= getAnnotation(directClassFile.getAttributes(), XMLVMDelegate.class);
    if (delegateAnnotation != null)
    {
      for (NameValuePair pair : delegateAnnotation.getNameValuePairs())
      {
        if (pair.getName().getString().equals("protocolType"))
        {
          String protocolType= ((CstString) pair.getValue()).getString().getString();
          classElement.setAttribute("delegateProtocolType", protocolType);
View Full Code Here

    codeElement.addContent(catchTableElement);
  }

  private void addDelegateElement(Method method, Element methodElement)
  {
    Annotation delegateAnnotation= getAnnotation(method.getAttributes(), XMLVMDelegateMethod.class);
    if (delegateAnnotation != null)
    {
      Element delegateMethodElement= new Element("delegateMethod", NS_XMLVM);
      methodElement.addContent(delegateMethodElement);

      for (NameValuePair pair : delegateAnnotation.getNameValuePairs())
      {
        String attrName= pair.getName().getString();
        if (attrName.equals("selector"))
        {
          String selector= ((CstString) pair.getValue()).getString().getString();
          delegateMethodElement.setAttribute("selector", selector);
        }
        else if (attrName.equals("params"))
        {
          CstArray.List paramList= ((CstArray) pair.getValue()).getList();
          for (int i= 0; i < paramList.size(); i++)
          {
            Element paramElement= new Element("param", NS_XMLVM);
            delegateMethodElement.addContent(paramElement);

            Annotation paramsAnnotation= ((CstAnnotation) paramList.get(i)).getAnnotation();
            for (NameValuePair paramsPair : paramsAnnotation.getNameValuePairs())
            {
              String paramsAttrName= paramsPair.getName().getString();
              if (paramsAttrName.equals("type"))
              {
                String type= ((CstString) paramsPair.getValue()).getString().getString();
View Full Code Here

TOP

Related Classes of com.android.dx.rop.annotation.Annotation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.