* representation
*/
protected void writeArrayPropertyAsElement(String aPropName, Class aPropClass, Object aValue,
String aArrayElementTagName, String aNamespace, ContentHandler aContentHandler)
throws SAXException {
CharacterValidatingContentHandler cc = (CharacterValidatingContentHandler) aContentHandler;
// if aPropClass is generic Object, reader won't know whether to expect
// an array, so we tell it be writing an "array" element here.
Node arraySubElement = findMatchingSubElement(aContentHandler, "array");
if (aPropClass == Object.class) { // skip writting <array> unless the property class (of objects in the array) is "Object"
// skipped e.g. in <fixedFlow> values, where aPropClass is String
outputStartElement(aContentHandler, arraySubElement, aNamespace, "array", "array", EMPTY_ATTRIBUTES);
cc.lastOutputNodeAddLevel();
}
// iterate through elements of the array (at this point we don't allow
// nested arrays here
int len = ((Object[]) aValue).length;
try {
for (int i = 0; i < len; i++) {
Object curElem = Array.get(aValue, i);
Node matchingArrayElement = findMatchingSubElement(aContentHandler, aArrayElementTagName);
// if a particular array element tag has been specified, write it
outputStartElement(aContentHandler, matchingArrayElement, aNamespace, aArrayElementTagName, aArrayElementTagName,
EMPTY_ATTRIBUTES);
// if attribute's value is an XMLizable object, call its toXML method
if (curElem instanceof XMLizable) {
((XMLizable) curElem).toXML(aContentHandler);
}
// else, attempt to write it as a primitive
else {
if (aArrayElementTagName == null) {
// need to include the type, e.g. <string>
writePrimitiveValue(curElem, aContentHandler);
} else {
// don't include the type - just write the value
String valStr = curElem.toString();
aContentHandler.characters(valStr.toCharArray(), 0, valStr.length());
}
}
// if we started an element, end it
outputEndElement(aContentHandler, matchingArrayElement, aNamespace, aArrayElementTagName, aArrayElementTagName);
}
} finally {
if (aPropClass == Object.class) {
cc.lastOutputNodeClearLevel();
}
}
// if we started an "Array" element, end it
if (aPropClass == Object.class) {