org.simpleframework.xml.stream.OutputNode Java Examples

The following examples show how to use org.simpleframework.xml.stream.OutputNode. 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: CompositeInlineMapTest.java    From simplexml with Apache License 2.0 6 votes vote down vote up
public void testNotInlineString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(false, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "key", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   CompositeInlineMap value = new CompositeInlineMap(source, entry, new ClassType(Map.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));
   Map exampleMap = new HashMap();
   
   exampleMap.put("a", "1");
   exampleMap.put("b", "2");
   value.write(node.getChild("notInlineString").getChild("map"), exampleMap);
   node.commit();            
}
 
Example #2
Source File: CompositeList.java    From simplexml with Apache License 2.0 6 votes vote down vote up
/**
 * This <code>write</code> method will write the specified object
 * to the given XML element as as list entries. Each entry within
 * the given collection must be assignable from the annotated 
 * type specified within the <code>ElementList</code> annotation.
 * Each entry is serialized as a root element, that is, its
 * <code>Root</code> annotation is used to extract the name. 
 * 
 * @param source this is the source collection to be serialized 
 * @param node this is the XML element container to be populated
 */ 
public void write(OutputNode node, Object source) throws Exception {
   Collection list = (Collection) source;                
   
   for(Object item : list) {
      if(item != null) {
         Class expect = entry.getType();
         Class actual = item.getClass();

         if(!expect.isAssignableFrom(actual)) {
            throw new PersistenceException("Entry %s does not match %s for %s", actual, entry, type);                     
         }
         root.write(node, item, expect, name);
      }
   }
}
 
Example #3
Source File: PrimitiveKeyTest.java    From simplexml with Apache License 2.0 6 votes vote down vote up
public void testAttributeNoKeyString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(true, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   PrimitiveKey value = new PrimitiveKey(source, entry, new ClassType(String.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));
   
   value.write(node.getChild("attributeNoKeyString"), "example");
   node.commit();
}
 
Example #4
Source File: PrimitiveValueTest.java    From simplexml with Apache License 2.0 6 votes vote down vote up
public void testNotInlineString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(false, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "key", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   PrimitiveValue value = new PrimitiveValue(source, entry, new ClassType(String.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));
   
   value.write(node.getChild("notInlineString"), "example");
   node.commit();            
}
 
Example #5
Source File: Traverser.java    From simplexml with Apache License 2.0 6 votes vote down vote up
/**
 * This <code>write</code> method is used to convert the provided
 * object to an XML element. This creates a child node from the
 * given <code>OutputNode</code> object. Once this child element 
 * is created it is populated with the fields of the source object
 * in accordance with the XML schema class.  
 * 
 * @param source this is the object to be serialized to XML
 * @param expect this is the class that is expected to be written
 * @param name this is the name of the root annotation used 
 * 
 * @throws Exception thrown if there is a problem serializing
 */
public void write(OutputNode node, Object source, Class expect, String name) throws Exception {
   OutputNode child = node.getChild(name);
   Type type = getType(expect);
   
   if(source != null) {
      Class actual = source.getClass();
      Decorator decorator = getDecorator(actual);
      
      if(decorator != null) {
         decorator.decorate(child);
      }
      if(!context.setOverride(type, source, child)) {
         getComposite(actual).write(child, source);         
      }
   }         
   child.commit();      
}
 
Example #6
Source File: CompositeMapTest.java    From simplexml with Apache License 2.0 6 votes vote down vote up
public void testAttributeNoKeyString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(true, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   CompositeMap value = new CompositeMap(source, entry, new ClassType(Map.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));
   Map exampleMap = new HashMap();
   
   exampleMap.put("a", "1");
   exampleMap.put("b", "2");
   value.write(node.getChild("attributeNoKeyString"), exampleMap);
   node.commit();
}
 
