예제 #1
0
    /**
     * static method to create the object Precondition: If this object is an element, the current or
     * next start element starts this object and any intervening reader events are ignorable If this
     * object is not an element, it is a complex type and the reader is at the event just after the
     * outer start element Postcondition: If this object is an element, the reader is positioned at
     * its end element If this object is a complex type, the reader is positioned at the end element
     * of its outer element
     */
    public static ClassificationReason_type0 parse(javax.xml.stream.XMLStreamReader reader)
        throws java.lang.Exception {
      ClassificationReason_type0 object = new ClassificationReason_type0();

      int event;
      java.lang.String nillableValue = null;
      java.lang.String prefix = "";
      java.lang.String namespaceuri = "";
      try {

        while (!reader.isStartElement() && !reader.isEndElement()) reader.next();

        // Note all attributes that were handled. Used to differ normal attributes
        // from anyAttributes.
        java.util.Vector handledAttributes = new java.util.Vector();

        while (!reader.isEndElement()) {
          if (reader.isStartElement() || reader.hasText()) {

            if (reader.isStartElement() || reader.hasText()) {

              nillableValue =
                  reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "nil");
              if ("true".equals(nillableValue) || "1".equals(nillableValue)) {
                throw new org.apache.axis2.databinding.ADBException(
                    "The element: " + "classificationReason_type0" + "  cannot be null");
              }

              java.lang.String content = reader.getElementText();

              object.setClassificationReason_type0(
                  org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content));

            } // End of if for expected property start element
            else {
              // A start element we are not expecting indicates an invalid parameter was passed
              throw new org.apache.axis2.databinding.ADBException(
                  "Unexpected subelement " + reader.getName());
            }

          } else {
            reader.next();
          }
        } // end of while loop

      } catch (javax.xml.stream.XMLStreamException e) {
        throw new java.lang.Exception(e);
      }

      return object;
    }
예제 #2
0
    public static RigStateType parse(final XMLStreamReader reader) throws Exception {
      RigStateType object = null;
      new HashMap<Object, Object>();

      String prefix = "";
      String namespaceuri = "";
      try {
        while (!reader.isStartElement() && !reader.isEndElement()) {
          reader.next();
        }

        while (!reader.isEndElement()) {
          if (reader.isStartElement() || reader.hasText()) {
            final String content = reader.getElementText();
            if (content.indexOf(":") > 0) {
              prefix = content.substring(0, content.indexOf(":"));
              namespaceuri = reader.getNamespaceURI(prefix);
              object = RigStateType.Factory.fromString(content, namespaceuri);
            } else {
              object = RigStateType.Factory.fromString(content, "");
            }
          } else {
            reader.next();
          }
        }
      } catch (final XMLStreamException e) {
        throw new Exception(e);
      }

      return object;
    }
예제 #3
0
    /**
     * static method to create the object Precondition: If this object is an element, the current or
     * next start element starts this object and any intervening reader events are ignorable If this
     * object is not an element, it is a complex type and the reader is at the event just after the
     * outer start element Postcondition: If this object is an element, the reader is positioned at
     * its end element If this object is a complex type, the reader is positioned at the end element
     * of its outer element
     */
    public static DebugLevel parse(javax.xml.stream.XMLStreamReader reader)
        throws java.lang.Exception {
      DebugLevel object = null;
      // initialize a hash map to keep values
      java.util.Map attributeMap = new java.util.HashMap();
      java.util.List extraAttributeList =
          new java.util.ArrayList<org.apache.axiom.om.OMAttribute>();

      int event;
      java.lang.String nillableValue = null;
      java.lang.String prefix = "";
      java.lang.String namespaceuri = "";
      try {

        while (!reader.isStartElement() && !reader.isEndElement()) reader.next();

        // Note all attributes that were handled. Used to differ normal attributes
        // from anyAttributes.
        java.util.Vector handledAttributes = new java.util.Vector();

        while (!reader.isEndElement()) {
          if (reader.isStartElement() || reader.hasText()) {

            nillableValue =
                reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "nil");
            if ("true".equals(nillableValue) || "1".equals(nillableValue)) {
              throw new org.apache.axis2.databinding.ADBException(
                  "The element: " + "DebugLevel" + "  cannot be null");
            }

            java.lang.String content = reader.getElementText();

            if (content.indexOf(":") > 0) {
              // this seems to be a Qname so find the namespace and send
              prefix = content.substring(0, content.indexOf(":"));
              namespaceuri = reader.getNamespaceURI(prefix);
              object = DebugLevel.Factory.fromString(content, namespaceuri);
            } else {
              // this seems to be not a qname send and empty namespace incase of it is
              // check is done in fromString method
              object = DebugLevel.Factory.fromString(content, "");
            }

          } else {
            reader.next();
          }
        } // end of while loop

      } catch (javax.xml.stream.XMLStreamException e) {
        throw new java.lang.Exception(e);
      }

      return object;
    }
