Java 类java.io.Reader 实例源码

项目:AndroidApktool    文件:Yaml.java   
/**
 * Parse all YAML documents in a stream and produce corresponding
 * representation trees.
 * 
 * @see <a href="http://yaml.org/spec/1.1/#id859333">Processing Overview</a>
 * @param yaml
 *            stream of YAML documents
 * @return parsed root Nodes for all the specified YAML documents
 */
public Iterable<Node> composeAll(Reader yaml) {
    final Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver);
    constructor.setComposer(composer);
    Iterator<Node> result = new Iterator<Node>() {
        public boolean hasNext() {
            return composer.checkNode();
        }

        public Node next() {
            return composer.getNode();
        }

        public void remove() {
            throw new UnsupportedOperationException();
        }
    };
    return new NodeIterable(result);
}
项目:the-vigilantes    文件:JDBC4ServerPreparedStatement.java   
/**
 * @see java.sql.PreparedStatement#setNCharacterStream(int, java.io.Reader, long)
 */
public void setNCharacterStream(int parameterIndex, Reader reader, long length) throws SQLException {
    // can't take if characterEncoding isn't utf8
    if (!this.charEncoding.equalsIgnoreCase("UTF-8") && !this.charEncoding.equalsIgnoreCase("utf8")) {
        throw SQLError.createSQLException("Can not call setNCharacterStream() when connection character set isn't UTF-8", getExceptionInterceptor());
    }

    checkClosed();

    if (reader == null) {
        setNull(parameterIndex, java.sql.Types.BINARY);
    } else {
        BindValue binding = getBinding(parameterIndex, true);
        resetToType(binding, MysqlDefs.FIELD_TYPE_BLOB);

        binding.value = reader;
        binding.isLongData = true;

        if (this.connection.getUseStreamLengthsInPrepStmts()) {
            binding.bindLength = length;
        } else {
            binding.bindLength = -1;
        }
    }
}
项目:incubator-servicecomb-java-chassis    文件:SSLOptionTest.java   
@Test
public void testBuildIOException() {
  new MockUp<Properties>() {
    @Mock
    public synchronized void load(Reader reader) throws IOException {
      throw new IOException();
    }
  };
  boolean validAssert = true;
  try {
    SSLOption option = SSLOption.build(DIR + "/server.ssl.properties");
    Assert.assertEquals("revoke.crl", option.getCrl());
  } catch (Exception e) {
    Assert.assertEquals("java.lang.IllegalArgumentException", e.getClass().getName());
    validAssert = false;
  }
  Assert.assertFalse(validAssert);
}
项目:TextEmoji    文件:HttpRequest.java   
/**
 * Copy from reader to writer
 *
 * @param input
 * @param output
 * @return this request
 * @throws IOException
 */
protected HttpRequest copy(final Reader input, final Writer output)
    throws IOException {
  return new CloseOperation<HttpRequest>(input, ignoreCloseExceptions) {

    @Override
    public HttpRequest run() throws IOException {
      final char[] buffer = new char[bufferSize];
      int read;
      while ((read = input.read(buffer)) != -1) {
        output.write(buffer, 0, read);
        totalWritten += read;
        progress.onUpload(totalWritten, -1);
      }
      return HttpRequest.this;
    }
  }.call();
}
项目:mun3code    文件:CsvReader.java   
/**
 * Reads from the provided reader until the end and returns a CsvContainer containing the data.
 *
 * This library uses built-in buffering, so you do not need to pass in a buffered Reader
 * implementation such as {@link java.io.BufferedReader}.
 * Performance may be even likely better if you do not.
 *
 * @param reader the data source to read from.
 * @return the entire file's data - never {@code null}.
 * @throws IOException if an I/O error occurs.
 */
