/** * This is use to apply the <code>Namespace</code> annotations on * the node. If there is no namespace then this will return and * the node will be left unchanged. If however the namespace is * not null then the reference is applied to the specified node. * * @param node this is the node to apply the namespace to */ private void namespace(OutputNode node) { if(primary != null) { String reference = primary.reference(); node.setReference(reference); } } }
/** * This is use to apply the <code>Namespace</code> annotations on * the node. If there is no namespace then this will return and * the node will be left unchanged. If however the namespace is * not null then the reference is applied to the specified node. * * @param node this is the node to apply the namespace to */ private void namespace(OutputNode node) { if(primary != null) { String reference = primary.reference(); node.setReference(reference); } } }
/** * This is use to apply the <code>Namespace</code> annotations on * the node. If there is no namespace then this will return and * the node will be left unchanged. If however the namespace is * not null then the reference is applied to the specified node. * * @param node this is the node to apply the namespace to */ private void namespace(OutputNode node) { if(primary != null) { String reference = primary.reference(); node.setReference(reference); } } }
@Override public OutputNode writeElement(OutputNode output, String namespace, String element, Object source) { OutputNode node = null; if (!skip(null, source)) { try { node = output.getChild(element); } catch (Exception exception) { throw new XmlPersisterException(exception); } node.setReference(namespace == null ? EMPTY : namespace); write(node, source); } return node; }
@Override public void write(OutputNode node, T entity) throws Exception { for(org.w3c.dom.Element domElement : entity.getAny()) { ElementConverter.write(node, domElement); } Map<String, Field> entityFields = getEntityFields(); for (String fieldName : entityFields.keySet()) { Field field = entityFields.get(fieldName); Object value = getGetterForField(field).invoke(entity); if (value == null) { continue; } if (value instanceof String) { OutputNode childNode = node.getChild(fieldName); childNode.setReference(SardineUtil.DEFAULT_NAMESPACE_URI); childNode.setValue((String)value); } else { serializer.write(value, node); } } } }
@Override public OutputNode writeAttribute(OutputNode output, String namespace, String attribute, Object source) { OutputNode node = null; if (!skip(null, source)) { NodeMap<OutputNode> attributes = output.getAttributes(); node = attributes.get(attribute); if (node == null) { node = attributes.put(attribute, EMPTY); } node.setReference(namespace == null ? EMPTY : namespace); write(node, source); } return node; }
/** * This <code>writeSection</code> method is used to perform serialization * of the given source object. Serialization is performed by appending * elements and attributes from the source object to the provided XML * element object. How the objects contacts are serialized is * determined by the XML schema class that the source object is an * instance of. If a required contact is null an exception is thrown. * * @param source this is the source object to be serialized * @param node the XML element the object is to be serialized to * @param section this is the section that defines the XML structure */ private void writeSection(OutputNode node, Object source, Section section) throws Exception { NamespaceMap scope = node.getNamespaces(); String prefix = section.getPrefix(); if(prefix != null) { String reference = scope.getReference(prefix); if(reference == null) { throw new ElementException("Namespace prefix '%s' in %s is not in scope", prefix, type); } else { node.setReference(reference); } } writeAttributes(node, source, section); writeElements(node, source, section); writeText(node, source, section); }
/** * This <code>writeSection</code> method is used to perform serialization * of the given source object. Serialization is performed by appending * elements and attributes from the source object to the provided XML * element object. How the objects contacts are serialized is * determined by the XML schema class that the source object is an * instance of. If a required contact is null an exception is thrown. * * @param source this is the source object to be serialized * @param node the XML element the object is to be serialized to * @param section this is the section that defines the XML structure */ private void writeSection(OutputNode node, Object source, Section section) throws Exception { NamespaceMap scope = node.getNamespaces(); String prefix = section.getPrefix(); if(prefix != null) { String reference = scope.getReference(prefix); if(reference == null) { throw new ElementException("Namespace prefix '%s' in %s is not in scope", prefix, type); } else { node.setReference(reference); } } writeAttributes(node, source, section); writeElements(node, source, section); writeText(node, source, section); }
/** * This <code>writeSection</code> method is used to perform serialization * of the given source object. Serialization is performed by appending * elements and attributes from the source object to the provided XML * element object. How the objects contacts are serialized is * determined by the XML schema class that the source object is an * instance of. If a required contact is null an exception is thrown. * * @param source this is the source object to be serialized * @param node the XML element the object is to be serialized to * @param section this is the section that defines the XML structure */ private void writeSection(OutputNode node, Object source, Section section) throws Exception { NamespaceMap scope = node.getNamespaces(); String prefix = section.getPrefix(); if(prefix != null) { String reference = scope.getReference(prefix); if(reference == null) { throw new ElementException("Namespace prefix '%s' in %s is not in scope", prefix, type); } else { node.setReference(reference); } } writeAttributes(node, source, section); writeElements(node, source, section); writeText(node, source, section); }