public WikiClass read(XMLStreamReader xmlReader) throws XMLStreamException, WikiStreamException {
    WikiClass wikiClass = new WikiClass();

    for (xmlReader.nextTag(); xmlReader.isStartElement(); xmlReader.nextTag()) {
      String elementName = xmlReader.getLocalName();

      if (wikiClass.name == null && XARClassModel.ELEMENT_NAME.equals(elementName)) {
        wikiClass.name = xmlReader.getElementText();
      } else if (XARClassModel.CLASS_PARAMETERS.containsKey(elementName)) {
        String value = xmlReader.getElementText();

        EventParameter parameter = XARClassModel.CLASS_PARAMETERS.get(elementName);

        if (parameter != null) {
          Object wsValue = convert(parameter.type, value);
          if (wsValue != null) {
            wikiClass.parameters.put(parameter.name, wsValue);
          }
        }
      } else {
        wikiClass.addProperty((WikiClassProperty) this.propertyReader.read(xmlReader));
      }
    }

    return wikiClass;
  }
示例#2
0
  private static void parseModel(XMLStreamReader reader, ModelMetaData model)
      throws XMLStreamException {
    Properties props = getAttributes(reader);
    model.setName(props.getProperty(Element.NAME.getLocalName()));
    model.setModelType(props.getProperty(Element.TYPE.getLocalName(), "PHYSICAL"));
    model.setVisible(
        Boolean.parseBoolean(props.getProperty(Element.VISIBLE.getLocalName(), "true")));
    model.setPath(props.getProperty(Element.PATH.getLocalName()));

    while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
      Element element = Element.forName(reader.getLocalName());
      switch (element) {
        case DESCRIPTION:
          model.setDescription(reader.getElementText());
          break;
        case PROPERTY:
          parseProperty(reader, model);
          break;
        case SOURCE:
          Properties sourceProps = getAttributes(reader);
          String name = sourceProps.getProperty(Element.NAME.getLocalName());
          String translatorName =
              sourceProps.getProperty(Element.SOURCE_TRANSLATOR_NAME_ATTR.getLocalName());
          String connectionName =
              sourceProps.getProperty(Element.SOURCE_CONNECTION_JNDI_NAME_ATTR.getLocalName());
          model.addSourceMapping(name, translatorName, connectionName);
          ignoreTillEnd(reader);
          break;
        case VALIDATION_ERROR:
          Properties validationProps = getAttributes(reader);
          String msg = reader.getElementText();
          String severity =
              validationProps.getProperty(Element.VALIDATION_SEVERITY_ATTR.getLocalName());
          String path = validationProps.getProperty(Element.PATH.getLocalName());
          Message ve = new Message(Severity.valueOf(severity), msg);
          ve.setPath(path);
          model.addMessage(ve);
          break;
        case METADATA:
          Properties metdataProps = getAttributes(reader);
          String type = metdataProps.getProperty(Element.TYPE.getLocalName(), "DDL");
          String schema = reader.getElementText();
          model.setSchemaSourceType(type);
          model.setSchemaText(schema);
          break;
        default:
          throw new XMLStreamException(
              AdminPlugin.Util.gs(
                  "unexpected_element5",
                  reader.getName(),
                  Element.DESCRIPTION.getLocalName(),
                  Element.PROPERTY.getLocalName(),
                  Element.SOURCE.getLocalName(),
                  Element.METADATA.getLocalName(),
                  Element.VALIDATION_ERROR.getLocalName()),
              reader.getLocation());
      }
    }
  }