예제 #4
0
 /**
  * True if all the elements in the current node are blanks
  *
  * @return true if all are blanks
  * @throws javax.xml.stream.XMLStreamException
  */
 private boolean allBlanks() throws XMLStreamException {
   boolean res = true;
   if (!reader.hasText()) {
     return true;
   }
   String text = reader.getText();
   for (int i = 0, limit = text.length(); i < limit; i++) {
     res = res && Character.isWhitespace(text.charAt(i));
   }
   return res;
 }
    /**
     * static method to create the object Precondition: If this object is an element, the current or
     * next start element starts this object and any intervening reader events are ignorable If this
     * object is not an element, it is a complex type and the reader is at the event just after the
     * outer start element Postcondition: If this object is an element, the reader is positioned at
     * its end element If this object is a complex type, the reader is positioned at the end element
     * of its outer element
     */
    public static EnumMWSAttributeFormCategories_type0 parse(
        javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception {
      EnumMWSAttributeFormCategories_type0 object = null;
      // initialize a hash map to keep values
      java.util.Map attributeMap = new java.util.HashMap();
      java.util.List extraAttributeList = new java.util.ArrayList();

      int event;
      java.lang.String nillableValue = null;
      java.lang.String prefix = "";
      java.lang.String namespaceuri = "";
      try {

        while (!reader.isStartElement() && !reader.isEndElement()) reader.next();

        // Note all attributes that were handled. Used to differ normal
        // attributes
        // from anyAttributes.
        java.util.Vector handledAttributes = new java.util.Vector();

        while (!reader.isEndElement()) {
          if (reader.isStartElement() || reader.hasText()) {

            java.lang.String content = reader.getElementText();

            if (content.indexOf(":") > 0) {
              // this seems to be a Qname so find the namespace
              // and send
              prefix = content.substring(0, content.indexOf(":"));
              namespaceuri = reader.getNamespaceURI(prefix);
              object =
                  EnumMWSAttributeFormCategories_type0.Factory.fromString(content, namespaceuri);
            } else {
              // this seems to be not a qname send and empty
              // namespace incase of it is
              // check is done in fromString method
              object = EnumMWSAttributeFormCategories_type0.Factory.fromString(content, "");
            }

          } else {
            reader.next();
          }
        } // end of while loop

      } catch (javax.xml.stream.XMLStreamException e) {
        throw new java.lang.Exception(e);
      }

      return object;
    }
예제 #6
0
  /**
   * Method that will iterate through contents of an XML document using specified stream reader;
   * will also access some of data to make sure reader reads most of lazy-loadable data. Method is
   * usually called to try to get an exception for invalid content.
   *
   * @return Dummy value calculated on contents; used to make sure no dead code is eliminated
   */
  protected int streamThrough(XMLStreamReader sr) throws XMLStreamException {
    int result = 0;

    while (sr.hasNext()) {
      int type = sr.next();
      result += type;
      if (sr.hasText()) {
        /* will also do basic verification for text content, to
         * see that all text accessor methods return same content
         */
        result += getAndVerifyText(sr).hashCode();
      }
      if (sr.hasName()) {
        result += sr.getName().hashCode();
      }
    }

    return result;
  }
예제 #7
0
    /**
     * static method to create the object Precondition: If this object is an element, the current or
     * next start element starts this object and any intervening reader events are ignorable If this
     * object is not an element, it is a complex type and the reader is at the event just after the
     * outer start element Postcondition: If this object is an element, the reader is positioned at
     * its end element If this object is a complex type, the reader is positioned at the end element
     * of its outer element
     */
    public static DateTime parse(javax.xml.stream.XMLStreamReader reader)
        throws java.lang.Exception {
      DateTime object = new DateTime();

      int event;
      java.lang.String nillableValue = null;
      java.lang.String prefix = "";
      java.lang.String namespaceuri = "";
      try {

        while (!reader.isStartElement() && !reader.isEndElement()) reader.next();

        if (reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "type") != null) {
          java.lang.String fullTypeName =
              reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "type");
          if (fullTypeName != null) {
            java.lang.String nsPrefix = null;
            if (fullTypeName.indexOf(":") > -1) {
              nsPrefix = fullTypeName.substring(0, fullTypeName.indexOf(":"));
            }
            nsPrefix = nsPrefix == null ? "" : nsPrefix;

            java.lang.String type = fullTypeName.substring(fullTypeName.indexOf(":") + 1);

            if (!"dateTime".equals(type)) {
              // find namespace for the prefix
              java.lang.String nsUri = reader.getNamespaceContext().getNamespaceURI(nsPrefix);
              return (DateTime)
                  org.apache.axis2.databinding.types.soapencoding.ExtensionMapper.getTypeObject(
                      nsUri, type, reader);
            }
          }
        }

        // Note all attributes that were handled. Used to differ normal attributes
        // from anyAttributes.
        java.util.Vector handledAttributes = new java.util.Vector();

        while (!reader.isEndElement()) {
          if (reader.isStartElement() || reader.hasText()) {

            if (reader.isStartElement() || reader.hasText()) {

              java.lang.String content = reader.getElementText();

              object.setDateTime(
                  org.apache.axis2.databinding.utils.ConverterUtil.convertToDateTime(content));

            } // End of if for expected property start element
            else {
              // A start element we are not expecting indicates an invalid parameter was passed
              throw new org.apache.axis2.databinding.ADBException(
                  "Unexpected subelement " + reader.getLocalName());
            }

          } else {
            reader.next();
          }
        } // end of while loop

      } catch (javax.xml.stream.XMLStreamException e) {
        throw new java.lang.Exception(e);
      }

      return object;
    }
 public boolean hasText() {
   return streamReader.hasText();
 }