Example #7
Source File: AliasTest.java    From simplexml with Apache License 2.0 6 votes vote down vote up
public boolean write(Type field, Object value, NodeMap<OutputNode> node, Map map) throws Exception {
    boolean done = strategy.write(field, value, node, map);
    Node entry = node.remove("class");
    
    if(entry != null) {
        String className = entry.getValue();
        Class type = Class.forName(className);
        String name = forward.get(type);

        if(name == null) {
            throw new PersistenceException("Could not find alias for class %s", className);
        }
        node.put("type", name);
    }
    return done;
}
 
Example #8
Source File: Composite.java    From simplexml with Apache License 2.0 6 votes vote down vote up
/**
 * This <code>write</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
 */
public void write(OutputNode node, Object source) throws Exception {
   Class type = source.getClass();
   Schema schema = context.getSchema(type);
   Caller caller = schema.getCaller();
   
   try { 
      if(schema.isPrimitive()) {
         primitive.write(node, source);
      } else {
         caller.persist(source); 
         write(node, source, schema);
      }
   } finally {
      caller.complete(source);
   }
}
 
Example #9
Source File: CompositeMapTest.java    From simplexml with Apache License 2.0 6 votes vote down vote up
public void testNoAttributeString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(false, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   CompositeMap value = new CompositeMap(source, entry, new ClassType(Map.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));
   Map exampleMap = new HashMap();
   
   exampleMap.put("a", "1");
   exampleMap.put("b", "2");      
   value.write(node.getChild("noAttributeString"), exampleMap);
   node.commit();
}
 
Example #10
Source File: PrimitiveKeyTest.java    From simplexml with Apache License 2.0 6 votes vote down vote up
public void testInlineString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(true, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "key", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   PrimitiveKey value = new PrimitiveKey(source, entry, new ClassType(String.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));
   
   value.write(node.getChild("inlineString"), "example");
   node.commit();
}
 
Example #11
Source File: Composite.java    From simplexml with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #12
Source File: Composite.java    From simplexml with Apache License 2.0 6 votes vote down vote up
/**
 * This method is used to write the version attribute. A version is
 * written only if it is not the initial version or if it required.
 * The version is used to determine how to deserialize the XML. If
 * the version is different from the expected version then it allows
 * the object to be deserialized in a manner that does not require
 * any attributes or elements, and unmatched nodes are ignored. 
 * 
 * @param node this is the node to read the version attribute from
 * @param source this is the source object that is to be written
 * @param schema this is the schema that contains the version
 */
private void writeVersion(OutputNode node, Object source, Schema schema) throws Exception {
   Version version = schema.getRevision();
   Label label = schema.getVersion();
   
   if(version != null) {
      Double start = revision.getDefault();
      Double value = version.revision();
  
      if(revision.compare(value, start)) {
         if(label.isRequired()) {
            writeAttribute(node, value, label);
         }
      } else {
         writeAttribute(node, value, label);
      }
   }
}
 
Example #13
Source File: Composite.java    From simplexml with Apache License 2.0 6 votes vote down vote up
/**
 * This write method is used to append the provided object as an
 * element to the given XML element object. This will recursively
 * write the contacts from the provided object as elements. This is
 * done using the <code>Converter</code> acquired from the contact
 * label. If the type of the contact value is not of the same
 * type as the XML schema class a "class" attribute is appended.
 * <p>
 * If the element being written is inline, then this will not 
 * check to see if there is a "class" attribute specifying the
 * name of the class. This is because inline elements do not have
 * an outer class and thus could never have an override.
 * 
 * @param value this is the value to be set as an element
 * @param node this is the XML element to write the element to
 * @param label the label that contains the contact details
 */
private void writeElement(OutputNode node, Object value, Label label) throws Exception {
   if(value != null) {
      Class real = value.getClass();
      Label match = label.getLabel(real);
      String name = match.getName();
      Type type = label.getType(real); 
      OutputNode next = node.getChild(name);

      if(!match.isInline()) {
         writeNamespaces(next, type, match);
      }
      if(match.isInline() || !isOverridden(next, value, type)) {
         Converter convert = match.getConverter(context);
         boolean data = match.isData();
         
         next.setData(data);
         writeElement(next, value, convert);
      }
   }
}
 