示例#3
0
 @Override
 protected void processElement(TxTest metaData, XMLStreamReader reader) throws XMLStreamException {
   if (reader.getNamespaceURI().equals("urn:tx-timeout-test")) {
     final String localName = reader.getLocalName();
     if (localName.equals("timeout")) metaData.setTimeout(Long.valueOf(reader.getElementText()));
     else if (localName.equals("unit"))
       metaData.setUnit(TimeUnit.valueOf(reader.getElementText().toUpperCase()));
     else throw unexpectedElement(reader);
   } else super.processElement(metaData, reader);
 }
  /** Deserializes the object from XML */
  public DataField parseField(XMLStreamReader in) throws IOException, XMLStreamException {
    String label = in.getAttributeValue(null, "label");
    String type = in.getAttributeValue(null, "type");
    String var = in.getAttributeValue(null, "var");

    DataField field = new DataField(type, var, label);

    ArrayList<DataValue> valueList = new ArrayList<DataValue>();
    ArrayList<DataOption> optionList = new ArrayList<DataOption>();

    int tag = in.nextTag();
    while (tag > 0) {
      if (_isFinest) debug(in);

      if (XMLStreamReader.END_ELEMENT == tag) {
        field.setValueList(valueList);
        field.setOptionList(optionList);

        return field;
      }

      if (XMLStreamReader.START_ELEMENT == tag && "desc".equals(in.getLocalName())) {
        String desc = in.getElementText();

        field.setDesc(desc);

        skipToEnd(in, "desc");
      } else if (XMLStreamReader.START_ELEMENT == tag && "option".equals(in.getLocalName())) {
        optionList.add(parseOption(in));
      } else if (XMLStreamReader.START_ELEMENT == tag && "required".equals(in.getLocalName())) {
        field.setRequired(true);

        skipToEnd(in, "required");
      } else if (XMLStreamReader.START_ELEMENT == tag && "value".equals(in.getLocalName())) {
        String value = in.getElementText();

        valueList.add(new DataValue(value));

        skipToEnd(in, "value");
      } else if (XMLStreamReader.START_ELEMENT == tag) {
        log.finer(this + " <" + in.getLocalName() + "> is an unknown tag");

        skipToEnd(in, in.getLocalName());
      }

      tag = in.nextTag();
    }

    skipToEnd(in, "field");

    return field;
  }
    public boolean isCorrect(String word, String... uris) {
      try {
        RequestParameters params = new RequestParameters();
        params.add("service", "is-correct");
        params.add("word", word);
        params.add("uris", uris);

        XMLStreamReaderHandle readHandle = new XMLStreamReaderHandle();

        // call the service
        getServices().get(params, readHandle);

        QName correctName = new QName(XMLConstants.DEFAULT_NS_PREFIX, "correct");

        XMLStreamReader streamReader = readHandle.get();
        while (streamReader.hasNext()) {
          int current = streamReader.next();
          if (current == XMLStreamReader.START_ELEMENT) {
            if (correctName.equals(streamReader.getName())) {
              return "true".equals(streamReader.getElementText());
            }
          }
        }

        return false;
      } catch (XMLStreamException ex) {
        throw new RuntimeException(ex);
      }
    }
  protected void findDataSourceJNDI() {
    try {
      XMLInputFactory factory = XMLInputFactory.newInstance();
      XMLStreamReader reader =
          factory.createXMLStreamReader(
              Thread.currentThread()
                  .getContextClassLoader()
                  .getResourceAsStream("META-INF/persistence.xml"));

      while (reader.hasNext()) {
        int event = reader.next();

        switch (event) {
          case XMLStreamConstants.START_ELEMENT:
            if ("jta-data-source".equals(reader.getLocalName())) {

              jbpmDatasource = reader.getElementText();
              return;
            }
            break;
        }
      }
    } catch (XMLStreamException e) {
      logger.warn(
          "Unable to find out JNDI name fo data source to be used for data sets due to {} using default {}",
          e.getMessage(),
          jbpmDatasource,
          e);
    }
  }
    public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement) throws Exception {
      String resourceElement = XMLStreamReaderUtil.moveDown(xtr);
      if (StringUtils.isNotEmpty(resourceElement)
          && "resourceAssignmentExpression".equals(resourceElement)) {
        String expression = XMLStreamReaderUtil.moveDown(xtr);
        if (StringUtils.isNotEmpty(expression) && "formalExpression".equals(expression)) {
          List<String> assignmentList = new ArrayList<String>();
          String assignmentText = xtr.getElementText();
          if (assignmentText.contains(",")) {
            String[] assignmentArray = assignmentText.split(",");
            assignmentList = Arrays.asList(assignmentArray);
          } else {
            assignmentList.add(assignmentText);
          }
          for (String assignmentValue : assignmentList) {
            if (assignmentValue == null) continue;
            assignmentValue = assignmentValue.trim();
            if (assignmentValue.length() == 0) continue;

            if (assignmentValue.trim().startsWith("user(")) {
              ((UserTask) parentElement).getCandidateUsers().add(assignmentValue);

            } else {
              ((UserTask) parentElement).getCandidateGroups().add(assignmentValue);
            }
          }
        }
      }
    }
  @Override
  public WikiObject read(XMLStreamReader xmlReader) throws XMLStreamException, FilterException {
    WikiObject wikiObject = new WikiObject();

    for (xmlReader.nextTag(); xmlReader.isStartElement(); xmlReader.nextTag()) {
      String elementName = xmlReader.getLocalName();
      if (elementName.equals(XARClassModel.ELEMENT_CLASS)) {
        wikiObject.wikiClass = this.classReader.read(xmlReader);
      } else if (elementName.equals(XARObjectPropertyModel.ELEMENT_PROPERTY)) {
        wikiObject.properties.add(readObjectProperty(xmlReader, wikiObject.wikiClass));
      } else {
        String value = xmlReader.getElementText();

        EventParameter parameter = XARObjectModel.OBJECT_PARAMETERS.get(elementName);

        if (parameter != null) {
          Object wsValue = convert(parameter.type, value);
          if (wsValue != null) {
            wikiObject.parameters.put(parameter.name, wsValue);
          }
        }
      }
    }

    return wikiObject;
  }
