} operand has
* been called at least once
*/
public boolean isArgsSet() {
return argsIsSet;
}
/**
* Returns true if the {@code --}{@link FindOption#typeDirectory typeDirectory} option
* is set. The option is also known as {@code -}d option.
*
* Description: Consider only directories
*
* @return true if the {@code --typeDirectory} or {@code -d} option is set
*/
public boolean isTypeDirectory() {
return getOptions().isSet(FindOption.typeDirectory);
}
/**
* Returns true if the {@code --}{@link FindOption#typeFile typeFile} option
* is set. The option is also known as {@code -}f option.
*
* Description: Consider only regular files
*
* @return true if the {@code --typeFile} or {@code -f} option is set
*/
public boolean isTypeFile() {
return getOptions().isSet(FindOption.typeFile);
}
/**
* Returns true if the {@code --}{@link FindOption#typeSymlink typeSymlink} option
* is set. The option is also known as {@code -}l option.
*
* Description: Consider only symbolic links
*
* @return true if the {@code --typeSymlink} or {@code -l} option is set
*/
public boolean isTypeSymlink() {
return getOptions().isSet(FindOption.typeSymlink);
}
/**
* Returns true if the {@code --}{@link FindOption#typeOther typeOther} option
* is set. The option is also known as {@code -}x option.
*
* Description: Consider only files that are neither of directory (d),
regular file (f) or symlink (l).
*
* @return true if the {@code --typeOther} or {@code -x} option is set
*/
public boolean isTypeOther() {
return getOptions().isSet(FindOption.typeOther);
}
/**
* Returns true if the {@code --}{@link FindOption#regex regex} option
* is set. The option is also known as {@code -}r option.
*
* Description: Use full regular expression syntax for the patterns specified by the
name operand
(This option is ignored if no name operand is specified).
*
* @return true if the {@code --regex} or {@code -r} option is set
*/
public boolean isRegex() {
return getOptions().isSet(FindOption.regex);
}
/**
* Returns true if the {@code --}{@link FindOption#ignoreCase ignoreCase} option
* is set. The option is also known as {@code -}i option.
*
* Description: Use case insensitive matching when applying the file name pattern
specified by the name operand
(This option is ignored if no name operand is specified).
*
* @return true if the {@code --ignoreCase} or {@code -i} option is set
*/
public boolean isIgnoreCase() {
return getOptions().isSet(FindOption.ignoreCase);
}
/**
* Returns true if the {@code --}{@link FindOption#timeNewer timeNewer} option
* is set. The option is also known as {@code -}n option.
*
* Description: Consider only files that have been created, modified or accessed
after or at the time specified by the time operand (the default)
(This option is ignored if no time operand is specified).
*
* @return true if the {@code --timeNewer} or {@code -n} option is set
*/
public boolean isTimeNewer() {
return getOptions().isSet(FindOption.timeNewer);
}
/**
* Returns true if the {@code --}{@link FindOption#timeOlder timeOlder} option
* is set. The option is also known as {@code -}o option.
*
* Description: Consider only files that have been created, modified or accessed
before or at the time specified by the time operand
(This option is ignored if no time operand is specified).
*
* @return true if the {@code --timeOlder} or {@code -o} option is set
*/
public boolean isTimeOlder() {
return getOptions().isSet(FindOption.timeOlder);
}
/**
* Returns true if the {@code --}{@link FindOption#timeCreate timeCreate} option
* is set. The option is also known as {@code -}c option.
*
* Description: The time operand refers to the creation time of the file
(This option is ignored if no time operand is specified).
*
* @return true if the {@code --timeCreate} or {@code -c} option is set
*/
public boolean isTimeCreate() {
return getOptions().isSet(FindOption.timeCreate);
}
/**
* Returns true if the {@code --}{@link FindOption#timeAccess timeAccess} option
* is set. The option is also known as {@code -}a option.
*
* Description: The time operand refers to the last access time of the file
(This option is ignored if no time operand is specified).
*
* @return true if the {@code --timeAccess} or {@code -a} option is set
*/
public boolean isTimeAccess() {
return getOptions().isSet(FindOption.timeAccess);
}
/**
* Returns true if the {@code --}{@link FindOption#timeModified timeModified} option
* is set. The option is also known as {@code -}m option.
*
* Description: The time operand refers to the last modification time of the file
(the default)
(This option is ignored if no time operand is specified).
*
* @return true if the {@code --timeModified} or {@code -m} option is set
*/
public boolean isTimeModified() {
return getOptions().isSet(FindOption.timeModified);
}
/**
* Returns true if the {@code --}{@link FindOption#print0 print0} option
* is set. The option is also known as {@code -}z option.
*
* Description: Print the full file name on the standard output, followed by a null
character (instead of the newline character used by default). This
allows file names that contain newlines or other types of white
space to be correctly interpreted by programs that process the find
output. This option corresponds to the --delimiter0 option of xargs.
*
* @return true if the {@code --print0} or {@code -z} option is set
*/
public boolean isPrint0() {
return getOptions().isSet(FindOption.print0);
}
@Override
public String toString() {
// ok, we have options or arguments or both
final StringBuilder sb = new StringBuilder();
if (argsIsSet) {
for (String arg : args) {
if (sb.length() > 0) sb.append(' ');
sb.append(arg);
}
} else {
// first the options
if (options.size() > 0) {
sb.append(DefaultOptionSet.toString(options));
}
// operand:
if (pathIsSet) {
if (sb.length() > 0) sb.append(' ');
sb.append("--").append("path");
sb.append(" ").append(toString(getPath()));
}
// operand:
if (nameIsSet) {
if (sb.length() > 0) sb.append(' ');
sb.append("--").append("name");
sb.append(" ").append(toString(getName()));
}
// operand:
if (sizeIsSet) {
if (sb.length() > 0) sb.append(' ');
sb.append("--").append("size");
sb.append(" ").append(toString(getSize()));
}
// operand:
if (timeIsSet) {
if (sb.length() > 0) sb.append(' ');
sb.append("--").append("time");
sb.append(" ").append(toString(getTime()));
}
// operand:
if (argsIsSet) {
if (sb.length() > 0) sb.append(' ');
sb.append("--").append("args");
sb.append(" ").append(toString(getArgs()));
}
}
return sb.toString();
}
private static String toString(Object value) {
if (value != null && value.getClass().isArray()) {
return ArrayUtil.toString(value);
}
return String.valueOf(value);
}
}