Ejemplo n.º 1
0
  private String registerPrefix(final XMLStreamWriter xmlWriter, final String namespace)
      throws XMLStreamException {
    String prefix = xmlWriter.getPrefix(namespace);
    if (prefix == null) {
      prefix = SlotState.generatePrefix(namespace);
      while (xmlWriter.getNamespaceContext().getNamespaceURI(prefix) != null) {
        prefix = BeanUtil.getUniquePrefix();
      }

      xmlWriter.writeNamespace(prefix, namespace);
      xmlWriter.setPrefix(prefix, namespace);
    }

    return prefix;
  }
Ejemplo n.º 2
0
  @Override
  public void serialize(
      final QName parentQName,
      final OMFactory factory,
      final MTOMAwareXMLStreamWriter xmlWriter,
      final boolean serializeType)
      throws XMLStreamException, ADBException {
    final String namespace = parentQName.getNamespaceURI();
    final String localName = parentQName.getLocalPart();

    if (!namespace.equals("")) {
      String prefix = xmlWriter.getPrefix(namespace);
      if (prefix == null) {
        prefix = SlotState.generatePrefix(namespace);
        xmlWriter.writeStartElement(prefix, localName, namespace);
        xmlWriter.writeNamespace(prefix, namespace);
        xmlWriter.setPrefix(prefix, namespace);
      } else {
        xmlWriter.writeStartElement(namespace, localName);
      }
    } else {
      xmlWriter.writeStartElement(localName);
    }

    if (serializeType) {
      final String namespacePrefix =
          this.registerPrefix(xmlWriter, "http://remotelabs.eng.uts.edu.au/schedserver/bookings");
      if ((namespacePrefix != null) && (namespacePrefix.trim().length() > 0)) {
        this.writeAttribute(
            "xsi",
            "http://www.w3.org/2001/XMLSchema-instance",
            "type",
            namespacePrefix + ":state_type1",
            xmlWriter);
      } else {
        this.writeAttribute(
            "xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", "state_type1", xmlWriter);
      }
    }

    if (this.slotState == null) {
      throw new ADBException("Value cannot be null !!");
    } else {
      xmlWriter.writeCharacters(this.slotState);
    }

    xmlWriter.writeEndElement();
  }