示例#9
0
  private void parse() throws XMLStreamException {
    final InputStream stream = this.getClass().getResourceAsStream("cigars.xml");
    final XMLInputFactory inputFactory = XMLInputFactory.newInstance();
    final XMLStreamReader streamReader = inputFactory.createXMLStreamReader(stream);
    manufacturers = new HashMap<String, List<ParsedProduct>>();

    int manufacturerId = 1;
    while (streamReader.hasNext()) {
      streamReader.next();
      final int type = streamReader.getEventType();
      if (XMLEvent.START_ELEMENT == type) {
        final QName qName = streamReader.getName();
        if ("a".equals(qName.getLocalPart())) {
          UrlParser parser = new UrlParser(streamReader.getAttributeValue(0));
          parser.parse();
          if (parser.isValid()) {
            final String manufacturer = parser.getManufacturer();
            System.out.println("Id:" + parser.getId() + " , manufacture:" + manufacturer);

            List<ParsedProduct> products = manufacturers.get(manufacturer);
            if (products == null) {
              products = new ArrayList<ParsedProduct>();
              manufacturerId++;
              manufacturers.put(parser.getManufacturer(), products);
            }
            final String text = streamReader.getElementText();
            final ParsedProduct newProduct = new ParsedProduct(parser.getId(), text);
            products.add(newProduct);
            System.out.println(">>" + text);
          }
        }
      }
    }
  }
示例#10
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;
    }
示例#11
0
 public String getElementText() throws XMLStreamException {
   if (state == STATE_START_DOCUMENT || state == STATE_END_DOCUMENT) {
     throw new IllegalStateException();
   } else {
     return parent.getElementText();
   }
 }
示例#12
0
  private static Map<String, String> parseAmortizeObject(final XMLStreamReader reader) {

    Map<String, String> elementMap = new HashMap<>();

    /* still at start of amortize object.  Need to know when end is reached */
    QName parsingElement = reader.getName();

    try {
      parse:
      while (reader.hasNext()) {
        int event = reader.next();

        switch (event) {
          case XMLStreamConstants.START_ELEMENT:
            String element = reader.getLocalName();
            elementMap.put(element, reader.getElementText());
            break;
          case XMLStreamConstants.END_ELEMENT:
            if (reader.getName().equals(parsingElement)) {
              logger.finest("Found the end of the Amortize Object");
              break parse;
            }
            break;
          default:
            break;
        }
      }
    } catch (XMLStreamException e) {
      logger.log(Level.SEVERE, e.toString(), e);
    }

    return elementMap;
  }
