Support final and nullability am: c9e30c0f72 am: 4ae92fd359

Change-Id: If18613fd8004a6a3bedb7302fe9f9f5d1b8a0408
diff --git a/src/com/android/xsdc/XsdHandler.java b/src/com/android/xsdc/XsdHandler.java
index 5a7c0d4..a2cc57c 100644
--- a/src/com/android/xsdc/XsdHandler.java
+++ b/src/com/android/xsdc/XsdHandler.java
@@ -204,8 +204,10 @@
                     // Tags under simpleType <restriction>. They are ignored.
                     break;
                 case "annotation":
-                    stateStack.peek().deprecated = isDeprecated(state.attributeMap, state.tags);
-                    stateStack.peek().finalValue = isFinalValue(state.attributeMap, state.tags);
+                    stateStack.peek().deprecated = isDeprecated(state.attributeMap, state.tags,
+                            stateStack.peek().deprecated);
+                    stateStack.peek().finalValue = isFinalValue(state.attributeMap, state.tags,
+                            stateStack.peek().finalValue);
                     stateStack.peek().nullability = getNullability(state.attributeMap, state.tags,
                             stateStack.peek().nullability);
                     break;
@@ -656,22 +658,22 @@
                 state.finalValue, state.nullability);
     }
 
-    private boolean isDeprecated(Map<String, String> attributeMap,List<XsdTag> tags)
-            throws XsdParserException {
+    private boolean isDeprecated(Map<String, String> attributeMap,List<XsdTag> tags,
+            boolean deprecated) throws XsdParserException {
         String name = attributeMap.get("name");
         if ("Deprecated".equals(name)) {
             return true;
         }
-        return false;
+        return deprecated;
     }
 
-    private boolean isFinalValue(Map<String, String> attributeMap,List<XsdTag> tags)
-            throws XsdParserException {
+    private boolean isFinalValue(Map<String, String> attributeMap,List<XsdTag> tags,
+            boolean finalValue) throws XsdParserException {
         String name = attributeMap.get("name");
         if ("final".equals(name)) {
             return true;
         }
-        return false;
+        return finalValue;
     }
 
     private Nullability getNullability(Map<String, String> attributeMap,List<XsdTag> tags,
diff --git a/tests/resources/simple_complex_content/api/current.txt b/tests/resources/simple_complex_content/api/current.txt
index 601a57e..8ca1793 100644
--- a/tests/resources/simple_complex_content/api/current.txt
+++ b/tests/resources/simple_complex_content/api/current.txt
@@ -41,10 +41,10 @@
 
   public class SubAddress {
     ctor public SubAddress();
-    method @Nullable public String getChoice1_optional();
-    method @NonNull public String getChoice2_optional();
-    method public void setChoice1_optional(@Nullable String);
-    method public void setChoice2_optional(@NonNull String);
+    method @Nullable public final String getChoice1_optional();
+    method @NonNull public final String getChoice2_optional();
+    method public final void setChoice1_optional(@Nullable String);
+    method public final void setChoice2_optional(@NonNull String);
   }
 
   public final class USAddressP extends simple.complex.content.Address {
diff --git a/tests/resources/simple_complex_content/simple_complex_content.xsd b/tests/resources/simple_complex_content/simple_complex_content.xsd
index dc66cd3..62a6497 100644
--- a/tests/resources/simple_complex_content/simple_complex_content.xsd
+++ b/tests/resources/simple_complex_content/simple_complex_content.xsd
@@ -34,10 +34,12 @@
     <xs:complexType name="subAddress">
         <xs:choice>
             <xs:element name="choice1" type="xs:string">
+                <xs:annotation name="final"/>
                 <xs:annotation name="nullable"/>
             </xs:element>
             <xs:element name="choice2" type="xs:string">
                 <xs:annotation name="nonnull"/>
+                <xs:annotation name="final"/>
             </xs:element>
         </xs:choice>
     </xs:complexType>