/** * This is used to acquire the prefix for this output node. If * the output node is an element then this will search its parent * nodes until the prefix that is currently in scope is found. * If however this node is an attribute then the hierarchy of * nodes is not searched as attributes to not inherit namespaces. * * @return this returns the prefix associated with this node */ public String getPrefix() { return scope.getPrefix(reference); }
public static void write(OutputNode parent, Element domElement) throws Exception { OutputNode child = parent.getChild(domElement.getNodeName()); child.getNamespaces().setReference(domElement.getNamespaceURI(), domElement.getPrefix()); child.setValue(domElement.getTextContent()); child.commit(); } }
/** * This method will resolve the reference or the specified prefix * by searching the parent nodes in order. This allows the prefix * that is currently in scope for the reference to be acquired. * * @param prefix the prefix to find a matching reference for * * @return this will return the reference that is is scope */ private String resolveReference(String prefix) { NamespaceMap parent = source.getNamespaces(); if(parent != null) { return parent.getReference(prefix); } return null; }
/** * This is use to apply for <code>NamespaceList</code> annotations * on the node. If there is no namespace list then this will return * and the node will be left unchanged. If however the namespace * list is not empty the the namespaces are added. * * @param node this is the node to apply the namespace list to */ private void scope(OutputNode node) { NamespaceMap map = node.getNamespaces(); for(Namespace next : scope) { String reference = next.reference(); String prefix = next.prefix(); map.setReference(reference, prefix); } }
/** * This method will resolve the reference or the specified prefix * by searching the parent nodes in order. This allows the prefix * that is currently in scope for the reference to be acquired. * * @param prefix the prefix to find a matching reference for * * @return this will return the reference that is is scope */ private String resolveReference(String prefix) { NamespaceMap parent = source.getNamespaces(); if(parent != null) { return parent.getReference(prefix); } return null; }
/** * This is used to acquire the prefix for this output node. If * the output node is an element then this will search its parent * nodes until the prefix that is currently in scope is found. * If however this node is an attribute then the hierarchy of * nodes is not searched as attributes to not inherit namespaces. * * @return this returns the prefix associated with this node */ public String getPrefix() { return scope.getPrefix(reference); }
/** * This is use to apply for <code>NamespaceList</code> annotations * on the node. If there is no namespace list then this will return * and the node will be left unchanged. If however the namespace * list is not empty the the namespaces are added. * * @param node this is the node to apply the namespace list to */ private void scope(OutputNode node) { NamespaceMap map = node.getNamespaces(); for(Namespace next : scope) { String reference = next.reference(); String prefix = next.prefix(); map.setReference(reference, prefix); } }
/** * This method will resolve the reference or the specified prefix * by searching the parent nodes in order. This allows the prefix * that is currently in scope for the reference to be acquired. * * @param prefix the prefix to find a matching reference for * * @return this will return the reference that is is scope */ private String resolveReference(String prefix) { NamespaceMap parent = source.getNamespaces(); if(parent != null) { return parent.getReference(prefix); } return null; }
/** * This is used to acquire the prefix for this output node. If * the output node is an element then this will search its parent * nodes until the prefix that is currently in scope is found. * If however this node is an attribute then the hierarchy of * nodes is not searched as attributes to not inherit namespaces. * * @return this returns the prefix associated with this node */ public String getPrefix() { return scope.getPrefix(reference); }
/** * This is use to apply for <code>NamespaceList</code> annotations * on the node. If there is no namespace list then this will return * and the node will be left unchanged. If however the namespace * list is not empty the the namespaces are added. * * @param node this is the node to apply the namespace list to */ private void scope(OutputNode node) { NamespaceMap map = node.getNamespaces(); for(Namespace next : scope) { String reference = next.reference(); String prefix = next.prefix(); map.setReference(reference, prefix); } }
/** * 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 is used to acquire the prefix for this output node. If * the output node is an element then this will search its parent * nodes until the prefix that is currently in scope is found. * If however this node is an attribute then the hierarchy of * nodes is not searched as attributes to not inherit namespaces. * * @param inherit if there is no explicit prefix then inherit * * @return this returns the prefix associated with this node */ public String getPrefix(boolean inherit) { return scope.getPrefix(reference); }
/** * 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 is used to acquire the prefix for this output node. If * the output node is an element then this will search its parent * nodes until the prefix that is currently in scope is found. * If however this node is an attribute then the hierarchy of * nodes is not searched as attributes to not inherit namespaces. * * @param inherit if there is no explicit prefix then inherit * * @return this returns the prefix associated with this node */ public String getPrefix(boolean inherit) { return scope.getPrefix(reference); }
/** * 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 is used to acquire the prefix for this output node. If * the output node is an element then this will search its parent * nodes until the prefix that is currently in scope is found. * If however this node is an attribute then the hierarchy of * nodes is not searched as attributes to not inherit namespaces. * * @param inherit if there is no explicit prefix then inherit * * @return this returns the prefix associated with this node */ public String getPrefix(boolean inherit) { return scope.getPrefix(reference); }
/** * This is used to acquire the prefix for this output node. If * the output node is an element then this will search its parent * nodes until the prefix that is currently in scope is found. * If however this node is an attribute then the hierarchy of * nodes is not searched as attributes to not inherit namespaces. * * @param inherit if there is no explicit prefix then inherit * * @return this returns the prefix associated with this node */ public String getPrefix(boolean inherit) { String prefix = scope.getPrefix(reference); if(inherit) { if(prefix == null) { return parent.getPrefix(); } } return prefix; }
/** * This is used to acquire the prefix for this output node. If * the output node is an element then this will search its parent * nodes until the prefix that is currently in scope is found. * If however this node is an attribute then the hierarchy of * nodes is not searched as attributes to not inherit namespaces. * * @param inherit if there is no explicit prefix then inherit * * @return this returns the prefix associated with this node */ public String getPrefix(boolean inherit) { String prefix = scope.getPrefix(reference); if(inherit) { if(prefix == null) { return parent.getPrefix(); } } return prefix; }
/** * This is used to acquire the prefix for this output node. If * the output node is an element then this will search its parent * nodes until the prefix that is currently in scope is found. * If however this node is an attribute then the hierarchy of * nodes is not searched as attributes to not inherit namespaces. * * @param inherit if there is no explicit prefix then inherit * * @return this returns the prefix associated with this node */ public String getPrefix(boolean inherit) { String prefix = scope.getPrefix(reference); if(inherit) { if(prefix == null) { return parent.getPrefix(); } } return prefix; }
/** * This is used to write the namespaces of the specified node to * the output. This will iterate over each namespace entered on * to the node. Once written the node is considered qualified. * * @param node this is the node to have is attributes written */ private void writeNamespaces(OutputNode node) throws Exception { NamespaceMap map = node.getNamespaces(); for(String name : map) { String prefix = map.getPrefix(name); writer.writeNamespace(name, prefix); } } }