示例#13
0
  static String getNextElement(
      XMLStreamReader reader, String name, Map<String, String> attributes, boolean getElementText)
      throws XMLStreamException {
    if (!reader.hasNext()) {
      throw new XMLStreamException("Expected more elements", reader.getLocation());
    }
    int type = reader.next();
    while (reader.hasNext() && type != START_ELEMENT) {
      type = reader.next();
    }
    if (reader.getEventType() != START_ELEMENT) {
      throw new XMLStreamException("No <" + name + "> found");
    }
    if (!reader.getLocalName().equals("" + name + "")) {
      throw new XMLStreamException("<" + name + "> expected", reader.getLocation());
    }

    if (attributes != null) {
      for (int i = 0; i < reader.getAttributeCount(); i++) {
        String attr = reader.getAttributeLocalName(i);
        if (!attributes.containsKey(attr)) {
          throw new XMLStreamException("Unexpected attribute " + attr, reader.getLocation());
        }
        attributes.put(attr, reader.getAttributeValue(i));
      }
    }

    return getElementText ? reader.getElementText() : null;
  }
  private void parseWebFragmentXml() throws XMLStreamException, IOException, TransformerException {
    final XMLInputFactory xif = XMLInputFactory.newInstance();
    final XMLStreamReader xsr = xif.createXMLStreamReader(getInputStream());
    xsr.nextTag(); // web-fragment tag skipped

    while (xsr.hasNext() && xsr.nextTag() == XMLStreamConstants.START_ELEMENT) {
      final String tagName = xsr.getLocalName();
      // webFragmentName
      if ("name".equalsIgnoreCase(tagName)) {
        final String element = xsr.getElementText();
        allWebFragmentNames.add(element);
        webFragmentXmlComponents.add("<name>" + element + "</name>");
      } else {
        final TransformerFactory tf = TransformerFactory.newInstance();
        final Transformer t = tf.newTransformer();
        final StringWriter res = new StringWriter();
        t.transform(new StAXSource(xsr), new StreamResult(res));
        final String element =
            org.apache.commons.lang3.StringUtils.substringAfter(res.toString(), "?>");
        if ("ordering".equalsIgnoreCase(tagName)) {
          // ordering
          parseOrdering(element);
        } else {
          // webFragmentXmlComponents
          webFragmentXmlComponents.add(element);
        }
      }
    }
    if (allWebFragmentNames.isEmpty()) {
      throw new IllegalStateException(
          "Name tag is missing. Please specify a name in the web-fragment.xml!");
    }
  }
 private List<String> getPackageNamesFromGuvnor() {
   List<String> packages = new ArrayList<String>();
   String packagesURL =
       getGuvnorProtocol()
           + "://"
           + getGuvnorHost()
           + "/"
           + getGuvnorSubdomain()
           + "/rest/packages/";
   try {
     XMLInputFactory factory = XMLInputFactory.newInstance();
     XMLStreamReader reader =
         factory.createXMLStreamReader(getInputStreamForURL(packagesURL, "GET"));
     while (reader.hasNext()) {
       if (reader.next() == XMLStreamReader.START_ELEMENT) {
         if ("title".equals(reader.getLocalName())) {
           String pname = reader.getElementText();
           if (!pname.equalsIgnoreCase("Packages")) {
             packages.add(pname);
           }
         }
       }
     }
   } catch (Exception e) {
     logger.error("Error retriving packages from guvnor: " + e.getMessage());
   }
   return packages;
 }
示例#16
0
  private static String[] parseAccountSecurities(final XMLStreamReader reader) {

    assert reader.getAttributeCount() == 2;

    ArrayList<String> securities = new ArrayList<>();

    /* still at start of security array.  Need to know when end is reached */
    QName parsingElement = reader.getName();

    try {
      parse:
      while (reader.hasNext()) {
        int event = reader.next();

        switch (event) {
          case XMLStreamConstants.START_ELEMENT:
            securities.add(reader.getElementText());
            break;
          case XMLStreamConstants.END_ELEMENT:
            if (reader.getName().equals(parsingElement)) {
              logger.finest("Found the end of the Account Securities");
              break parse;
            }
            break;
          default:
            break;
        }
      }
    } catch (XMLStreamException e) {
      logger.log(Level.SEVERE, e.toString(), e);
    }

    return securities.toArray(new String[securities.size()]);
  }
 private static boolean get(
     XMLStreamReader parser, String xmlElem, String[] xmlNames, String[] strRet) {
   boolean ret = true;
   int maxElem = strRet.length;
   for (int i = 0; i < maxElem; ++i) {
     strRet[i] = "";
   }
   try {
     while (parser.hasNext()) {
       int event = parser.next();
       if (event == XMLStreamConstants.END_ELEMENT) {
         if (parser.getLocalName().equals(xmlElem)) {
           break;
         }
       }
       if (event == XMLStreamConstants.START_ELEMENT) {
         for (int i = 0; i < maxElem; ++i) {
           if (parser.getLocalName().equals(xmlNames[i])) {
             strRet[i] = parser.getElementText();
             break;
           }
         }
       }
     }
   } catch (Exception ex) {
     ret = false;
     Log.fehlerMeldung(467256394, ex);
   }
   return ret;
 }
