Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/QNameSet.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/QNameSet.java?rev=1882074&r1=1882073&r2=1882074&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/QNameSet.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/QNameSet.java Sun Sep 27 
21:25:33 2020
@@ -16,12 +16,10 @@
 package org.apache.xmlbeans;
 
 import javax.xml.namespace.QName;
-
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Collections;
 import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
 
 /**
  * This interface represents a lattice of finite and infinite sets of QNames.
@@ -66,106 +64,111 @@ import java.util.Arrays;
  *
  * @see QNameSetBuilder
  */
-public final class QNameSet implements QNameSetSpecification, 
java.io.Serializable
-{
+public final class QNameSet implements QNameSetSpecification, 
java.io.Serializable {
     private static final long serialVersionUID = 1L;
-    
+
     private final boolean _inverted;
-    private final Set _includedURIs;
-    private final Set _excludedQNames;
-    private final Set _includedQNames;
+    private final Set<String> _includedURIs;
+    private final Set<QName> _excludedQNames;
+    private final Set<QName> _includedQNames;
 
     /**
      * The empty QNameSet.
      */
-    public static final QNameSet EMPTY = new QNameSet(null, 
Collections.EMPTY_SET, Collections.EMPTY_SET, Collections.EMPTY_SET);
+    public static final QNameSet EMPTY = new QNameSet(null, 
Collections.emptySet(), Collections.emptySet(), Collections.emptySet());
 
     /**
      * The QNameSet containing all QNames.
      */
-    public static final QNameSet ALL = new QNameSet(Collections.EMPTY_SET, 
null, Collections.EMPTY_SET, Collections.EMPTY_SET);
+    public static final QNameSet ALL = new QNameSet(Collections.emptySet(), 
null, Collections.emptySet(), Collections.emptySet());
 
     /**
      * The QNameSet containing all QNames in the local (no-)namespace.
      */
-    public static final QNameSet LOCAL = new QNameSet(null, 
Collections.singleton(""), Collections.EMPTY_SET, Collections.EMPTY_SET);
+    public static final QNameSet LOCAL = new QNameSet(null, 
Collections.singleton(""), Collections.emptySet(), Collections.emptySet());
 
     /**
      * The QNameSet containing all QNames except for those in the local 
(no-)namespace.
      */
-    public static final QNameSet NONLOCAL = new 
QNameSet(Collections.singleton(""), null, Collections.EMPTY_SET, 
Collections.EMPTY_SET);
+    public static final QNameSet NONLOCAL = new 
QNameSet(Collections.singleton(""), null, Collections.emptySet(), 
Collections.emptySet());
 
     /**
      * Private function to minimize object creation when copying sets.
      */
-    private static Set minSetCopy(Set original)
-    {
-        if (original == null)
+    private static <T> Set<T> minSetCopy(Set<T> original) {
+        if (original == null) {
             return null;
-        if (original.isEmpty())
-            return Collections.EMPTY_SET;
-        if (original.size() == 1)
+        }
+        if (original.isEmpty()) {
+            return Collections.emptySet();
+        }
+        if (original.size() == 1) {
             return Collections.singleton(original.iterator().next());
-        return new HashSet(original);
+        }
+        return new HashSet<>(original);
     }
 
     /**
      * Returns a QNameSet based on the given sets of excluded URIs,
      * included URIs, excluded QNames in included namespaces, and included
      * QNames in excluded namespaces.
-     * 
-     * @param excludedURIs the finite set of namespace URI strings to exclude 
from the set, or null if this set is infinite
-     * @param includedURIs the finite set of namespace URI strings to include 
in the set, or null if this set is infinite
+     *
+     * @param excludedURIs                 the finite set of namespace URI 
strings to exclude from the set, or null if this set is infinite
+     * @param includedURIs                 the finite set of namespace URI 
strings to include in the set, or null if this set is infinite
      * @param excludedQNamesInIncludedURIs the finite set of exceptional 
QNames to exclude from the included namespaces
-     * @param excludedQNamesInIncludedURIs the finite set of exceptional 
QNames to include that are in the excluded namespaces
-     * 
+     * @param includedQNamesInExcludedURIs the finite set of exceptional 
QNames to include that are in the excluded namespaces
      * @return the constructed QNameSet
      */
-    public static QNameSet forSets(Set excludedURIs, Set includedURIs, Set 
excludedQNamesInIncludedURIs, Set includedQNamesInExcludedURIs)
-    {
-        if ((excludedURIs != null) == (includedURIs != null))
+    public static QNameSet forSets(Set<String> excludedURIs, Set<String> 
includedURIs, Set<QName> excludedQNamesInIncludedURIs, Set<QName> 
includedQNamesInExcludedURIs) {
+        if ((excludedURIs != null) == (includedURIs != null)) {
             throw new IllegalArgumentException("Exactly one of excludedURIs 
and includedURIs must be null");
+        }
 
-        if (excludedURIs == null && includedURIs.isEmpty() && 
includedQNamesInExcludedURIs.isEmpty())
+        if (excludedURIs == null && includedURIs.isEmpty() && 
includedQNamesInExcludedURIs.isEmpty()) {
             return EMPTY;
-        if (includedURIs == null && excludedURIs.isEmpty() && 
excludedQNamesInIncludedURIs.isEmpty())
+        }
+        if (includedURIs == null && excludedURIs.isEmpty() && 
excludedQNamesInIncludedURIs.isEmpty()) {
             return ALL;
+        }
         if (excludedURIs == null && includedURIs.size() == 1 && 
includedURIs.contains("") &&
-            includedQNamesInExcludedURIs.isEmpty() && 
excludedQNamesInIncludedURIs.isEmpty())
+            includedQNamesInExcludedURIs.isEmpty() && 
excludedQNamesInIncludedURIs.isEmpty()) {
             return LOCAL;
+        }
         if (includedURIs == null && excludedURIs.size() == 1 && 
excludedURIs.contains("") &&
-            excludedQNamesInIncludedURIs.isEmpty() && 
includedQNamesInExcludedURIs.isEmpty())
+            excludedQNamesInIncludedURIs.isEmpty() && 
includedQNamesInExcludedURIs.isEmpty()) {
             return NONLOCAL;
+        }
 
         return new QNameSet(
-                minSetCopy(excludedURIs),
-                minSetCopy(includedURIs),
-                minSetCopy(excludedQNamesInIncludedURIs),
-                minSetCopy(includedQNamesInExcludedURIs));
+            minSetCopy(excludedURIs),
+            minSetCopy(includedURIs),
+            minSetCopy(excludedQNamesInIncludedURIs),
+            minSetCopy(includedQNamesInExcludedURIs));
     }
 
     /**
      * Returns a QNameSet based on the given array of included QNames
-     * 
+     *
      * @param includedQNames the array of included QNames
      */
-    public static QNameSet forArray(QName[] includedQNames)
-    {
-        if (includedQNames == null)
+    public static QNameSet forArray(QName[] includedQNames) {
+        if (includedQNames == null) {
             throw new IllegalArgumentException("includedQNames cannot be 
null");
+        }
 
-        return new QNameSet(null, Collections.EMPTY_SET, 
Collections.EMPTY_SET, new HashSet(Arrays.asList(includedQNames)));
+        return new QNameSet(null, Collections.emptySet(), 
Collections.emptySet(), new HashSet<>(Arrays.asList(includedQNames)));
     }
 
     /**
      * Returns a QNameSet with the same contents as the given
      * QNameSetSpecification.
+     *
      * @return the copied QNameSet
      */
-    public static QNameSet forSpecification(QNameSetSpecification spec)
-    {
-        if (spec instanceof QNameSet)
-            return (QNameSet)spec;
+    public static QNameSet forSpecification(QNameSetSpecification spec) {
+        if (spec instanceof QNameSet) {
+            return (QNameSet) spec;
+        }
         return QNameSet.forSets(spec.excludedURIs(), spec.includedURIs(), 
spec.excludedQNamesInIncludedURIs(), spec.includedQNamesInExcludedURIs());
     }
 
@@ -173,56 +176,51 @@ public final class QNameSet implements Q
      * Returns a QNameSet corresponding to the given wildcard namespace string.
      * This is a space-separated list of URIs, plus special tokens as specified
      * in the XML Schema specification (##any, ##other, ##targetNamespace, 
##local).
+     *
      * @return the constructed QNameSet
      */
-    public static QNameSet forWildcardNamespaceString(String wildcard, String 
targetURI)
-    {
+    public static QNameSet forWildcardNamespaceString(String wildcard, String 
targetURI) {
         return QNameSet.forSpecification(new QNameSetBuilder(wildcard, 
targetURI));
     }
 
     /**
      * Returns a QNameSet containing only the given QName.
+     *
      * @return the constructed QNameSet
      */
-    public static QNameSet singleton(QName name)
-    {
-        return new QNameSet(null, Collections.EMPTY_SET, 
Collections.EMPTY_SET, Collections.singleton(name));
+    public static QNameSet singleton(QName name) {
+        return new QNameSet(null, Collections.emptySet(), 
Collections.emptySet(), Collections.singleton(name));
     }
 
     /**
      * Constructs a QNameSetBuilder whose contents are given by
      * the four sets.
-     *
+     * <p>
      * This constuctor is PRIVATE because it uses the given
      * sets directly, and it trusts its callers to set only immutable values.
      * This constructor is is only called by the static builder methods on
      * QNameSet: those methods are all careful assign only unchanging sets.
      */
-    private QNameSet(Set excludedURIs, Set includedURIs, Set 
excludedQNamesInIncludedURIs, Set includedQNamesInExcludedURIs)
-    {
-        if (includedURIs != null && excludedURIs == null)
-        {
+    private QNameSet(Set<String> excludedURIs, Set<String> includedURIs, 
Set<QName> excludedQNamesInIncludedURIs, Set<QName> 
includedQNamesInExcludedURIs) {
+        if (includedURIs != null && excludedURIs == null) {
             _inverted = false;
             _includedURIs = includedURIs;
             _excludedQNames = excludedQNamesInIncludedURIs;
             _includedQNames = includedQNamesInExcludedURIs;
-        }
-        else if (excludedURIs != null && includedURIs == null)
-        {
+        } else if (excludedURIs != null && includedURIs == null) {
             _inverted = true;
             _includedURIs = excludedURIs;
             _excludedQNames = includedQNamesInExcludedURIs;
             _includedQNames = excludedQNamesInIncludedURIs;
-        }
-        else
+        } else {
             throw new IllegalArgumentException("Exactly one of excludedURIs 
and includedURIs must be null");
+        }
     }
 
     /**
      * Local xml names are hased using "" as the namespace.
      */
-    private static String nsFromName(QName xmlName)
-    {
+    private static String nsFromName(QName xmlName) {
         String ns = xmlName.getNamespaceURI();
         return ns == null ? "" : ns;
     }
@@ -230,37 +228,34 @@ public final class QNameSet implements Q
     /**
      * True if this ModelTransitionSet contains the given qname.
      */
-    public boolean contains(QName name)
-    {
+    public boolean contains(QName name) {
         boolean in = _includedURIs.contains(nsFromName(name)) ?
-                     !_excludedQNames.contains(name) :
-                      _includedQNames.contains(name);
+            !_excludedQNames.contains(name) :
+            _includedQNames.contains(name);
         return _inverted ^ in;
     }
 
     /**
      * True if this ModelTransitionSet contains all QNames.
      */
-    public boolean isAll()
-    {
+    public boolean isAll() {
         return _inverted && _includedURIs.isEmpty() && 
_includedQNames.isEmpty();
     }
 
     /**
      * True if this ModelTransitionSet contains no QNames.
      */
-    public boolean isEmpty()
-    {
+    public boolean isEmpty() {
         return !_inverted && _includedURIs.isEmpty() && 
_includedQNames.isEmpty();
     }
 
     /**
      * Returns a new QNameSet that is the intersection of this one and another.
+     *
      * @param set the set to insersect with
      * @return the intersection
      */
-    public QNameSet intersect(QNameSetSpecification set)
-    {
+    public QNameSet intersect(QNameSetSpecification set) {
         QNameSetBuilder result = new QNameSetBuilder(this);
         result.restrict(set);
         return result.toQNameSet();
@@ -268,11 +263,11 @@ public final class QNameSet implements Q
 
     /**
      * Returns a new QNameSet that is the union of this one and another.
+     *
      * @param set the set to union with
      * @return the union
      */
-    public QNameSet union(QNameSetSpecification set)
-    {
+    public QNameSet union(QNameSetSpecification set) {
         QNameSetBuilder result = new QNameSetBuilder(this);
         result.addAll(set);
         return result.toQNameSet();
@@ -281,166 +276,160 @@ public final class QNameSet implements Q
     /**
      * Returns a new QNameSet that is the inverse of this one.
      */
-    public QNameSet inverse()
-    {
-        if (this == EMPTY)
+    public QNameSet inverse() {
+        if (this == EMPTY) {
             return ALL;
-        if (this == ALL)
+        }
+        if (this == ALL) {
             return EMPTY;
-        if (this == LOCAL)
+        }
+        if (this == LOCAL) {
             return NONLOCAL;
-        if (this == NONLOCAL)
+        }
+        if (this == NONLOCAL) {
             return LOCAL;
+        }
         return new QNameSet(includedURIs(), excludedURIs(), 
includedQNamesInExcludedURIs(), excludedQNamesInIncludedURIs());
     }
 
     /**
      * True if the given set is a subset of this one.
+     *
      * @param set the set to test
      * @return true if this contains all QNames contained by the given set
      */
-    public boolean containsAll(QNameSetSpecification set)
-    {
+    public boolean containsAll(QNameSetSpecification set) {
         // a.contains(b) == a.inverse.isDisjoint(b)
-        if (!_inverted && set.excludedURIs() != null)
+        if (!_inverted && set.excludedURIs() != null) {
             return false;
-        
+        }
+
         return inverse().isDisjoint(set);
     }
 
     /**
      * True if the given set is disjoint from this one.
+     *
      * @param set the set to test
      * @return true if the set is disjoint from this set
      */
-    public boolean isDisjoint(QNameSetSpecification set)
-    {
-        if (_inverted && set.excludedURIs() != null)
+    public boolean isDisjoint(QNameSetSpecification set) {
+        if (_inverted && set.excludedURIs() != null) {
             return false;
+        }
 
-        if (_inverted)
+        if (_inverted) {
             return isDisjointImpl(set, this);
-        else
+        } else {
             return isDisjointImpl(this, set);
+        }
     }
-    
-    private boolean isDisjointImpl(QNameSetSpecification set1, 
QNameSetSpecification set2)
-    {
-        Set includeURIs = set1.includedURIs();
-        Set otherIncludeURIs = set2.includedURIs();
-        if (otherIncludeURIs != null)
-        {
-            for (Iterator i = includeURIs.iterator(); i.hasNext(); )
-            {
-                if (otherIncludeURIs.contains(i.next()))
-                    return false;
+
+    private boolean isDisjointImpl(QNameSetSpecification set1, 
QNameSetSpecification set2) {
+        Set<String> includeURIs = set1.includedURIs();
+        Set<String> otherIncludeURIs = set2.includedURIs();
+
+        if (otherIncludeURIs != null) {
+            if (!Collections.disjoint(includeURIs, otherIncludeURIs)) {
+                return false;
             }
-        }
-        else
-        {
-            Set otherExcludeURIs = set2.excludedURIs();
-            for (Iterator i = includeURIs.iterator(); i.hasNext(); )
-            {
-                if (!otherExcludeURIs.contains(i.next()))
-                    return false;
+        } else {
+            if (!set2.excludedURIs().containsAll(includeURIs)) {
+                return false;
             }
         }
 
-        for (Iterator i = set1.includedQNamesInExcludedURIs().iterator(); 
i.hasNext(); )
-        {
-            if (set2.contains((QName)i.next()))
-                return false;
+        if 
(set1.includedQNamesInExcludedURIs().stream().anyMatch(set2::contains)) {
+            return false;
         }
 
-        if (includeURIs.size() > 0)
-            for (Iterator i = set2.includedQNamesInExcludedURIs().iterator(); 
i.hasNext(); )
-        {
-            if (set1.contains((QName)i.next()))
-                return false;
+        if 
(set2.includedQNamesInExcludedURIs().stream().anyMatch(set1::contains)) {
+            return false;
         }
 
         return true;
     }
 
-    
+
     /**
      * Namespaces that are fully excluded from the set except for a finite
      * number of individual QName exceptions.  Returns null if this set is 
infinite.
+     *
      * @return the set of excluded namespace URI strings
-     */ 
-    public Set excludedURIs()
-    {
-        if (_inverted) return Collections.unmodifiableSet(_includedURIs);
+     */
+    public Set<String> excludedURIs() {
+        if (_inverted) {
+            return Collections.unmodifiableSet(_includedURIs);
+        }
         return null;
     }
 
     /**
      * Namespaces that are fully included in set except for a finite
      * number of individual QName exceptions. Returns null if this set is 
infinite.
+     *
      * @return the set of included namespace URI strings
-     */ 
-    public Set includedURIs()
-    {
-        if (!_inverted) return _includedURIs;
+     */
+    public Set<String> includedURIs() {
+        if (!_inverted) {
+            return _includedURIs;
+        }
         return null;
     }
-    
+
     /**
      * The set of QNames excluded from the set even though they are within
      * a namespace that is otherwise fully included in the set.
+     *
      * @return the set of excluded QNames from within includedURI namespaces
-     */ 
-    public Set excludedQNamesInIncludedURIs()
-    {
+     */
+    public Set<QName> excludedQNamesInIncludedURIs() {
         return Collections.unmodifiableSet(_inverted ? _includedQNames : 
_excludedQNames);
     }
 
     /**
      * The set of QNames included in the set even though they are within
      * a namespace that is otherwise fully included in the set.
+     *
      * @return the set of included QNames from within excludedURI namespaces
-     */ 
-    public Set includedQNamesInExcludedURIs()
-    {
+     */
+    public Set<QName> includedQNamesInExcludedURIs() {
         return Collections.unmodifiableSet(_inverted ? _excludedQNames : 
_includedQNames);
     }
-    
-    private String prettyQName(QName name)
-    {
-        if (name.getNamespaceURI() == null)
+
+    private String prettyQName(QName name) {
+        if (name.getNamespaceURI() == null) {
             return name.getLocalPart();
+        }
         return name.getLocalPart() + "@" + name.getNamespaceURI();
     }
 
     /**
      * Returns a string representation useful for debugging, subject to change.
-     */ 
-    public String toString()
-    {
+     */
+    public String toString() {
         StringBuilder sb = new StringBuilder();
         sb.append("QNameSet");
         sb.append(_inverted ? "-(" : "+(");
-        for (Iterator i = _includedURIs.iterator(); i.hasNext(); )
-        {
+        for (String includedURIs : _includedURIs) {
             sb.append("+*@");
-            sb.append(i.next());
+            sb.append(includedURIs);
             sb.append(", ");
         }
-        for (Iterator i = _excludedQNames.iterator(); i.hasNext(); )
-        {
+        for (QName excludedQName : _excludedQNames) {
             sb.append("-");
-            sb.append(prettyQName((QName)i.next()));
+            sb.append(prettyQName(excludedQName));
             sb.append(", ");
         }
-        for (Iterator i = _includedQNames.iterator(); i.hasNext(); )
-        {
+        for (QName includedQName : _includedQNames) {
             sb.append("+");
-            sb.append(prettyQName((QName)i.next()));
+            sb.append(prettyQName(includedQName));
             sb.append(", ");
         }
         int index = sb.lastIndexOf(", ");
-        if (index > 0)
+        if (index > 0) {
             sb.setLength(index);
+        }
         sb.append(')');
         return sb.toString();
     }

Modified: 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/QNameSetSpecification.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/QNameSetSpecification.java?rev=1882074&r1=1882073&r2=1882074&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/QNameSetSpecification.java 
(original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/QNameSetSpecification.java 
Sun Sep 27 21:25:33 2020
@@ -16,19 +16,17 @@
 package org.apache.xmlbeans;
 
 import javax.xml.namespace.QName;
-
 import java.util.Set;
 
 /**
  * Represents a lattice of finite and infinite sets of QNames.
- * 
+ *
  * @see QNameSet
  */
-public interface QNameSetSpecification
-{
+public interface QNameSetSpecification {
     /**
      * True if the set contains the given QName.
-     *
+     * <p>
      * Roughly equivalent to:
      *    (includedURIs() == null ?
      *           excludedURIs().contains(namespace) :
@@ -51,9 +49,9 @@ public interface QNameSetSpecification
 
     /**
      * True if the parameter is a subset of this set.
-     */ 
+     */
     boolean containsAll(QNameSetSpecification set);
-    
+
     /**
      * True if is disjoint from the specified set.
      */
@@ -88,7 +86,7 @@ public interface QNameSetSpecification
      * <p>
      * The same set as inverse().includedURIs().
      */
-    Set excludedURIs();
+    Set<String> excludedURIs();
 
     /**
      * The finite set of namespace URIs that are almost completely included in
@@ -101,7 +99,7 @@ public interface QNameSetSpecification
      * <p>
      * The same as inverse.excludedURIs().
      */
-    Set includedURIs();
+    Set<String> includedURIs();
 
     /**
      * The finite set of QNames that are excluded from the set within 
namespaces
@@ -113,7 +111,7 @@ public interface QNameSetSpecification
      * <p>
      * The same set as inverse().includedQNames().
      */
-    Set excludedQNamesInIncludedURIs();
+    Set<QName> excludedQNamesInIncludedURIs();
 
     /**
      * The finite set of QNames that are included in the set within namespaces
@@ -125,5 +123,5 @@ public interface QNameSetSpecification
      * <p>
      * The same as inverse().excludedQNames().
      */
-    Set includedQNamesInExcludedURIs();
+    Set<QName> includedQNamesInExcludedURIs();
 }

Modified: 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/SchemaIdentityConstraint.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/SchemaIdentityConstraint.java?rev=1882074&r1=1882073&r2=1882074&view=diff
==============================================================================
--- 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/SchemaIdentityConstraint.java 
(original)
+++ 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/SchemaIdentityConstraint.java 
Sun Sep 27 21:25:33 2020
@@ -15,14 +15,12 @@
 
 package org.apache.xmlbeans;
 
-import javax.xml.namespace.QName;
 import java.util.Map;
 
 /**
  * Represents an identity constraint definition.
- */ 
-public interface SchemaIdentityConstraint extends SchemaComponent, 
SchemaAnnotated
-{
+ */
+public interface SchemaIdentityConstraint extends SchemaComponent, 
SchemaAnnotated {
     /**
      * Return the selector xpath as a string.
      */
@@ -44,18 +42,24 @@ public interface SchemaIdentityConstrain
     Object getFieldPath(int index);
 
     /**
-     * Return a read-only copy of the namespace map. This is the 
+     * Return a read-only copy of the namespace map. This is the
      * set of prefix to URI mappings that were in scope in the
      * schema at the point at which this constraint was declared
      */
-    Map getNSMap();
+    Map<String, String> getNSMap();
 
-    /** A <a target="_blank" 
href="http://www.w3.org/TR/xmlschema-1/#declare-key";>xs:key</a> constraint.  
See {@link #getConstraintCategory}. */
-    public static final int CC_KEY = 1;
-    /** A <a target="_blank" 
href="http://www.w3.org/TR/xmlschema-1/#declare-key";>xs:keyRef</a> constraint.  
See {@link #getConstraintCategory}. */
-    public static final int CC_KEYREF = 2;
-    /** A <a target="_blank" 
href="http://www.w3.org/TR/xmlschema-1/#declare-key";>xs:unique</a> constraint.  
See {@link #getConstraintCategory}. */
-    public static final int CC_UNIQUE = 3;
+    /**
+     * A <a target="_blank" 
href="http://www.w3.org/TR/xmlschema-1/#declare-key";>xs:key</a> constraint.  
See {@link #getConstraintCategory}.
+     */
+    int CC_KEY = 1;
+    /**
+     * A <a target="_blank" 
href="http://www.w3.org/TR/xmlschema-1/#declare-key";>xs:keyRef</a> constraint.  
See {@link #getConstraintCategory}.
+     */
+    int CC_KEYREF = 2;
+    /**
+     * A <a target="_blank" 
href="http://www.w3.org/TR/xmlschema-1/#declare-key";>xs:unique</a> constraint.  
See {@link #getConstraintCategory}.
+     */
+    int CC_UNIQUE = 3;
 
     /**
      * Return the constraint category. Either {@link #CC_KEY}, {@link 
#CC_KEYREF},
@@ -71,26 +75,28 @@ public interface SchemaIdentityConstrain
 
     /**
      * Used to allow on-demand loading of identity constraints.
-     * 
-     * @exclude
      */
-    public static final class Ref extends SchemaComponent.Ref
-    {
-        public Ref(SchemaIdentityConstraint idc)
-            { super(idc); }
-
-        public Ref(SchemaTypeSystem system, String handle)
-            { super(system, handle); }
-
-        public final int getComponentType()
-            { return SchemaComponent.IDENTITY_CONSTRAINT; }
-
-        public final SchemaIdentityConstraint get()
-            { return (SchemaIdentityConstraint)getComponent(); }
+    final class Ref extends SchemaComponent.Ref {
+        public Ref(SchemaIdentityConstraint idc) {
+            super(idc);
+        }
+
+        public Ref(SchemaTypeSystem system, String handle) {
+            super(system, handle);
+        }
+
+        public final int getComponentType() {
+            return SchemaComponent.IDENTITY_CONSTRAINT;
+        }
+
+        public final SchemaIdentityConstraint get() {
+            return (SchemaIdentityConstraint) getComponent();
+        }
     }
 
     /**
      * Returns user-specific information.
+     *
      * @see SchemaBookmark
      */
     Object getUserData();

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/SimpleValue.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/SimpleValue.java?rev=1882074&r1=1882073&r2=1882074&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/SimpleValue.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/SimpleValue.java Sun Sep 
27 21:25:33 2020
@@ -135,12 +135,12 @@ public interface SimpleValue extends Xml
     /**
      * Returns the value as a {@link List} of friendly Java objects (String, 
Integer, Byte, Short, Long, BigInteger, Decimal, Float, Double, byte[], 
Calendar, GDuration).
      */
-    List getListValue();
+    List<?> getListValue();
 
     /**
      * Returns the value as a {@link List} of XmlAnySimpleType objects.
      */
-    List xgetListValue();
+    List<? extends XmlAnySimpleType> xgetListValue();
 
     /**
      * Returns a union value as a its natural friendly Java object (String, 
Integer, Byte, Short, Long, BigInteger, Decimal, Float, Double, byte[], 
Calendar, GDuration).

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/XmlError.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/XmlError.java?rev=1882074&r1=1882073&r2=1882074&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/XmlError.java (original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/XmlError.java Sun Sep 27 
21:25:33 2020
@@ -15,13 +15,15 @@
 
 package org.apache.xmlbeans;
 
+import javax.xml.stream.Location;
+import java.io.File;
 import java.net.URI;
 import java.net.URISyntaxException;
-import java.io.File;
-import java.util.ResourceBundle;
-import java.util.PropertyResourceBundle;
 import java.text.MessageFormat;
-import javax.xml.stream.Location;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.PropertyResourceBundle;
+import java.util.ResourceBundle;
 
 /**
  * Represents a message at a specific XML location.
@@ -36,28 +38,27 @@ import javax.xml.stream.Location;
  * @see XmlOptions#setErrorListener
  * @see XmlException
  */
-public class XmlError implements java.io.Serializable
-{
+public class XmlError implements java.io.Serializable {
     private static final long serialVersionUID = 1L;
 
-    private static final ResourceBundle _bundle = 
PropertyResourceBundle.getBundle("org.apache.xmlbeans.message");
+    private static final ResourceBundle _bundle = 
PropertyResourceBundle.getBundle("org.apache.xmlbeans.message", Locale.ROOT);
 
-    private String _message;
-    private String _code;
-    private String _source;
-    private int    _severity = SEVERITY_ERROR;
-    private int    _line = -1;
-    private int    _column = -1;
-    private int    _offset = -1;
+    private final String _message;
+    private final String _code;
+    private final String _source;
+    private final int _severity;
+    private final int _line;
+    private final int _column;
+    private int _offset = -1;
 
     private transient XmlCursor _cursor;
 
     /**
      * Copy constructor.
+     *
      * @param src The original XmlError to copy.
      */
-    public XmlError(XmlError src)
-    {
+    public XmlError(XmlError src) {
         _message = src.getMessage();
         _code = src.getErrorCode();
         _severity = src.getSeverity();
@@ -73,8 +74,7 @@ public class XmlError implements java.io
      * this constructor.
      */
     private XmlError(String message, String code, int severity,
-                     String source, int line, int column, int offset, 
XmlCursor cursor)
-    {
+                     String source, int line, int column, int offset, 
XmlCursor cursor) {
         _message = message;
         _code = code;
         _severity = severity;
@@ -86,37 +86,34 @@ public class XmlError implements java.io
     }
 
     private XmlError(String code, Object[] args, int severity,
-                     String source, int line, int column, int offset, 
XmlCursor cursor)
-    {
-        this(XmlError.formattedMessage(code, args), code, severity,  source, 
line, column, offset, cursor);
+                     String source, int line, int column, int offset, 
XmlCursor cursor) {
+        this(XmlError.formattedMessage(code, args), code, severity, source, 
line, column, offset, cursor);
     }
 
     /**
      * The static factory methods should be used instead of
      * this constructor.
      */
-    protected XmlError(String message, String code, int severity, XmlCursor 
cursor)
-    {
+    protected XmlError(String message, String code, int severity, XmlCursor 
cursor) {
         String source = null;
         int line = -1;
         int column = -1;
         int offset = -1;
 
-        if (cursor != null)
-        {
+        if (cursor != null) {
             // Hunt down the line/column/offset
             source = cursor.documentProperties().getSourceName();
 
             XmlCursor c = cursor.newCursor();
 
             XmlLineNumber ln =
-                (XmlLineNumber) c.getBookmark( XmlLineNumber.class );
+                (XmlLineNumber) c.getBookmark(XmlLineNumber.class);
 
-            if (ln == null)
-                ln = (XmlLineNumber) c.toPrevBookmark( XmlLineNumber.class );
+            if (ln == null) {
+                ln = (XmlLineNumber) c.toPrevBookmark(XmlLineNumber.class);
+            }
 
-            if (ln != null)
-            {
+            if (ln != null) {
                 line = ln.getLine();
                 column = ln.getColumn();
                 offset = ln.getOffset();
@@ -135,8 +132,7 @@ public class XmlError implements java.io
         _cursor = cursor;
     }
 
-    protected XmlError(String code, Object[] args, int severity, XmlCursor 
cursor)
-    {
+    protected XmlError(String code, Object[] args, int severity, XmlCursor 
cursor) {
         this(XmlError.formattedMessage(code, args), code, severity, cursor);
     }
 
@@ -144,19 +140,18 @@ public class XmlError implements java.io
      * The static factory methods should be used instead of
      * this constructor.
      */
-    protected XmlError(String message, String code, int severity, Location loc)
-    {
+    protected XmlError(String message, String code, int severity, Location 
loc) {
         String source = null;
         int line = -1;
         int column = -1;
 
-        if (loc != null)
-        {
+        if (loc != null) {
             line = loc.getLineNumber();
             column = loc.getColumnNumber();
             source = loc.getPublicId();
-            if (source==null)
+            if (source == null) {
                 source = loc.getSystemId();
+            }
         }
 
         _message = message;
@@ -167,291 +162,288 @@ public class XmlError implements java.io
         _column = column;
     }
 
-    protected XmlError(String code, Object[] args, int severity, Location loc)
-    {
+    protected XmlError(String code, Object[] args, int severity, Location loc) 
{
         this(XmlError.formattedMessage(code, args), code, severity, loc);
     }
 
     /**
      * Returns an XmlError for the given message, with no location and {@link 
#SEVERITY_ERROR}.
+     *
      * @param message the error message
      */
-    public static XmlError forMessage(String message)
-    {
+    public static XmlError forMessage(String message) {
         return forMessage(message, SEVERITY_ERROR);
     }
 
     /**
      * Returns an XmlError for the given message, with no location and the 
given severity.
-     * @param message the error message
+     *
+     * @param message  the error message
      * @param severity the severity ({@link #SEVERITY_ERROR}, {@link 
#SEVERITY_WARNING}, or {@link #SEVERITY_INFO})
      */
-    public static XmlError forMessage(String message, int severity)
-    {
+    public static XmlError forMessage(String message, int severity) {
         return forSource(message, severity, null);
     }
 
     /**
      * Returns an XmlError for the given message, with no location and the 
given severity.
+     *
      * @param code the error code
      * @param args the arguments to use in formatting the error message
      */
-    public static XmlError forMessage(String code, Object[] args)
-    {
+    public static XmlError forMessage(String code, Object[] args) {
         return forSource(code, args, SEVERITY_ERROR, null);
     }
 
     /**
      * Returns an XmlError for the given message, with no location and the 
given severity.
-     * @param code the error code
-     * @param args the arguments to use in formatting the error message
+     *
+     * @param code     the error code
+     * @param args     the arguments to use in formatting the error message
      * @param severity the severity ({@link #SEVERITY_ERROR}, {@link 
#SEVERITY_WARNING}, or {@link #SEVERITY_INFO})
      */
-    public static XmlError forMessage(String code, Object[] args, int severity)
-    {
+    public static XmlError forMessage(String code, Object[] args, int 
severity) {
         return forSource(code, args, severity, null);
     }
 
     /**
      * Returns an XmlError for the given message, located in the given file 
and {@link #SEVERITY_ERROR}.
-     * @param message the error message
+     *
+     * @param message    the error message
      * @param sourceName the URL or other name for the file
      */
-    public static XmlError forSource(String message, String sourceName)
-    {
+    public static XmlError forSource(String message, String sourceName) {
         return forLocation(message, SEVERITY_ERROR, sourceName, -1, -1, -1);
     }
 
     /**
      * Returns an XmlError for the given message, with the given severity, 
located in the given file.
-     * @param message the error message
-     * @param severity the severity ({@link #SEVERITY_ERROR}, {@link 
#SEVERITY_WARNING}, or {@link #SEVERITY_INFO})
+     *
+     * @param message    the error message
+     * @param severity   the severity ({@link #SEVERITY_ERROR}, {@link 
#SEVERITY_WARNING}, or {@link #SEVERITY_INFO})
      * @param sourceName the URL or other name for the file
      */
-    public static XmlError forSource(String message, int severity, String 
sourceName)
-    {
+    public static XmlError forSource(String message, int severity, String 
sourceName) {
         return forLocation(message, severity, sourceName, -1, -1, -1);
     }
 
     /**
      * Returns an XmlError for the given message, with the given severity, 
located in the given file.
-     * @param code the error code
-     * @param args the arguments to use in formatting the error message
-     * @param severity the severity ({@link #SEVERITY_ERROR}, {@link 
#SEVERITY_WARNING}, or {@link #SEVERITY_INFO})
+     *
+     * @param code       the error code
+     * @param args       the arguments to use in formatting the error message
+     * @param severity   the severity ({@link #SEVERITY_ERROR}, {@link 
#SEVERITY_WARNING}, or {@link #SEVERITY_INFO})
      * @param sourceName the URL or other name for the file
      */
-    public static XmlError forSource(String code, Object[] args, int severity, 
String sourceName)
-    {
+    public static XmlError forSource(String code, Object[] args, int severity, 
String sourceName) {
         return forLocation(code, args, severity, sourceName, -1, -1, -1);
     }
 
     /**
      * Returns an XmlError for the given message, located at a specific point 
in the given file and {@link #SEVERITY_ERROR}.
-     * @param message the error message
+     *
+     * @param message    the error message
      * @param sourceName the URL or other name for the file
-     * @param location the location from an xml stream
+     * @param location   the location from an xml stream
      */
-    public static XmlError forLocation(String message, String sourceName, 
Location location)
-    {
-        return new XmlError(message, (String)null, SEVERITY_ERROR, sourceName,
+    public static XmlError forLocation(String message, String sourceName, 
Location location) {
+        return new XmlError(message, (String) null, SEVERITY_ERROR, sourceName,
             location.getLineNumber(), location.getColumnNumber(), -1, null);
     }
 
     /**
      * Returns an XmlError for the given message, located at a specific point 
in the given file and {@link #SEVERITY_ERROR}.
-     * @param message the error message
+     *
+     * @param message    the error message
      * @param sourceName the URL or other name for the file
-     * @param line the 1-based line number, or -1 if not known
-     * @param column the 1-based column number, or -1 if not known
-     * @param offset the 0-base file character offset, or -1 if not known
-     */
-    public static XmlError forLocation(String message, String sourceName, int 
line, int column, int offset)
-    {
-        return new XmlError(message, (String)null, SEVERITY_ERROR, sourceName, 
line, column, offset, null);
+     * @param line       the 1-based line number, or -1 if not known
+     * @param column     the 1-based column number, or -1 if not known
+     * @param offset     the 0-base file character offset, or -1 if not known
+     */
+    public static XmlError forLocation(String message, String sourceName, int 
line, int column, int offset) {
+        return new XmlError(message, (String) null, SEVERITY_ERROR, 
sourceName, line, column, offset, null);
     }
 
     /**
      * Returns an XmlError for the given message, with the given severity, 
located at a specific point in the given file.
-     * @param code the error code
-     * @param args the arguments to use in formatting the error message
-     * @param severity the severity ({@link #SEVERITY_ERROR}, {@link 
#SEVERITY_WARNING}, or {@link #SEVERITY_INFO})
+     *
+     * @param code       the error code
+     * @param args       the arguments to use in formatting the error message
+     * @param severity   the severity ({@link #SEVERITY_ERROR}, {@link 
#SEVERITY_WARNING}, or {@link #SEVERITY_INFO})
      * @param sourceName the URL or other name for the file
-     * @param line the 1-based line number, or -1 if not known
-     * @param column the 1-based column number, or -1 if not known
-     * @param offset the 0-base file character offset, or -1 if not known
+     * @param line       the 1-based line number, or -1 if not known
+     * @param column     the 1-based column number, or -1 if not known
+     * @param offset     the 0-base file character offset, or -1 if not known
      */
-    public static XmlError forLocation(String code, Object[] args, int 
severity, String sourceName, int line, int column, int offset)
-    {
+    public static XmlError forLocation(String code, Object[] args, int 
severity, String sourceName, int line, int column, int offset) {
         return new XmlError(code, args, severity, sourceName, line, column, 
offset, null);
     }
 
     /**
      * Returns an XmlError for the given message, with the given severity, 
located at a specific point in the given file.
-     * @param message the error message
-     * @param severity the severity ({@link #SEVERITY_ERROR}, {@link 
#SEVERITY_WARNING}, or {@link #SEVERITY_INFO})
+     *
+     * @param message    the error message
+     * @param severity   the severity ({@link #SEVERITY_ERROR}, {@link 
#SEVERITY_WARNING}, or {@link #SEVERITY_INFO})
      * @param sourceName the URL or other name for the file
-     * @param line the 1-based line number, or -1 if not known
-     * @param column the 1-based column number, or -1 if not known
-     * @param offset the 0-base file character offset, or -1 if not known
-     */
-    public static XmlError forLocation(String message, int severity, String 
sourceName, int line, int column, int offset)
-    {
-        return new XmlError(message, (String)null, severity, sourceName, line, 
column, offset, null);
+     * @param line       the 1-based line number, or -1 if not known
+     * @param column     the 1-based column number, or -1 if not known
+     * @param offset     the 0-base file character offset, or -1 if not known
+     */
+    public static XmlError forLocation(String message, int severity, String 
sourceName, int line, int column, int offset) {
+        return new XmlError(message, (String) null, severity, sourceName, 
line, column, offset, null);
     }
 
     /**
      * Returns an XmlError for the given message, with the given severity, 
located at the given physcial location and XmlCursor.
-     * @param message the error message
-     * @param severity the severity ({@link #SEVERITY_ERROR}, {@link 
#SEVERITY_WARNING}, or {@link #SEVERITY_INFO})
+     *
+     * @param message    the error message
+     * @param severity   the severity ({@link #SEVERITY_ERROR}, {@link 
#SEVERITY_WARNING}, or {@link #SEVERITY_INFO})
      * @param sourceName the URL or other name for the file
-     * @param line the 1-based line number, or -1 if not known
-     * @param column the 1-based column number, or -1 if not known
-     * @param offset the 0-base file character offset, or -1 if not known
-     * @param cursor the XmlCursor representing the location of the error
+     * @param line       the 1-based line number, or -1 if not known
+     * @param column     the 1-based column number, or -1 if not known
+     * @param offset     the 0-base file character offset, or -1 if not known
+     * @param cursor     the XmlCursor representing the location of the error
      */
-    public static XmlError forLocationAndCursor(String message, int severity, 
String sourceName, int line, int column, int offset, XmlCursor cursor)
-    {
-        return new XmlError(message, (String)null, severity, sourceName, line, 
column, offset, cursor);
+    public static XmlError forLocationAndCursor(String message, int severity, 
String sourceName, int line, int column, int offset, XmlCursor cursor) {
+        return new XmlError(message, (String) null, severity, sourceName, 
line, column, offset, cursor);
     }
 
     /**
      * Returns an XmlError for the given message, located at the XmlObject, 
with {@link #SEVERITY_ERROR}.
+     *
      * @param message the error message
-     * @param xobj the XmlObject representing the location of the error
+     * @param xobj    the XmlObject representing the location of the error
      */
-    public static XmlError forObject(String message, XmlObject xobj)
-    {
+    public static XmlError forObject(String message, XmlObject xobj) {
         return forObject(message, SEVERITY_ERROR, xobj);
     }
 
     /**
      * Returns an XmlError for the given message, located at the XmlObject, 
with {@link #SEVERITY_ERROR}.
+     *
      * @param code the error code
      * @param args the arguments to use in formatting the error message
      * @param xobj the XmlObject representing the location of the error
      */
-    public static XmlError forObject(String code, Object[] args, XmlObject 
xobj)
-    {
+    public static XmlError forObject(String code, Object[] args, XmlObject 
xobj) {
         return forObject(code, args, SEVERITY_ERROR, xobj);
     }
 
     /**
      * Returns an XmlError for the given message, with the given severity, 
located at the XmlObject.
-     * @param message the error message
+     *
+     * @param message  the error message
      * @param severity the severity ({@link #SEVERITY_ERROR}, {@link 
#SEVERITY_WARNING}, or {@link #SEVERITY_INFO})
-     * @param xobj the XmlObject representing the location of the error
+     * @param xobj     the XmlObject representing the location of the error
      */
-    public static XmlError forObject(String message, int severity, XmlObject 
xobj)
-    {
-        if (xobj == null)
+    public static XmlError forObject(String message, int severity, XmlObject 
xobj) {
+        if (xobj == null) {
             return forMessage(message, severity);
+        }
 
         XmlCursor cur = xobj.newCursor();
-        XmlError result = forCursor(message, severity, cur);
-        return result;
+        return forCursor(message, severity, cur);
     }
 
     /**
      * Returns an XmlError for the given message, with the given severity, 
located at the XmlObject.
-     * @param code the error code
-     * @param args the arguments to use in formatting the error message
+     *
+     * @param code     the error code
+     * @param args     the arguments to use in formatting the error message
      * @param severity the severity ({@link #SEVERITY_ERROR}, {@link 
#SEVERITY_WARNING}, or {@link #SEVERITY_INFO})
-     * @param xobj the XmlObject representing the location of the error
+     * @param xobj     the XmlObject representing the location of the error
      */
-    public static XmlError forObject(String code, Object[] args, int severity, 
XmlObject xobj)
-    {
-        if (xobj == null)
+    public static XmlError forObject(String code, Object[] args, int severity, 
XmlObject xobj) {
+        if (xobj == null) {
             return forMessage(code, args, severity);
+        }
 
         XmlCursor cur = xobj.newCursor();
-        XmlError result = forCursor(code, args, severity, cur);
-        return result;
+        return forCursor(code, args, severity, cur);
     }
 
     /**
      * Returns an XmlError for the given message, located at the XmlCursor, 
with {@link #SEVERITY_ERROR}.
+     *
      * @param message the error message
-     * @param cursor the XmlCursor representing the location of the error
+     * @param cursor  the XmlCursor representing the location of the error
      */
-    public static XmlError forCursor(String message, XmlCursor cursor)
-    {
+    public static XmlError forCursor(String message, XmlCursor cursor) {
         return forCursor(message, SEVERITY_ERROR, cursor);
     }
 
     /**
      * Returns an XmlError for the given message, located at the XmlCursor, 
with {@link #SEVERITY_ERROR}.
-     * @param code the error code
-     * @param args the arguments to use in formatting the error message
+     *
+     * @param code   the error code
+     * @param args   the arguments to use in formatting the error message
      * @param cursor the XmlCursor representing the location of the error
      */
-    public static XmlError forCursor(String code, Object[] args, XmlCursor 
cursor)
-    {
+    public static XmlError forCursor(String code, Object[] args, XmlCursor 
cursor) {
         return forCursor(code, args, SEVERITY_ERROR, cursor);
     }
 
     /**
      * Returns an XmlError for the given message, with the given severity, 
located at the XmlCursor.
-     * @param message the error message
+     *
+     * @param message  the error message
      * @param severity the severity ({@link #SEVERITY_ERROR}, {@link 
#SEVERITY_WARNING}, or {@link #SEVERITY_INFO})
-     * @param cursor the XmlCursor representing the location of the error
+     * @param cursor   the XmlCursor representing the location of the error
      */
-    public static XmlError forCursor(String message, int severity, XmlCursor 
cursor)
-    {
-        return new XmlError(message, (String)null, severity, cursor);
+    public static XmlError forCursor(String message, int severity, XmlCursor 
cursor) {
+        return new XmlError(message, (String) null, severity, cursor);
     }
 
     /**
      * Returns an XmlError for the given message, with the given severity, 
located at the XmlCursor.
-     * @param code the error code
-     * @param args the arguments to use in formatting the error message
+     *
+     * @param code     the error code
+     * @param args     the arguments to use in formatting the error message
      * @param severity the severity ({@link #SEVERITY_ERROR}, {@link 
#SEVERITY_WARNING}, or {@link #SEVERITY_INFO})
-     * @param cursor the XmlCursor representing the location of the error
+     * @param cursor   the XmlCursor representing the location of the error
      */
-    public static XmlError forCursor(String code, Object[] args, int severity, 
XmlCursor cursor)
-    {
+    public static XmlError forCursor(String code, Object[] args, int severity, 
XmlCursor cursor) {
         return new XmlError(code, args, severity, cursor);
     }
 
     /**
      * Tries to produce a nicely formatted filename from the given string.
      */
-    protected static String formattedFileName(String rawString, URI base)
-    {
-        if (rawString == null)
+    protected static String formattedFileName(String rawString, URI base) {
+        if (rawString == null) {
             return null;
+        }
 
-        URI uri = null;
+        URI uri;
 
-        try
-        {
+        try {
             // if it looks like an absolute URI, treat it as such
             uri = new URI(rawString);
 
             // otherwise, treat it like a filename
-            if (!uri.isAbsolute())
+            if (!uri.isAbsolute()) {
                 uri = null;
-        }
-        catch (URISyntaxException e)
-        {
+            }
+        } catch (URISyntaxException e) {
             uri = null;
         }
 
         // looks like a filename; convert it to uri for relativization
-        if (uri == null)
+        if (uri == null) {
             uri = new File(rawString).toURI();
+        }
 
-        if (base != null)
+        if (base != null) {
             uri = base.relativize(uri);
+        }
 
         // filenames get their file: stripped off and their /'s turned into 
\'s (MSDOS)
         if (uri.isAbsolute() ? uri.getScheme().compareToIgnoreCase("file") == 
0 :
-            base != null && base.isAbsolute() && 
base.getScheme().compareToIgnoreCase("file") == 0)
-        {
-            try
-            {
+            base != null && base.isAbsolute() && 
base.getScheme().compareToIgnoreCase("file") == 0) {
+            try {
                 return (new File(uri)).toString();
+            } catch (Exception ignored) {
             }
-            catch (Exception e) {};
         }
 
         return uri.toString();
@@ -460,35 +452,23 @@ public class XmlError implements java.io
     /**
      * Tries to format a message using the error code.
      */
-    public static String formattedMessage(String code, Object[] args)
-    {
-        if (code == null)
+    public static String formattedMessage(String code, Object[] args) {
+        if (code == null) {
             return null;
-
-        String message;
-
-        try
-        {
-            message = MessageFormat.format(_bundle.getString(code), args);
-        }
-        catch (java.util.MissingResourceException e)
-        {
-            return 
MessageFormat.format(_bundle.getString("message.missing.resource"),
-                new Object[] { e.getMessage() });
-        }
-        catch (IllegalArgumentException e)
-        {
-            return 
MessageFormat.format(_bundle.getString("message.pattern.invalid"),
-                new Object[] { e.getMessage() });
         }
 
-        return message;
+        try {
+            return new MessageFormat(_bundle.getString(code), 
Locale.ROOT).format(args);
+        } catch (MissingResourceException | IllegalArgumentException e) {
+            String bnd = (e instanceof MissingResourceException) ? 
"message.missing.resource" : "message.pattern.invalid";
+            return new MessageFormat(_bundle.getString(bnd), 
Locale.ROOT).format(e.getMessage());
+        }
     }
 
     /**
      * An error. See {@link #getSeverity}.
      */
-    public static final int SEVERITY_ERROR   = 0;
+    public static final int SEVERITY_ERROR = 0;
     /**
      * A warning. See {@link #getSeverity}.
      */
@@ -496,53 +476,68 @@ public class XmlError implements java.io
     /**
      * An informational message. See {@link #getSeverity}.
      */
-    public static final int SEVERITY_INFO    = 2;
+    public static final int SEVERITY_INFO = 2;
 
     /**
      * Returns the severity.  Either {@link #SEVERITY_ERROR}, {@link 
#SEVERITY_WARNING}, or {@link #SEVERITY_INFO}.
      */
-    public int    getSeverity   ( ) { return _severity; }
+    public int getSeverity() {
+        return _severity;
+    }
 
     /**
      * Returns the error message without location information.
      */
-    public String getMessage    ( ) { return _message; }
+    public String getMessage() {
+        return _message;
+    }
 
     /**
      * Returns the error code or null. See {@link XmlErrorCodes}.
      */
-    public String getErrorCode  ( ) { return _code; }
+    public String getErrorCode() {
+        return _code;
+    }
 
     /**
      * Returns the URL (or other name) of the file with the error, if 
available.
      */
-    public String getSourceName ( ) { return _source; }
+    public String getSourceName() {
+        return _source;
+    }
 
     /**
      * Returns the line number of the error, if available, -1 if not.
      */
-    public int    getLine       ( ) { return _line; }
+    public int getLine() {
+        return _line;
+    }
 
     /**
      * Returns the column number of the error, if available, -1 if not.
      */
-    public int    getColumn     ( ) { return _column; }
+    public int getColumn() {
+        return _column;
+    }
 
     /**
      * Returns the file character offset of the error, if available, -1 if not.
      */
-    public int    getOffset     ( ) { return _offset; }
+    public int getOffset() {
+        return _offset;
+    }
 
     /**
      * Returns a location object of the given type.  XmlCursor.class and
      * XmlObject.class can be passed, for example.  Null if not available.
      */
-    public Object getLocation ( Object type )
-    {
-        if (type == XmlCursor.class)
+    public Object getLocation(Object type) {
+        if (type == XmlCursor.class) {
             return _cursor;
-        if (type == XmlObject.class && _cursor != null)
+        }
+        if (type == XmlObject.class && _cursor != null) {
             return _cursor.getObject();
+        }
         return null;
     }
 
@@ -550,27 +545,24 @@ public class XmlError implements java.io
      * Returns a location of the error as an {@link XmlCursor}, null if
      * not available.
      */
-    public XmlCursor getCursorLocation ( )
-    {
-        return (XmlCursor) getLocation( XmlCursor.class );
+    public XmlCursor getCursorLocation() {
+        return (XmlCursor) getLocation(XmlCursor.class);
     }
 
     /**
      * Returns a location of the error as an {@link XmlObject}, null if
      * not available.
      */
-    public XmlObject getObjectLocation ( )
-    {
-        return (XmlObject) getLocation( XmlObject.class );
+    public XmlObject getObjectLocation() {
+        return (XmlObject) getLocation(XmlObject.class);
     }
 
     /**
      * Produces a standard string for the error message, complete with
      * filename and location offsets if available.
      */
-    public String toString ( )
-    {
-        return toString( null );
+    public String toString() {
+        return toString(null);
     }
 
     /**
@@ -578,8 +570,7 @@ public class XmlError implements java.io
      * URI is supplied, source names are relativized against the given
      * URI.
      */
-    public String toString ( URI base )
-    {
+    public String toString(URI base) {
         // modified to carefully match the IDE's
         // workshop.workspace.ant.AntLogger regex
         // which also matches javac (davidbau)
@@ -588,45 +579,46 @@ public class XmlError implements java.io
 
         String source = formattedFileName(getSourceName(), base);
 
-        if ( source != null )
-        {
-            sb.append( source );
+        if (source != null) {
+            sb.append(source);
             int line = getLine();
-            if ( line < 0 )
+            if (line < 0) {
                 line = 0;
+            }
 
-            sb.append( ':' );
-            sb.append( line );
-            sb.append( ':' );
-            if (getColumn() > 0)
-            {
-                sb.append( getColumn() );
-                sb.append( ':' );
+            sb.append(':');
+            sb.append(line);
+            sb.append(':');
+            if (getColumn() > 0) {
+                sb.append(getColumn());
+                sb.append(':');
             }
             sb.append(" ");
         }
 
-        switch ( getSeverity() )
-        {
-            case SEVERITY_ERROR   : sb.append( "error: " );   break;
-            case SEVERITY_WARNING : sb.append( "warning: " ); break;
-            case SEVERITY_INFO : break;
+        switch (getSeverity()) {
+            case SEVERITY_ERROR:
+                sb.append("error: ");
+                break;
+            case SEVERITY_WARNING:
+                sb.append("warning: ");
+                break;
+            case SEVERITY_INFO:
+                break;
         }
 
-        if (getErrorCode() != null)
-        {
+        if (getErrorCode() != null) {
             sb.append(getErrorCode()).append(": ");
         }
 
         String msg = getMessage();
 
-        sb.append( msg == null ? "<Unspecified message>" : msg );
+        sb.append(msg == null ? "<Unspecified message>" : msg);
 
         return sb.toString();
     }
 
-    public static String severityAsString(int severity)
-    {
+    public static String severityAsString(int severity) {
         switch (severity) {
             case SEVERITY_ERROR:
                 return ("error");

Modified: 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/XmlOptionCharEscapeMap.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/XmlOptionCharEscapeMap.java?rev=1882074&r1=1882073&r2=1882074&view=diff
==============================================================================
--- 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/XmlOptionCharEscapeMap.java 
(original)
+++ 
xmlbeans/trunk/src/main/java/org/apache/xmlbeans/XmlOptionCharEscapeMap.java 
Sun Sep 27 21:25:33 2020
@@ -16,6 +16,7 @@
 package org.apache.xmlbeans;
 
 import java.util.HashMap;
+import java.util.Map;
 
 /**
  * Corresponds to the Saver and XmlOptions.
@@ -44,73 +45,68 @@ import java.util.HashMap;
  *
  * </pre>
  */
-public class XmlOptionCharEscapeMap
-{
+public class XmlOptionCharEscapeMap {
     public static final int PREDEF_ENTITY = 0;
-    public static final int DECIMAL       = 1;
-    public static final int HEXADECIMAL   = 2;
+    public static final int DECIMAL = 1;
+    public static final int HEXADECIMAL = 2;
 
     // map of Character to String which will represent it in the output 
document
-    private HashMap _charMap;
+    private final Map<Character, String> _charMap;
 
     // internal HashMap just for predefined entities
-    private static final HashMap _predefEntities = new HashMap();
+    private static final Map<Character, String> _predefEntities = new 
HashMap<>();
+
     static {
-        _predefEntities.put(new Character('<'), "&lt;");
-        _predefEntities.put(new Character('>'), "&gt;");
-        _predefEntities.put(new Character('&'), "&amp;");
-        _predefEntities.put(new Character('\''), "&apos;");
-        _predefEntities.put(new Character('"'), "&quot;");
+        _predefEntities.put('<', "&lt;");
+        _predefEntities.put('>', "&gt;");
+        _predefEntities.put('&', "&amp;");
+        _predefEntities.put('\'', "&apos;");
+        _predefEntities.put('"', "&quot;");
     }
 
     /**
      * Construct a new XmlOptionCharEncoder.
      */
-    public XmlOptionCharEscapeMap()
-    {
-        _charMap = new HashMap();
+    public XmlOptionCharEscapeMap() {
+        _charMap = new HashMap<>();
     }
 
     /**
-     *  @return whether a character encoding exists for this character
+     * @return whether a character encoding exists for this character
      */
-    public boolean containsChar(char ch)
-    {
-        return _charMap.containsKey(new Character(ch));
+    public boolean containsChar(char ch) {
+        return _charMap.containsKey(ch);
     }
 
     /**
      * set up this character to be escaped in output documents
      * according to the given mode
      */
-    public void addMapping(char ch, int mode) throws XmlException
-    {
-        Character theChar = new Character(ch);
-        switch(mode)
-        {
+    public void addMapping(char ch, int mode) throws XmlException {
+        Character theChar = ch;
+        switch (mode) {
             case PREDEF_ENTITY:
-                String replString = (String)_predefEntities.get(theChar);
-                if ( replString == null )
-                {
+                String replString = _predefEntities.get(theChar);
+                if (replString == null) {
                     throw new 
XmlException("XmlOptionCharEscapeMap.addMapping(): " +
-                        "the PREDEF_ENTITY mode can only be used for the 
following " +
-                        "characters: <, >, &, \" and '");
+                                           "the PREDEF_ENTITY mode can only be 
used for the following " +
+                                           "characters: <, >, &, \" and '");
                 }
                 _charMap.put(theChar, replString);
                 break;
 
             case DECIMAL:
-                _charMap.put(theChar, "&#" + (int)ch + ";");
+                _charMap.put(theChar, "&#" + (int) ch + ";");
                 break;
 
             case HEXADECIMAL:
-                String hexCharPoint = Integer.toHexString((int)ch);
+                String hexCharPoint = Integer.toHexString(ch);
                 _charMap.put(theChar, "&#x" + hexCharPoint + ";");
                 break;
 
             default:
                 throw new XmlException("XmlOptionCharEscapeMap.addMapping(): " 
+
-                    "mode must be PREDEF_ENTITY, DECIMAL or HEXADECIMAL");
+                                       "mode must be PREDEF_ENTITY, DECIMAL or 
HEXADECIMAL");
         }
     }
 
@@ -118,16 +114,13 @@ public class XmlOptionCharEscapeMap
      * set up this contiguous set of characters to be escaped in
      * output documents according to the given mode
      */
-    public void addMappings(char ch1, char ch2, int mode) throws XmlException
-    {
-        if (ch1 > ch2)
-        {
+    public void addMappings(char ch1, char ch2, int mode) throws XmlException {
+        if (ch1 > ch2) {
             throw new XmlException("XmlOptionCharEscapeMap.addMappings(): " +
-                "ch1 must be <= ch2");
+                                   "ch1 must be <= ch2");
         }
 
-        for (char c = ch1; c <= ch2; c++)
-        {
+        for (char c = ch1; c <= ch2; c++) {
             addMapping(c, mode);
         }
     }
@@ -135,8 +128,7 @@ public class XmlOptionCharEscapeMap
     /**
      * returns the escaped String for the character
      */
-    public String getEscapedString(char ch)
-    {
-        return (String)_charMap.get(new Character(ch));
+    public String getEscapedString(char ch) {
+        return _charMap.get(ch);
     }
 }

Modified: xmlbeans/trunk/src/main/java/org/apache/xmlbeans/XmlSimpleList.java
URL: 
http://svn.apache.org/viewvc/xmlbeans/trunk/src/main/java/org/apache/xmlbeans/XmlSimpleList.java?rev=1882074&r1=1882073&r2=1882074&view=diff
==============================================================================
--- xmlbeans/trunk/src/main/java/org/apache/xmlbeans/XmlSimpleList.java 
(original)
+++ xmlbeans/trunk/src/main/java/org/apache/xmlbeans/XmlSimpleList.java Sun Sep 
27 21:25:33 2020
@@ -15,10 +15,7 @@
 
 package org.apache.xmlbeans;
 
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
+import java.util.*;
 
 /**
  * The immutable {@link List} returned for XML simple list values.
@@ -27,17 +24,17 @@ import java.util.ListIterator;
  * contents, so two XmlSimpleLists are the same if they have the same
  * values in the same order.
  */
-public class XmlSimpleList implements List<Object>, java.io.Serializable {
+public class XmlSimpleList<T> implements List<T>, java.io.Serializable {
     private static final long serialVersionUID = 1L;
 
-    private final List<Object> underlying;
+    private final List<T> underlying;
 
     /**
      * Constructs an immutable XmlSimpleList that wraps (does not copy)
      * the given {@link List}.  All non-mutating methods delegate to
      * the underlying List instance.
      */
-    public XmlSimpleList(List<Object> list) {
+    public XmlSimpleList(List<T> list) {
         this.underlying = list;
     }
 
@@ -79,7 +76,8 @@ public class XmlSimpleList implements Li
     /**
      * Copies the collection to an array of a specified type.
      */
-    public <T> T[] toArray(T[] a) {
+    @SuppressWarnings("SuspiciousToArrayCall")
+    public <X> X[] toArray(X[] a) {
         return underlying.toArray(a);
     }
 
@@ -128,14 +126,14 @@ public class XmlSimpleList implements Li
     /**
      * Returns the object at the specified position in this list.
      */
-    public Object get(int index) {
+    public T get(int index) {
         return underlying.get(index);
     }
 
     /**
      * Unsupported because this list is immutable.
      */
-    public Object set(int index, Object element) {
+    public T set(int index, T element) {
         throw new UnsupportedOperationException();
     }
 
@@ -149,7 +147,7 @@ public class XmlSimpleList implements Li
     /**
      * Unsupported because this list is immutable.
      */
-    public Object remove(int index) {
+    public T remove(int index) {
         throw new UnsupportedOperationException();
     }
 
@@ -177,22 +175,22 @@ public class XmlSimpleList implements Li
     /**
      * Returns a view of the portion of this list between the specified 
fromIndex, inclusive, and toIndex, exclusive.
      */
-    public List<Object> subList(int from, int to) {
-        return new XmlSimpleList(underlying.subList(from, to));
+    public List<T> subList(int from, int to) {
+        return new XmlSimpleList<>(underlying.subList(from, to));
     }
 
     /**
      * Returns an iterator over the elements in this list in proper sequence.
      */
-    public Iterator<Object> iterator() {
-        return new Iterator<Object>() {
-            final Iterator<Object> i = underlying.iterator();
+    public Iterator<T> iterator() {
+        return new Iterator<T>() {
+            final Iterator<T> i = underlying.iterator();
 
             public boolean hasNext() {
                 return i.hasNext();
             }
 
-            public Object next() {
+            public T next() {
                 return i.next();
             }
 
@@ -205,22 +203,22 @@ public class XmlSimpleList implements Li
     /**
      * Returns a list iterator of the elements in this list in proper sequence.
      */
-    public ListIterator<Object> listIterator() {
+    public ListIterator<T> listIterator() {
         return listIterator(0);
     }
 
     /**
      * Returns a list iterator of the elements in this list in proper 
sequence, starting at the specified position in this list.
      */
-    public ListIterator<Object> listIterator(final int index) {
-        return new ListIterator<Object>() {
-            final ListIterator<Object> i = underlying.listIterator(index);
+    public ListIterator<T> listIterator(final int index) {
+        return new ListIterator<T>() {
+            final ListIterator<T> i = underlying.listIterator(index);
 
             public boolean hasNext() {
                 return i.hasNext();
             }
 
-            public Object next() {
+            public T next() {
                 return i.next();
             }
 
@@ -228,7 +226,7 @@ public class XmlSimpleList implements Li
                 return i.hasPrevious();
             }
 
-            public Object previous() {
+            public T previous() {
                 return i.previous();
             }
 
@@ -295,16 +293,14 @@ public class XmlSimpleList implements Li
         if (!(o instanceof XmlSimpleList)) {
             return false;
         }
-        final XmlSimpleList xmlSimpleList = (XmlSimpleList) o;
-        List<Object> underlying2 = xmlSimpleList.underlying;
+        final XmlSimpleList<?> xmlSimpleList = (XmlSimpleList<?>) o;
+        List<?> underlying2 = xmlSimpleList.underlying;
         int size = underlying.size();
         if (size != underlying2.size()) {
             return false;
         }
         for (int i = 0; i < size; i++) {
-            Object item = underlying.get(i);
-            Object item2 = underlying2.get(i);
-            if (item == null ? item2 != null : !item.equals(item2)) {
+            if (!Objects.equals(underlying.get(i), underlying2.get(i))) {
                 return false;
             }
         }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to