org.glite.wmsui.guij
Class ExprChecker

java.lang.Object
  extended byorg.glite.wmsui.guij.ExprChecker

public class ExprChecker
extends java.lang.Object

Implementation of the ExprChecker class. This class provides some parsing methods. It is used to check the correctness of a file or string classad representation and to create a JobAd containing attributes with corresponding values.

Version:
1.0
Author:
Giuseppe Avellino

Constructor Summary
ExprChecker()
           
 
Method Summary
static java.lang.String checkResult(java.lang.String result, java.lang.String[] attributesToCheck)
          Checks a String representing a job.
static java.lang.String checkResult(java.lang.String result, java.lang.String[] attributesToCheck, boolean localAccess)
          Checks a String representing a job.
 java.lang.String getErrorMsg()
          Returns all parsing errors found during last parse operation.
 java.lang.String getWarningMsg()
           
 org.glite.jdl.JobAd parse(java.io.File file)
          Parses a file and creates a JobAd containing the found attributes.
 org.glite.jdl.JobAd parse(java.io.File file, boolean localAccess)
          Parses a file and creates a JobAd containing the found attributes.
 org.glite.jdl.JobAd parse(java.io.File file, boolean localAccess, int type)
          Parses a file and creates a JobAd containing the found attributes.
 org.glite.jdl.JobAd parse(java.io.File file, boolean localAccess, org.glite.jdl.JobAd jobAdAttributeToAdd)
          Parses a file and creates a JobAd containing the found attributes.
 org.glite.jdl.JobAd parse(java.lang.String inputString)
          Parses an input string and creates a JobAd containing the found attributes.
 org.glite.jdl.JobAd parse(java.lang.String inputString, boolean localAccess, java.lang.String defaultRequirements, java.lang.String defaultRank)
          Parses an input string and creates a JobAd containing the found attributes.
 org.glite.jdl.JobAd parseLineByLine(java.lang.String inputString)
          Parses an input String representing a job.
 java.lang.String rTrim(java.lang.String text)
          Returns right trimmed input String
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExprChecker

public ExprChecker()
Method Detail

parse

public org.glite.jdl.JobAd parse(java.io.File file)
                          throws java.text.ParseException
Parses a file and creates a JobAd containing the found attributes. Local check will be done.

Parameters:
file - the file to parse.
Returns:
the jobAd containing attributes names and values, if the input string represent a correct jdl file and contains at least one attribute; a null jobAd otherwise.
Throws:
java.text.ParseException

parse

public org.glite.jdl.JobAd parse(java.io.File file,
                                 boolean localAccess)
                          throws java.text.ParseException
Parses a file and creates a JobAd containing the found attributes. Local check will be done depending on the value of localAccess parameter.

Parameters:
file - the file to parse.
localAccess - a boolean value indicating if local check must be done.
Returns:
the jobAd containing attributes names and values, if the input string represent a correct jdl file and contains at least one attribute; a null jobAd otherwise.
Throws:
java.text.ParseException

parse

public org.glite.jdl.JobAd parse(java.io.File file,
                                 boolean localAccess,
                                 int type)
                          throws java.text.ParseException
Parses a file and creates a JobAd containing the found attributes. Local check will be done depending on the value of localAccess parameter.

Parameters:
file - the file to parse.
localAccess - a boolean value indicating if local check must be done.
type - the type of the file to parse: normal or XML
Returns:
the jobAd containing attributes names and values, if the input string represent a correct jdl file and contains at least one attribute; a null jobAd otherwise.
Throws:
java.text.ParseException

parse

public org.glite.jdl.JobAd parse(java.io.File file,
                                 boolean localAccess,
                                 org.glite.jdl.JobAd jobAdAttributeToAdd)
                          throws java.text.ParseException
Parses a file and creates a JobAd containing the found attributes. It also add all the attributes contained in the JobAd passed as argument if they are not already present. Local check will be done depending on the value of localAccess parameter.

Parameters:
file - the file to parse.
localAccess - a boolean value indicating if local check must be done.
Returns:
the jobAd containing attributes names and values, if the input string represent a correct jdl file and contains at least one attribute; a null jobAd otherwise.
Throws:
java.text.ParseException

parse

public org.glite.jdl.JobAd parse(java.lang.String inputString)
Parses an input string and creates a JobAd containing the found attributes. Local check will be done.

Parameters:
inputString - the input string to parse.
Returns:
the jobAd containing attributes names and values, if the input string represent a correct jdl file and contains at least one attribute; a null jobAd otherwise.

parse

public org.glite.jdl.JobAd parse(java.lang.String inputString,
                                 boolean localAccess,
                                 java.lang.String defaultRequirements,
                                 java.lang.String defaultRank)
Parses an input string and creates a JobAd containing the found attributes. Local check will be done depending on the value of localAccess parameter.

Parameters:
inputString - the input string to parse.
localAccess - a boolean value indicating if local check must be done.
defaultRequirements - requirements attribute default value.
defaultRank - rank attribute default value.
Returns:
the jobAd containing attributes names and values, if the input string represent a correct jdl file and contains at least one attribute; a null jobAd otherwise.

getErrorMsg

public java.lang.String getErrorMsg()
Returns all parsing errors found during last parse operation. Parsing errors are syntax errors or attribute duplications.

Returns:
a string containing all parsing errors found during last parse operation.

getWarningMsg

public java.lang.String getWarningMsg()

parseLineByLine

public org.glite.jdl.JobAd parseLineByLine(java.lang.String inputString)
Parses an input String representing a job. The check of the String is made line by line in order to get all the present syntax errors or attribute duplications

Parameters:
inputString - the String to parse
Returns:
the JobAd representation of the job or null in case of error

rTrim

public java.lang.String rTrim(java.lang.String text)
Returns right trimmed input String

Parameters:
text - the input String to trim
Returns:
a right trimmed String

checkResult

public static java.lang.String checkResult(java.lang.String result,
                                           java.lang.String[] attributesToCheck)
Checks a String representing a job. Only the attributes contained in the String array will be checked.

Parameters:
result - String to check
attributesToCheck - the attributes array to check
Returns:
a String containing error messages, if any

checkResult

public static java.lang.String checkResult(java.lang.String result,
                                           java.lang.String[] attributesToCheck,
                                           boolean localAccess)
Checks a String representing a job. Only the attributes contained in the String array will be checked.

Parameters:
result - String to check
attributesToCheck - the attributes array to check
localAccess - declares if the local access check has to be made or not
Returns:
a String containing error messages, if any