Java Code Examples for org.simpleframework.xml.stream.OutputNode#setName()

The following examples show how to use org.simpleframework.xml.stream.OutputNode#setName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CompositeListUnion.java    From simplexml with Apache License 2.0 5 votes vote down vote up
/**
 * The <code>write</code> method uses the name of the XML element to
 * select a converter to be used to write the instance. Selection of
 * the converter is done by looking up the associated label from
 * the union group using the instance type. Once the converter has
 * been selected it is used to write the instance.
 * 
 * @param node this is the XML element used to write the instance
 * @param item this is the individual list entry to be serialized
 * @param label this is the label to used to acquire the converter     
 */
private void write(OutputNode node, Object item, Label label) throws Exception {
   Converter converter = label.getConverter(context);
   Collection list = Collections.singleton(item);

   if(!label.isInline()) {
      String name = label.getName();
      String root = style.getElement(name);
     
      if(!node.isCommitted()) {
         node.setName(root);
      }
   }
   converter.write(node, list);    
}
 
Example 2
Source File: CompositeMapUnion.java    From simplexml with Apache License 2.0 5 votes vote down vote up
/**
 * The <code>write</code> method uses the name of the XML element to
 * select a converter to be used to write the instance. Selection of
 * the converter is done by looking up the associated label from
 * the union group using the instance type. Once the converter has
 * been selected it is used to write the instance.
 * 
 * @param node this is the XML element used to write the instance
 * @param key this is the key associated with the item to write
 * @param item this is the value associated with the item to write
 * @param label this is the label to used to acquire the converter     
 */
private void write(OutputNode node, Object key, Object item, Label label) throws Exception {  
   Converter converter = label.getConverter(context);
   Map map = Collections.singletonMap(key, item);
   
   if(!label.isInline()) {
      String name = label.getName();
      String root = style.getElement(name);
     
      if(!node.isCommitted()) {
         node.setName(root);
      }
   }
   converter.write(node, map);   
}
 
Example 3
Source File: VisitorSetNodeNameTest.java    From simplexml with Apache License 2.0 4 votes vote down vote up
public void write(Type type, NodeMap<OutputNode> node) throws Exception {        
   OutputNode parent = node.getNode();
   String name = parent.getName();
   name = name.toUpperCase();
   parent.setName(name);
}