org.jf.dexlib2.util.EncodedValueUtils Java Examples

The following examples show how to use org.jf.dexlib2.util.EncodedValueUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FieldDefinition.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public static void writeTo(IndentingWriter writer, Field field, boolean setInStaticConstructor) throws IOException {
    EncodedValue initialValue = field.getInitialValue();
    int accessFlags = field.getAccessFlags();

    if (setInStaticConstructor &&
            AccessFlags.STATIC.isSet(accessFlags) &&
            AccessFlags.FINAL.isSet(accessFlags) &&
            initialValue != null) {
        if (!EncodedValueUtils.isDefaultValue(initialValue)) {
            writer.write("# The value of this static final field might be set in the static constructor\n");
        } else {
            // don't write out the default initial value for static final fields that get set in the static
            // constructor
            initialValue = null;
        }
    }

    writer.write(".field ");
    writeAccessFlags(writer, field.getAccessFlags());
    writer.write(field.getName());
    writer.write(':');
    writer.write(field.getType());
    if (initialValue != null) {
        writer.write(" = ");
        EncodedValueAdaptor.writeTo(writer, initialValue);
    }

    writer.write('\n');

    Collection<? extends Annotation> annotations = field.getAnnotations();
    if (annotations.size() > 0) {
        writer.indent(4);
        AnnotationFormatter.writeTo(writer, annotations);
        writer.deindent(4);
        writer.write(".end field\n");
    }
}
 
Example #2
Source File: FieldDefinition.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
public static void writeTo(IndentingWriter writer, Field field, boolean setInStaticConstructor) throws IOException {
    EncodedValue initialValue = field.getInitialValue();
    int accessFlags = field.getAccessFlags();

    if (setInStaticConstructor &&
            AccessFlags.STATIC.isSet(accessFlags) &&
            AccessFlags.FINAL.isSet(accessFlags) &&
            initialValue != null) {
        if (!EncodedValueUtils.isDefaultValue(initialValue)) {
            writer.write("# The value of this static final field might be set in the static constructor\n");
        } else {
            // don't write out the default initial value for static final fields that get set in the static
            // constructor
            initialValue = null;
        }
    }

    writer.write(".field ");
    writeAccessFlags(writer, field.getAccessFlags());
    writer.write(field.getName());
    writer.write(':');
    writer.write(field.getType());
    if (initialValue != null) {
        writer.write(" = ");
        EncodedValueAdaptor.writeTo(writer, initialValue);
    }

    writer.write('\n');

    Collection<? extends Annotation> annotations = field.getAnnotations();
    if (annotations.size() > 0) {
        writer.indent(4);
        AnnotationFormatter.writeTo(writer, annotations);
        writer.deindent(4);
        writer.write(".end field\n");
    }
}
 
Example #3
Source File: FieldDefinition.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
public static void writeTo(IndentingWriter writer, Field field, boolean setInStaticConstructor) throws IOException {
    EncodedValue initialValue = field.getInitialValue();
    int accessFlags = field.getAccessFlags();

    if (setInStaticConstructor &&
            AccessFlags.STATIC.isSet(accessFlags) &&
            AccessFlags.FINAL.isSet(accessFlags) &&
            initialValue != null) {
        if (!EncodedValueUtils.isDefaultValue(initialValue)) {
            writer.write("# The value of this static final field might be set in the static constructor\n");
        } else {
            // don't write out the default initial value for static final fields that get set in the static
            // constructor
            initialValue = null;
        }
    }

    writer.write(".field ");
    writeAccessFlags(writer, field.getAccessFlags());
    writer.write(field.getName());
    writer.write(':');
    writer.write(field.getType());
    if (initialValue != null) {
        writer.write(" = ");
        EncodedValueAdaptor.writeTo(writer, initialValue);
    }

    writer.write('\n');

    Collection<? extends Annotation> annotations = field.getAnnotations();
    if (annotations.size() > 0) {
        writer.indent(4);
        AnnotationFormatter.writeTo(writer, annotations);
        writer.deindent(4);
        writer.write(".end field\n");
    }
}
 
Example #4
Source File: FieldDefinition.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
public static void writeTo(IndentingWriter writer, Field field, boolean setInStaticConstructor) throws IOException {
    EncodedValue initialValue = field.getInitialValue();
    int accessFlags = field.getAccessFlags();

    if (setInStaticConstructor &&
            AccessFlags.STATIC.isSet(accessFlags) &&
            AccessFlags.FINAL.isSet(accessFlags) &&
            initialValue != null) {
        if (!EncodedValueUtils.isDefaultValue(initialValue)) {
            writer.write("# The value of this static final field might be set in the static constructor\n");
        } else {
            // don't write out the default initial value for static final fields that get set in the static
            // constructor
            initialValue = null;
        }
    }

    writer.write(".field ");
    writeAccessFlags(writer, field.getAccessFlags());
    writer.write(field.getName());
    writer.write(':');
    writer.write(field.getType());
    if (initialValue != null) {
        writer.write(" = ");
        EncodedValueAdaptor.writeTo(writer, initialValue);
    }

    writer.write('\n');

    Collection<? extends Annotation> annotations = field.getAnnotations();
    if (annotations.size() > 0) {
        writer.indent(4);
        AnnotationFormatter.writeTo(writer, annotations);
        writer.deindent(4);
        writer.write(".end field\n");
    }
}
 
Example #5
Source File: ClassPool.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
@Override
public boolean apply(Field input) {
    EncodedValue encodedValue = input.getInitialValue();
    return encodedValue != null && !EncodedValueUtils.isDefaultValue(encodedValue);
}
 
Example #6
Source File: BuilderClassPool.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
@Override
public boolean apply(Field input) {
    EncodedValue encodedValue = input.getInitialValue();
    return encodedValue != null && !EncodedValueUtils.isDefaultValue(encodedValue);
}
 
Example #7
Source File: ClassPool.java    From zjdroid with Apache License 2.0 4 votes vote down vote up
@Override
public boolean apply(Field input) {
    EncodedValue encodedValue = input.getInitialValue();
    return encodedValue != null && !EncodedValueUtils.isDefaultValue(encodedValue);
}
 
Example #8
Source File: BuilderClassPool.java    From zjdroid with Apache License 2.0 4 votes vote down vote up
@Override
public boolean apply(Field input) {
    EncodedValue encodedValue = input.getInitialValue();
    return encodedValue != null && !EncodedValueUtils.isDefaultValue(encodedValue);
}
 
Example #9
Source File: ClassPool.java    From HeyGirl with Apache License 2.0 4 votes vote down vote up
@Override
public boolean apply(Field input) {
    EncodedValue encodedValue = input.getInitialValue();
    return encodedValue != null && !EncodedValueUtils.isDefaultValue(encodedValue);
}
 
Example #10
Source File: BuilderClassPool.java    From HeyGirl with Apache License 2.0 4 votes vote down vote up
@Override
public boolean apply(Field input) {
    EncodedValue encodedValue = input.getInitialValue();
    return encodedValue != null && !EncodedValueUtils.isDefaultValue(encodedValue);
}
 
Example #11
Source File: ClassPool.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
@Override
public boolean apply(Field input) {
    EncodedValue encodedValue = input.getInitialValue();
    return encodedValue != null && !EncodedValueUtils.isDefaultValue(encodedValue);
}
 
Example #12
Source File: BuilderClassPool.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
@Override
public boolean apply(Field input) {
    EncodedValue encodedValue = input.getInitialValue();
    return encodedValue != null && !EncodedValueUtils.isDefaultValue(encodedValue);
}