/** * Write the xml for a {@link Property}. * * @param property * @param contentHandler * @throws SAXException */ protected static void generateXML( Property property, ContentHandler contentHandler, boolean isScrPrivateFile) throws SAXException { final AttributesImpl ai = new AttributesImpl(); IOUtils.addAttribute(ai, "name", property.getName()); IOUtils.addAttribute(ai, "type", property.getType()); IOUtils.addAttribute(ai, "value", property.getValue()); // we have to write more information if this is our scr private file if (isScrPrivateFile) { IOUtils.addAttribute(ai, "private", String.valueOf(property.isPrivate())); if (property.getLabel() != null) { IOUtils.addAttribute(ai, "label", String.valueOf(property.getLabel())); } if (property.getDescription() != null) { IOUtils.addAttribute(ai, "description", String.valueOf(property.getDescription())); } if (property.getCardinality() != null) { IOUtils.addAttribute(ai, "cardinality", String.valueOf(property.getCardinality())); } } IOUtils.indent(contentHandler, 2); contentHandler.startElement( INNER_NAMESPACE_URI, ComponentDescriptorIO.PROPERTY, ComponentDescriptorIO.PROPERTY_QNAME, ai); if (property.getMultiValue() != null && property.getMultiValue().length > 0) { // generate a new line first IOUtils.text(contentHandler, "\n"); for (int i = 0; i < property.getMultiValue().length; i++) { IOUtils.indent(contentHandler, 3); IOUtils.text(contentHandler, property.getMultiValue()[i]); IOUtils.newline(contentHandler); } IOUtils.indent(contentHandler, 2); } contentHandler.endElement( INNER_NAMESPACE_URI, ComponentDescriptorIO.PROPERTY, ComponentDescriptorIO.PROPERTY_QNAME); IOUtils.newline(contentHandler); }