/** * Writes the attribute value. Optionally emits empty string values. * * @param localName the local name of the attribute. * @param alwaysWriteEmptyString always emit the empty string as the value. * @param value the value * @throws ServiceXmlSerializationException the service xml serialization exception */ public void writeAttributeValue(String localName, boolean alwaysWriteEmptyString, Object value) throws ServiceXmlSerializationException { OutParam<String> stringOut = new OutParam<String>(); String stringValue = null; if (this.tryConvertObjectToString(value, stringOut)) { stringValue = stringOut.getParam(); if ((null != stringValue) && (alwaysWriteEmptyString || (stringValue.length() != 0))) { this.writeAttributeString(localName, stringValue); } } else { throw new ServiceXmlSerializationException(String.format( "Values of type '%s' can't be used for the '%s' attribute.", value.getClass() .getName(), localName)); } }
/** * Writes the attribute value. * * @param namespacePrefix the namespace prefix * @param localName the local name of the attribute * @param value the value * @throws ServiceXmlSerializationException the service xml serialization exception */ public void writeAttributeValue(String namespacePrefix, String localName, Object value) throws ServiceXmlSerializationException { OutParam<String> stringOut = new OutParam<String>(); String stringValue = null; if (this.tryConvertObjectToString(value, stringOut)) { stringValue = stringOut.getParam(); if (null != stringValue && !stringValue.isEmpty()) { this.writeAttributeString(namespacePrefix, localName, stringValue); } } else { throw new ServiceXmlSerializationException(String.format( "Values of type '%s' can't be used for the '%s' attribute.", value.getClass() .getName(), localName)); } }
/** * Writes the element value. * * @param xmlNamespace the XML namespace * @param localName the local name of the element * @param displayName the name that should appear in the exception message when the value can not be serialized * @param value the value * @throws XMLStreamException the XML stream exception * @throws ServiceXmlSerializationException the service xml serialization exception */ public void writeElementValue(XmlNamespace xmlNamespace, String localName, String displayName, Object value) throws XMLStreamException, ServiceXmlSerializationException { String stringValue = null; OutParam<String> strOut = new OutParam<String>(); if (this.tryConvertObjectToString(value, strOut)) { stringValue = strOut.getParam(); if (null != stringValue) { // allow an empty string to create an empty element (like <Value // />). this.writeStartElement(xmlNamespace, localName); this.writeValue(stringValue, displayName); this.writeEndElement(); } } else { throw new ServiceXmlSerializationException(String.format( "Values of type '%s' can't be used for the '%s' element.", value.getClass() .getName(), localName)); } }
/** * Writes the attribute value. Optionally emits empty string values. * * @param localName the local name of the attribute. * @param alwaysWriteEmptyString always emit the empty string as the value. * @param value the value * @throws ServiceXmlSerializationException the service xml serialization exception */ public void writeAttributeValue(String localName, boolean alwaysWriteEmptyString, Object value) throws ServiceXmlSerializationException { OutParam<String> stringOut = new OutParam<String>(); String stringValue = null; if (this.tryConvertObjectToString(value, stringOut)) { stringValue = stringOut.getParam(); if ((null != stringValue) && (alwaysWriteEmptyString || (stringValue.length() != 0))) { this.writeAttributeString(localName, stringValue); } } else { throw new ServiceXmlSerializationException(String.format( "Values of type '%s' can't be used for the '%s' attribute.", value.getClass() .getName(), localName)); } }
/** * Writes the attribute value. * * @param namespacePrefix the namespace prefix * @param localName the local name of the attribute * @param value the value * @throws ServiceXmlSerializationException the service xml serialization exception */ public void writeAttributeValue(String namespacePrefix, String localName, Object value) throws ServiceXmlSerializationException { OutParam<String> stringOut = new OutParam<String>(); String stringValue = null; if (this.tryConvertObjectToString(value, stringOut)) { stringValue = stringOut.getParam(); if (null != stringValue && !stringValue.isEmpty()) { this.writeAttributeString(namespacePrefix, localName, stringValue); } } else { throw new ServiceXmlSerializationException(String.format( "Values of type '%s' can't be used for the '%s' attribute.", value.getClass() .getName(), localName)); } }
/** * Writes the element value. * * @param xmlNamespace the XML namespace * @param localName the local name of the element * @param displayName the name that should appear in the exception message when the value can not be serialized * @param value the value * @throws XMLStreamException the XML stream exception * @throws ServiceXmlSerializationException the service xml serialization exception */ public void writeElementValue(XmlNamespace xmlNamespace, String localName, String displayName, Object value) throws XMLStreamException, ServiceXmlSerializationException { String stringValue = null; OutParam<String> strOut = new OutParam<String>(); if (this.tryConvertObjectToString(value, strOut)) { stringValue = strOut.getParam(); if (null != stringValue) { // allow an empty string to create an empty element (like <Value // />). this.writeStartElement(xmlNamespace, localName); this.writeValue(stringValue, displayName); this.writeEndElement(); } } else { throw new ServiceXmlSerializationException(String.format( "Values of type '%s' can't be used for the '%s' element.", value.getClass() .getName(), localName)); } }