Top Description Inners Fields Constructors Methods
org.apache.tools.ant.filters.util

public final Class ChainReaderHelper

extends Object
Class Inheritance
Imports
java.io.FilterReader, .IOException, .Reader, java.lang.reflect.Constructor, .InvocationTargetException, java.util.ArrayList, .Collection, .List, .Optional, .Vector, java.util.function.Consumer, java.util.stream.Collectors, .Stream, org.apache.tools.ant.AntClassLoader, .BuildException, .Project, org.apache.tools.ant.filters.BaseFilterReader, .ChainableReader, org.apache.tools.ant.types.AntFilterReader, .FilterChain, .Parameterizable, .Path, org.apache.tools.ant.util.FileUtils

Process a FilterReader chain.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public class

Field Summary

Modifier and TypeField and Description
public int
bufferSize

The size of the buffer to be used.

private static final int
public Vector<FilterChain>
filterChains

Chain of filters

public Reader
primaryReader

The primary reader to which the reader chain is to be attached.

private Project
project

The Ant project

Constructor Summary

AccessConstructor and Description
public
ChainReaderHelper()

Default constructor.

public
ChainReaderHelper(Project
ditto
project
,
Reader
ditto
primaryReader
,
Iterable<FilterChain>
ditto
filterChains
)

Convenience constructor.

Method Summary

Modifier and TypeMethod and Description
private static void
cleanUpClassLoaders(List<AntClassLoader> loaders)

Deregisters Classloaders from the project so GC can remove them later.

private Reader
expandReader(final AntFilterReader filter, final Reader ancestor, final List<AntClassLoader> classLoadersToCleanUp)

Creates and parameterizes a new FilterReader from a <filterreader> element.

public ChainReaderHelper.ChainReader

Returns:

the assembled reader
getAssembledReader
()

Assemble the reader

public Project

Returns:

the current project
getProject
()

Get the project

public String

Returns:

the contents of the file as a string
readFully
(Reader
the reader object
rdr
)

Read data from the reader and return the contents as a string.

public void
setBufferSize(int
the buffer size to use
size
)

Sets the buffer size to be used.

public void
setFilterChains(Vector<FilterChain>
the filter chains collection
fchain
)

Sets the collection of filter reader sets

public void
setPrimaryReader(Reader
the reader object
rdr
)

Sets the primary Reader

public void
setProject(final Project
the current project
project
)

Set the project to work with

private void
setProjectOnObject(Object obj)

helper method to set the project on an object.

public ChainReaderHelper

Returns:

this
with
(Consumer<ChainReaderHelper>
ditto
consumer
)

Fluent mechanism to apply some Consumer.

public ChainReaderHelper

Returns:

this
withBufferSize
(int
ditto
size
)

Fluent buffer size mutator.

public ChainReaderHelper

Returns:

this
withFilterChains
(Iterable<FilterChain>
ditto
filterChains
)

Fluent filterChains mutator.

public ChainReaderHelper

Returns:

this
withPrimaryReader
(Reader
Reader
rdr
)

Fluent primary Reader mutator.

public ChainReaderHelper

Returns:

this
withProject
(Project
ditto
project
)

Fluent Project mutator.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bufferSizeback to summary
public int bufferSize

The size of the buffer to be used.

DEFAULT_BUFFER_SIZEback to summary
private static final int DEFAULT_BUFFER_SIZE
filterChainsback to summary
public Vector<FilterChain> filterChains

Chain of filters

primaryReaderback to summary
public Reader primaryReader

The primary reader to which the reader chain is to be attached.

projectback to summary
private Project project

The Ant project

Constructor Detail

ChainReaderHelperback to summary
public ChainReaderHelper()

Default constructor.

ChainReaderHelperback to summary
public ChainReaderHelper(Project project, Reader primaryReader, Iterable<FilterChain> filterChains)

Convenience constructor.

Parameters
project:Project

ditto

primaryReader:Reader

ditto

filterChains:Iterable<FilterChain>

ditto

Method Detail

cleanUpClassLoadersback to summary
private static void cleanUpClassLoaders(List<AntClassLoader> loaders)

Deregisters Classloaders from the project so GC can remove them later.

expandReaderback to summary
private Reader expandReader(final AntFilterReader filter, final Reader ancestor, final List<AntClassLoader> classLoadersToCleanUp)

Creates and parameterizes a new FilterReader from a <filterreader> element.

Since
Ant 1.8.0
getAssembledReaderback to summary
public ChainReaderHelper.ChainReader getAssembledReader() throws BuildException

Assemble the reader

Returns:ChainReaderHelper.ChainReader

the assembled reader

Exceptions
BuildException:
if an error occurs
getProjectback to summary
public Project getProject()

Get the project

Returns:Project

the current project

readFullyback to summary
public String readFully(Reader rdr) throws IOException

Read data from the reader and return the contents as a string.

Parameters
rdr:Reader

the reader object

Returns:String

the contents of the file as a string

