JavaParser Source Viewer

Home|JavaParser/com/github/javaparser/StreamProvider.java
1/* Generated by: ParserGeneratorCC: Do not edit this line. StreamProvider.java Version 1.1 */
2/* ParserGeneratorCCOptions:KEEP_LINE_COLUMN=true */
3/*
4 * Copyright (C) 2007-2010 JĂșlio Vilmar Gesser.
5 * Copyright (C) 2011, 2013-2020 The JavaParser Team.
6 *
7 * This file is part of JavaParser.
8 *
9 * JavaParser can be used either under the terms of
10 * a) the GNU Lesser General Public License as published by
11 *     the Free Software Foundation, either version 3 of the License, or
12 *     (at your option) any later version.
13 * b) the terms of the Apache License
14 *
15 * You should have received a copy of both licenses in LICENCE.LGPL and
16 * LICENCE.APACHE. Please refer to those files for details.
17 *
18 * JavaParser is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 * GNU Lesser General Public License for more details.
22 */
23package com.github.javaparser;
24
25
26import java.io.BufferedReader;
27import java.io.IOException;
28import java.io.InputStream;
29import java.io.InputStreamReader;
30import java.io.Reader;
31
32/**
33 * NOTE : This generated class can be safely deleted if installing in a GWT installation (use StringProvider instead)
34 */
35public class StreamProvider implements Provider
36{
37    private Reader m_aReader;
38    
39  @Deprecated
40  public StreamProvider(final InputStream streamfinal String charsetName) throws IOException
41  {
42    this (new BufferedReader (new InputStreamReader (streamcharsetName)));
43  }
44  
45  public StreamProvider(final InputStream streamfinal java.nio.charset.Charset charset)
46  {
47    this (new BufferedReader (new InputStreamReader (streamcharset)));
48  }
49
50  public StreamProvider (final Reader reader)
51  {
52    m_aReader = reader;
53  }
54
55  public int read (final char[] aDestfinal int nOfsfinal int nLen) throws IOException
56  {
57    int result = m_aReader.read(aDestnOfsnLen);
58
59    /* CBA -- Added 2014/03/29 -- 
60       This logic allows the generated Java code to be easily translated to C# (via sharpen) -
61       as in C# 0 represents end of file, and in Java, -1 represents end of file
62       See : http://msdn.microsoft.com/en-us/library/9kstw824(v=vs.110).aspx
63       ** Technically, this is not required for java but the overhead is extremely low compared to the code generation benefits.
64       */
65    if (result == 0)
66      if (nOfs < aDest.length && nLen > 0)
67        result = -1;
68       
69    return result;
70    }
71
72    public void close () throws IOException
73    {
74      if (m_aReader != null)
75      m_aReader.close();
76    }
77}
78/* ParserGeneratorCC - OriginalChecksum=b9eca802845867da8b35946746967e8e (do not edit this line) */
79
MembersX
StreamProvider:read:Block:result
StreamProvider:close
StreamProvider:read
StreamProvider:m_aReader
StreamProvider:StreamProvider
Members
X