public CsvContainer read(final Reader reader) throws IOException {
    final CsvParser csvParser =
        parse(Objects.requireNonNull(reader, "reader must not be null"));

    final List<CsvRow> rows = new ArrayList<>();
    CsvRow csvRow;
    while ((csvRow = csvParser.nextRow()) != null) {
        rows.add(csvRow);
    }

    if (rows.isEmpty()) {
        return null;
    }

    final List<String> header = containsHeader ? csvParser.getHeader() : null;
    return new CsvContainer(header, rows);
}
项目:GitHub    文件:JSONReaderScannerTest_int.java   
public void test_scanInt() throws Exception {
    StringBuffer buf = new StringBuffer();
    buf.append('[');
    for (int i = 0; i < 1024; ++i) {
        if (i != 0) {
            buf.append(',');
        }
        buf.append(i);
    }
    buf.append(']');

    Reader reader = new StringReader(buf.toString());

    JSONReaderScanner scanner = new JSONReaderScanner(reader);

    DefaultJSONParser parser = new DefaultJSONParser(scanner);
    JSONArray array = (JSONArray) parser.parse();
    for (int i = 0; i < array.size(); ++i) {
        Assert.assertEquals(i, ((Integer) array.get(i)).intValue()); 
    }
}
项目:lams    文件:SingleLineSqlCommandExtractor.java   
@Override
public String[] extractCommands(Reader reader) {
    BufferedReader bufferedReader = new BufferedReader( reader );
    List<String> statementList = new LinkedList<String>();
    try {
        for ( String sql = bufferedReader.readLine(); sql != null; sql = bufferedReader.readLine() ) {
            String trimmedSql = sql.trim();
            if ( StringHelper.isEmpty( trimmedSql ) || isComment( trimmedSql ) ) {
                continue;
            }
            if ( trimmedSql.endsWith( ";" ) ) {
                trimmedSql = trimmedSql.substring( 0, trimmedSql.length() - 1 );
            }
            statementList.add( trimmedSql );
        }
        return statementList.toArray( new String[statementList.size()] );
    }
    catch ( IOException e ) {
        throw new ImportScriptException( "Error during import script parsing.", e );
    }
}
项目:Guardian.java    文件:RequestTest.java   
@Test
public void shouldNotFailIfDeleteHasBody() throws Exception {
    getRequest("DELETE", getUrl("/user/123"))
            .setParameter("some", "parameter")
            .execute();

    verify(converter).serialize(mapCaptor.capture());
    verify(converter).parse(any(Class.class), any(Reader.class));
    verifyNoMoreInteractions(converter);
    Map<String, Object> body = mapCaptor.getValue();
    assertThat(body, hasEntry("some", (Object) "parameter"));

    verify(client).newCall(requestCaptor.capture());
    okhttp3.Request request = requestCaptor.getValue();

    assertThat(request.method(), is(equalTo("DELETE")));
    assertThat(request.url().encodedPath(), is(equalTo("/user/123")));
}
项目:myfaces-trinidad    文件:FileUtils.java   
/**
 * Returns a Reader for reading the UTF-8 encoded file at the specified
 * path.
 */