Example #14
Source File: PrimitiveKeyTest.java    From simplexml with Apache License 2.0 6 votes vote down vote up
public void testNotInlineString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(false, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "key", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   PrimitiveKey value = new PrimitiveKey(source, entry, new ClassType(String.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));
   
   value.write(node.getChild("notInlineString"), "example");
   node.commit();            
}
 
Example #15
Source File: PrimitiveValueTest.java    From simplexml with Apache License 2.0 6 votes vote down vote up
public void testAttributeNoKeyString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(true, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   PrimitiveValue value = new PrimitiveValue(source, entry, new ClassType(String.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));
   
   value.write(node.getChild("attributeNoKeyString"), "example");
   node.commit();
}
 
Example #16
Source File: Composite.java    From simplexml with Apache License 2.0 6 votes vote down vote up
/**
 * This write method is used to write all the attribute contacts from
 * the provided source object to the XML element. This visits all
 * the contacts marked with the <code>Attribute</code> annotation in
 * the source object. All annotated contacts are written as attributes
 * to the XML element. This will throw an exception if a required
 * contact within the source object is null. 
 * 
 * @param source this is the source object to be serialized
 * @param node this is the XML element to write attributes to
 * @param section this is the section that defines the XML structure
 */
private void writeAttributes(OutputNode node, Object source, Section section) throws Exception {
   LabelMap attributes = section.getAttributes();

   for(Label label : attributes) {
      Contact contact = label.getContact();         
      Object value = contact.get(source);
      Class expect = context.getType(type, source);
      
      if(value == null) {
         value = label.getEmpty(context);
      }
      if(value == null && label.isRequired()) {
         throw new AttributeException("Value for %s is null in %s", label, expect);
      }
      writeAttribute(node, value, label);              
   }      
}
 
Example #17
Source File: CompositeInlineMapTest.java    From simplexml with Apache License 2.0 6 votes vote down vote up
public void testNoAttributeString() throws Exception 
{
   Source source = new Source(new TreeStrategy(), new Support(), new Session());
   MockElementMap map = new MockElementMap(false, // attribute
                                           false, // data
                                           "entry", // entry 
                                           true,  // inline
                                           "", // key
                                           String.class, // keyType
                                           "name", // name
                                           true, // required
                                           "value", // value
                                           String.class); // valueType
   PrimitiveType type = new PrimitiveType(map);
   Contact string = type.getString();
   Entry entry = new Entry(string, map);
   CompositeInlineMap value = new CompositeInlineMap(source, entry, new ClassType(Map.class));
   OutputNode node = NodeBuilder.write(new PrintWriter(System.out));
   Map exampleMap = new HashMap();
   
   exampleMap.put("a", "1");
   exampleMap.put("b", "2");      
   value.write(node.getChild("noAttributeString").getChild("map"), exampleMap);
   node.commit();
}
 
Example #18
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 #19
Source File: AnnotationTypeTest.java    From simplexml with Apache License 2.0 5 votes vote down vote up
public boolean write(Type type, Object value, NodeMap<OutputNode> node, Map map) throws Exception {
   Component component = type.getAnnotation(Component.class);
   
   if(component != null) {
      String name = component.name();
   
      if(name != null) {
         node.put(KEY, name);
      }
   }
   return strategy.write(type, value, node, map);
}
 
Example #20
Source File: ClassToNamespaceVisitor.java    From simplexml with Apache License 2.0 5 votes vote down vote up
public void write(Type field, NodeMap<OutputNode> node) throws Exception {
   OutputNode value = node.remove("class");
   if(value != null) {
      String type = value.getValue();
      String name = new PackageParser().parse(type);
      if(name == null) {
         throw new PersistenceException("Could not match class %s", type);
      }
      if(comment) {
         node.getNode().setComment(type);
      }
      node.getNode().getNamespaces().setReference(name, "class");
      node.getNode().setReference(name);
   }
}
 
