Parse statement
@param reader The reader
@return The result
@exception XMLStreamException XMLStreamException
@exception ParserException ParserException
@exception ValidateException ValidateException
337191
protected Statement parseStatementSettings(XMLStreamReader reader) throws XMLStreamException, ParserException,
      ValidateException
   {

      Long preparedStatementsCacheSize = null;
      Boolean sharePreparedStatements = Defaults.SHARE_PREPARED_STATEMENTS;
      TrackStatementsEnum trackStatements = null;

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

      while (reader.hasNext())
      {
         switch (reader.nextTag())
         {
            case END_ELEMENT : {
               if (XML.ELEMENT_STATEMENT.equals(reader.getLocalName()))
               {
                  return new StatementImpl(sharePreparedStatements, preparedStatementsCacheSize, trackStatements,
                          !expressions.isEmpty() ? expressions : null);
               }
               else
               {
                  switch (reader.getLocalName())
                  {
                     case XML.ELEMENT_PREPARED_STATEMENT_CACHE_SIZE :
                     case XML.ELEMENT_TRACK_STATEMENTS :
                     case XML.ELEMENT_SHARE_PREPARED_STATEMENTS :
                        break;
                     default :
                        throw new ParserException(bundle.unexpectedEndTag(reader.getLocalName()));
                  }
               }
               break;
            }
            case START_ELEMENT : {
               switch (reader.getLocalName())
               {
                  case XML.ELEMENT_PREPARED_STATEMENT_CACHE_SIZE : {
                     preparedStatementsCacheSize = elementAsLong(reader, XML.ELEMENT_PREPARED_STATEMENT_CACHE_SIZE,
                                                                 expressions);
                     break;
                  }
                  case XML.ELEMENT_TRACK_STATEMENTS : {
                     String elementString = elementAsString(reader, XML.ELEMENT_TRACK_STATEMENTS, expressions);
                     trackStatements = TrackStatementsEnum.valueOf(elementString == null ? "FALSE" : elementString
                        .toUpperCase(Locale.US));
                     break;
                  }
                  case XML.ELEMENT_SHARE_PREPARED_STATEMENTS : {
                     sharePreparedStatements = elementAsBoolean(reader, XML.ELEMENT_SHARE_PREPARED_STATEMENTS,
                                                                expressions);
                     break;
                  }
                  default :
                     throw new ParserException(bundle.unexpectedElement(reader.getLocalName()));
               }
               break;
            }
         }
      }
      throw new ParserException(bundle.unexpectedEndOfDocument());
   }
884534
public static String getText(Reader reader) throws IOException {
    try {
      StringBuilder source = new StringBuilder();
      BufferedReader buffered = new BufferedReader(reader);
      String line = buffered.readLine();

      while (line != null) {
        source.append(line);
        source.append('\n');
        line = buffered.readLine();
      }

      return source.toString();
    } finally {
      closeQuietly(reader);
    }
  }
882798
@Override
    public void readElement(final XMLExtendedStreamReader reader, final ServerProvisioningDescription result) throws XMLStreamException {
        for (int i = 0; i < reader.getAttributeCount(); i++) {
            final Attribute attribute = Attribute.of(reader.getAttributeName(i));
            switch (attribute) {
                case COPY_MODULE_ARTIFACTS:
                    result.setCopyModuleArtifacts(Boolean.parseBoolean(reader.getAttributeValue(i)));
                    break;
                case EXTRACT_SCHEMAS:
                    result.setExtractSchemas(Boolean.parseBoolean(reader.getAttributeValue(i)));
                    break;
                case EXTRACT_SCHEMAS_GROUPS:
                    result.setExtractSchemasGroups(reader.getAttributeValue(i));
                    break;
                case EXCLUDE_DEPENDENCIES:
                    result.setExcludeDependencies(Boolean.parseBoolean(reader.getAttributeValue(i)));
                    break;
                default:
                    throw ParsingUtils.unexpectedAttribute(reader, i);
            }
        }

        while (reader.hasNext()) {
            switch (reader.nextTag()) {
                case XMLStreamConstants.END_ELEMENT: {
                    return;
                }
                case XMLStreamConstants.START_ELEMENT: {
                    final Element element = Element.of(reader.getLocalName());

                    switch (element) {
                        case FEATURE_PACKS:
                            parseFeaturePacks(reader, result);
                            break;
                        case VERSION_OVERRIDES:
                            parseVersionOverrides(reader, result);
                            break;
                        case COPY_ARTIFACTS:
                            copyArtifactsModelParser.parseCopyArtifacts(reader, result.getCopyArtifacts());
                            break;
                        default:
                            throw new XMLStreamException(String.format("Unknown element: '%s', elementName: %s, localName: %s", element, reader.getName(), reader.getLocalName()), reader.getLocation());
                            //throw ParsingUtils.unexpectedContent(reader);
                    }
                    break;
                }
                default: {
                    throw ParsingUtils.unexpectedContent(reader);
                }
            }
        }
        throw ParsingUtils.endOfDocument(reader.getLocation());
    }