static public Reader getUTF8Reader(String path)
  throws FileNotFoundException
{
  FileInputStream in = new FileInputStream(path);
  InputStreamReader reader = null;

  try
  {
    reader = new InputStreamReader(in, _UTF8_ENCODING);
  }
  catch (UnsupportedEncodingException e)
  {
    // UTF-8 should always be supported!
    assert false;
    return null;
  }

  return new BufferedReader(reader);
}
项目:elasticsearch_my    文件:CustomAnalyzer.java   
@Override
protected Reader initReader(String fieldName, Reader reader) {
    if (charFilters != null && charFilters.length > 0) {
        for (CharFilterFactory charFilter : charFilters) {
            reader = charFilter.create(reader);
        }
    }
    return reader;
}
项目:Auto.js    文件:JavaScriptSource.java   
@NonNull
public Reader getNonNullScriptReader() {
    Reader reader = getScriptReader();
    if (reader == null) {
        return new StringReader(getScript());
    }
    return reader;
}
项目:sstore-soft    文件:JDBC4ResultSet.java   
@Override
public Reader getCharacterStream(int columnIndex) throws SQLException {
    checkColumnBounds(columnIndex);
    try {
        String value = table.getString(columnIndex - 1);
        if (!wasNull())
            return new StringReader(value);
        return null;
    } catch (Exception x) {
        throw SQLError.get(x);
    }
}
项目:careconnect-reference-implementation    文件:ImmunizationResourceProvider.java   
@Read
public Immunization getImmunizationById(HttpServletRequest httpRequest, @IdParam IdType internalId) {

    ProducerTemplate template = context.createProducerTemplate();



    Immunization immunization = null;
    IBaseResource resource = null;
    try {
        InputStream inputStream = (InputStream)  template.sendBody("direct:FHIRImmunization",
                ExchangePattern.InOut,httpRequest);


        Reader reader = new InputStreamReader(inputStream);
        resource = ctx.newJsonParser().parseResource(reader);
    } catch(Exception ex) {
        log.error("JSON Parse failed " + ex.getMessage());
        throw new InternalErrorException(ex.getMessage());
    }
    if (resource instanceof Immunization) {
        immunization = (Immunization) resource;
    }else if (resource instanceof OperationOutcome)
    {

        OperationOutcome operationOutcome = (OperationOutcome) resource;
        log.info("Sever Returned: "+ctx.newJsonParser().encodeResourceToString(operationOutcome));

        OperationOutcomeFactory.convertToException(operationOutcome);
    } else {
        throw new InternalErrorException("Unknown Error");
    }

    return immunization;
}
项目:LoRaWAN-Smart-Parking    文件:Util.java   
/** Returns the remainder of 'reader' as a string, closing it when done. */
public static String readFully(Reader reader) throws IOException {
  try {
    StringWriter writer = new StringWriter();
    char[] buffer = new char[1024];
    int count;
    while ((count = reader.read(buffer)) != -1) {
      writer.write(buffer, 0, count);
    }
    return writer.toString();
  } finally {
    reader.close();
  }
}
项目:incubator-netbeans    文件:HTMLDocView.java   
/** Sets the javadoc content as HTML document */
public void setContent(final String content, final String reference) {
    SwingUtilities.invokeLater(new Runnable(){
        public void run(){
            Reader in = new StringReader("<HTML><BODY>"+content+"</BODY></HTML>");//NOI18N                
            try{
                Document doc = getDocument();
                doc.remove(0, doc.getLength());
                getEditorKit().read(in, getDocument(), 0);  //!!! still too expensive to be called from AWT
                setCaretPosition(0);
                if (reference != null) {
                    SwingUtilities.invokeLater(new Runnable(){
                        public void run(){
                            scrollToReference(reference);
                        }
                    });
                } else {
                    scrollRectToVisible(new Rectangle(0,0,0,0));
                }
            }catch(IOException ioe){
                ioe.printStackTrace();
            }catch(BadLocationException ble){
                ble.printStackTrace();
            }
        }
    });
}
项目:dev-courses    文件:SessionData.java   
private void allocateClobSegments(long lobID, long offset,
                                  Reader reader) throws IOException {

    int             bufferLength  = session.getStreamBlockSize();
    CharArrayWriter charWriter    = new CharArrayWriter(bufferLength);
    long            currentOffset = offset;

    while (true) {
        charWriter.reset();
        charWriter.write(reader, bufferLength);

        char[] charArray = charWriter.getBuffer();

        if (charWriter.size() == 0) {
            return;
        }

        Result actionResult = database.lobManager.setChars(lobID,
            currentOffset, charArray, charWriter.size());

        currentOffset += charWriter.size();

        if (charWriter.size() < bufferLength) {
            return;
        }
    }
}
项目:googles-monorepo-demo    文件:ReaderInputStream.java   
/**
 * Creates a new input stream that will encode the characters from {@code reader} into bytes using
 * the given character set. Malformed input and unmappable characters will be replaced.
 *
 * @param reader input source
 * @param charset character set used for encoding chars to bytes
 * @param bufferSize size of internal input and output buffers
 * @throws IllegalArgumentException if bufferSize is non-positive
 */
ReaderInputStream(Reader reader, Charset charset, int bufferSize) {
  this(
      reader,
      charset
          .newEncoder()
          .onMalformedInput(CodingErrorAction.REPLACE)
          .onUnmappableCharacter(CodingErrorAction.REPLACE),
      bufferSize);
}
项目:googles-monorepo-demo    文件:SourceSinkFactories.java   
@Override
public String getSinkContents() throws IOException {
  File file = getFile();
  Reader reader = new InputStreamReader(new FileInputStream(file), Charsets.UTF_8);
  StringBuilder builder = new StringBuilder();
  CharBuffer buffer = CharBuffer.allocate(100);
  while (reader.read(buffer) != -1) {
    buffer.flip();
    builder.append(buffer);
    buffer.clear();
  }
  return builder.toString();
}
项目:util    文件:PropertiesUtil.java   
/**
 * 从字符串内容加载Properties
 */
