Java Code Examples for org.simpleframework.xml.stream.InputNode#getParent()

The following examples show how to use org.simpleframework.xml.stream.InputNode#getParent() . 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: CompositeInlineList.java    From simplexml with Apache License 2.0 6 votes vote down vote up
/**
 * This <code>read</code> method wll read the XML element list from
 * the provided node and deserialize its children as entry types.
 * This will each entry type is deserialized as a root type, that 
 * is, its <code>Root</code> annotation must be present and the
 * name of the entry element must match that root element name.
 * 
 * @param node this is the XML element that is to be deserialized
 * @param list this is the collection that is to be populated
 * 
 * @return this returns the item to attach to the object contact
 */ 
private Object read(InputNode node, Collection list) throws Exception {              
   InputNode from = node.getParent();
   String name = node.getName();
   
   while(node != null) {
      Class type = entry.getType();
      Object item = read(node, type);
      
      if(item != null) {
         list.add(item);
      }      
      node = from.getNext(name);
   }
   return list;
}
 
Example 2
Source File: CompositeInlineList.java    From simplexml with Apache License 2.0 6 votes vote down vote up
/**
 * This <code>read</code> method will read the XML element list from
 * the provided node and deserialize its children as entry types.
 * This will each entry type is deserialized as a root type, that 
 * is, its <code>Root</code> annotation must be present and the
 * name of the entry element must match that root element name.
 * 
 * @param node this is the XML element that is to be deserialized
 * 
 * @return this returns the item to attach to the object contact
 */ 
public boolean validate(InputNode node) throws Exception{
   InputNode from = node.getParent();
   Class type = entry.getType();
   String name = node.getName();
   
   while(node != null) {
      boolean valid = root.validate(node, type);
  
      if(valid == false) {
         return false;
      }
      node = from.getNext(name);
   }  
   return true;
}
 
Example 3
Source File: CompositeInlineMap.java    From simplexml with Apache License 2.0 6 votes vote down vote up
/**
 * This <code>read</code> method will read the XML element map from
 * the provided node and deserialize its children as entry types.
 * Each entry type must contain a key and value so that the entry 
 * can be inserted in to the map as a pair. If either the key or 
 * value is composite it is read as a root object, which means its
 * <code>Root</code> annotation must be present and the name of the
 * object element must match that root element name.
 * 
 * @param node this is the XML element that is to be deserialized
 * @param map this is the map object that is to be populated
 * 
 * @return this returns the item to attach to the object contact
 */
private Object read(InputNode node, Map map) throws Exception {
   InputNode from = node.getParent();
   String name = node.getName();                

   while(node != null) {         
      Object index = key.read(node);
      Object item = value.read(node);
         
      if(map != null) {
         map.put(index, item);
      }
      node = from.getNext(name);
   }
   return map;
}
 
Example 4
Source File: CompositeInlineMap.java    From simplexml with Apache License 2.0 6 votes vote down vote up
/**
 * This <code>read</code> method will read the XML element map from
 * the provided node and deserialize its children as entry types.
 * Each entry type must contain a key and value so that the entry 
 * can be inserted in to the map as a pair. If either the key or 
 * value is composite it is read as a root object, which means its
 * <code>Root</code> annotation must be present and the name of the
 * object element must match that root element name.
 * 
 * @param node this is the XML element that is to be deserialized
 * 
 * @return this returns the item to attach to the object contact
 */
public boolean validate(InputNode node) throws Exception{
   InputNode from = node.getParent();
   String name = node.getName();                
   
   while(node != null) {
      if(!key.validate(node)) {
         return false;
      }
      if(!value.validate(node)) {
         return false;
      }
      node = from.getNext(name);
   }
   return true;
}
 
Example 5
Source File: PrimitiveInlineList.java    From simplexml with Apache License 2.0 5 votes vote down vote up
/**
 * This <code>read</code> method wll read the XML element list from
 * the provided node and deserialize its children as entry types.
 * 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 XML element that is to be deserialized
 * @param list this is the collection that is to be populated
 * 
 * @return this returns the item to attach to the object contact
 */ 
private Object read(InputNode node, Collection list) throws Exception {              
   InputNode from = node.getParent();
   String name = node.getName();
   
   while(node != null) {
      Object item = root.read(node);
      
      if(item != null) {
         list.add(item);
      }      
      node = from.getNext(name);
   }
   return list;
}
 
Example 6
Source File: PrimitiveInlineList.java    From simplexml with Apache License 2.0 5 votes vote down vote up
/**
 * This <code>read</code> method wll read the XML element list from
 * the provided node and deserialize its children as entry types.
 * 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 XML element that is to be deserialized
 * 
 * @return this returns the item to attach to the object contact
 */ 
public boolean validate(InputNode node) throws Exception{     
   InputNode from = node.getParent();
   String name = node.getName();
   
   while(node != null) {
      boolean valid = root.validate(node);
      
      if(valid == false) {
         return false;            
      }      
      node = from.getNext(name);
   }
   return true;
}
 
Example 7
Source File: CompositeListUnion.java    From simplexml with Apache License 2.0 3 votes vote down vote up
/**
 * The <code>readText</code> method is used to read free text from
 * between the declared elements and add them to a list. Consuming
 * free text in this manner enables an element list union to parse
 * unstructured XML such as XHTML.
 * 
 * @param node this is the node to consume the free text from
 * @param value this is the value that is to be repeated
 * 
 * @return this returns the list with the text added to it
 */
private Object readText(InputNode node, Object value) throws Exception {
   Label label = group.getText();
   Converter converter = label.getConverter(context);
   InputNode parent = node.getParent();
   
   return converter.read(parent, value);
}