//
//  Generated by the J2ObjC translator.  DO NOT EDIT!
//  source: /Users/antoniocortes/j2objcprj/relases/j2objc/guava/build_result/java/com/google/common/io/CharSource.java
//

#include "../../../../../J2ObjC_header.h"

#pragma push_macro("INCLUDE_ALL_ComGoogleCommonIoCharSource")
#ifdef RESTRICT_ComGoogleCommonIoCharSource
#define INCLUDE_ALL_ComGoogleCommonIoCharSource 0
#else
#define INCLUDE_ALL_ComGoogleCommonIoCharSource 1
#endif
#undef RESTRICT_ComGoogleCommonIoCharSource

#pragma clang diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"

#if __has_feature(nullability)
#pragma clang diagnostic push
#pragma GCC diagnostic ignored "-Wnullability"
#pragma GCC diagnostic ignored "-Wnullability-completeness"
#endif

#if !defined (ComGoogleCommonIoCharSource_) && (INCLUDE_ALL_ComGoogleCommonIoCharSource || defined(INCLUDE_ComGoogleCommonIoCharSource))
#define ComGoogleCommonIoCharSource_

@class ComGoogleCommonBaseOptional;
@class ComGoogleCommonCollectImmutableList;
@class ComGoogleCommonIoByteSource;
@class ComGoogleCommonIoCharSink;
@class IOSObjectArray;
@class JavaIoBufferedReader;
@class JavaIoReader;
@class JavaNioCharsetCharset;
@protocol ComGoogleCommonIoLineProcessor;
@protocol JavaLangAppendable;
@protocol JavaLangCharSequence;
@protocol JavaLangIterable;
@protocol JavaUtilFunctionConsumer;
@protocol JavaUtilIterator;
@protocol JavaUtilStreamStream;

/*!
 @brief A readable source of characters, such as a text file.Unlike a <code>Reader</code>, a <code>CharSource</code>
  is not an open, stateful stream of characters that can be read and closed.
 Instead,
  it is an immutable <i>supplier</i> of <code>Reader</code> instances. 
 <p><code>CharSource</code> provides two kinds of methods: 
 <ul>
    <li><b>Methods that return a reader:</b> These methods should return a <i>new</i>, independent
        instance each time they are called. The caller is responsible for ensuring that the
        returned reader is closed.   
 <li><b>Convenience methods:</b> These are implementations of common operations that are
        typically implemented by opening a reader using one of the methods in the first category,
        doing something and finally closing the reader that was opened. 
 </ul>
  
 <p>Several methods in this class, such as <code>readLines()</code>, break the contents of the source
  into lines. Like <code>BufferedReader</code>, these methods break lines on any of <code>\n</code>, <code>\r</code>
  or <code>\r\n</code>, do not include the line separator in each line and do not consider there to
  be an empty line at the end if the contents are terminated with a line separator. 
 <p>Any <code>ByteSource</code> containing text encoded with a specific encoding
  may be viewed as a <code>CharSource</code> using <code>ByteSource.asCharSource(Charset)</code>.
 @since 14.0
 @author Colin Decker
 */
@interface ComGoogleCommonIoCharSource : NSObject

#pragma mark Public

/*!
 @brief Returns a <code>ByteSource</code> view of this char source that encodes chars read from this source
  as bytes using the given <code>Charset</code>.
 <p>If <code>ByteSource.asCharSource</code> is called on the returned source with the same charset,
  the default implementation of this method will ensure that the original <code>CharSource</code> is
  returned, rather than round-trip encoding. Subclasses that override this method should behave
  the same way.
 @since 20.0
 */
- (ComGoogleCommonIoByteSource *)asByteSourceWithJavaNioCharsetCharset:(JavaNioCharsetCharset *)charset;

/*!
 @brief Concatenates multiple <code>CharSource</code> instances into a single source.Streams returned from
  the source will contain the concatenated data from the streams of the underlying sources.
 <p>Only one underlying stream will be open at a time. Closing the concatenated stream will
  close the open underlying stream.
 @param sources the sources to concatenate
 @return a <code>CharSource</code> containing the concatenated data
 @throw NullPointerExceptionif any of <code>sources</code> is <code>null</code>
 @since 15.0
 */
+ (ComGoogleCommonIoCharSource *)concatWithComGoogleCommonIoCharSourceArray:(IOSObjectArray *)sources;

/*!
 @brief Concatenates multiple <code>CharSource</code> instances into a single source.Streams returned from
  the source will contain the concatenated data from the streams of the underlying sources.
 <p>Only one underlying stream will be open at a time. Closing the concatenated stream will
  close the open underlying stream.
 @param sources the sources to concatenate
 @return a <code>CharSource</code> containing the concatenated data
 @since 15.0
 */
+ (ComGoogleCommonIoCharSource *)concatWithJavaLangIterable:(id<JavaLangIterable>)sources;

