Package com.android.dx.cf.iface

Examples of com.android.dx.cf.iface.Field


        CstType thisClass = cf.getThisClass();
        FieldList fields = cf.getFields();
        int sz = fields.size();

        for (int i = 0; i < sz; i++) {
            Field one = fields.get(i);
            try {
                CstFieldRef field = new CstFieldRef(thisClass, one.getNat());
                int accessFlags = one.getAccessFlags();

                if (AccessFlags.isStatic(accessFlags)) {
                    TypedConstant constVal = one.getConstantValue();
                    EncodedField fi = new EncodedField(field, accessFlags);
                    if (constVal != null) {
                        constVal = coerceConstant(constVal, field.getType());
                    }
                    out.addStaticField(fi, constVal);
                } else {
                    EncodedField fi = new EncodedField(field, accessFlags);
                    out.addInstanceField(fi);
                }

                Annotations annotations =
                    AttributeTranslator.getAnnotations(one.getAttributes());
                if (annotations.size() != 0) {
                    out.addFieldAnnotations(field, annotations);
                }
            } catch (RuntimeException ex) {
                String msg = "...while processing " + one.getName().toHuman() +
                    " " + one.getDescriptor().toHuman();
                throw ExceptionWithContext.withContext(ex, msg);
            }
        }
    }
View Full Code Here


   */
  private void processFields(FieldList fieldList, Element classElement, Map<String, ReferenceKind> referencedTypes, boolean skeletonOnly)
  {
    for (int i= 0; i < fieldList.size(); ++i)
    {
      Field field= fieldList.get(i);
      if (hasAnnotation(field.getAttributes(), XMLVMIgnore.class))
      {
        // If this field has the @XMLVMIgnore annotation, we just
        // simply ignore it.
        continue;
      }
      if (skeletonOnly && (field.getAccessFlags() & (AccessFlags.ACC_PRIVATE | AccessFlags.ACC_SYNTHETIC)) != 0)
      {
        // This field is private or synthetic and we want to generate
        // only a skeleton, so we just simply ignore it.
        continue;
      }
      Element fieldElement= new Element("field", NS_XMLVM);
      fieldElement.setAttribute("name", field.getName().toHuman());
      String fieldType= field.getNat().getFieldType().toHuman();
      if (isRedType(fieldType))
      {
        fieldType= JLO;
      }
      else
      {
        addReference(referencedTypes, fieldType, ReferenceKind.USAGE);
      }

      fieldElement.setAttribute("type", fieldType);
      TypedConstant value= field.getConstantValue();
      if (value != null)
      {
        String constValue= null;
        if (fieldType.equals("java.lang.String"))
        {
          constValue= ((CstString) value).getString().getString();
          encodeString(fieldElement, constValue);
        }
        else
        {
          constValue= value.toHuman();
          fieldElement.setAttribute("value", constValue);
        }
      }
      processAccessFlags(field.getAccessFlags(), fieldElement);
      classElement.addContent(fieldElement);
    }
  }
View Full Code Here

TOP

Related Classes of com.android.dx.cf.iface.Field

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.