public static Properties loadFromString(String content) {
    Properties p = new Properties();
    Reader reader = new StringReader(content);
    try {
        p.load(reader);
    } catch (IOException ignored) {
    } finally {
        IOUtil.closeQuietly(reader);
    }

    return p;
}
项目:elasticsearch_my    文件:XMoreLikeThis.java   
/**
 * Adds term frequencies found by tokenizing text from reader into the Map words
 *
 * @param r a source of text to be tokenized
 * @param termFreqMap a Map of terms and their frequencies
 * @param fieldName Used by analyzer for any special per-field analysis
 */
private void addTermFrequencies(Reader r, Map<String, Int> termFreqMap, String fieldName)
        throws IOException {
    if (analyzer == null) {
        throw new UnsupportedOperationException("To use MoreLikeThis without " +
                "term vectors, you must provide an Analyzer");
    }
    try (TokenStream ts = analyzer.tokenStream(fieldName, r)) {
        int tokenCount = 0;
        // for every token
        CharTermAttribute termAtt = ts.addAttribute(CharTermAttribute.class);
        ts.reset();
        while (ts.incrementToken()) {
            String word = termAtt.toString();
            tokenCount++;
            if (tokenCount > maxNumTokensParsed) {
                break;
            }
            if (isNoiseWord(word)) {
                continue;
            }
            if (isSkipTerm(fieldName, word)) {
                continue;
            }

            // increment frequency
            Int cnt = termFreqMap.get(word);
            if (cnt == null) {
                termFreqMap.put(word, new Int());
            } else {
                cnt.x++;
            }
        }
        ts.end();
    }
}
项目:CF-rating-prediction    文件:JsonReader.java   
private static String readWhole(Reader reader) throws IOException {
    StringBuilder text = new StringBuilder();
    char[] cbuf = new char[BUFFER_SIZE];
    int readed = 0;
    while (readed != -1) {
        readed = reader.read(cbuf);
        if (readed > 0) {
            text.append(Arrays.copyOfRange(cbuf, 0, readed));
        }
    }
    return text.toString();
}
项目:BaseClient    文件:PlayerProfileCache.java   
/**
 * Load the cached profiles from disk
 */
public void load()
{
    BufferedReader bufferedreader = null;

    try
    {
        bufferedreader = Files.newReader(this.usercacheFile, Charsets.UTF_8);
        List<PlayerProfileCache.ProfileEntry> list = (List)this.gson.fromJson((Reader)bufferedreader, TYPE);
        this.usernameToProfileEntryMap.clear();
        this.uuidToProfileEntryMap.clear();
        this.gameProfiles.clear();

        for (PlayerProfileCache.ProfileEntry playerprofilecache$profileentry : Lists.reverse(list))
        {
            if (playerprofilecache$profileentry != null)
            {
                this.addEntry(playerprofilecache$profileentry.getGameProfile(), playerprofilecache$profileentry.getExpirationDate());
            }
        }
    }
    catch (FileNotFoundException var9)
    {
        ;
    }
    catch (JsonParseException var10)
    {
        ;
    }
    finally
    {
        IOUtils.closeQuietly((Reader)bufferedreader);
    }
}
项目:lams    文件:RollingCharBuffer.java   
/** Clear array and switch to new reader. */
public void reset(Reader reader) {
  this.reader = reader;
  nextPos = 0;
  nextWrite = 0;
  count = 0;
  end = false;
}
项目:OpenJSharp    文件:XMLStreamReaderFactory.java   
@Override
public XMLStreamReader doCreate(String systemId, Reader in, boolean rejectDTDs) {
    try {
        return xif.get().createXMLStreamReader(systemId,in);
    } catch (XMLStreamException e) {
        throw new XMLReaderException("stax.cantCreate",e);
    }
}
项目:jdk8u-jdk    文件:DTDInputStream.java   
/**
 * Push an entire input stream
 */
void push(Reader in) throws IOException {
    stack.push(new Integer(ln));
    stack.push(new Integer(ch));
    stack.push(this.in);
    this.in = in;
    ch = in.read();
}
项目:openjdk-jdk10    文件:ValidatorHandlerImpl.java   
/**
 * Resolves the given resource and adapts the <code>LSInput</code>
 * returned into an <code>InputSource</code>.
 */
