You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2008/05/19 06:38:35 UTC
svn commit: r657721 - in /xerces/java/trunk/src/org/apache/xerces/impl/xs:
SchemaGrammar.java XSModelImpl.java
Author: mrglavas
Date: Sun May 18 21:38:35 2008
New Revision: 657721
URL: http://svn.apache.org/viewvc?rev=657721&view=rev
Log:
If the XSModel or SchemaGrammar has no annotations return
the singleton empty list instead of creating a new one.
Modified:
xerces/java/trunk/src/org/apache/xerces/impl/xs/SchemaGrammar.java
xerces/java/trunk/src/org/apache/xerces/impl/xs/XSModelImpl.java
Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/SchemaGrammar.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/SchemaGrammar.java?rev=657721&r1=657720&r2=657721&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/SchemaGrammar.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/SchemaGrammar.java Sun May 18 21:38:35 2008
@@ -1202,15 +1202,20 @@
* @see org.apache.xerces.xs.XSNamespaceItem#getAnnotations()
*/
public XSObjectList getAnnotations() {
+ if (fNumAnnotations == 0) {
+ return XSObjectListImpl.EMPTY_LIST;
+ }
return new XSObjectListImpl(fAnnotations, fNumAnnotations);
}
public void addAnnotation(XSAnnotationImpl annotation) {
- if(annotation == null)
+ if (annotation == null) {
return;
- if(fAnnotations == null) {
+ }
+ if (fAnnotations == null) {
fAnnotations = new XSAnnotationImpl[2];
- } else if(fNumAnnotations == fAnnotations.length) {
+ }
+ else if (fNumAnnotations == fAnnotations.length) {
XSAnnotationImpl[] newArray = new XSAnnotationImpl[fNumAnnotations << 1];
System.arraycopy(fAnnotations, 0, newArray, 0, fNumAnnotations);
fAnnotations = newArray;
Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/XSModelImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/XSModelImpl.java?rev=657721&r1=657720&r2=657721&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/XSModelImpl.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/XSModelImpl.java Sun May 18 21:38:35 2008
@@ -89,7 +89,7 @@
private final XSNamedMap[][] fNSComponents;
// store all annotations
- private XSObjectListImpl fAnnotations = null;
+ private XSObjectList fAnnotations = null;
// whether there is any IDC in this XSModel
private final boolean fHasIDC;
@@ -453,7 +453,8 @@
}
/**
- * {annotations} A set of annotations.
+ * [annotations]: a set of annotations if it exists, otherwise an empty
+ * <code>XSObjectList</code>.
*/
public synchronized XSObjectList getAnnotations() {
if (fAnnotations != null) {
@@ -465,6 +466,10 @@
for (int i = 0; i < fGrammarCount; i++) {
totalAnnotations += fGrammarList[i].fNumAnnotations;
}
+ if (totalAnnotations == 0) {
+ fAnnotations = XSObjectListImpl.EMPTY_LIST;
+ return fAnnotations;
+ }
XSAnnotationImpl [] annotations = new XSAnnotationImpl [totalAnnotations];
int currPos = 0;
for (int i = 0; i < fGrammarCount; i++) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org