org.unix4j.unix.Head Maven / Gradle / Ivy
package org.unix4j.unix;
import org.unix4j.command.CommandInterface;
import org.unix4j.unix.head.HeadFactory;
import org.unix4j.unix.head.HeadOption;
import org.unix4j.unix.head.HeadOptions;
import org.unix4j.unix.head.HeadOptionSets;
/**
* Non-instantiable module with inner types making up the head command.
*
* NAME
*
* head - display first lines of a file
*
* SYNOPSIS
*
*
* {@code head}
* {@code head }
* {@code head }
* {@code head [-cq] }
* {@code head }
* {@code head }
* {@code head }
* {@code head [-cq] }
* {@code head [-cq] }
*
*
* See {@link Interface} for the corresponding command signature methods.
*
* DESCRIPTION
*
*
This filter displays the first count lines or characters of each of the specified files, or of the standard input if no files are specified. If count is omitted it defaults to 10. Both line and character counts start from 1.
If more than a single file is specified, each file is preceded by a header consisting of the string {@code "==> XXX <=="} where {@code "XXX"} is the name of the file.
*
*
* Options
*
* The following options are supported:
*
*
* {@code -c} {@code --chars} The {@code count} argument is in units of characters instead of
lines. Starts from 1 and includes line ending characters.
* {@code -q} {@code --suppressHeaders} Suppresses printing of headers when multiple files are being
examined.
*
*
* OPERANDS
*
* The following operands are supported:
*
*
* {@code } : {@code long} The first {@code count} lines of each input file are
copied to standard output, starting from 1 (characters instead of
lines if the {@code -c} option is specified). Must be a non-negative
integer or an exception is thrown. If {@code count} is greater than
the number number of lines (characters) in the input, the
application will not error and send the whole file to the output.
* {@code } : {@code String...} Pathnames of the input files to be filtered; wildcards * and ? are
supported; relative paths are resolved on the basis of the current
working directory.
* {@code } : {@code java.io.File...} The input files to be filtered; relative paths are not resolved (use
the string paths argument to enable relative path resolving based on
the current working directory).
* {@code } : {@code String...} String arguments defining the options and operands for the command.
Options can be specified by acronym (with a leading dash "-") or by
long name (with two leading dashes "--"). Operands other than the
default "--paths" operand have to be prefixed with the operand
name (e.g. "--count" for a subsequent count operand value).
* {@code } : {@code HeadOptions} Options for the head command.
*
*/
public final class Head {
/**
* The "head" command name.
*/
public static final String NAME = "head";
/**
* Interface defining all method signatures for the "head" command.
*
* @param
* the generic return type for all command signature methods
* to support different implementor types; the methods of a
* command factory for instance returns a command instance;
* command builders can also implement this interface, but their
* methods return the builder itself enabling for chained method
* invocation to create joined commands
*/
public static interface Interface extends CommandInterface {
/**
* Reads the first 10 lines from the standard input and writes them to
the standard output.
*
* @return the generic type {@code } defined by the implementing class;
* the command itself returns no value and writes its result to the
* standard output; see class level parameter comments for more
* details
*/
R head();
/**
* Reads the first n lines from each of the files specified and writes
them to the standard output. If more than a single file is
specified, each file is preceded by a header consisting of the
string {@code "==> XXX <=="} where {@code "XXX"} is the name
of the file.
Options can be specified by acronym (with a leading dash "-") or by
long name (with two leading dashes "--"). Operands other than the
default "--paths" operand have to be prefixed with the operand
name.
*
* @param args String arguments defining the options and operands for the command.
Options can be specified by acronym (with a leading dash "-") or by
long name (with two leading dashes "--"). Operands other than the
default "--paths" operand have to be prefixed with the operand
name (e.g. "--count" for a subsequent count operand value).
* @return the generic type {@code } defined by the implementing class;
* the command itself returns no value and writes its result to the
* standard output; see class level parameter comments for more
* details
*/
R head(String... args);
/**
* Reads the first {@code count} lines from the standard input and
writes them to the standard output.
*
* @param count The first {@code count} lines of each input file are
copied to standard output, starting from 1 (characters instead of
lines if the {@code -c} option is specified). Must be a non-negative
integer or an exception is thrown. If {@code count} is greater than
the number number of lines (characters) in the input, the
application will not error and send the whole file to the output.
* @return the generic type {@code } defined by the implementing class;
* the command itself returns no value and writes its result to the
* standard output; see class level parameter comments for more
* details
*/
R head(long count);
/**
* Reads the first {@code count} lines or characters from the standard
input and writes them to the standard output.
*
* @param options Options for the head command.
* @param count The first {@code count} lines of each input file are
copied to standard output, starting from 1 (characters instead of
lines if the {@code -c} option is specified). Must be a non-negative
integer or an exception is thrown. If {@code count} is greater than
the number number of lines (characters) in the input, the
application will not error and send the whole file to the output.
* @return the generic type {@code } defined by the implementing class;
* the command itself returns no value and writes its result to the
* standard output; see class level parameter comments for more
* details
*/
R head(HeadOptions options, long count);
/**
* Reads the first 10 lines from each of the specified files and writes
them to the standard output. If more than a single file is
specified, each file is preceded by a header consisting of the
string {@code "==> XXX <=="} where {@code "XXX"} is the name
of the file.
*
* @param files The input files to be filtered; relative paths are not resolved (use
the string paths argument to enable relative path resolving based on
the current working directory).
* @return the generic type {@code } defined by the implementing class;
* the command itself returns no value and writes its result to the
* standard output; see class level parameter comments for more
* details
*/
R head(java.io.File... files);
/**
* Reads the first {@code count} lines from each of the specified files
and writes them to the standard output. If more than a single file
is specified, each file is preceded by a header consisting of the
string {@code "==> XXX <=="} where {@code "XXX"} is the name
of the file.
*
* @param count The first {@code count} lines of each input file are
copied to standard output, starting from 1 (characters instead of
lines if the {@code -c} option is specified). Must be a non-negative
integer or an exception is thrown. If {@code count} is greater than
the number number of lines (characters) in the input, the
application will not error and send the whole file to the output.
* @param files The input files to be filtered; relative paths are not resolved (use
the string paths argument to enable relative path resolving based on
the current working directory).
* @return the generic type {@code } defined by the implementing class;
* the command itself returns no value and writes its result to the
* standard output; see class level parameter comments for more
* details
*/
R head(long count, java.io.File... files);
/**
* Reads the first {@code count} lines from each of the specified files
and writes them to the standard output. If more than a single file
is specified, each file is preceded by a header consisting of the
string {@code "==> XXX <=="} where {@code "XXX"} is the name
of the file.
*
* @param count The first {@code count} lines of each input file are
copied to standard output, starting from 1 (characters instead of
lines if the {@code -c} option is specified). Must be a non-negative
integer or an exception is thrown. If {@code count} is greater than
the number number of lines (characters) in the input, the
application will not error and send the whole file to the output.
* @param paths Pathnames of the input files to be filtered; wildcards * and ? are
supported; relative paths are resolved on the basis of the current
working directory.
* @return the generic type {@code } defined by the implementing class;
* the command itself returns no value and writes its result to the
* standard output; see class level parameter comments for more
* details
*/
R head(long count, String... paths);
/**
* Reads the first {@code count} lines or characters from each of the
specified files and writes them to the standard output. If more than
a single file is specified and the {@code -q} option is not
specified, each file is preceded by a header consisting of the
string {@code "==> XXX <=="} where {@code "XXX"} is the name
of the file.
*
* @param options Options for the head command.
* @param count The first {@code count} lines of each input file are
copied to standard output, starting from 1 (characters instead of
lines if the {@code -c} option is specified). Must be a non-negative
integer or an exception is thrown. If {@code count} is greater than
the number number of lines (characters) in the input, the
application will not error and send the whole file to the output.
* @param files The input files to be filtered; relative paths are not resolved (use
the string paths argument to enable relative path resolving based on
the current working directory).
* @return the generic type {@code } defined by the implementing class;
* the command itself returns no value and writes its result to the
* standard output; see class level parameter comments for more
* details
*/
R head(HeadOptions options, long count, java.io.File... files);
/**
* Reads the first {@code count} lines or characters from each of the
specified files and writes them to the standard output. If more than
a single file is specified and the {@code -q} option is not
specified, each file is preceded by a header consisting of the
string {@code "==> XXX <=="} where {@code "XXX"} is the name
of the file.
*
* @param options Options for the head command.
* @param count The first {@code count} lines of each input file are
copied to standard output, starting from 1 (characters instead of
lines if the {@code -c} option is specified). Must be a non-negative
integer or an exception is thrown. If {@code count} is greater than
the number number of lines (characters) in the input, the
application will not error and send the whole file to the output.
* @param paths Pathnames of the input files to be filtered; wildcards * and ? are
supported; relative paths are resolved on the basis of the current
working directory.
* @return the generic type {@code } defined by the implementing class;
* the command itself returns no value and writes its result to the
* standard output; see class level parameter comments for more
* details
*/
R head(HeadOptions options, long count, String... paths);
}
/**
* Options for the "head" command: {@link HeadOption#chars c}, {@link HeadOption#suppressHeaders q}.
*
*
* {@code -c} {@code --chars} The {@code count} argument is in units of characters instead of
lines. Starts from 1 and includes line ending characters.
* {@code -q} {@code --suppressHeaders} Suppresses printing of headers when multiple files are being
examined.
*
*/
public static final HeadOptionSets Options = HeadOptionSets.INSTANCE;
/**
* Singleton {@link HeadFactory factory} instance for the "head" command.
*/
public static final HeadFactory Factory = HeadFactory.INSTANCE;
// no instances
private Head() {
super();
}
}