Sort the individual name/value pairs in an annotation by name

git-svn-id: https://smali.googlecode.com/svn/trunk@61 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
JesusFreke@JesusFreke.com 2009-06-03 04:42:37 +00:00
parent 9b649b5efc
commit c7a1ff2452
2 changed files with 14 additions and 1 deletions

View File

@ -30,7 +30,8 @@ package org.JesusFreke.dexlib.EncodedValue;
import org.JesusFreke.dexlib.*;
public class AnnotationElement extends CompositeField<AnnotationElement> {
public class AnnotationElement extends CompositeField<AnnotationElement>
implements Comparable<AnnotationElement> {
private final IndexedItemReference<StringIdItem> elementName;
private final EncodedValue encodedValue;
@ -51,4 +52,8 @@ public class AnnotationElement extends CompositeField<AnnotationElement> {
this.encodedValue = encodedValue
};
}
public int compareTo(AnnotationElement annotationElement) {
return elementName.compareTo(annotationElement.elementName);
}
}

View File

@ -32,6 +32,9 @@ import org.JesusFreke.dexlib.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Arrays;
import java.util.Collections;
import java.lang.reflect.Array;
public class AnnotationEncodedValueSubField extends CompositeField<AnnotationEncodedValueSubField>
implements EncodedValueSubField<AnnotationEncodedValueSubField> {
@ -71,6 +74,11 @@ public class AnnotationEncodedValueSubField extends CompositeField<AnnotationEnc
return 0;
}
public int place(int offset) {
Collections.sort(annotationElementList);
return super.place(offset);
}
public ValueType getValueType() {
return ValueType.VALUE_ANNOTATION;
}