Ejemplo n.º 1
0
  public Object unmarshal(Object arg0, IUnmarshallingContext arg1) throws JiBXException {

    // make sure we're at the appropriate start tag
    UnmarshallingContext ctx = (UnmarshallingContext) arg1;
    if (!ctx.isAt(m_uri, m_name)) {
      ctx.throwStartTagNameError(m_uri, m_name);
    }

    ctx.parseToStartTag(m_uri, m_name);

    String type = ctx.attributeText(m_uri, TYPE);
    ctx.parsePastStartTag(m_uri, m_name);

    String text = ctx.parseContentText();

    ctx.parsePastEndTag(m_uri, m_name);

    Object obj = null;
    if (type.equals(FLOAT)) obj = new Float((String) text);
    else if (type.equals(COLOR)) obj = colorConverter.fromString(text);
    else if (type.equals(VECTOR)) obj = vectorConverter.fromString(text);
    else if (type.equals(POINT)) obj = pointConverter.fromString(text);

    return obj;
  }
Ejemplo n.º 2
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);
    }
  }