Examples of TagElement


Examples of org.apache.etch.util.core.xml.XmlParser.TagElement

    stack.pop();
  }

  public void writeArrayElement( Object value ) throws IOException
  {
    TagElement te = stack.peek().addTag( ELEMENT_TAG );
    stack.push( te );
    writeValue( value );
    stack.pop();
  }
View Full Code Here

Examples of org.apache.etch.util.core.xml.XmlParser.TagElement

  @SuppressWarnings("deprecation")
  private void writeValue( Object value ) throws IOException
  {
    // the caller has already created an element for us.
   
    TagElement te = stack.peek();
   
    int type = checkValue( value );
   
    switch (type)
    {
      case TypeCode.NULL:
      {
        te.setAttr( null, ELEMENT_TYPE_ATTR, NULL_TYPE );
        break;
      }
     
      case TypeCode.BOOLEAN_FALSE:
      case TypeCode.BOOLEAN_TRUE:
      {
        te.setAttr( null, ELEMENT_TYPE_ATTR, BOOLEAN_TYPE );
        te.addCdata( value.toString() );
        break;
      }
     
      case TypeCode.BYTE:
      case TypeCode.SHORT:
      case TypeCode.INT:
      {
        te.setAttr( null, ELEMENT_TYPE_ATTR, INTEGER_TYPE );
        te.addCdata( value.toString() );
        break;
      }
     
      case TypeCode.LONG:
      {
        te.setAttr( null, ELEMENT_TYPE_ATTR, LONG_TYPE );
        te.addCdata( value.toString() );
        break;
      }
     
      case TypeCode.FLOAT:
      {
        te.setAttr( null, ELEMENT_TYPE_ATTR, FLOAT_TYPE );
        te.addCdata( value.toString() );
        break;
      }
     
      case TypeCode.DOUBLE:
      {
        te.setAttr( null, ELEMENT_TYPE_ATTR, DOUBLE_TYPE );
        te.addCdata( value.toString() );
        break;
      }
     
      case TypeCode.BYTES:
      {
        byte[] b = (byte[]) value;
        te.setAttr( null, ELEMENT_TYPE_ATTR, BYTES_TYPE );
        te.addCdata( bytes2string( b ) );
        break;
      }
     
      case TypeCode.EMPTY_STRING:
      case TypeCode.STRING:
      {
        String s = (String) value;
        te.setAttr( null, ELEMENT_TYPE_ATTR, STRING_TYPE );
        te.addCdata( s );
        break;
      }
     
      case TypeCode.ARRAY:
        te.setAttr( null, ELEMENT_TYPE_ATTR, ARRAY_TYPE );
        if (value instanceof ArrayValue)
          writeArray( (ArrayValue) value, null );
        else
          writeArray( toArrayValue( value, null ), null );
        break;
       
      case TypeCode.STRUCT:
      case TypeCode.CUSTOM:
      {
        StructValue struct = vf.exportCustomValue( value );
       
        if (struct == null)
          throw new UnsupportedOperationException( "unsupported type "+value.getClass() );
       
        te.setAttr( null, ELEMENT_TYPE_ATTR, CUSTOM_TYPE );
        writeStruct( struct );
        break;
      }
     
      default:
View Full Code Here

Examples of org.apache.etch.util.core.xml.XmlParser.TagElement

  public Message startMessage() throws IOException
  {
    stack.clear();
   
    TagElement te = new XmlParser().parseOne( rdr, null, MESSAGE_TAG );
    stack.push( te );
    elementList.push( te.getChildren() );
   
    Integer id = te.getIntAttr( null, STRUCT_TYPE_ATTR );
    Type type = vf.getType( id );
    return new Message( type, vf );
  }
View Full Code Here

Examples of org.apache.etch.util.core.xml.XmlParser.TagElement

     
  }

  public StructValue startStruct()
  {
    TagElement te = stack.peek();
    elementList.push( te.getChildren() );
   
    Integer id = te.getIntAttr( null, STRUCT_TYPE_ATTR );
    Type type = vf.getType( id );
    return new StructValue( type, vf );
  }
View Full Code Here

Examples of org.apache.etch.util.core.xml.XmlParser.TagElement

    return new StructValue( type, vf );
  }

  public boolean readStructElement( StructElement se ) throws IOException
  {
    TagElement te = readNextTagElement();
    if (te == null)
      return false;
   
    Type t = null; // TODO this needs to come from somewhere.
    Integer id = te.getIntAttr( null, KEY_ATTR );
    se.key = t.getField( id );
   
    stack.push( te );
    se.value = intReadValue();
    stack.pop();
View Full Code Here

Examples of org.apache.etch.util.core.xml.XmlParser.TagElement

    elementList.pop();
  }

  public ArrayValue startArray()
  {
    TagElement te = stack.peek();
    elementList.push( te.getChildren() );
    return new ArrayValue( null );
  }
View Full Code Here

Examples of org.apache.etch.util.core.xml.XmlParser.TagElement

    public Object value;
  }

  public boolean readArrayElement( ArrayElement ae ) throws IOException
  {
    TagElement te = readNextTagElement();
    if (te == null)
      return false;
   
    stack.push( te );
    ae.value = intReadValue();
View Full Code Here

Examples of org.apache.etch.util.core.xml.XmlParser.TagElement

    return (TagElement) e;
  }
 
  private Object intReadValue() throws IOException
  {
    TagElement te = stack.peek();
    System.out.printf( "readValue: %s\n", te );
    String type = te.getAttr( null, ELEMENT_TYPE_ATTR );
   
    if (type.equals( NULL_TYPE ))
      return null;
   
    if (type.equals( BOOLEAN_TYPE ))
      return new Boolean( te.getCdataValue() );
   
    if (type.equals( INTEGER_TYPE ))
      return new Integer( te.getCdataValue() );
   
    if (type.equals( LONG_TYPE ))
      return new Long( te.getCdataValue() );
   
    if (type.equals( FLOAT_TYPE ))
      return new Float( te.getCdataValue() );
   
    if (type.equals( DOUBLE_TYPE ))
      return new Double( te.getCdataValue() );

    if (type.equals( BYTES_TYPE ))
      return string2bytes( te.getCdataValue() );
   
    if (type.equals( STRING_TYPE ))
      return te.getCdataValue();
   
    if (type.equals( ARRAY_TYPE ))
      return readArray(null);
   
    if (type.equals( STRUCT_TYPE ))
View Full Code Here

Examples of org.apache.etch.util.core.xml.XmlParser.TagElement

      System.exit( 1 );
    }

    StringArrayIterator i = new StringArrayIterator( args );

    TagElement te = new XmlParser().parseOne( new File( i.next() ), null,
      "interoptest" );
    // System.out.println( te );
    InteropTestIntf itest = InteropTest.parse( te );
    te = null;
View Full Code Here

Examples of org.apache.etch.util.core.xml.XmlParser.TagElement

            "tag "+r.getQName()+": cdata not allowed here: '"+e+"'" );
       
        continue;
      }
     
      TagElement te = (TagElement) e;
      if (!tag( te ))
        throw new IllegalArgumentException(
          "tag "+r.getQName()+": tag "+te.getQName()+" not allowed here" );
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.