示例#18
0
 /**
  * Post: reader will be unchanged or on success at {@link XMLStreamConstants #END_ELEMENT} of the
  * matching element or at {@link XMLStreamConstants #START_ELEMENT} of the next element if
  * requested.
  *
  * @param reader pointing to the current element.
  * @param elementName of the current element.
  * @param defaultValue to return if the current name was not the one given or the value could not
  *     be parsed as a integer.
  * @param nextElemOnSucces if true the reader will be moved to the next tag if the retrieval was
  *     successful.
  * @return the text of the current element (which should have element name) parsed as a integer.
  * @throws XMLStreamException from {@link XMLStreamReader#getElementText()}.
  */
 public static int getElementTextAsInteger(
     XMLStreamReader reader, QName elementName, int defaultValue, boolean nextElemOnSucces)
     throws XMLStreamException {
   int value = defaultValue;
   if (elementName.equals(reader.getName()) && reader.isStartElement()) {
     String s = reader.getElementText();
     if (s != null) {
       try {
         value = Integer.parseInt(s);
         if (nextElemOnSucces) {
           nextElement(reader);
         }
       } catch (NumberFormatException nfe) {
         LOG.debug(
             reader.getLocation()
                 + ") Value "
                 + s
                 + " in element: "
                 + elementName
                 + " was not a parsable integer, returning integer value: "
                 + defaultValue);
       }
     }
   }
   return value;
 }
    /**
     * 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 ReleaseAddressTypeChoice_type0 parse(javax.xml.stream.XMLStreamReader reader)
        throws java.lang.Exception {
      ReleaseAddressTypeChoice_type0 object = new ReleaseAddressTypeChoice_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();

        if (reader.isStartElement()
            && new javax.xml.namespace.QName("http://ec2.amazonaws.com/doc/2012-08-15/", "publicIp")
                .equals(reader.getName())) {

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

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

          reader.next();

        } // End of if for expected property start element
        else if (reader.isStartElement()
            && new javax.xml.namespace.QName(
                    "http://ec2.amazonaws.com/doc/2012-08-15/", "allocationId")
                .equals(reader.getName())) {

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

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

          reader.next();
        } // End of if for expected property start element

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

      return object;
    }
示例#20
0
  private static void parseExchangeRate(final XMLStreamReader reader) {
    Map<String, String> elementMap = new HashMap<>();

    /* still at start of the exchange rate.  Need to know when end is reached */
    QName parsingElement = reader.getName();

    try {
      while (reader.hasNext()) {

        int event = reader.next();

        switch (event) {
          case XMLStreamConstants.START_ELEMENT:
            String element = reader.getLocalName();
            elementMap.put(element.intern(), reader.getElementText());
            break;
          case XMLStreamConstants.END_ELEMENT:
            if (reader.getName().equals(parsingElement)) {
              logger.finest("Found the end of the exchange rate");

              try {
                String key = elementMap.get("key");

                if (key != null && key.length() == 6) {

                  Engine e = EngineFactory.getEngine(EngineFactory.DEFAULT);

                  CurrencyNode cOne = e.getCurrency(key.substring(0, 3));
                  CurrencyNode cTwo = e.getCurrency(key.substring(3, 6));

                  // jGnash 1.x would hold onto old exchange rates for deleted commodities
                  if (cOne != null && cTwo != null) {
                    BigDecimal rate = new BigDecimal(elementMap.get("rate"));

                    EngineFactory.getEngine(EngineFactory.DEFAULT)
                        .setExchangeRate(cOne, cTwo, rate);

                    logger.log(
                        Level.FINE,
                        "Set ExchangeRate {0}:{1}",
                        new Object[] {key, rate.toString()});
                  }
                }

              } catch (Exception e) {
                logger.log(Level.SEVERE, e.toString(), e);
              }
              return;
            }
            break;
          default:
            break;
        }
      }
    } catch (XMLStreamException e) {
      logger.severe("Error importing exchange rate");
      logger.log(Level.SEVERE, e.toString(), e);
    }
  }
 @Override
 protected void parseCharactersEvent(XMLStreamReader xmlStreamReader) throws SAXException {
   try {
     contentHandler.characters(xmlStreamReader.getElementText());
   } catch (XMLStreamException e) {
     super.parseCharactersEvent(xmlStreamReader);
   }
 }
  public List<String> getAllProcessesInPackage(String pkgName) {
    List<String> processes = new ArrayList<String>();
    String assetsURL =
        getGuvnorProtocol()
            + "://"
            + getGuvnorHost()
            + "/"
            + getGuvnorSubdomain()
            + "/rest/packages/"
            + pkgName
            + "/assets/";

    try {
      XMLInputFactory factory = XMLInputFactory.newInstance();
      XMLStreamReader reader =
          factory.createXMLStreamReader(getInputStreamForURL(assetsURL, "GET"));

      String format = "";
      String title = "";
      while (reader.hasNext()) {
        int next = reader.next();
        if (next == XMLStreamReader.START_ELEMENT) {
          if ("format".equals(reader.getLocalName())) {
            format = reader.getElementText();
          }
          if ("title".equals(reader.getLocalName())) {
            title = reader.getElementText();
          }
          if ("asset".equals(reader.getLocalName())) {
            if (format.equals(EXT_BPMN) || format.equals(EXT_BPMN2)) {
              processes.add(title);
              title = "";
              format = "";
            }
          }
        }
      }
      // last one
      if (format.equals(EXT_BPMN) || format.equals(EXT_BPMN2)) {
        processes.add(title);
      }
    } catch (Exception e) {
      logger.error("Error finding processes in package: " + e.getMessage());
    }
    return processes;
  }
 public void readValues(XMLStreamReader reader) {
   try {
     String values = reader.getElementText();
     blocks = getBlocks(values);
   } catch (XMLStreamException ex) {
     log.error("Failure to read values from swe block", ex);
   }
 }
 private String readElement(XMLStreamReader parser, String string) throws XMLStreamException {
   while (true) {
     if (parser.nextTag() == XMLStreamConstants.START_ELEMENT
         && parser.getLocalName().equals(string)) {
       return parser.getElementText();
     }
   }
 }
