gov.nasa.pds.krtool
Class KRTool

java.lang.Object
  extended by gov.nasa.pds.krtool.KRTool
All Implemented Interfaces:
KRToolFlags, gov.nasa.pds.tools.flags.ToolsFlags

public class KRTool
extends java.lang.Object
implements KRToolFlags

Main class of the Keyword Report Tool (KRTool). KRTool will report a list of statements that match the user supplied list of keywords.

Author:
mcayanan

Field Summary
 
Fields inherited from interface gov.nasa.pds.krtool.options.KRToolFlags
IGNOREDIR, IGNOREFILE, KEYWORDS, LOCAL, REGEXP, TARGET, WHATIS_IGNOREDIR, WHATIS_IGNOREFILE, WHATIS_KEYWORDS, WHATIS_LOCAL, WHATIS_REGEXP, WHATIS_TARGET
 
Fields inherited from interface gov.nasa.pds.tools.flags.ToolsFlags
ARGNAME, CONFIG, DICT, HELP, LONG, REPORT, SHORT, VERSION, WHATIS_CONFIG, WHATIS_DICT, WHATIS_HELP, WHATIS_REPORT, WHATIS_VERSION
 
Constructor Summary
KRTool()
           
 
Method Summary
 gov.nasa.pds.tools.file.FileList crawl(java.lang.String target, boolean traverse)
          Crawl the given target.
 void doProcessing()
          Method that does the KRTool processing.
 void doQuery(org.apache.commons.cli.CommandLine commandLine)
          Process the options that were found in the command-line.
static void main(java.lang.String[] argv)
           
 gov.nasa.pds.tools.label.Label parse(java.net.URL url)
          Parse the given URL.
 org.apache.commons.cli.CommandLine parseLine(java.lang.String[] argv)
          Parses the command-line.
 void runStatementFinder(java.util.List targets, boolean recurse, java.util.List<java.lang.String> identifiers)
          Find statements in a set of targets, that match the user supplied keywords.
 java.util.Map<java.lang.String,java.util.List<gov.nasa.pds.tools.label.AttributeStatement>> runStatementFinder(java.net.URL url, java.util.List<java.lang.String> identifiers)
          Find statements in a single file, that match the user supplied keywords.
 void showHelp()
          Show the KRTool usage.
 void showVersion()
          Show the version and disclaimer notice.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KRTool

public KRTool()
Method Detail

parseLine

public org.apache.commons.cli.CommandLine parseLine(java.lang.String[] argv)
                                             throws ApplicationException
Parses the command-line.

Parameters:
argv - Arguments given on the command-line.
Returns:
A class representation of the options found on the command-line.
Throws:
ApplicationException - If there was an error in parsing the command-line.

doQuery

public void doQuery(org.apache.commons.cli.CommandLine commandLine)
             throws InvalidOptionException
Process the options that were found in the command-line.

Parameters:
commandLine - An object that holds information about the options that were set on the command-line.
Throws:
InvalidOptionException - If an error occurred while doing the query.

showVersion

public void showVersion()
                 throws java.io.IOException
Show the version and disclaimer notice.

Throws:
java.io.IOException - If the properties file could not be read.

showHelp

public void showHelp()
Show the KRTool usage.


parse

public gov.nasa.pds.tools.label.Label parse(java.net.URL url)
Parse the given URL.

Parameters:
url - The URL to parse.
Returns:
An object representation of the PDS label.

crawl

public gov.nasa.pds.tools.file.FileList crawl(java.lang.String target,
                                              boolean traverse)
                                       throws ApplicationException
Crawl the given target.

Parameters:
target - A file, URL, or directory.
traverse - 'true' to perform directory recursion, 'false' otherwise
Returns:
a FileList object containing a list of files and directories found within the given target.
Throws:
ApplicationException - If there was an error crawling the target.

runStatementFinder

public void runStatementFinder(java.util.List targets,
                               boolean recurse,
                               java.util.List<java.lang.String> identifiers)
                        throws ApplicationException,
                               java.net.MalformedURLException
Find statements in a set of targets, that match the user supplied keywords.

Parameters:
targets - A list of files, URLs, or directories.
recurse - Whether to perform directory recursion on a directory.
identifiers - A list of keywords to find in a PDS label.
Throws:
ApplicationException - If there was an error crawling a target directory.
java.net.MalformedURLException - If a target could not be made into a URL.

runStatementFinder

public java.util.Map<java.lang.String,java.util.List<gov.nasa.pds.tools.label.AttributeStatement>> runStatementFinder(java.net.URL url,
                                                                                                                      java.util.List<java.lang.String> identifiers)
Find statements in a single file, that match the user supplied keywords.

Parameters:
url - URL of the PDS label.
identifiers - a list of keywords to find in the PDS label.
Returns:
a Map containing the statements that match the user supplied keywords.

doProcessing

public void doProcessing()
                  throws ApplicationException,
                         java.net.MalformedURLException
Method that does the KRTool processing.

Throws:
ApplicationException
java.net.MalformedURLException

main

public static void main(java.lang.String[] argv)


Copyright © 2005-2009 Planetary Data System. All Rights Reserved.