Java Code Examples for org.jf.dexlib2.util.EncodedValueUtils#isDefaultValue()

The following examples show how to use org.jf.dexlib2.util.EncodedValueUtils#isDefaultValue() . These examples are extracted from open source projects. 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 Project: ZjDroid   File: FieldDefinition.java    License: 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 Project: zjdroid   File: FieldDefinition.java    License: 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 Project: HeyGirl   File: FieldDefinition.java    License: 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 Project: ZjDroid   File: FieldDefinition.java    License: 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 Project: ZjDroid   File: ClassPool.java    License: 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 Project: ZjDroid   File: BuilderClassPool.java    License: 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 Project: zjdroid   File: ClassPool.java    License: 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 Project: zjdroid   File: BuilderClassPool.java    License: 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 Project: HeyGirl   File: ClassPool.java    License: 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 Project: HeyGirl   File: BuilderClassPool.java    License: 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 Project: ZjDroid   File: ClassPool.java    License: 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 Project: ZjDroid   File: BuilderClassPool.java    License: 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);
}