Package org.freezedry.persistence.tree

Examples of org.freezedry.persistence.tree.InfoNode


  {
    // grab the root key from all the values and use it to create the root info node.
    // recall that the root key should have the same name as the clazz we're using as
    // a template.
    final String rootKey = getRootKey( keyValues, clazz );
    final InfoNode rootNode = InfoNode.createRootNode( rootKey, clazz );
   
    // build the semantic model
    buildInfoNode( rootNode, keyValues );
   
    return rootNode;
View Full Code Here


      {
        renderer.buildInfoNode( parentNode, keyValues );
      }
      else
      {
        final InfoNode node = InfoNode.createCompoundNode( null, groupName, null );
        parentNode.addChild( node );
        buildInfoNode( node, keyValues );
      }
    }
  }
View Full Code Here

    {
      LOGGER.info( DomUtils.toString( document ) );
    }

    // convert the DOM tree to an InfoNode tree (from which we can build the object)
    final InfoNode node = buildInfoNode( clazz, document );
   
    return node;
  }
View Full Code Here

    // grab the class for the object to persist
    final Class< ? > clazz = object.getClass();
   
    // we must convert the object to the appropriate format
    final String date = DateUtils.createStringFromDate( (Calendar)object, ISO_8601_DATE_FORMAT );
    final InfoNode stringNode = InfoNode.createLeafNode( "value", date, "value", String.class );

    // create the root node and add the string rep of the date
    final InfoNode node = InfoNode.createRootNode( persistName, clazz );
    node.addChild( stringNode );
   
    // return the node
    return node;
  }
View Full Code Here

   * @return The {@link InfoNode} tree representing the DOM
   * @throws ClassNotFoundException
   */
  public static InfoNode buildInfoNode( final Class< ? > rootClass, final Document document )
  {
    InfoNode rootInfoNode = null;
//    if( hosOnlyTextChildNodes( document ) )
//    {
//      rootInfoNode = InfoNode.createRootNode( rootClass.getSimpleName(), rootClass );
//     
//      final Node textNode = document.getChildNodes().item( 0 );
View Full Code Here

    final NodeList domSubnodes = domNode.getChildNodes();
    for( int i = 0; i < domSubnodes.getLength(); ++i )
    {
      // grab the sub node for the index, create an info node, and add it to the parent
      final Node domSubnode = domSubnodes.item( i );
      final InfoNode newInfoNode = createInfoNode( domSubnode );
      infoNode.addChild( newInfoNode );
    }
  }
View Full Code Here

   * @return The object constructed based on the info node.
   */
  @Override
  public Calendar createObject( final Class< ? > clazz, final InfoNode node )
  {
    final InfoNode valueNode = node.getChild( 0 );
    final String value = (String)valueNode.getValue();
    // try the ISO 8601 format (strict)
    Calendar date;
    try
    {
      date = DateUtils.createDateFromString( value, ISO_8601_DATE_FORMAT );
View Full Code Here

      message.append( "Nodes can either have elements or one text element." );
      LOGGER.error( message.toString() );
      throw new IllegalStateException( message.toString() );
    }
   
    InfoNode infoNode = null;
    // compound node (no text value and there are subnodes
    if( nodeValue == null && numNodes > 0 )
    {
      // create the compound info node and then recursively to build out its children
      infoNode = InfoNode.createCompoundNode( null, persistName, type );
View Full Code Here

   */
  @Override
  public InfoNode createInfoNode( final Object object, final String persistName )
  {
    // create the root node and add the string rep of the date
    final InfoNode node = InfoNode.createRootNode( persistName, object.getClass() );
    node.addChild( InfoNode.createLeafNode( "value", ((Enum)object).name(), "value", String.class ) );

    // return the node
    return node;
  }
View Full Code Here

     
    // the first/top of the json string must be the class name, so there should only be one key,
    // and one value associated with that key { "root_key" : { members } }, where members is
    // defined by { pair, members } and pair is defined by "key", "value" (see class documentation).
    // we still have to add the value as a node.
    final InfoNode rootNode = createRootNode( jsonObject, clazz );
   
    // grab the value and deal with one of the three possibilities:
    // 1. the value is a json object and therefore has name-value pairs
    // 2. the value is a json array and therefore has elements
    // 3. the value is neither, and therefore is a simple value
    // In the first two cases, we build out the remainder of the nodes recursively. In
    // the third case, we set in the value and class in root node and we're done.
    final Object value = JsonUtils.getValue( jsonObject, rootNode.getPersistName() );
    if( value instanceof JSONObject )
    {
      buildInfoNode( (JSONObject)value, rootNode );
    }
    else if( value instanceof JSONArray )
View Full Code Here

TOP

Related Classes of org.freezedry.persistence.tree.InfoNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.