/*!
 @brief Concatenates multiple <code>CharSource</code> instances into a single source.Streams returned from
  the source will contain the concatenated data from the streams of the underlying sources.
 <p>Only one underlying stream will be open at a time. Closing the concatenated stream will
  close the open underlying stream. 
 <p>Note: The input <code>Iterator</code> will be copied to an <code>ImmutableList</code> when this method
  is called. This will fail if the iterator is infinite and may cause problems if the iterator
  eagerly fetches data for each source when iterated (rather than producing sources that only
  load data through their streams). Prefer using the <code>concat(Iterable)</code> overload if
  possible.
 @param sources the sources to concatenate
 @return a <code>CharSource</code> containing the concatenated data
 @throw NullPointerExceptionif any of <code>sources</code> is <code>null</code>
 @since 15.0
 */
+ (ComGoogleCommonIoCharSource *)concatWithJavaUtilIterator:(id<JavaUtilIterator>)sources;

/*!
 @brief Appends the contents of this source to the given <code>Appendable</code> (such as a <code>Writer</code>).
 Does not close <code>appendable</code> if it is <code>Closeable</code>.
 @return the number of characters copied
 @throw IOExceptionif an I/O error occurs while reading from this source or writing to <code>appendable</code>
 */
- (jlong)copyToWithJavaLangAppendable:(id<JavaLangAppendable>)appendable OBJC_METHOD_FAMILY_NONE;

/*!
 @brief Copies the contents of this source to the given sink.
 @return the number of characters copied
 @throw IOExceptionif an I/O error occurs while reading from this source or writing to <code>sink</code>
 */
- (jlong)copyToWithComGoogleCommonIoCharSink:(ComGoogleCommonIoCharSink *)sink OBJC_METHOD_FAMILY_NONE;

/*!
 @brief Returns an immutable <code>CharSource</code> that contains no characters.
 @since 15.0
 */
+ (ComGoogleCommonIoCharSource *)empty;

/*!
 @brief Reads all lines of text from this source, running the given <code>action</code> for each line as it
  is read.
 <p>Like <code>BufferedReader.readLine()</code>, this method considers a line to be a sequence of
  text that is terminated by (but does not include) one of <code>\r\n</code>, <code>\r</code> or <code>\n</code>
 . If the source's content does not end in a line termination sequence, it is treated as if
  it does.
 @throw IOExceptionif an I/O error occurs while reading from this source or if <code>action</code>
      throws an <code>UncheckedIOException</code>
 @since 22.0
 */
- (void)forEachLineWithJavaUtilFunctionConsumer:(id<JavaUtilFunctionConsumer>)action;

/*!
 @brief Returns whether the source has zero chars.The default implementation first checks <code>lengthIfKnown</code>
 , returning true if it's known to be zero and false if it's known to be
  non-zero.
 If the length is not known, it falls back to opening a stream and checking for EOF. 
 <p>Note that, in cases where <code>lengthIfKnown</code> returns zero, it is <i>possible</i> that
  chars are actually available for reading. This means that a source may return <code>true</code> from 
 <code>isEmpty()</code> despite having readable content.
 @throw IOExceptionif an I/O error occurs
 @since 15.0
 */
- (jboolean)isEmpty;

/*!
 @brief Returns the length of this source in chars, even if doing so requires opening and traversing an
  entire stream.To avoid a potentially expensive operation, see <code>lengthIfKnown</code>.
 <p>The default implementation calls <code>lengthIfKnown</code> and returns the value if present. If
  absent, it will fall back to a heavyweight operation that will open a stream, <code>skip</code>
  to the end of the stream, and return the total number of chars that
  were skipped. 
 <p>Note that for sources that implement <code>lengthIfKnown</code> to provide a more efficient
  implementation, it is <i>possible</i> that this method will return a different number of chars
  than would be returned by reading all of the chars. 
 <p>In either case, for mutable sources such as files, a subsequent read may return a different
  number of chars if the contents are changed.
 @throw IOExceptionif an I/O error occurs while reading the length of this source
 @since 19.0
 */
- (jlong)length;

/*!
 @brief Returns the size of this source in chars, if the size can be easily determined without actually
  opening the data stream.
 <p>The default implementation returns <code>Optional.absent</code>. Some sources, such as a <code>CharSequence</code>
 , may return a non-absent value. Note that in such cases, it is <i>possible</i>
  that this method will return a different number of chars than would be returned by reading all
  of the chars. 
 <p>Additionally, for mutable sources such as <code>StringBuilder</code>s, a subsequent read may
  return a different number of chars if the contents are changed.
 @since 19.0
 */
- (ComGoogleCommonBaseOptional *)lengthIfKnown;

/*!
 @brief Opens a new <code>Stream</code> for reading text one line at a time from this source.This method
  returns a new, independent stream each time it is called.
 <p>The returned stream is lazy and only reads from the source in the terminal operation. If an
  I/O error occurs while the stream is reading from the source or when the stream is closed, an 
 <code>UncheckedIOException</code> is thrown. 
 <p>Like <code>BufferedReader.readLine()</code>, this method considers a line to be a sequence of
  text that is terminated by (but does not include) one of <code>\r\n</code>, <code>\r</code> or <code>\n</code>
 . If the source's content does not end in a line termination sequence, it is treated as if
  it does. 
 <p>The caller is responsible for ensuring that the returned stream is closed. For example: 
 @code
 try (Stream<String> lines = source.lines()) {
    lines.map(...)
       .filter(...)
       .forEach(...);
  } 
 
@endcode
 @throw IOExceptionif an I/O error occurs while opening the stream
 @since 22.0
 */