Exceptions
IOException:
if an error occurs
setBufferSizeback to summary
public void setBufferSize(int size)

Sets the buffer size to be used. Defaults to 8192, if this method is not invoked.

Parameters
size:int

the buffer size to use

setFilterChainsback to summary
public void setFilterChains(Vector<FilterChain> fchain)

Sets the collection of filter reader sets

Parameters
fchain:Vector<FilterChain>

the filter chains collection

setPrimaryReaderback to summary
public void setPrimaryReader(Reader rdr)

Sets the primary Reader

Parameters
rdr:Reader

the reader object

setProjectback to summary
public void setProject(final Project project)

Set the project to work with

Parameters
project:Project

the current project

setProjectOnObjectback to summary
private void setProjectOnObject(Object obj)

helper method to set the project on an object. the reflection setProject does not work for anonymous/protected/private classes, even if they have public methods.

withback to summary
public ChainReaderHelper with(Consumer<ChainReaderHelper> consumer)

Fluent mechanism to apply some Consumer.

Parameters
consumer:Consumer<ChainReaderHelper>

ditto

Returns:ChainReaderHelper

this

withBufferSizeback to summary
public ChainReaderHelper withBufferSize(int size)

Fluent buffer size mutator.

Parameters
size:int

ditto

Returns:ChainReaderHelper

this

withFilterChainsback to summary
public ChainReaderHelper withFilterChains(Iterable<FilterChain> filterChains)

Fluent filterChains mutator.

Parameters
filterChains:Iterable<FilterChain>

ditto

Returns:ChainReaderHelper

this

withPrimaryReaderback to summary
public ChainReaderHelper withPrimaryReader(Reader rdr)

Fluent primary Reader mutator.

Parameters
rdr:Reader

Reader

Returns:ChainReaderHelper

this

withProjectback to summary
public ChainReaderHelper withProject(Project project)

Fluent Project mutator.

Parameters
project:Project

ditto

Returns:ChainReaderHelper

this

org.apache.tools.ant.filters.util back to summary

public Class ChainReaderHelper.ChainReader

extends FilterReader
Class Inheritance

Created type.

Field Summary

Modifier and TypeField and Description
private List<AntClassLoader>
Inherited from java.io.FilterReader:
in

Constructor Summary

AccessConstructor and Description
private
ChainReader(Reader in, List<AntClassLoader> cleanupLoaders)

Method Summary

Modifier and TypeMethod and Description
public void
close()

Overrides java.io.FilterReader.close.

Implements java.io.Closeable.close.

Closes the stream and releases any system resources associated with it.
protected void
finalize()

Overrides java.lang.Object.finalize.

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
public String
Inherited from java.io.FilterReader:
markmarkSupportedreadreadreadyresetskip

Field Detail

cleanupLoadersback to summary
private List<AntClassLoader> cleanupLoaders

Constructor Detail

ChainReaderback to summary
private ChainReader(Reader in, List<AntClassLoader> cleanupLoaders)

Method Detail

closeback to summary
public void close() throws IOException

Overrides java.io.FilterReader.close.

Implements java.io.Closeable.close.

Doc from java.io.Reader.close.

Closes the stream and releases any system resources associated with it. Once the stream has been closed, further read(), ready(), mark(), reset(), or skip() invocations will throw an IOException. Closing a previously closed stream has no effect.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
finalizeback to summary
protected void finalize() throws Throwable

Overrides java.lang.Object.finalize.

Doc from java.lang.Object.finalize.

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. A subclass overrides the finalize method to dispose of system resources or to perform other cleanup.

When running in a Java virtual machine in which finalization has been disabled or removed, the garbage collector will never call finalize(). In a Java virtual machine in which finalization is enabled, the garbage collector might call finalize only after an indefinite delay.

The general contract of finalize is that it is invoked if and when the Java virtual machine has determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, except as a result of an action taken by the finalization of some other object or class which is ready to be finalized. The finalize method may take any action, including making this object available again to other threads; the usual purpose of finalize, however, is to perform cleanup actions before the object is irrevocably discarded. For example, the finalize method for an object that represents an input/output connection might perform explicit I/O transactions to break the connection before the object is permanently discarded.

The finalize method of class Object performs no special action; it simply returns normally. Subclasses of Object may override this definition.

The Java programming language does not guarantee which thread will invoke the finalize method for any given object. It is guaranteed, however, that the thread that invokes finalize will not be holding any user-visible synchronization locks when finalize is invoked. If an uncaught exception is thrown by the finalize method, the exception is ignored and finalization of that object terminates.

After the finalize method has been invoked for an object, no further action is taken until the Java virtual machine has again determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, including possible actions by other objects or classes which are ready to be finalized, at which point the object may be discarded.

The finalize method is never invoked more than once by a Java virtual machine for any given object.

Any exception thrown by the finalize method causes the finalization of this object to be halted, but is otherwise ignored.

Annotations
@Override
Exceptions
Throwable:
the Exception raised by this method
readFullyback to summary
public String readFully() throws IOException