@Override
 protected void marshalXmlStreamWriter(Object graph, XMLStreamWriter streamWriter)
     throws XmlMappingException {
   try {
     MarshallingContext marshallingContext = (MarshallingContext) createMarshallingContext();
     IXMLWriter xmlWriter = new StAXWriter(marshallingContext.getNamespaces(), streamWriter);
     marshallingContext.setXmlWriter(xmlWriter);
     marshallingContext.marshalDocument(graph);
   } catch (JiBXException ex) {
     throw convertJibxException(ex, false);
   }
 }
Ejemplo n.º 2
0
  /**
   * @see org.jibx.runtime.IMarshaller#marshal(java.lang.Object,
   *     org.jibx.runtime.IMarshallingContext)
   */
  public void marshal(Object obj, IMarshallingContext ictx) throws JiBXException {

    // make sure the parameters are as expected
    if (!(obj instanceof Measure)) {
      throw new JiBXException("Invalid object type for marshaller");
    }
    if (!(ictx instanceof MarshallingContext)) {
      throw new JiBXException("Invalid object type for marshaller");
    }
    MarshallingContext ctx = (MarshallingContext) ictx;
    Measure<?, ?> measure = (Measure<?, ?>) obj;

    ctx.startTagAttributes(this.index, this.name);
    ctx.attribute(this.index, "unit", measure.getUnit().toString());
    ctx.closeStartContent();
    ctx.content(String.valueOf(measure.getValue()));
    ctx.endTag(this.index, this.name);
  }
Ejemplo n.º 3
0
  public void marshal(Object arg0, IMarshallingContext arg1) throws JiBXException {

    if (arg0 instanceof Float) {

      MarshallingContext ctx = (MarshallingContext) arg1;

      ctx.startTagAttributes(m_index, m_name).attribute(m_index, TYPE, FLOAT).closeStartContent();
      ctx.content(((Float) arg0).toString());

      /*
       * ctx.startTagAttributes(m_index, "FLOAT"); ctx.attribute(m_index,
       * "CHAVE", ((Float)arg0).toString()); ctx.closeStartContent(); //
       */
      ctx.endTag(m_index, m_name);
    } else if (arg0 instanceof Colorf) {
      MarshallingContext ctx = (MarshallingContext) arg1;

      ctx.startTagAttributes(m_index, m_name).attribute(m_index, TYPE, COLOR).closeStartContent();
      ctx.content(colorConverter.toString(arg0));

      ctx.endTag(m_index, m_name);
    } else if (arg0 instanceof Vector3f) {
      MarshallingContext ctx = (MarshallingContext) arg1;

      ctx.startTagAttributes(m_index, m_name).attribute(m_index, TYPE, VECTOR).closeStartContent();
      ctx.content(vectorConverter.toString(arg0));

      ctx.endTag(m_index, m_name);
    } else if (arg0 instanceof Point3f) {
      MarshallingContext ctx = (MarshallingContext) arg1;

      ctx.startTagAttributes(m_index, m_name).attribute(m_index, TYPE, POINT).closeStartContent();
      ctx.content(pointConverter.toString(arg0));

      ctx.endTag(m_index, m_name);
    }
  }