Example #21
Source File: TextList.java    From simplexml with Apache License 2.0 5 votes vote down vote up
/**
 * The <code>write</code> method writes the fields from the given 
 * object to the XML element. After this has finished the element
 * contains all attributes and sub-elements from the object.
 * 
 * @param object this is the object to be written to the element
 * @param node this is the element that is to be populated
 */
public void write(OutputNode node, Object object) throws Exception {
   Collection list = (Collection) object;
   OutputNode parent = node.getParent();
   
   for(Object item : list) {
      primitive.write(parent, item);
   }
}
 
Example #22
Source File: PrimitiveList.java    From simplexml with Apache License 2.0 5 votes vote down vote up
/**
 * This <code>write</code> method will write the specified object
 * to the given XML element as as list entries. Each entry within
 * the given list must be assignable to the given primitive type.
 * This will deserialize each entry type as a primitive value. In
 * order to do this the parent string provided forms the element.
 * 
 * @param source this is the source object array to be serialized 
 * @param node this is the XML element container to be populated
 */ 
public void write(OutputNode node, Object source) throws Exception {
   Collection list = (Collection) source;                
   
   for(Object item : list) {
      if(item != null) {
         OutputNode child = node.getChild(parent);         

         if(!isOverridden(child, item)) { 
            root.write(child, item);
         }
      }
   }
}
 
Example #23
Source File: DynamicMapOfAttributesTest.java    From simplexml with Apache License 2.0 5 votes vote down vote up
public void write(OutputNode node, Car car) throws Exception {
   Set<String> keys = car.furtherAttributes.keySet();
   
   for(String name : keys) {
      String value = car.furtherAttributes.get(name);
      
      node.setAttribute(name, value);
   }
}
 
Example #24
Source File: NamespaceDecoratorTest.java    From simplexml with Apache License 2.0 5 votes vote down vote up
public void testQualifier() throws Exception {
   NamespaceDecorator global = new NamespaceDecorator();
   NamespaceDecorator qualifier = new NamespaceDecorator();
   NamespaceDecorator attribute = new NamespaceDecorator();
   
   global.add(new MockNamespace("global", "http://www.domain.com/global")); 
   qualifier.add(new MockNamespace("a", "http://www.domain.com/a"));
   qualifier.add(new MockNamespace("b", "http://www.domain.com/b"));
   qualifier.add(new MockNamespace("c", "http://www.domain.com/c"));
   attribute.add(new MockNamespace("d", "http://www.domain.com/d"));
   
   global.set(new MockNamespace("first", "http://www.domain.com/ignore"));
   qualifier.set(new MockNamespace("a", "http://www.domain.com/a"));
   attribute.set(new MockNamespace("b", "http://www.domain.com/b"));

   StringWriter out = new StringWriter(); 
   
   OutputNode top = NodeBuilder.write(out);
   OutputNode root = top.getChild("root");
   
   root.setAttribute("version", "1.0");
   qualifier.decorate(root, global);
   
   OutputNode child = root.getChild("child");
   child.setAttribute("name", "John Doe");
   
   OutputNode name = child.getAttributes().get("name");
   attribute.decorate(name);
   
   OutputNode grandChild = child.getChild("grandChild");
   grandChild.setValue("this is the grand child");
   
   root.commit();
   validate(out.toString());     
}
 
Example #25
Source File: PrimitiveValue.java    From simplexml with Apache License 2.0 5 votes vote down vote up
/**
 * This method is used to write the value to the specified node.
 * The value written to the node can be an attribute or an element
 * depending on the annotation attribute values. This method will
 * maintain references for serialized elements.
 * 
 * @param node this is the node that the value is written to
 * @param item this is the item that is to be written
 * @param key this is the name of the element to be created
 */   