예제 #9
0
 private static XMLStreamException unexpectedContent(final XMLStreamReader reader) {
   final String kind;
   switch (reader.getEventType()) {
     case XMLStreamConstants.ATTRIBUTE:
       kind = "attribute";
       break;
     case XMLStreamConstants.CDATA:
       kind = "cdata";
       break;
     case XMLStreamConstants.CHARACTERS:
       kind = "characters";
       break;
     case XMLStreamConstants.COMMENT:
       kind = "comment";
       break;
     case XMLStreamConstants.DTD:
       kind = "dtd";
       break;
     case XMLStreamConstants.END_DOCUMENT:
       kind = "document end";
       break;
     case XMLStreamConstants.END_ELEMENT:
       kind = "element end";
       break;
     case XMLStreamConstants.ENTITY_DECLARATION:
       kind = "entity declaration";
       break;
     case XMLStreamConstants.ENTITY_REFERENCE:
       kind = "entity ref";
       break;
     case XMLStreamConstants.NAMESPACE:
       kind = "namespace";
       break;
     case XMLStreamConstants.NOTATION_DECLARATION:
       kind = "notation declaration";
       break;
     case XMLStreamConstants.PROCESSING_INSTRUCTION:
       kind = "processing instruction";
       break;
     case XMLStreamConstants.SPACE:
       kind = "whitespace";
       break;
     case XMLStreamConstants.START_DOCUMENT:
       kind = "document start";
       break;
     case XMLStreamConstants.START_ELEMENT:
       kind = "element start";
       break;
     default:
       kind = "unknown";
       break;
   }
   final StringBuilder b =
       new StringBuilder("Unexpected content of type '").append(kind).append('\'');
   if (reader.hasName()) {
     b.append(" named '").append(reader.getName()).append('\'');
   }
   if (reader.hasText()) {
     b.append(", text is: '").append(reader.getText()).append('\'');
   }
   return new XMLStreamException(b.toString(), reader.getLocation());
 }
예제 #10
0
 public boolean hasText() {
   return state != STATE_START_DOCUMENT && state != STATE_END_DOCUMENT && parent.hasText();
 }