public InputSource resolveEntity(String name, String publicId,
        String baseURI, String systemId) throws SAXException, IOException {
    if (fEntityResolver != null) {
        LSInput lsInput = fEntityResolver.resolveResource(XML_TYPE, null, publicId, systemId, baseURI);
        if (lsInput != null) {
            final String pubId = lsInput.getPublicId();
            final String sysId = lsInput.getSystemId();
            final String baseSystemId = lsInput.getBaseURI();
            final Reader charStream = lsInput.getCharacterStream();
            final InputStream byteStream = lsInput.getByteStream();
            final String data = lsInput.getStringData();
            final String encoding = lsInput.getEncoding();

            /**
             * An LSParser looks at inputs specified in LSInput in
             * the following order: characterStream, byteStream,
             * stringData, systemId, publicId. For consistency
             * with the DOM Level 3 Load and Save Recommendation
             * use the same lookup order here.
             */
            InputSource inputSource = new InputSource();
            inputSource.setPublicId(pubId);
            inputSource.setSystemId((baseSystemId != null) ? resolveSystemId(sysId, baseSystemId) : sysId);

            if (charStream != null) {
                inputSource.setCharacterStream(charStream);
            }
            else if (byteStream != null) {
                inputSource.setByteStream(byteStream);
            }
            else if (data != null && data.length() != 0) {
                inputSource.setCharacterStream(new StringReader(data));
            }
            inputSource.setEncoding(encoding);
            return inputSource;
        }
    }
    return null;
}
项目:Equella    文件:AbstractOffice2007Extracter.java   
private static void gatherValuesForTagName(String tagName, Reader xml, StringBuilder gatherer, int maxSize)
    throws XmlPullParserException, IOException
{
    XmlPullParser parser = new MXParser();
    parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
    parser.setInput(xml);

    int event = parser.getEventType();
    while( event != XmlPullParser.END_DOCUMENT )
    {
        if( event == XmlPullParser.START_TAG && parser.getName().equals(tagName) )
        {
            while( parser.next() == XmlPullParser.TEXT )
            {
                String s = parser.getText();
                if( s != null )
                {
                    // Removal all tabs, newlines, returns, etc.. and trim
                    // white space
                    s = s.replaceAll("\\cM?\r?\r\n\t", "").trim();
                    if( s.length() > 0 )
                    {
                        gatherer.append(s);
                        gatherer.append(' ');
                    }
                }
            }

            if( gatherer.length() >= maxSize )
            {
                return;
            }
        }
        event = parser.next();
    }
}
项目:PACE    文件:SignatureConfigBuilder.java   
/**
 * Read the configuration from a Reader.
 *
 * @param in
 *          Stream to read from.
 * @return builder.
 */