- (id<JavaUtilStreamStream>)lines;

/*!
 @brief Opens a new <code>BufferedReader</code> for reading from this source.This method returns a new,
  independent reader each time it is called.
 <p>The caller is responsible for ensuring that the returned reader is closed.
 @throw IOExceptionif an I/O error occurs while of opening the reader
 */
- (JavaIoBufferedReader *)openBufferedStream;

/*!
 @brief Opens a new <code>Reader</code> for reading from this source.This method returns a new, independent
  reader each time it is called.
 <p>The caller is responsible for ensuring that the returned reader is closed.
 @throw IOExceptionif an I/O error occurs while opening the reader
 */
- (JavaIoReader *)openStream;

/*!
 @brief Reads the contents of this source as a string.
 @throw IOExceptionif an I/O error occurs while reading from this source
 */
- (NSString *)read;

/*!
 @brief Reads the first line of this source as a string.Returns <code>null</code> if this source is empty.
 <p>Like <code>BufferedReader.readLine()</code>, this method considers a line to be a sequence of
  text that is terminated by (but does not include) one of <code>\r\n</code>, <code>\r</code> or <code>\n</code>
 . If the source's content does not end in a line termination sequence, it is treated as if
  it does.
 @throw IOExceptionif an I/O error occurs while reading from this source
 */
- (NSString * __nullable)readFirstLine;

/*!
 @brief Reads all the lines of this source as a list of strings.The returned list will be empty if
  this source is empty.
 <p>Like <code>BufferedReader.readLine()</code>, this method considers a line to be a sequence of
  text that is terminated by (but does not include) one of <code>\r\n</code>, <code>\r</code> or <code>\n</code>
 . If the source's content does not end in a line termination sequence, it is treated as if
  it does.
 @throw IOExceptionif an I/O error occurs while reading from this source
 */
- (ComGoogleCommonCollectImmutableList *)readLines;

/*!
 @brief Reads lines of text from this source, processing each line as it is read using the given <code>processor</code>
 .Stops when all lines have been processed or the processor returns 
 <code>false</code> and returns the result produced by the processor.
 <p>Like <code>BufferedReader.readLine()</code>, this method considers a line to be a sequence of
  text that is terminated by (but does not include) one of <code>\r\n</code>, <code>\r</code> or <code>\n</code>
 . If the source's content does not end in a line termination sequence, it is treated as if
  it does.
 @throw IOExceptionif an I/O error occurs while reading from this source or if <code>processor</code>
  throws an <code>IOException</code>
 @since 16.0
 */
- (id)readLinesWithComGoogleCommonIoLineProcessor:(id<ComGoogleCommonIoLineProcessor>)processor;

/*!
 @brief Returns a view of the given character sequence as a <code>CharSource</code>.The behavior of the
  returned <code>CharSource</code> and any <code>Reader</code> instances created by it is unspecified if
  the <code>charSequence</code> is mutated while it is being read, so don't do that.
 @since 15.0 (since 14.0 as <code>CharStreams.asCharSource(String)</code>)
 */
+ (ComGoogleCommonIoCharSource *)wrapWithJavaLangCharSequence:(id<JavaLangCharSequence>)charSequence;

#pragma mark Protected

/*!
 @brief Constructor for use by subclasses.
 */
- (instancetype __nonnull)init;

@end

J2OBJC_EMPTY_STATIC_INIT(ComGoogleCommonIoCharSource)

FOUNDATION_EXPORT void ComGoogleCommonIoCharSource_init(ComGoogleCommonIoCharSource *self);

FOUNDATION_EXPORT ComGoogleCommonIoCharSource *ComGoogleCommonIoCharSource_concatWithJavaLangIterable_(id<JavaLangIterable> sources);

FOUNDATION_EXPORT ComGoogleCommonIoCharSource *ComGoogleCommonIoCharSource_concatWithJavaUtilIterator_(id<JavaUtilIterator> sources);

FOUNDATION_EXPORT ComGoogleCommonIoCharSource *ComGoogleCommonIoCharSource_concatWithComGoogleCommonIoCharSourceArray_(IOSObjectArray *sources);

FOUNDATION_EXPORT ComGoogleCommonIoCharSource *ComGoogleCommonIoCharSource_wrapWithJavaLangCharSequence_(id<JavaLangCharSequence> charSequence);

FOUNDATION_EXPORT ComGoogleCommonIoCharSource *ComGoogleCommonIoCharSource_empty(void);

J2OBJC_TYPE_LITERAL_HEADER(ComGoogleCommonIoCharSource)

#endif


#if __has_feature(nullability)
#pragma clang diagnostic pop
#endif

#pragma clang diagnostic pop
#pragma pop_macro("INCLUDE_ALL_ComGoogleCommonIoCharSource")