private void writeElement(OutputNode node, Object item, String key) throws Exception {
   String name = style.getAttribute(key);
   OutputNode child = node.getChild(name);

   if(item != null) {        
      if(!isOverridden(child, item)) {
         root.write(child, item);
      }
   }
}
 
Example #26
Source File: CompositeInlineList.java    From simplexml with Apache License 2.0 5 votes vote down vote up
/**
 * This <code>write</code> method will write the specified object
 * to the given XML element as as list entries. Each entry within
 * the given collection must be assignable from the annotated 
 * type specified within the <code>ElementList</code> annotation.
 * Each entry is serialized as a root element, that is, its
 * <code>Root</code> annotation is used to extract the name. 
 * 
 * @param list this is the source collection to be serialized 
 * @param node this is the XML element container to be populated
 */ 
public void write(OutputNode node, Collection list) throws Exception {  
   for(Object item : list) {
      if(item != null) {
         Class expect = entry.getType();
         Class actual = item.getClass();

         if(!expect.isAssignableFrom(actual)) {
            throw new PersistenceException("Entry %s does not match %s for %s", actual, expect, type);
         }
         root.write(node, item, expect, name);
      }
   }
}
 
Example #27
Source File: PrimitiveInlineList.java    From simplexml with Apache License 2.0 5 votes vote down vote up
/**
 * This <code>write</code> method will write the specified object
 * to the given XML element as as list entries. Each entry within
 * the given list must be assignable to the given primitive type.
 * This will deserialize each entry type as a primitive value. In
 * order to do this the parent string provided forms the element.
 * 
 * @param node this is the parent output node to write values to
 * @param source this is the source collection to be serialized 
 * @param mode this is used to determine whether to output CDATA    
 */ 
private void write(OutputNode node, Object source, Mode mode) throws Exception {
   Collection list = (Collection) source;
   
   for(Object item : list) {
      if(item != null) {
         OutputNode child = node.getChild(parent);
      
         if(!isOverridden(child, item)) { 
            child.setMode(mode);
            root.write(child, item);
         }
      }
   }
}
 
Example #28
Source File: ConverterMapTest.java    From simplexml with Apache License 2.0 5 votes vote down vote up
public void write(OutputNode node, Map map) throws Exception {
   Set keys = map.keySet();
   
   for(Object key : keys) {
      OutputNode next = node.getChild("entry");
      next.setAttribute("key", key.toString());
      OutputNode value = next.getChild("value");
      value.setValue(map.get(key).toString());
   }
}
 
Example #29
Source File: CompositeInlineMap.java    From simplexml with Apache License 2.0 5 votes vote down vote up
/**
 * This <code>write</code> method will write the key value pairs
 * within the provided map to the specified XML node. This will 
 * write each entry type must contain a key and value so that
 * the entry can be deserialized in to the map as a pair. If the
 * key or value object is composite it is read as a root object 
 * so its <code>Root</code> annotation must be present.
 * 
 * @param node this is the node the map is to be written to
 * @param map this is the source map that is to be written 
 * @param mode this is the mode that has been inherited
 */
private void write(OutputNode node, Map map, Mode mode) throws Exception {   
   String root = entry.getEntry();
   String name = style.getElement(root);
   
   for(Object index : map.keySet()) {
      OutputNode next = node.getChild(name);
      Object item = map.get(index);            
      
      next.setMode(mode); 
      key.write(next, index);            
      value.write(next, item);                  
   }
}
 
Example #30
Source File: UARTActivity.java    From Android-nRF-Toolbox with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void write(final Type type, final NodeMap<OutputNode> node) {
	if (type.getType().equals(Command[].class)) {
		final OutputNode element = node.getNode();

		final StringBuilder builder = new StringBuilder("A configuration must have 9 commands, one for each button.\n        Possible icons are:");
		for (Command.Icon icon : Command.Icon.values())
			builder.append("\n          - ").append(icon.toString());
		element.setComment(builder.toString());
	}
}