aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSundong Ahn <sundongahn@google.com>2020-03-30 09:35:49 +0900
committerSundong Ahn <sundongahn@google.com>2020-03-30 09:50:45 +0900
commitc9e30c0f72acab790f8f494a37b4316cfcf3f078 (patch)
tree78d04f8a5ef6a414b67dba731e2f4a6af9d0b4f0
parent30b1c4f8d95ff5134517ed67d31989b1fa8ce273 (diff)
downloadxsdc-c9e30c0f72acab790f8f494a37b4316cfcf3f078.tar.gz
If both final annotation and nullability annotation are present, the final annotation can be ignored. So modify xsd parser code to not ignore final annotation. Bug: 151155782 Test: make update-api && make checkapi Merged-In: Ib1e558cb77f912fbbf96dc1970ae02060bbf823d Change-Id: Ib1e558cb77f912fbbf96dc1970ae02060bbf823d (cherry picked from commit 8f946dced8299a7ff6a91b61b28c303db4901b0e)
-rw-r--r--src/com/android/xsdc/XsdHandler.java18
-rw-r--r--tests/resources/simple_complex_content/api/current.txt8
-rw-r--r--tests/resources/simple_complex_content/simple_complex_content.xsd2
3 files changed, 16 insertions, 12 deletions
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 @@ public class XsdHandler extends DefaultHandler {
// 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 @@ public class XsdHandler extends DefaultHandler {
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 @@ package simple.complex.content {
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>