Logo Search packages:      
Sourcecode: uimaj version File versions  Download package

void org::apache::uima::resource::metadata::impl::MetaDataObject_impl::writePropertyAsElement ( PropertyXmlInfo  aPropInfo,
String  aNamespace,
ContentHandler  aContentHandler 
) throws SAXException [inline, protected, inherited]

Utility method used to write a property out as an XML element.

Parameters:
aPropInfoinformation on how to represent the property in XML
aNamespaceXML namespace URI for this object
aContentHandlercontent handler to which this object will send events that describe its XML representation

Reimplemented in org::apache::uima::analysis_engine::impl::AnalysisEngineDescription_impl, org::apache::uima::analysis_engine::metadata::impl::AnalysisEngineMetaData_impl, org::apache::uima::resource::metadata::impl::ConfigurationParameterSettings_impl, org::apache::uima::resource::metadata::impl::FsIndexKeyDescription_impl, org::apache::uima::resource::metadata::impl::ResourceManagerConfiguration_impl, and org::apache::uima::resource::metadata::impl::TypePriorities_impl.

Definition at line 652 of file MetaDataObject_impl.java.

References org::apache::uima::internal::util::XMLUtils::writePrimitiveValue().

                                                              {
    // get value of property
    Object val = getAttributeValue(aPropInfo.propertyName);

    // if null or empty array, check to see if we're supposed to omit it
    if (aPropInfo.omitIfNull
            && (val == null || (val.getClass().isArray() && ((Object[]) val).length == 0)))
      return;

    // if XML element name was supplied, write a tag
    if (aPropInfo.xmlElementName != null) {
      aContentHandler.startElement(aNamespace, aPropInfo.xmlElementName, aPropInfo.xmlElementName,
              EMPTY_ATTRIBUTES);
    }

    // get class of property
    Class propClass = getAttributeClass(aPropInfo.propertyName);

    // if value is null then write nothing
    if (val != null) {
      // if value is an array then we have to treat that specially
      if (val.getClass().isArray()) {
        writeArrayPropertyAsElement(aPropInfo.propertyName, propClass, val,
                aPropInfo.arrayElementTagName, aNamespace, aContentHandler);
      } else {
        // if value is an XMLizable object, call its toXML method
        if (val instanceof XMLizable) {
          ((XMLizable) val).toXML(aContentHandler);
        }
        // else, if property's class is java.lang.Object, attempt to write
        // it as a primitive
        else if (propClass == Object.class) {
          XMLUtils.writePrimitiveValue(val, aContentHandler);
        } else {
          // assume attribute's class is known (e.g. String, Integer), so it
          // is not necessary to write the class name to the XML. Just write
          // the string representation of the object
          // XMLUtils.writeNormalizedString(val.toString(), aWriter, true);
          String valStr = val.toString();
          aContentHandler.characters(valStr.toCharArray(), 0, valStr.length());
        }
      }
    }

    // if XML element name was supplied, end the element that we started
    if (aPropInfo.xmlElementName != null) {
      aContentHandler.endElement(aNamespace, aPropInfo.xmlElementName, aPropInfo.xmlElementName);
    }
  }

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index