Skip to content
Snippets Groups Projects
Commit 7fb53723 authored by felmer's avatar felmer
Browse files

as a result of a code review inner classes in interface ILineFilter have been moved outside.

SVN: 968
parent f0e78a95
No related branches found
No related tags found
No related merge requests found
package ch.systemsx.cisd.common.parser;
/**
* A default line filter that accepts any line.
*
* @author Christian Ribeaud
*/
public final class AlwaysAcceptLineFilter implements ILineFilter
{
public static final ILineFilter INSTANCE = new AlwaysAcceptLineFilter();
private AlwaysAcceptLineFilter() {}
public final boolean acceptLine(String line, int lineNumber)
{
return true;
}
}
\ No newline at end of file
......@@ -69,7 +69,7 @@ public class DefaultReaderParser<E> implements IReaderParser<E>
public final List<E> parse(Reader reader) throws IOException
{
return parse(reader, ILineFilter.ALWAYS_ACCEPT_LINE);
return parse(reader, AlwaysAcceptLineFilter.INSTANCE);
}
public final List<E> parse(Reader reader, ILineFilter lineFilter) throws IOException
......
package ch.systemsx.cisd.common.parser;
/**
* A default <code>LineFilter</code> implementation that excludes empty and comment lines.
* <p>
* A comment line starts with '#'.
* </p>
*
* @author Christian Ribeaud
*/
public final class ExcludeEmptyAndCommentLineFilter implements ILineFilter
{
public static final ILineFilter INSTANCE = new ExcludeEmptyAndCommentLineFilter();
private ExcludeEmptyAndCommentLineFilter() {}
public final boolean acceptLine(String line, int lineNumber)
{
final String trimmed = line.trim();
return trimmed.length() > 0 && trimmed.startsWith("#") == false;
}
}
\ No newline at end of file
......@@ -37,7 +37,7 @@ public final class HeaderLineFilter implements ILineFilter
public final boolean acceptLine(String line, int lineNumber)
{
if (ILineFilter.EXCLUDE_EMPTY_AND_COMMENT_LINE.acceptLine(line, lineNumber) == false
if (ExcludeEmptyAndCommentLineFilter.INSTANCE.acceptLine(line, lineNumber) == false
|| lineNumber == headerLineNumber)
{
return false;
......
......@@ -24,40 +24,6 @@ package ch.systemsx.cisd.common.parser;
public interface ILineFilter
{
/** A default <code>LineFilter</code> implementation that accepts any line. */
public final static ILineFilter ALWAYS_ACCEPT_LINE = new ILineFilter()
{
//
// LineFilter
//
public final boolean acceptLine(String line, int lineNumber)
{
return true;
}
};
/**
* A default <code>LineFilter</code> implementation that excludes empty and comment lines.
* <p>
* A comment line starts with '#'.
* </p>
*/
public final static ILineFilter EXCLUDE_EMPTY_AND_COMMENT_LINE = new ILineFilter()
{
//
// LineFilter
//
public final boolean acceptLine(String line, int lineNumber)
{
final String trimmed = line.trim();
return trimmed.length() > 0 && trimmed.startsWith("#") == false;
}
};
/**
* If given <code>line</code> should be accepted or not.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment