Skip to content

Commit 9499a84

Browse files
committed
Add getEmptyAttributes helper
Signed-off-by: Tony Germano <[email protected]>
1 parent cfe08df commit 9499a84

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

server/src/org/openintegrationengine/engine/plugins/datatypes/AbstractXMLReader.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.xml.sax.SAXNotRecognizedException;
1515
import org.xml.sax.SAXNotSupportedException;
1616
import org.xml.sax.XMLReader;
17+
import org.xml.sax.helpers.AttributesImpl;
1718

1819
/**
1920
* A base class for custom XMLReaders used in data type plugins.
@@ -37,6 +38,9 @@ public abstract class AbstractXMLReader implements XMLReader {
3738
/** The EntityResolver to resolve external entities. */
3839
protected EntityResolver entityResolver;
3940

41+
/** Reusable instance that is cleared on each call of the accessor */
42+
private final AttributesImpl emptyAttributes = new AttributesImpl();
43+
4044
/**
4145
* Helper method for subclasses to ensure the ContentHandler is configured.
4246
* <p>
@@ -51,6 +55,20 @@ protected void ensureHandlerSet() throws SAXException {
5155
}
5256
}
5357

58+
/**
59+
* Helper method for subclasses to get an empty instance of {@link AttributesImpl}.
60+
* <p>
61+
* This method reuses the same instance of {@link AttributesImpl} and clears it
62+
* before use.
63+
* </p>
64+
*
65+
* @return An empty instance of {@link AttributesImpl}
66+
*/
67+
protected AttributesImpl getEmptyAttributes() {
68+
emptyAttributes.clear();
69+
return emptyAttributes;
70+
}
71+
5472
/**
5573
* Parse an XML document from the given input source.
5674
* <p>

0 commit comments

Comments
 (0)