public SignatureConfigBuilder readFromFile(Reader in) throws IOException {
  Ini configIni = new Ini(in);
  Section section = configIni.get(SignatureConfig.SECTION_NAME);

  setSigner(ValueSigner.fromString(section.get("algorithm")));
  setDestination(section.containsKey("destination") ? Destination.fromString(section.get("destination")) : Destination.VALUE);
  setProvider(section.get("provider")).setDestinationTable(section.get("table"));
  setDefaultVisibility(section.containsKey("defaultVisibility") ? section.get("defaultVisibility").getBytes(VISIBILITY_CHARSET) : null);

  return this;
}
项目:InstaShare    文件:JsonReader.java   
private static String readAll(Reader rd) throws IOException {
    StringBuilder sb = new StringBuilder();
    int cp;
    while ((cp = rd.read()) != -1) {
        sb.append((char) cp);
    }
    return sb.toString();
}
项目:bibliome-java-utils    文件:JSONUtils.java   
public static void main(String args[]) throws ParserConfigurationException, IOException, TransformerException {
    Reader reader = new FileReader(args[0]);
    Object object = JSONValue.parse(reader);
    reader.close();
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder = dbf.newDocumentBuilder();
    Document doc = toXML(docBuilder, object);
    TransformerFactory transformerFactory = TransformerFactory.newInstance();
    Transformer transformer = transformerFactory.newTransformer();
    Source source = new DOMSource(doc);
    Result result = new StreamResult(new File(args[1]));
    transformer.transform(source, result);
}
项目:nativead    文件:IOUtils.java   
private static void close(Object obj) {
    if (obj == null) {
        return;
    }

    if (obj instanceof InputStream) {
        closeIS((InputStream) obj);
    } else if (obj instanceof OutputStream) {
        closeOS((OutputStream) obj);
    } else if (obj instanceof Writer) {
        closeWriter((Writer) obj);
    } else if (obj instanceof Reader) {
        closeReader((Reader) obj);
    } else if (obj instanceof RandomAccessFile) {
        closeFile((RandomAccessFile) obj);
    } else if (obj instanceof Socket) {
        closeSocket((Socket) obj);
    } else if (obj instanceof ServerSocket) {
        closeServerSocket((ServerSocket) obj);
    } else if (obj instanceof Process) {
        closeProcess((Process) obj);
    } else if (obj instanceof Cursor) {
        closeCursor((Cursor) obj);
    } else if (obj instanceof Closeable) {
        close((Closeable) obj);
    } else {
        throw new RuntimeException("unSupport");
    }
}
项目:flume-release-1.7.0    文件:TestAbstractZooKeeperConfigurationProvider.java   
protected void addData() throws Exception {
  Reader in = new InputStreamReader(getClass().getClassLoader()
      .getResourceAsStream(FLUME_CONF_FILE), Charsets.UTF_8);
  try {
    String config = IOUtils.toString(in);
    client.setData().forPath(AGENT_PATH, config.getBytes());
  } finally {
    in.close();
  }
}
项目:jdk8u-jdk    文件:StubWebRowSetImpl.java   
@Override
public void setClob(String parameterName, Reader reader) throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}
项目:FSTestTools    文件:MockingGenerationContext.java   
@Override
public TemplateDocument parse(final Reader reader) throws IOException {
    return null;
}
项目:org.ops4j.pax.transx    文件:StubResultSet.java   
/** {@inheritDoc} */
public void updateCharacterStream(int columnIndex, Reader x) throws SQLException
{
}
项目:openjdk-jdk10    文件:StubWebRowSetImpl.java   
@Override
public void setClob(String parameterName, Reader reader, long length) throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}
项目:openjdk-jdk10    文件:StubJoinRowSetImpl.java   
@Override
public void setClob(String parameterName, Reader reader) throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}
项目:dacapobench    文件:TargetJDK1_4.java   
public JavaParserTokenManager createJavaParserTokenManager(Reader in) {
    return new JavaParserTokenManager(new JavaCharStream(in));
}
项目:OpenVertretung    文件:JDBC4MysqlSQLXML.java   
Reader toReader() {
    return new StringReader(this.buf.toString());
}
项目:OpenJSharp    文件:SourceReaderFactory.java   
public static XMLStreamReader createSourceReader(Source source, boolean rejectDTDs, String charsetName) {
    try {
        if (source instanceof StreamSource) {
            StreamSource streamSource = (StreamSource) source;
            InputStream is = streamSource.getInputStream();

            if (is != null) {
                // Wrap input stream in Reader if charset is specified
                if (charsetName != null) {
                    return XMLStreamReaderFactory.create(
                        source.getSystemId(), new InputStreamReader(is, charsetName), rejectDTDs);
                }
                else {
                    return XMLStreamReaderFactory.create(
                        source.getSystemId(), is, rejectDTDs);
                }
            }
            else {
                Reader reader = streamSource.getReader();
                if (reader != null) {
                    return XMLStreamReaderFactory.create(
                        source.getSystemId(), reader, rejectDTDs);
                }
                else {
                    return XMLStreamReaderFactory.create(
                        source.getSystemId(), new URL(source.getSystemId()).openStream(), rejectDTDs );
                }
            }
        }
        else if (source.getClass() == fastInfosetSourceClass) {
            return FastInfosetUtil.createFIStreamReader((InputStream)
                fastInfosetSource_getInputStream.invoke(source));
        }
        else if (source instanceof DOMSource) {
            DOMStreamReader dsr =  new DOMStreamReader();
            dsr.setCurrentNode(((DOMSource) source).getNode());
            return dsr;
        }
        else if (source instanceof SAXSource) {
            // TODO: need SAX to StAX adapter here -- Use transformer for now
            Transformer tx =  XmlUtil.newTransformer();
            DOMResult domResult = new DOMResult();
            tx.transform(source, domResult);
            return createSourceReader(
                new DOMSource(domResult.getNode()),
                rejectDTDs);
        }
        else {
            throw new XMLReaderException("sourceReader.invalidSource",
                    source.getClass().getName());
        }
    }
    catch (Exception e) {
        throw new XMLReaderException(e);
    }
}