当前位置: 首页>>代码示例>>Java>>正文


Java OutputNode.getChild方法代码示例

本文整理汇总了Java中org.simpleframework.xml.stream.OutputNode.getChild方法的典型用法代码示例。如果您正苦于以下问题:Java OutputNode.getChild方法的具体用法?Java OutputNode.getChild怎么用?Java OutputNode.getChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.simpleframework.xml.stream.OutputNode的用法示例。


在下文中一共展示了OutputNode.getChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeList

import org.simpleframework.xml.stream.OutputNode; //导入方法依赖的package包/类
private static <T> void writeList(Serializer ser, OutputStream os, String listElement, List<T> list) throws Exception {
	Format format = new Format("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
	OutputNode doc = NodeBuilder.write(new OutputStreamWriter(os, UTF_8), format);
	OutputNode root = doc.getChild("root");
	root.setComment(BACKUP_COMMENT);
	OutputNode listNode = root.getChild(listElement);

	if (list != null) {
		for (T t : list) {
			try {
				ser.write(t, listNode);
			} catch (Exception e) {
				log.debug("Exception While writing node of type: " + t.getClass(), e);
			}
		}
	}
	root.commit();
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:19,代码来源:BackupExport.java

示例2: write

import org.simpleframework.xml.stream.OutputNode; //导入方法依赖的package包/类
/**
 * 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();      
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:31,代码来源:Traverser.java

示例3: writeElement

import org.simpleframework.xml.stream.OutputNode; //导入方法依赖的package包/类
/**
 * This method is used to write the value to the specified node.
 * This will write the item as an element to the provided node,
 * also this enables references to be used during serialization.
 * 
 * @param node this is the node that the value is written to
 * @param item this is the item that is to be written
 */
private void writeElement(OutputNode node, Object item) throws Exception {
   Class expect = type.getType();
   String key = entry.getKey();
   
   if(key == null) {
      key = context.getName(expect);
   }    
   String name = style.getElement(key);
   OutputNode child = node.getChild(name);  
   
   if(item != null) {
      if(!isOverridden(child, item)) {
         root.write(child, item);
      }
   }
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:25,代码来源:PrimitiveKey.java

示例4: writeElements

import org.simpleframework.xml.stream.OutputNode; //导入方法依赖的package包/类
/**
 * This write method is used to write all the element contacts from
 * the provided source object to the XML element. This visits all
 * the contacts marked with the <code>Element</code> annotation in
 * the source object. All annotated contacts are written as children
 * 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 elements to
 * @param section this is the section that defines the XML structure
 */
private void writeElements(OutputNode node, Object source, Section section) throws Exception {
    for(String name : section) {
      Section child = section.getSection(name);
      
      if(child != null) {
         OutputNode next = node.getChild(name);

         writeSection(next, source, child);
      } else {
         String path = section.getPath(name);
         Label label = section.getElement(path);
         Class expect = context.getType(type, source);
         Object value = criteria.get(label);
         
         if(value == null) {
            if(label == null) {
              throw new ElementException("Element '%s' not defined in %s", name, expect);
            }
            writeUnion(node, source, section, label);
         }
      }            
   }
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:36,代码来源:Composite.java

示例5: writeElement

import org.simpleframework.xml.stream.OutputNode; //导入方法依赖的package包/类
/**
 * 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);
      }
   }
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:38,代码来源:Composite.java

示例6: testLargeList

import org.simpleframework.xml.stream.OutputNode; //导入方法依赖的package包/类
public void testLargeList() throws Exception {
   Context context = getContext();
   Group group = getGroup();
   Type type = new ClassType(CompositeListUnionTest.class);
   List<Shape> list = new ArrayList<Shape>();
   Expression expression = new PathParser("some/path", type, new Format());
   CompositeListUnion union = new CompositeListUnion(
         context,
         group,
         expression,
         type);
   InputNode node = NodeBuilder.read(new StringReader(LARGE_SOURCE));
   
   for(InputNode next = node.getNext(); next != null; next = node.getNext()) {
      union.read(next, list);
   }
   OutputNode output = NodeBuilder.write(new PrintWriter(System.err), new Format(3));
   OutputNode parent = output.getChild("parent");
   
   union.write(parent, list);
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:22,代码来源:CompositeListUnionTest.java

示例7: write

import org.simpleframework.xml.stream.OutputNode; //导入方法依赖的package包/类
public void write(OutputNode node) throws Exception {
    OutputNode member = node.getChild(CODE);
    OutputNode nameNode = member.getChild(Member.NAME);
    nameNode.setValue(name);
    OutputNode valueNode = member.getChild(Value.CODE);
    value.write(valueNode);
}
 
开发者ID:erickok,项目名称:retrofit-xmlrpc,代码行数:8,代码来源:Member.java

示例8: write

import org.simpleframework.xml.stream.OutputNode; //导入方法依赖的package包/类
@Override
public void write(OutputNode node) throws Exception {
    OutputNode child = node.getChild(CODE);
    OutputNode dataNode = child.getChild(ArrayValue.DATA);
    for (Value datum : data) {
        datum.write(dataNode.getChild(Value.CODE));
    }
}
 
开发者ID:erickok,项目名称:retrofit-xmlrpc,代码行数:9,代码来源:ArrayValue.java

示例9: write

import org.simpleframework.xml.stream.OutputNode; //导入方法依赖的package包/类
@Override
public void write(OutputNode node) throws Exception {
    OutputNode struct = node.getChild(CODE);
    for (Member member : members) {
        member.write(struct);
    }
}
 
开发者ID:erickok,项目名称:retrofit-xmlrpc,代码行数:8,代码来源:StructValue.java

示例10: write

import org.simpleframework.xml.stream.OutputNode; //导入方法依赖的package包/类
/**
 * 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);
         }
      }
   }
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:26,代码来源:PrimitiveInlineList.java

示例11: write

import org.simpleframework.xml.stream.OutputNode; //导入方法依赖的package包/类
/**
 * 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);                  
   }
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:26,代码来源:CompositeInlineMap.java

示例12: writeElement

import org.simpleframework.xml.stream.OutputNode; //导入方法依赖的package包/类
/**
 * 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);
      }
   }
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:21,代码来源:PrimitiveValue.java

示例13: write

import org.simpleframework.xml.stream.OutputNode; //导入方法依赖的package包/类
/**
 * This <code>write</code> method will write the specified object
 * to the given XML element as as array entries. Each entry within
 * the given array must be assignable to the array component 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 {
   int size = Array.getLength(source);
   
   for(int i = 0; i < size; i++) {
      OutputNode child = node.getChild(parent);
      
      if(child == null) {
         break;
      }
      write(child, source, i);
   }
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:23,代码来源:PrimitiveArray.java

示例14: write

import org.simpleframework.xml.stream.OutputNode; //导入方法依赖的package包/类
/**
 * 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 source this is the source map that is to be written 
 */
public void write(OutputNode node, Object source) throws Exception {
   Map map = (Map) source;                
   
   for(Object index : map.keySet()) {
      String root = entry.getEntry();
      String name = style.getElement(root);
      OutputNode next = node.getChild(name);
      Object item = map.get(index);            
      
      key.write(next, index);            
      value.write(next, item);                  
   }
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:25,代码来源:CompositeMap.java

示例15: write

import org.simpleframework.xml.stream.OutputNode; //导入方法依赖的package包/类
/**
 * 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);
         }
      }
   }
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:24,代码来源:PrimitiveList.java


注:本文中的org.simpleframework.xml.stream.OutputNode.getChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。