示例#25
0
 public static QName getElementTextAsRelaxedQName(XMLStreamReader xmlStream)
     throws XMLParsingException, XMLStreamException {
   String s = xmlStream.getElementText();
   if (s == null) {
     throw new XMLParsingException(xmlStream, "No element text, but QName expected.");
   }
   return asRelaxedQName(xmlStream, s);
 }
示例#26
0
 private static void parsePermission(XMLStreamReader reader, PermissionMetaData permission)
     throws XMLStreamException {
   while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
     Element element = Element.forName(reader.getLocalName());
     switch (element) {
       case RESOURCE_NAME:
         permission.setResourceName(reader.getElementText());
         break;
       case ALLOW_ALTER:
         permission.setAllowAlter(Boolean.parseBoolean(reader.getElementText()));
         break;
       case ALLOW_CREATE:
         permission.setAllowCreate(Boolean.parseBoolean(reader.getElementText()));
         break;
       case ALLOW_LANGUAGE:
         permission.setAllowLanguage(Boolean.parseBoolean(reader.getElementText()));
         break;
       case ALLOW_DELETE:
         permission.setAllowDelete(Boolean.parseBoolean(reader.getElementText()));
         break;
       case ALLOW_EXECUTE:
         permission.setAllowExecute(Boolean.parseBoolean(reader.getElementText()));
         break;
       case ALLOW_READ:
         permission.setAllowRead(Boolean.parseBoolean(reader.getElementText()));
         break;
       case ALLOW_UPADTE:
         permission.setAllowUpdate(Boolean.parseBoolean(reader.getElementText()));
         break;
       case CONDITION:
         permission.setCondition(reader.getElementText());
         break;
       default:
         throw new XMLStreamException(
             AdminPlugin.Util.gs(
                 "unexpected_element7",
                 reader.getName(),
                 Element.RESOURCE_NAME.getLocalName(),
                 Element.ALLOW_ALTER.getLocalName(),
                 Element.ALLOW_CREATE.getLocalName(),
                 Element.ALLOW_DELETE.getLocalName(),
                 Element.ALLOW_EXECUTE.getLocalName(),
                 Element.ALLOW_READ.getLocalName(),
                 Element.ALLOW_UPADTE.getLocalName(),
                 Element.ALLOW_LANGUAGE.getLocalName(),
                 Element.CONDITION.getLocalName()),
             reader.getLocation());
     }
   }
 }
 public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement) throws Exception {
   String resourceElement = XMLStreamReaderUtil.moveDown(xtr);
   if (StringUtils.isNotEmpty(resourceElement)
       && "resourceAssignmentExpression".equals(resourceElement)) {
     String expression = XMLStreamReaderUtil.moveDown(xtr);
     if (StringUtils.isNotEmpty(expression) && "formalExpression".equals(expression)) {
       ((UserTask) parentElement).setAssignee(xtr.getElementText());
     }
   }
 }