예제 #11
0
    /**
     * static method to create the object Precondition: If this object is an element, the current or
     * next start element starts this object and any intervening reader events are ignorable If this
     * object is not an element, it is a complex type and the reader is at the event just after the
     * outer start element Postcondition: If this object is an element, the reader is positioned at
     * its end element If this object is a complex type, the reader is positioned at the end element
     * of its outer element
     */
    public static Notes parse(javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception {
      Notes object = new Notes();

      int event;
      java.lang.String nillableValue = null;
      java.lang.String prefix = "";
      java.lang.String namespaceuri = "";
      try {

        while (!reader.isStartElement() && !reader.isEndElement()) reader.next();

        if (reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "type") != null) {
          java.lang.String fullTypeName =
              reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "type");
          if (fullTypeName != null) {
            java.lang.String nsPrefix = null;
            if (fullTypeName.indexOf(":") > -1) {
              nsPrefix = fullTypeName.substring(0, fullTypeName.indexOf(":"));
            }
            nsPrefix = nsPrefix == null ? "" : nsPrefix;

            java.lang.String type = fullTypeName.substring(fullTypeName.indexOf(":") + 1);

            if (!"notes".equals(type)) {
              // find namespace for the prefix
              java.lang.String nsUri = reader.getNamespaceContext().getNamespaceURI(nsPrefix);
              return (Notes)
                  net.x_rd.ee.municipality.producer.ExtensionMapper.getTypeObject(
                      nsUri, type, reader);
            }
          }
        }

        // Note all attributes that were handled. Used to differ normal attributes
        // from anyAttributes.
        java.util.Vector handledAttributes = new java.util.Vector();

        // handle attribute "lang"
        java.lang.String tempAttribLang =
            reader.getAttributeValue("http://www.w3.org/XML/1998/namespace", "lang");

        if (tempAttribLang != null) {
          java.lang.String content = tempAttribLang;

          object.setLang(
              org.w3.www.xml._1998.namespace.Lang_type0.Factory.fromString(reader, tempAttribLang));

        } else {

        }
        handledAttributes.add("lang");

        while (!reader.isEndElement()) {
          if (reader.isStartElement() || reader.hasText()) {

            if (reader.isStartElement() || reader.hasText()) {

              nillableValue =
                  reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "nil");
              if ("true".equals(nillableValue) || "1".equals(nillableValue)) {
                throw new org.apache.axis2.databinding.ADBException(
                    "The element: " + "string" + "  cannot be null");
              }

              java.lang.String content = reader.getElementText();

              object.setString(
                  org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content));

            } // End of if for expected property start element
            else {
              // A start element we are not expecting indicates an invalid parameter was passed
              throw new org.apache.axis2.databinding.ADBException(
                  "Unexpected subelement " + reader.getName());
            }

          } else {
            reader.next();
          }
        } // end of while loop

      } catch (javax.xml.stream.XMLStreamException e) {
        throw new java.lang.Exception(e);
      }

      return object;
    }
예제 #12
0
  /**
   * Parse the <e> elements
   *
   * @throws javax.xml.stream.XMLStreamException
   */
  private void procEntry() throws XMLStreamException {
    String attribute = attrib(COMPILER_RESTRICTION_ATTR);
    String ignore = attrib(COMPILER_IGNORE_ATTR);
    String name = "";
    if (ignore.equals(COMPILER_IGNORE_YES_VAL)
        || (!(attribute.equals("")) && !(attribute.equals(direction)))) {
      while (!(name.equals(COMPILER_ENTRY_ELEM))) {
        reader.next();
        if (reader.getEventType() == XMLStreamConstants.END_ELEMENT) {
          name = reader.getLocalName();
        }
      }
      return;
    }

    ArrayList<EntryToken> elements = new ArrayList<EntryToken>();

    while (true) {
      if (!reader.hasNext()) {
        throw new RuntimeException(
            "Error (" + reader.getLocation().getLineNumber() + "): Parse error.");
      }
      if (reader.getEventType() == XMLStreamConstants.START_ELEMENT) {
        name = reader.getLocalName();
      }
      skipBlanks();
      name = reader.getLocalName();
      int type = reader.getEventType();

      if (name.equals(COMPILER_PAIR_ELEM)) {
        elements.add(procTransduction());
      } else if (name.equals(COMPILER_IDENTITY_ELEM)) {
        elements.add(procIdentity());
      } else if (name.equals(COMPILER_FLAG_ELEM)) {
        elements.add(procFlag());
      } else if (name.equals(COMPILER_REGEXP_ELEM)) {
        elements.add(procRegexp());
      } else if (name.equals(COMPILER_PAR_ELEM)) {
        EntryToken par = procPar();
        elements.add(par);

        // detection of the use of undefined paradigms
        String p = par.paradigmName;
        TransducerComp t = paradigms.get(p);
        if (t == null) {
          throw new RuntimeException("Error: Undefined paradigm '" + p + "'.");
        }
        // descartar entradas con paradigms vac�os (por las direciones,
        // normalmente
        if (t.isEmpty()) {
          while (!name.equals(COMPILER_ENTRY_ELEM) || type != XMLStreamConstants.END_ELEMENT) {
            reader.next();
            if (reader.hasName()) {
              name = reader.getLocalName();
            }
            type = reader.getEventType();
          }
          return;
        }
        reader.next();
      } else if (name.equals(COMPILER_ENTRY_ELEM) && type == XMLStreamConstants.END_ELEMENT) {
        // insertar elements into letter transducer
        insertEntryTokens(elements);
        reader.next();
        return;
      } else if (reader.isWhiteSpace()) {
      } else if (allBlanks()) {
        if (!reader.hasText()) {}
      } else {
        throw new RuntimeException(
            "Error ("
                + reader.getLocation().getLineNumber()
                + "): Invalid inclusion of '<"
                + name
                + ">' into '<"
                + COMPILER_ENTRY_ELEM
                + ">'.");
      }
    }
  }
