Top Description Fields Constructors Methods
org.glassfish.pfl.basic.tools.file

public Class Recognizer

extends Object
implements Action
Class Inheritance
All Implemented Interfaces
org.glassfish.pfl.basic.tools.file.Scanner.Action, org.glassfish.pfl.basic.func.UnaryPredicate, java.util.function.Predicate
Imports
java.io.IOException, java.util.HashMap, .Map

References Deprecated

Scanner.Action is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Recognizes files according to patterns, and performs actions accordingly.

Field Summary

Modifier and TypeField and Description
private Scanner.Action
defaultAction

References Deprecated Scanner.Action is deprecated or references (maybe indirectly) at least one deprecated element.
private final boolean
private final Map<String, Scanner.Action>
private Scanner.Action
shellScriptAction

References Deprecated Scanner.Action is deprecated or references (maybe indirectly) at least one deprecated element.
private final Map<String, Scanner.Action>
private final int

Constructor Summary

AccessConstructor and Description
pack-priv
Recognizer(final int verbose, final boolean dryRun)

Method Summary

Modifier and TypeMethod and Description
public void
addKnownName(final String name, final Scanner.Action action)
References Deprecated Scanner.Action is deprecated or references (maybe indirectly) at least one deprecated element.

public void
addKnownSuffix(final String suffix, final Scanner.Action action)
References Deprecated Scanner.Action is deprecated or references (maybe indirectly) at least one deprecated element.

public void
dump()

public boolean

Returns:

result of matching action.
evaluate
(final FileWrapper
The file to act upon.
file
)

Implements org.glassfish.pfl.basic.func.UnaryPredicate.evaluate.

Apply the action that matches the classification of this file.

public void
setDefaultAction(final Scanner.Action
The default action is nothing else matches.
action
)
References Deprecated Scanner.Action is deprecated or references (maybe indirectly) at least one deprecated element.

This defines the default action.

public void
setShellScriptAction(final Scanner.Action
The action to perform on shell scripts.
action
)
References Deprecated Scanner.Action is deprecated or references (maybe indirectly) at least one deprecated element.

If set, this defines the action taken for text files that start with the patter "#!", which is the standard for all *nix shell scripts.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

defaultActionback to summary
private Scanner.Action defaultAction

References Deprecated

Scanner.Action is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

dryRunback to summary
private final boolean dryRun
nameActionsback to summary
private final Map<String, Scanner.Action> nameActions
shellScriptActionback to summary
private Scanner.Action shellScriptAction

References Deprecated

Scanner.Action is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

suffixActionsback to summary
private final Map<String, Scanner.Action> suffixActions
verboseback to summary
private final int verbose

Constructor Detail

Recognizerback to summary
pack-priv Recognizer(final int verbose, final boolean dryRun)

Method Detail

addKnownNameback to summary
public void addKnownName(final String name, final Scanner.Action action)

References Deprecated

Scanner.Action is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

addKnownSuffixback to summary
public void addKnownSuffix(final String suffix, final Scanner.Action action)

References Deprecated

Scanner.Action is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

dumpback to summary
public void dump()
evaluateback to summary
public boolean evaluate(final FileWrapper file)

Implements org.glassfish.pfl.basic.func.UnaryPredicate.evaluate.

Apply the action that matches the classification of this file. Returns the result of that action.

Parameters
file:FileWrapper

The file to act upon.

Returns:boolean

result of matching action.

Annotations
@Override
setDefaultActionback to summary
public void setDefaultAction(final Scanner.Action action)

References Deprecated

Scanner.Action is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

This defines the default action. The standard default action prints a message identifying the File that was not processed, and returns false. This allows overriding the default action.

Parameters
action:Scanner.Action

The default action is nothing else matches.

setShellScriptActionback to summary
public void setShellScriptAction(final Scanner.Action action)

References Deprecated

Scanner.Action is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

If set, this defines the action taken for text files that start with the patter "#!", which is the standard for all *nix shell scripts. If not set, such files are handled by the default action (if not otherwise handled by name or suffix match.

Parameters
action:Scanner.Action

The action to perform on shell scripts.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override