Package jason.stdlib
Class list_files
java.lang.Object
jason.asSemantics.DefaultInternalAction
jason.stdlib.list_files
- All Implemented Interfaces:
InternalAction
,java.io.Serializable
@Manual(literal=".list_files(path,pattern)", hint="lists files of a folder", argsHint={"path to be listed","a regular expression file names should match [optional]"}, argsType={"string","string"}, examples={".list_files(\"./\",R): unifies R with the list of all files in the working directory and subdirectories",".list_files(\"./src/agt\",\".*.asl\",L): unifies L with the list of all \'.asl\' files in the directory and subdirectories",".list_files(\"/media/movies\",\".*[(][0-9]{4}[)].*\",L): unifies L with the list of all files in \'/media/movies\' in which the name contains 4 numbers between parenthesis."}, seeAlso={"jason.stdlib.create_agent","jason.stdlib.save_agent"}) public class list_files extends DefaultInternalAction
Internal action: .list_files
.
Description: lists files of a folder
Parameters:
- + path (string): path to be listed.
- + pattern (string -- optional): a regular expression file names should match.
Examples:
-
.list_files("./",R)
: unify in R the list of all files in the working directory and its subdirectories. -
.list_files("./src/agt",".*.asl",L)
: unify in L the list of all '.asl' files in the directory '.src/agt/' and its subdirectories (e.g. [./src/agt/bob.asl, .src/agt/alice.asl]) -
.list_files("/media/movies",".*[(][0-9]{4}[)].*",L)
: unify in L the list of all files in '/media/movies' in which the name contains 4 numbers between parenthesis.
- See Also:
create_agent
,save_agent
, Serialized Form
-
Constructor Summary
Constructors Constructor Description list_files()
-
Method Summary
Modifier and Type Method Description protected void
checkArguments(Term[] args)
java.lang.Object
execute(TransitionSystem ts, Unifier un, Term[] args)
Executes the internal action.protected java.lang.String
getFolder(Term[] args)
int
getMaxArgs()
int
getMinArgs()
protected java.lang.String
getPattern(Term[] args)
(package private) void
listFiles(java.lang.String pattern, java.io.File folder, java.util.List<Term> fileList)
Methods inherited from class jason.asSemantics.DefaultInternalAction
canBeUsedInContext, destroy, prepareArguments, suspendIntention
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
list_files
public list_files()
-
-
Method Details
-
getMinArgs
public int getMinArgs()- Overrides:
getMinArgs
in classDefaultInternalAction
-
getMaxArgs
public int getMaxArgs()- Overrides:
getMaxArgs
in classDefaultInternalAction
-
checkArguments
- Overrides:
checkArguments
in classDefaultInternalAction
- Throws:
JasonException
-
execute
public java.lang.Object execute(TransitionSystem ts, Unifier un, Term[] args) throws java.lang.ExceptionDescription copied from interface:InternalAction
Executes the internal action. It should return a Boolean or an Iterator. A true boolean return means that the IA was successfully executed. An Iterator result means that there is more than one answer for this IA (e.g. see member internal action). - Specified by:
execute
in interfaceInternalAction
- Overrides:
execute
in classDefaultInternalAction
- Throws:
java.lang.Exception
-
getFolder
- Throws:
JasonException
-
getPattern
- Throws:
JasonException
-
listFiles
-