예제 #1
0
  public static final void _write(
      final XoXMLStreamWriter writer, final Timer timer, RuntimeContext context) throws Exception {
    if (timer == null) {
      writer.writeXsiNil();
      return;
    }

    if (context == null) {
      context = new RuntimeContext();
    }

    final String prefix = writer.getUniquePrefix("http://java.sun.com/xml/ns/javaee");
    if (Timer.class != timer.getClass()) {
      context.unexpectedSubclass(writer, timer, Timer.class);
      return;
    }

    context.beforeMarshal(timer, LifecycleCallback.NONE);

    // ATTRIBUTE: id
    final String idRaw = timer.id;
    if (idRaw != null) {
      String id = null;
      try {
        id = Adapters.collapsedStringAdapterAdapter.marshal(idRaw);
      } catch (final Exception e) {
        context.xmlAdapterError(
            timer, "id", CollapsedStringAdapter.class, String.class, String.class, e);
      }
      writer.writeAttribute("", "", "id", id);
    }

    // ELEMENT: descriptions
    Text[] descriptions = null;
    try {
      descriptions = timer.getDescriptions();
    } catch (final Exception e) {
      context.getterError(timer, "descriptions", Timer.class, "getDescriptions", e);
    }
    if (descriptions != null) {
      for (final Text descriptionsItem : descriptions) {
        if (descriptionsItem != null) {
          writer.writeStartElement(prefix, "description", "http://java.sun.com/xml/ns/javaee");
          writeText(writer, descriptionsItem, context);
          writer.writeEndElement();
        } else {
          context.unexpectedNullValue(timer, "descriptions");
        }
      }
    }

    // ELEMENT: schedule
    final TimerSchedule schedule = timer.schedule;
    if (schedule != null) {
      writer.writeStartElement(prefix, "schedule", "http://java.sun.com/xml/ns/javaee");
      writeTimerSchedule(writer, schedule, context);
      writer.writeEndElement();
    } else {
      context.unexpectedNullValue(timer, "schedule");
    }

    // ELEMENT: start
    final XMLGregorianCalendar start = timer.start;
    if (start != null) {
      writer.writeStartElement(prefix, "start", "http://java.sun.com/xml/ns/javaee");
      writer.writeCharacters(start.toXMLFormat());
      writer.writeEndElement();
    }

    // ELEMENT: end
    final XMLGregorianCalendar end = timer.end;
    if (end != null) {
      writer.writeStartElement(prefix, "end", "http://java.sun.com/xml/ns/javaee");
      writer.writeCharacters(end.toXMLFormat());
      writer.writeEndElement();
    }

    // ELEMENT: timeoutMethod
    final NamedMethod timeoutMethod = timer.timeoutMethod;
    if (timeoutMethod != null) {
      writer.writeStartElement(prefix, "timeout-method", "http://java.sun.com/xml/ns/javaee");
      writeNamedMethod(writer, timeoutMethod, context);
      writer.writeEndElement();
    } else {
      context.unexpectedNullValue(timer, "timeoutMethod");
    }

    // ELEMENT: persistent
    final Boolean persistent = timer.persistent;
    if (persistent != null) {
      writer.writeStartElement(prefix, "persistent", "http://java.sun.com/xml/ns/javaee");
      writer.writeCharacters(Boolean.toString(persistent));
      writer.writeEndElement();
    }

    // ELEMENT: timezone
    final String timezoneRaw = timer.timezone;
    String timezone = null;
    try {
      timezone = Adapters.collapsedStringAdapterAdapter.marshal(timezoneRaw);
    } catch (final Exception e) {
      context.xmlAdapterError(
          timer, "timezone", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (timezone != null) {
      writer.writeStartElement(prefix, "timezone", "http://java.sun.com/xml/ns/javaee");
      writer.writeCharacters(timezone);
      writer.writeEndElement();
    }

    // ELEMENT: info
    final String infoRaw = timer.info;
    String info = null;
    try {
      info = Adapters.collapsedStringAdapterAdapter.marshal(infoRaw);
    } catch (final Exception e) {
      context.xmlAdapterError(
          timer, "info", CollapsedStringAdapter.class, String.class, String.class, e);
    }
    if (info != null) {
      writer.writeStartElement(prefix, "info", "http://java.sun.com/xml/ns/javaee");
      writer.writeCharacters(info);
      writer.writeEndElement();
    }

    context.afterMarshal(timer, LifecycleCallback.NONE);
  }