示例#28
0
  private List<SecurityHistoryNode> parseHistoryNodes(final XMLStreamReader reader) {
    List<SecurityHistoryNode> list = new ArrayList<>();

    assert reader.getAttributeCount() == 3;

    // number of history nodes to parse
    int count = Integer.parseInt(reader.getAttributeValue(2));

    logger.log(Level.FINEST, "Parsing {0} SecurityHistoryNodes", count);

    Map<String, String> elementMap = new HashMap<>();

    QName parsingElement = null;

    try {
      while (reader.hasNext() && list.size() < count) {
        int event = reader.next();

        switch (event) {
          case XMLStreamConstants.START_ELEMENT:
            if (reader.getAttributeCount() > 0
                && reader.getAttributeValue(0).equals("SecurityHistoryNode")) { // start of hNode

              parsingElement = reader.getName();
            } else {
              String element = reader.getLocalName();
              elementMap.put(element, reader.getElementText());
            }
            break;
          case XMLStreamConstants.END_ELEMENT:
            if (reader.getName().equals(parsingElement)) {
              // build the security history node;
              SecurityHistoryNode hNode = new SecurityHistoryNode();

              hNode.setDate(decodeDate(elementMap.get("date")));
              hNode.setHigh(new BigDecimal(elementMap.get("high")));
              hNode.setLow(new BigDecimal(elementMap.get("low")));
              hNode.setPrice(new BigDecimal(elementMap.get("price")));
              hNode.setVolume(Long.parseLong(elementMap.get("volume")));

              elementMap.clear();

              list.add(hNode);
            }
            break;
          default:
            break;
        }
      }
    } catch (XMLStreamException e) {
      logger.log(Level.SEVERE, e.toString(), e);
    }

    return list;
  }
示例#29
0
 private static void parseVDB(XMLStreamReader reader, VDBMetaData vdb) throws XMLStreamException {
   while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
     Element element = Element.forName(reader.getLocalName());
     switch (element) {
       case DESCRIPTION:
         vdb.setDescription(reader.getElementText());
         break;
       case PROPERTY:
         parseProperty(reader, vdb);
         break;
       case MODEL:
         ModelMetaData model = new ModelMetaData();
         parseModel(reader, model);
         vdb.addModel(model);
         break;
       case TRANSLATOR:
         VDBTranslatorMetaData translator = new VDBTranslatorMetaData();
         parseTranslator(reader, translator);
         vdb.addOverideTranslator(translator);
         break;
       case DATA_ROLE:
         DataPolicyMetadata policy = new DataPolicyMetadata();
         parseDataRole(reader, policy);
         vdb.addDataPolicy(policy);
         break;
       case IMPORT_VDB:
         VDBImportMetadata vdbImport = new VDBImportMetadata();
         Properties props = getAttributes(reader);
         vdbImport.setName(props.getProperty(Element.NAME.getLocalName()));
         vdbImport.setVersion(Integer.parseInt(props.getProperty(Element.VERSION.getLocalName())));
         vdbImport.setImportDataPolicies(
             Boolean.parseBoolean(
                 props.getProperty(Element.IMPORT_POLICIES.getLocalName(), "true")));
         vdb.getVDBImports().add(vdbImport);
         ignoreTillEnd(reader);
         break;
       case ENTRY:
         EntryMetaData entry = new EntryMetaData();
         parseEntry(reader, entry);
         vdb.getEntries().add(entry);
         break;
       default:
         throw new XMLStreamException(
             AdminPlugin.Util.gs(
                 "unexpected_element5",
                 reader.getName(),
                 Element.DESCRIPTION.getLocalName(),
                 Element.PROPERTY.getLocalName(),
                 Element.MODEL.getLocalName(),
                 Element.TRANSLATOR.getLocalName(),
                 Element.DATA_ROLE.getLocalName()),
             reader.getLocation());
     }
   }
 }
示例#30
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;
    }