예제 #13
0
 public boolean hasText() {
   return reader.hasText();
 }
예제 #14
0
    /**
     * static method to create the object Precondition: If this object is an element, the current or
     * next start element starts this object and any intervening reader events are ignorable If this
     * object is not an element, it is a complex type and the reader is at the event just after the
     * outer start element Postcondition: If this object is an element, the reader is positioned at
     * its end element If this object is a complex type, the reader is positioned at the end element
     * of its outer element
     */
    public static GetSiteResponse parse(javax.xml.stream.XMLStreamReader reader)
        throws java.lang.Exception {
      GetSiteResponse object = new GetSiteResponse();

      int event;
      java.lang.String nillableValue = null;
      java.lang.String prefix = "";
      java.lang.String namespaceuri = "";
      try {

        while (!reader.isStartElement() && !reader.isEndElement()) reader.next();

        if (reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "type") != null) {
          java.lang.String fullTypeName =
              reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "type");
          if (fullTypeName != null) {
            java.lang.String nsPrefix = null;
            if (fullTypeName.indexOf(":") > -1) {
              nsPrefix = fullTypeName.substring(0, fullTypeName.indexOf(":"));
            }
            nsPrefix = nsPrefix == null ? "" : nsPrefix;

            java.lang.String type = fullTypeName.substring(fullTypeName.indexOf(":") + 1);

            if (!"GetSiteResponse".equals(type)) {
              // find namespace for the prefix
              java.lang.String nsUri = reader.getNamespaceContext().getNamespaceURI(nsPrefix);
              return (GetSiteResponse)
                  org.example.www.site.ExtensionMapper.getTypeObject(nsUri, type, reader);
            }
          }
        }

        // Note all attributes that were handled. Used to differ normal attributes
        // from anyAttributes.
        java.util.Vector handledAttributes = new java.util.Vector();

        reader.next();

        while (!reader.isStartElement() && !reader.isEndElement()) reader.next();

        if (reader.isStartElement()
            && new javax.xml.namespace.QName("", "messages").equals(reader.getName())) {
          reader.next();
          if (isReaderMTOMAware(reader)
              && java.lang.Boolean.TRUE.equals(
                  reader.getProperty(org.apache.axiom.om.OMConstants.IS_BINARY))) {
            // MTOM aware reader - get the datahandler directly and put it in the object
            object.setMessages(
                (javax.activation.DataHandler)
                    reader.getProperty(org.apache.axiom.om.OMConstants.DATA_HANDLER));
          } else {
            if (reader.getEventType() == javax.xml.stream.XMLStreamConstants.START_ELEMENT
                && reader
                    .getName()
                    .equals(
                        new javax.xml.namespace.QName(
                            org.apache.axiom.om.impl.MTOMConstants.XOP_NAMESPACE_URI,
                            org.apache.axiom.om.impl.MTOMConstants.XOP_INCLUDE))) {
              java.lang.String id =
                  org.apache.axiom.om.util.ElementHelper.getContentID(reader, "UTF-8");
              object.setMessages(
                  ((org.apache.axiom.soap.impl.builder.MTOMStAXSOAPModelBuilder)
                          ((org.apache.axiom.om.impl.llom.OMStAXWrapper) reader).getBuilder())
                      .getDataHandler(id));
              reader.next();

              reader.next();

            } else if (reader.hasText()) {
              // Do the usual conversion
              java.lang.String content = reader.getText();
              object.setMessages(
                  org.apache.axis2.databinding.utils.ConverterUtil.convertToBase64Binary(content));

              reader.next();
            }
          }

          reader.next();

        } // End of if for expected property start element
        else {
          // A start element we are not expecting indicates an invalid parameter was passed
          throw new org.apache.axis2.databinding.ADBException(
              "Unexpected subelement " + reader.getLocalName());
        }

        while (!reader.isStartElement() && !reader.isEndElement()) reader.next();

        if (reader.isStartElement())
          // A start element we are not expecting indicates a trailing invalid property
          throw new org.apache.axis2.databinding.ADBException(
              "Unexpected subelement " + reader.getLocalName());

      } catch (javax.xml.stream.XMLStreamException e) {
        throw new java.lang.Exception(e);
      }

      return object;
    }