1275351
@Override
    public ParseResult parse(Source source) {
        if (!testSrcInfo.equals(source.getSrcInfo())) {
            throw new RuntimeException("testSrcInfo and source.getSrcInfo were not equal. testSrcInfo = " + testSrcInfo + ", source.getSrcInfo = " + source.getSrcInfo());
        }
        try {
            BufferedReader reader = source.createReader();
            try {
                if (!testString.equals(reader.readLine())) {
                    throw new RuntimeException("testString and reader.readLine() were not equal");
                }
                final String secondLine = reader.readLine();
                if (secondLine != null) {
                    throw new RuntimeException("got a second line '" + secondLine + "' from the reader");
                }
            } finally {
                reader.close();
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return testResult;
    }
896148
public static String read(Reader reader) {
        StringWriter writer = new StringWriter();
        try {
            char[] buffer = new char[DEFAULT_BUFFER_SIZE];
            int n;
            while (-1 != (n = reader.read(buffer))) {
                writer.write(buffer, 0, n);
            }

            return writer.toString();
        } catch (IOException ex) {
            throw new IllegalStateException("read error", ex);
        }
    }
142036
public TypeDefinitionRegistry parse(Reader reader) throws SchemaProblem {
        try (Reader input = reader) {
            return parseImpl(input);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
449898
public static Analysis readAnalysis(final Reader reader) throws IOException {
        checkNotNull(reader);
        try {
            JAXBContext context = JAXBContext.newInstance(Analysis.class);
            Unmarshaller unmarshaller = context.createUnmarshaller();
            SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
            URL commonSchemaURL = SraReader.class.getResource("/org/nmdp/ngs/sra/xsd/SRA.common.xsd");
            URL analysisSchemaURL = SraReader.class.getResource("/org/nmdp/ngs/sra/xsd/SRA.analysis.xsd");
            Schema schema = schemaFactory.newSchema(new StreamSource[] { new StreamSource(commonSchemaURL.toString()), new StreamSource(analysisSchemaURL.toString()) });
            unmarshaller.setSchema(schema);
            return (Analysis) unmarshaller.unmarshal(reader);
        }
        catch (JAXBException | SAXException e) {
            throw new IOException("could not unmarshal Analysis", e);
        }
    }
1021717
@FFDCIgnore(XMLStreamException.class)
    public ConfigElement parseConfigElement(Reader reader) throws ConfigParserException {
        behaviorStack.add(MergeBehavior.MERGE);
        docLocationStack.add("Test Server");
        DepthAwareXMLStreamReader parser = null;
        try {
            parser = new DepthAwareXMLStreamReader(getXMLInputFactory().createXMLStreamReader(reader));
            ConfigElement configElement = null;
            int depth = parser.getDepth();
            while (parser.hasNext(depth)) {
                int event = parser.next();
                if (event == XMLStreamConstants.START_ELEMENT) {
                    configElement = parseConfigElement(parser, parser.getLocalName(), null, null, null, false);
                    break;
                }
            }
            parser.close();
            return configElement;
        } catch (IllegalArgumentException ex) {
            throw new ConfigParserException(ex);
        } catch (XMLStreamException e) {
            throw new ConfigParserException(e);
        }
    }
370376
public <T> T parse(InputStream in, JsonReaderI<T> mapper) throws ParseException, UnsupportedEncodingException {
		InputStreamReader i2 = new InputStreamReader(in, "utf8");
		//
		return super.parse(i2, mapper);
	}
910459
protected Driver parseDriver(XMLStreamReader reader) throws XMLStreamException, ParserException,
      ValidateException
   {
      String driverClass = null;
      String dataSourceClass = null;
      String xaDataSourceClass = null;

      //attributes reading

      String name = null;
      Integer majorVersion = null;
      Integer minorVersion = null;
      String module = null;

      Map<String, String> expressions = new HashMap<String, String>();
      
      for (int i = 0; i < reader.getAttributeCount(); i++)
      {
         switch (reader.getAttributeLocalName(i))
         {
            case XML.ATTRIBUTE_NAME : {
               name = attributeAsString(reader, XML.ATTRIBUTE_NAME, expressions);
               break;
            }
            case XML.ATTRIBUTE_MAJOR_VERSION : {
               majorVersion = attributeAsInt(reader, XML.ATTRIBUTE_MAJOR_VERSION, expressions);
               break;
            }
            case XML.ATTRIBUTE_MINOR_VERSION : {
               minorVersion = attributeAsInt(reader, XML.ATTRIBUTE_MINOR_VERSION, expressions);
               break;
            }
            case XML.ATTRIBUTE_MODULE : {
               module = attributeAsString(reader, XML.ATTRIBUTE_MODULE, expressions);
               break;
            }
            default :
               break;
         }
      }

      //elements reading
      while (reader.hasNext())
      {
         switch (reader.nextTag())
         {
            case END_ELEMENT : {
               if (XML.ELEMENT_DRIVER.equals(reader.getLocalName()))
               {
                  return new DriverImpl(name, majorVersion, minorVersion, module,
                                        driverClass, dataSourceClass, xaDataSourceClass,
                          !expressions.isEmpty() ? expressions : null);
               }
               else
               {
                  switch (reader.getLocalName())
                  {
                     case XML.ELEMENT_DATASOURCE_CLASS :
                     case XML.ELEMENT_XA_DATASOURCE_CLASS :
                     case XML.ELEMENT_DRIVER_CLASS :
                        break;
                     default :
                        throw new ParserException(bundle.unexpectedEndTag(reader.getLocalName()));
                  }
               }
               break;
            }
            case START_ELEMENT : {
               switch (reader.getLocalName())
               {
                  case XML.ELEMENT_DATASOURCE_CLASS : {
                     dataSourceClass = elementAsString(reader, XML.ELEMENT_DATASOURCE_CLASS, expressions);
                     break;
                  }
                  case XML.ELEMENT_XA_DATASOURCE_CLASS : {
                     xaDataSourceClass = elementAsString(reader, XML.ELEMENT_XA_DATASOURCE_CLASS, expressions);
                     break;
                  }
                  case XML.ELEMENT_DRIVER_CLASS : {
                     driverClass = elementAsString(reader, XML.ELEMENT_DRIVER_CLASS, expressions);
                     break;
                  }
                  default :
                     throw new ParserException(bundle.unexpectedElement(reader.getLocalName()));
               }
               break;
            }
         }
      }
      throw new ParserException(bundle.unexpectedEndOfDocument());
   }
591708
@Override
  public ParseResult parse(Reader reader, AttributeSource parent)
      throws IOException {
    ParseResult res = new ParseResult();

    // get MtasUpdateRequestProcessorResult
    StringBuilder sb = new StringBuilder();
    char[] buf = new char[128];
    int cnt;
    while ((cnt = reader.read(buf)) > 0) {
      sb.append(buf, 0, cnt);
    }
    Iterator<MtasUpdateRequestProcessorResultItem> iterator;

    try (
        MtasUpdateRequestProcessorResultReader result = new MtasUpdateRequestProcessorResultReader(
            sb.toString());) {
      iterator = result.getIterator();
      if (iterator != null && iterator.hasNext()) {
        res.str = result.getStoredStringValue();
        res.bin = result.getStoredBinValue();
      } else {
        res.str = null;
        res.bin = null;
        result.close();
        return res;
      }
      parent.clearAttributes();
      while (iterator.hasNext()) {
        MtasUpdateRequestProcessorResultItem item = iterator.next();
        if (item.tokenTerm != null) {
          CharTermAttribute catt = parent.addAttribute(CharTermAttribute.class);
          catt.append(item.tokenTerm);
        }
        if (item.tokenFlags != null) {
          FlagsAttribute flags = parent.addAttribute(FlagsAttribute.class);
          flags.setFlags(item.tokenFlags);
        }
        if (item.tokenPosIncr != null) {
          PositionIncrementAttribute patt = parent
              .addAttribute(PositionIncrementAttribute.class);
          patt.setPositionIncrement(item.tokenPosIncr);
        }
        if (item.tokenPayload != null) {
          PayloadAttribute p = parent.addAttribute(PayloadAttribute.class);
          p.setPayload(new BytesRef(item.tokenPayload));
        }
        if (item.tokenOffsetStart != null && item.tokenOffsetEnd != null) {
          OffsetAttribute offset = parent.addAttribute(OffsetAttribute.class);
          offset.setOffset(item.tokenOffsetStart, item.tokenOffsetEnd);
        }
        // capture state and add to result
        State state = parent.captureState();
        res.states.add(state.clone());
        // reset for reuse
        parent.clearAttributes();
      }
    } catch (IOException e) {
      // ignore
      log.debug(e);
    }
    return res;
  }
225648
public static JsonElement parseReader(JsonReader reader)
      throws JsonIOException, JsonSyntaxException {
    boolean lenient = reader.isLenient();
    reader.setLenient(true);
    try {
      return Streams.parse(reader);
    } catch (StackOverflowError e) {
      throw new JsonParseException("Failed parsing JSON source: " + reader + " to Json", e);
    } catch (OutOfMemoryError e) {
      throw new JsonParseException("Failed parsing JSON source: " + reader + " to Json", e);
    } finally {
      reader.setLenient(lenient);
    }
  }
1224992
public void parse(Reader xmlReader) throws XMLStreamException {
    if (isoControlCharsAwareParser) {
      throw new XMLStreamException("Method call not supported when isoControlCharsAwareParser=true");
    }
    parse(inf.rootElementCursor(xmlReader));
  }
1183916
public synchronized XMLReader getXMLReader() throws SAXException {
        XMLReader reader;
        boolean readerInUse;

        if (m_readers == null) {
            // When the m_readers.get() method is called for the first time
            // on a thread, a new XMLReader will automatically be created.
            m_readers = new ThreadLocal();
        }

        if (m_inUse == null) {
            m_inUse = new Hashtable();
        }

        // If the cached reader for this thread is in use, construct a new
        // one; otherwise, return the cached reader.
        reader = (XMLReader) m_readers.get();
        boolean threadHasReader = (reader != null);
        if (!threadHasReader || m_inUse.get(reader) == Boolean.TRUE) {
            try {
                try {
                    // According to JAXP 1.2 specification, if a SAXSource
                    // is created using a SAX InputSource the Transformer or
                    // TransformerFactory creates a reader via the
                    // XMLReaderFactory if setXMLReader is not used
                    reader = XMLReaderFactory.createXMLReader();
                } catch (Exception e) {
                   try {
                        // If unable to create an instance, let's try to use
                        // the XMLReader from JAXP
                        if (m_parserFactory == null) {
                            m_parserFactory = SAXParserFactory.newInstance();
                            m_parserFactory.setNamespaceAware(true);
                        }

                        reader = m_parserFactory.newSAXParser().getXMLReader();
                   } catch (ParserConfigurationException pce) {
                       throw pce;   // pass along pce
                   }
                }
                try {
                    reader.setFeature(NAMESPACES_FEATURE, true);
                    reader.setFeature(NAMESPACE_PREFIXES_FEATURE, false);
                } catch (SAXException se) {
                    // Try to carry on if we've got a parser that
                    // doesn't know about namespace prefixes.
                }
            } catch (ParserConfigurationException ex) {
                throw new SAXException(ex);
            } catch (FactoryConfigurationError ex1) {
                throw new SAXException(ex1.toString());
            } catch (NoSuchMethodError ex2) {
            } catch (AbstractMethodError ame) {
            }

            // Cache the XMLReader if this is the first time we've created
            // a reader for this thread.
            if (!threadHasReader) {
                m_readers.set(reader);
                m_inUse.put(reader, Boolean.TRUE);
            }
        } else {
            m_inUse.put(reader, Boolean.TRUE);
        }

        return reader;
    }
703904
public boolean parseNextLine()
    {
        if (firstTime)
        {
            firstTime = false;
            
         // Obtain an instance of an XMLReader implementation from a system property
            try {
                XMLReader parser = org.xml.sax.helpers.XMLReaderFactory.createXMLReader();
            
                // Set the ContentHandler...
                parser.setContentHandler( m_handler );
        
                   // Parse the file...
                parser.parse( new InputSource( m_reader ));
        
            } catch (IOException e) {
                e.printStackTrace();
            } catch (SAXException e) {
                e.printStackTrace();
            }
            
            m_record.close();
        }
        try {
            return m_record.hasNext();
        } catch (DBException e) {
            e.printStackTrace();
        }
        return false;
    }
1179584
protected Timeout parseTimeoutSettings(XMLStreamReader reader) throws XMLStreamException, ParserException,
      ValidateException
   {

      Long blockingTimeoutMillis = null;
      Integer idleTimeoutMinutes = null;
      Boolean setTxQuertTimeout = Defaults.SET_TX_QUERY_TIMEOUT;
      Long queryTimeout = null;
      Integer allocationRetry = null;
      Long allocationRetryWaitMillis = null;
      Long useTryLock = null;
      Integer xaResourceTimeout = null;

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

      while (reader.hasNext())
      {
         switch (reader.nextTag())
         {
            case END_ELEMENT : {
               if (XML.ELEMENT_TIMEOUT.equals(reader.getLocalName()))
               {
                  return new TimeoutImpl(blockingTimeoutMillis, idleTimeoutMinutes, allocationRetry,
                                         allocationRetryWaitMillis, xaResourceTimeout, setTxQuertTimeout,
                                         queryTimeout, useTryLock,
                          !expressions.isEmpty() ? expressions : null);
               }
               else
               {
                  switch (reader.getLocalName())
                  {
                     case XML.ELEMENT_ALLOCATION_RETRY :
                     case XML.ELEMENT_ALLOCATION_RETRY_WAIT_MILLIS :
                     case XML.ELEMENT_BLOCKING_TIMEOUT_MILLIS :
                     case XML.ELEMENT_IDLE_TIMEOUT_MINUTES :
                     case XML.ELEMENT_QUERY_TIMEOUT :
                     case XML.ELEMENT_SET_TX_QUERY_TIMEOUT :
                     case XML.ELEMENT_USE_TRY_LOCK :
                     case XML.ELEMENT_XA_RESOURCE_TIMEOUT :
                        break;
                     default :
                        throw new ParserException(bundle.unexpectedEndTag(reader.getLocalName()));
                  }
               }
               break;
            }
            case START_ELEMENT : {
               switch (reader.getLocalName())
               {
                  case XML.ELEMENT_ALLOCATION_RETRY : {
                     allocationRetry = elementAsInteger(reader, XML.ELEMENT_ALLOCATION_RETRY, expressions);
                     break;
                  }
                  case XML.ELEMENT_ALLOCATION_RETRY_WAIT_MILLIS : {
                     allocationRetryWaitMillis = elementAsLong(reader, XML.ELEMENT_ALLOCATION_RETRY_WAIT_MILLIS,
                                                               expressions);
                     break;
                  }
                  case XML.ELEMENT_BLOCKING_TIMEOUT_MILLIS : {
                     blockingTimeoutMillis = elementAsLong(reader, XML.ELEMENT_BLOCKING_TIMEOUT_MILLIS, expressions);
                     break;
                  }
                  case XML.ELEMENT_IDLE_TIMEOUT_MINUTES : {
                     idleTimeoutMinutes = elementAsInteger(reader, XML.ELEMENT_IDLE_TIMEOUT_MINUTES, expressions);
                     break;
                  }
                  case XML.ELEMENT_QUERY_TIMEOUT : {
                     queryTimeout = elementAsLong(reader, XML.ELEMENT_QUERY_TIMEOUT, expressions);
                     break;
                  }
                  case XML.ELEMENT_SET_TX_QUERY_TIMEOUT : {
                     setTxQuertTimeout = elementAsBoolean(reader, XML.ELEMENT_SET_TX_QUERY_TIMEOUT, expressions);
                     break;
                  }
                  case XML.ELEMENT_USE_TRY_LOCK : {
                     useTryLock = elementAsLong(reader, XML.ELEMENT_USE_TRY_LOCK, expressions);
                     break;
                  }
                  case XML.ELEMENT_XA_RESOURCE_TIMEOUT : {
                     xaResourceTimeout = elementAsInteger(reader, XML.ELEMENT_XA_RESOURCE_TIMEOUT, expressions);
                     break;
                  }
                  default :
                     throw new ParserException(bundle.unexpectedElement(reader.getLocalName()));
               }
               break;
            }
         }
      }
      throw new ParserException(bundle.unexpectedEndOfDocument());
   }
1262698
@Override
	public JacksonWrapperParser createParser(Reader reader) {
		try {
			return new JacksonWrapperParser(innerFactory.createParser(reader), getSupportedFormat());
		} catch (IOException e) {
			e.printStackTrace();
			throw new KriptonRuntimeException(e);
		}
	}