org.glite.jdl
Class JobAd

java.lang.Object
  extended by org.glite.jdl.Ad
      extended by org.glite.jdl.JobAd
Direct Known Subclasses:
ParametricAd

public class JobAd
extends Ad

Provides a representation of the job description in the JDL language and the functions for building and manipulating it. Basically the JDL is the Condor ClassAd language, so it is legitimate the direct use of the Condor API library for creating, modifying, deleting a job description. However the JobAd class extends the ClassAd class of the Condor ClassAd library additionally providing some helper methods that ease the construction of job descriptions being fully compliant to WP1 WMS specification.

Version:
0.1
Author:
Alessandro Maraschini

Field Summary
 
Fields inherited from class org.glite.jdl.Ad
jobAd, TYPE_AD, TYPE_BOOL, TYPE_EXPRESSION, TYPE_INTEGER, TYPE_REAL, TYPE_STRING, TYPE_UNKNOWN
 
Constructor Summary
JobAd()
          Default Constructor Instantiates an empty JobAd object
JobAd(condor.classad.RecordExpr ad)
          Instantiates a JobAd object from the given recordExpr
JobAd(java.lang.String ad)
          Constructor from String: parse the string and create a JobAd
 
Method Summary
 void addAttribute(java.lang.String attrName, Ad attrValue)
          Allow adding a value to an already set attribute of the JobAd instance (i.e.
 void addAttribute(java.lang.String attrName, boolean attrValue)
          Allow adding a value to an already set attribute of the JobAd instance (i.e.
 void addAttribute(java.lang.String attrName, double attrValue)
          Allow adding a value to an already set attribute of the JobAd instance (i.e.
 void addAttribute(java.lang.String attrName, int attrValue)
          Allow adding a value to an already set attribute of the JobAd instance (i.e.
 void addAttribute(java.lang.String attrName, java.lang.String attrValue)
          Allow adding a value to an already set attribute of the JobAd instance (i.e.
 void checkAll()
          Check the JobAd instance for both syntax and semanthic errors.
 void checkAll(java.lang.String[] attributes)
          Check the JobAd instance for both syntax and semanthic errors
 void clear()
          Reset the JobAd Instance.
 java.lang.Object clone()
          Copy all the attributes of the instance into a new JobAd
 JobAd copy(condor.classad.RecordExpr source)
          Make a deep copy of the JobAd instance
 condor.classad.RecordExpr copyAd()
          Copy the attributes of the classAd into a new Record Expression
 void delAttribute(java.lang.String attrName)
          Delete an Attribute.
 java.lang.String getAttributeExpr(java.lang.String attrName)
          Retreive the value of the specified Expression attribute as a string
 boolean getBoolean(java.lang.String attrName)
          Retrieve the value of the specified attribute, only if it is of non-list type
 double getDouble(java.lang.String attrName)
          Retrieve the value of the specified attribute, only if it is of non-list type
 int getInt(java.lang.String attrName)
          Retrieve the value of the specified attribute, only if it is of non-list type
 JobAd getJobAdValue(java.lang.String attrName)
          Retreive the JobAd value of the specified attribute
 java.lang.String getString(java.lang.String attrName)
          Retrieve the value of the specified attribute, only if it is of non-list type
 boolean hasAttribute(java.lang.String attrName, java.lang.String attrValue)
          Check wheater an atribute has the value between its values.
 boolean hasAttribute(java.lang.String attrName, java.lang.String attrValue, boolean unsensitive)
          Check wheater an atribute has the value between its values.
 void setAttribute(java.lang.String attrName, boolean attrValue)
          Add The specified String Attribute to the jdl istance
 void setAttribute(java.lang.String attrName, double attrValue)
          Add The specified String Attribute to the jdl istance
 void setAttribute(java.lang.String attrName, condor.classad.Expr attrValue)
          Add The specified Expression Attribute to the jdl istance
 void setAttribute(java.lang.String attrName, int attrValue)
          Add The specified Integer Attribute to the jdl istance
 void setAttribute(java.lang.String attrName, java.lang.String attrValue)
          Add The specified String Attribute to the jdl istance
 void setAttributeExpr(java.lang.String attrName, java.lang.String attrValue)
          Add The specified Expression Attribute to the jdl istance
 void setDefaultRank(java.lang.String attrValue)
          Rank default attribute initialisation
 void setDefaultRequirements(java.lang.String attrValue)
          Requirements default attribute initialisation
 void setLocalAccess(boolean lookInto)
          If JobAd is used inside an applet, it is impossible to look into the local hard-disk by default this parameter is set to TRUE
 void setSchema(JobAdSchema schema)
          Set the JobAd checking attributes utilised schema (Default Schema: Glue)
 void toFile(java.lang.String filePath)
          Print the JobAd instance into the specified file, with its multi-lines representation
 java.lang.String toLines()
          Convert the JobAd Instance into its String representation, one line per attribute, multi line for listed attribute active This method is the same as toString ( true , true )
 java.lang.String toString()
          Convert the JobAd Instance into a sinlge-line String representation
 java.lang.String toString(boolean multiLines, boolean multiLists)
          Convert the JobAd Instance into its String representation, one line per attribute, multi line for listed attribute active
 java.lang.String toSubmissionString()
          Perform a check over the JobAd instance and if possible convert it into its String representation as it would be ready for a submission
 
Methods inherited from class org.glite.jdl.Ad
appendValue, attributes, copy, fromFile, fromRecord, fromString, getAd, getAdValue, getBooleanValue, getConstant, getDoubleValue, getIntValue, getStringValue, getType, getValue, hasAttribute, isSet, lookup, setAttribute, size
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JobAd

public JobAd()
Default Constructor Instantiates an empty JobAd object


JobAd

public JobAd(java.lang.String ad)
      throws java.text.ParseException,
             JobAdException
Constructor from String: parse the string and create a JobAd

Parameters:
ad - the JDL string to be parsed
Throws:
java.text.ParseException
JobAdException

JobAd

public JobAd(condor.classad.RecordExpr ad)
      throws JobAdException
Instantiates a JobAd object from the given recordExpr

Parameters:
ad - classAd Expression representing the Ad
Throws:
java.text.ParseException - The Classad has JDL syntax error. Unable to build a valid Ad
JobAdException - One or more attributes contain syntax error(s)
Method Detail

copy

public JobAd copy(condor.classad.RecordExpr source)
           throws JobAdException
Make a deep copy of the JobAd instance

Parameters:
source - the expression to copy from
Throws:
JobAdException

clone

public java.lang.Object clone()
Copy all the attributes of the instance into a new JobAd

Overrides:
clone in class Ad
Returns:
a new JobAd with a copy of all the attributes contained in the current JobAd instance

copyAd

public condor.classad.RecordExpr copyAd()
Copy the attributes of the classAd into a new Record Expression

Returns:
the condor Excpression representing the Ad instance

hasAttribute

public boolean hasAttribute(java.lang.String attrName,
                            java.lang.String attrValue)
Check wheater an atribute has the value between its values. The search is

Parameters:
attrName - the name of the attribute to be checked
attrValue - the String value to search for. The case of the seek is unsensitive
Returns:
true if the specified value is present, false otherwise (also when the attribute is no set)

hasAttribute

public boolean hasAttribute(java.lang.String attrName,
                            java.lang.String attrValue,
                            boolean unsensitive)
Check wheater an atribute has the value between its values. The search is

Parameters:
attrName - the name of the attribute to be checked
attrValue - the String value to search for
determine - wheater the case of the value should be sensitive or unsensitive
Returns:
true if the specified value is present, false otherwise (also when the attribute is no set)

toLines

public java.lang.String toLines()
Convert the JobAd Instance into its String representation, one line per attribute, multi line for listed attribute active This method is the same as toString ( true , true )

Returns:
The JobAd representation into multi line
See Also:
toSubmissionString(), toString()

toString

public java.lang.String toString(boolean multiLines,
                                 boolean multiLists)
Convert the JobAd Instance into its String representation, one line per attribute, multi line for listed attribute active

Overrides:
toString in class Ad
Parameters:
multiLines - one-attribute per line representation enablng
multiLists - list attributes splitted into multi line representation enablng
See Also:
toSubmissionString(), toString()

toSubmissionString

public java.lang.String toSubmissionString()
                                    throws JobAdException
Perform a check over the JobAd instance and if possible convert it into its String representation as it would be ready for a submission

Throws:
JobAdException - - one or more values do not match with jobad semantic rule
See Also:
toString(), toLines()

toString

public java.lang.String toString()
Convert the JobAd Instance into a sinlge-line String representation

Overrides:
toString in class Ad
See Also:
toSubmissionString(), toLines()

toFile

public void toFile(java.lang.String filePath)
            throws java.lang.Exception
Print the JobAd instance into the specified file, with its multi-lines representation

Parameters:
filePath - where to write the JobAd
Throws:
java.io.IOException - - if unable to write the specified file
java.lang.Exception
See Also:
toLines()

setLocalAccess

public void setLocalAccess(boolean lookInto)
If JobAd is used inside an applet, it is impossible to look into the local hard-disk by default this parameter is set to TRUE

Parameters:
lookInto - allow all the check methods to access to the local hard disk (true) or skip the check (false)

setAttribute

public void setAttribute(java.lang.String attrName,
                         condor.classad.Expr attrValue)
                  throws javax.naming.directory.InvalidAttributeValueException,
                         java.lang.IllegalArgumentException
Add The specified Expression Attribute to the jdl istance

Overrides:
setAttribute in class Ad
Parameters:
attrName - - The Name of the attribute to be added
attrValue - - The Expression of the value to be added
Throws:
java.lang.IllegalArgumentException - The type of value is not allowed for the specified attribute name
javax.naming.directory.InvalidAttributeValueException - The value has not the right format for the specified attribute

setAttributeExpr

public void setAttributeExpr(java.lang.String attrName,
                             java.lang.String attrValue)
                      throws java.lang.IllegalArgumentException,
                             javax.naming.directory.InvalidAttributeValueException
Add The specified Expression Attribute to the jdl istance

Parameters:
attrName - - The Name of the attribute to be added
attrValue - - The value of the attribute to be added
Throws:
java.lang.IllegalArgumentException - - The type of value is not allowed for the specified attribute name
javax.naming.directory.InvalidAttributeValueException - - the value has not the right format for the specifiedattribute

setAttribute

public void setAttribute(java.lang.String attrName,
                         int attrValue)
                  throws java.lang.IllegalArgumentException,
                         javax.naming.directory.InvalidAttributeValueException
Add The specified Integer Attribute to the jdl istance

Overrides:
setAttribute in class Ad
Parameters:
attrName - - The Name of the attribute to be added
attrValue - - The value of the attribute to be added
Throws:
java.lang.IllegalArgumentException - - The type of value is not allowed for the specified attribute name
javax.naming.directory.InvalidAttributeValueException - - The specified value is out of limits for the specified attribute

setAttribute

public void setAttribute(java.lang.String attrName,
                         java.lang.String attrValue)
                  throws java.lang.IllegalArgumentException,
                         javax.naming.directory.InvalidAttributeValueException
Add The specified String Attribute to the jdl istance

Overrides:
setAttribute in class Ad
Parameters:
attrName - - The Name of the attribute to be added
attrValue - - The value of the attribute to be added
Throws:
java.lang.IllegalArgumentException - - The type of value is not allowed for the specified attribute name
javax.naming.directory.InvalidAttributeValueException - - the value has not the right format for the specified attribute

setAttribute

public void setAttribute(java.lang.String attrName,
                         double attrValue)
                  throws java.lang.IllegalArgumentException,
                         javax.naming.directory.InvalidAttributeValueException
Add The specified String Attribute to the jdl istance

Overrides:
setAttribute in class Ad
Parameters:
attrName - - The Name of the attribute to be added
attrValue - - The value of the attribute to be added
Throws:
IllegalArgumentException- - The attribute attrName had been
javax.naming.directory.InvalidAttributeValueException - - the value is out of limits for the specified attribute
java.lang.IllegalArgumentException

setAttribute

public void setAttribute(java.lang.String attrName,
                         boolean attrValue)
                  throws java.lang.IllegalArgumentException,
                         javax.naming.directory.InvalidAttributeValueException
Add The specified String Attribute to the jdl istance

Overrides:
setAttribute in class Ad
Parameters:
attrName - - The Name of the attribute to be added
attrValue - - The value of the attribute to be added
Throws:
IllegalArgumentException- - The attribute attrName had been already set
javax.naming.directory.InvalidAttributeValueException - - A value has not the right type for an attribute
java.lang.IllegalArgumentException

addAttribute

public void addAttribute(java.lang.String attrName,
                         Ad attrValue)
                  throws java.lang.IllegalArgumentException,
                         javax.naming.directory.InvalidAttributeValueException
Allow adding a value to an already set attribute of the JobAd instance (i.e. it transforms it in a list attribute). if used on a non-set attribute the corresponding setAttribute method is automatically called.

Overrides:
addAttribute in class Ad
Parameters:
attrName - a String representing the attribute name
attrValue - - The value of the attribute to be added
Throws:
IllegalArgumentException- - The specified value is not allowed for the attribute
javax.naming.directory.InvalidAttributeValueException - - A value has not the right type for an attribute
java.lang.IllegalArgumentException

addAttribute

public void addAttribute(java.lang.String attrName,
                         int attrValue)
                  throws java.lang.IllegalArgumentException,
                         javax.naming.directory.InvalidAttributeValueException
Allow adding a value to an already set attribute of the JobAd instance (i.e. it transforms it in a list attribute). if used on a non-set attribute the corresponding setAttribute method is automatically called.

Overrides:
addAttribute in class Ad
Parameters:
attrName - a String representing the attribute name
attrValue - - The value of the attribute to be added
Throws:
IllegalArgumentException- - The specified value is not allowed for the attribute
javax.naming.directory.InvalidAttributeValueException - - A value has not the right type for an attribute
java.lang.IllegalArgumentException

addAttribute

public void addAttribute(java.lang.String attrName,
                         double attrValue)
                  throws java.lang.IllegalArgumentException,
                         javax.naming.directory.InvalidAttributeValueException
Allow adding a value to an already set attribute of the JobAd instance (i.e. it transforms it in a list attribute). if used on a non-set attribute the corresponding setAttribute method is automatically called.

Overrides:
addAttribute in class Ad
Parameters:
attrName - a String representing the attribute name
attrValue - - The value of the attribute to be added
Throws:
IllegalArgumentException- - The specified value is not allowed for the attribute
javax.naming.directory.InvalidAttributeValueException - - the has not the right format for the attribute
java.lang.IllegalArgumentException

addAttribute

public void addAttribute(java.lang.String attrName,
                         boolean attrValue)
                  throws java.lang.IllegalArgumentException,
                         javax.naming.directory.InvalidAttributeValueException
Allow adding a value to an already set attribute of the JobAd instance (i.e. it transforms it in a list attribute). if used on a non-set attribute the corresponding setAttribute method is automatically called.

Overrides:
addAttribute in class Ad
Parameters:
attrName - a String representing the attribute name
attrValue - - The value of the attribute to be added
Throws:
IllegalArgumentException- - The specified value is not allowed for the attribute
javax.naming.directory.InvalidAttributeValueException - - the value has not the right format for the attribute
java.lang.IllegalArgumentException

addAttribute

public void addAttribute(java.lang.String attrName,
                         java.lang.String attrValue)
                  throws java.lang.IllegalArgumentException,
                         javax.naming.directory.InvalidAttributeValueException
Allow adding a value to an already set attribute of the JobAd instance (i.e. it transforms it in a list attribute). if used on a non-set attribute the corresponding setAttribute method is automatically called.

Overrides:
addAttribute in class Ad
Parameters:
attrName - a String representing the attribute name
attrValue - - The value of the attribute to be added
Throws:
java.lang.IllegalArgumentException - The specified type is not allowed for the attribute value
javax.naming.directory.InvalidAttributeValueException - The value has not the right format for the attribute

getAttributeExpr

public java.lang.String getAttributeExpr(java.lang.String attrName)
                                  throws java.lang.Exception
Retreive the value of the specified Expression attribute as a string

Parameters:
attrName - The name of the attribute name to be retrieved
Returns:
the String representng the value of the specified attribute
Throws:
javax.naming.directory.InvalidAttributeValueException - - Not an Expression value is allowed for the specified attribute
java.lang.NoSuchFieldException - - The attribute is not present in the JobAd
java.lang.Exception

getJobAdValue

public JobAd getJobAdValue(java.lang.String attrName)
                    throws java.lang.NoSuchFieldException,
                           java.lang.IllegalArgumentException,
                           JobAdException
Retreive the JobAd value of the specified attribute

Parameters:
attrName - The name of the attribute name to be retrieved
Returns:
a Vector cantaining the values listed in the specified attribute , (1-size Vector if the attribute has a single value)
Throws:
nvalidAttributeValueException - The specified attribute is of list type
java.lang.IllegalArgumentException - - The type of retrieved value is not allowed for the specified attribute name
java.lang.NoSuchFieldException - - The requested attribute has not been set yet
JobAdException

getString

public java.lang.String getString(java.lang.String attrName)
                           throws java.lang.NoSuchFieldException,
                                  java.lang.IllegalArgumentException,
                                  javax.naming.directory.InvalidAttributeValueException
Retrieve the value of the specified attribute, only if it is of non-list type

Parameters:
attrName - The name of the attribute to be retrieved
Returns:
the value of the specified aqttribute as in the JobAd
Throws:
nvalidAttributeValueException - The specified attribute is of list type
java.lang.IllegalArgumentException - - The type of retrieved value is not allowed for the specified attribute name
java.lang.NoSuchFieldException - - The requested attribute has not been set yet
javax.naming.directory.InvalidAttributeValueException
See Also:
Ad.getStringValue(java.lang.String)

getInt

public int getInt(java.lang.String attrName)
           throws java.lang.NoSuchFieldException,
                  java.lang.IllegalArgumentException,
                  javax.naming.directory.InvalidAttributeValueException
Retrieve the value of the specified attribute, only if it is of non-list type

Parameters:
attrName - The name of the attribute to be retrieved
Returns:
the int value found inside the JobAd
Throws:
javax.naming.directory.InvalidAttributeValueException - The specified attribute is of list type
java.lang.IllegalArgumentException - - The type of retrieved value is not allowed for the specified attribute name
java.lang.NoSuchFieldException - - The requested attribute has not been set yet
See Also:
Ad.getIntValue(java.lang.String)

getBoolean

public boolean getBoolean(java.lang.String attrName)
                   throws java.lang.NoSuchFieldException,
                          java.lang.IllegalArgumentException,
                          javax.naming.directory.InvalidAttributeValueException
Retrieve the value of the specified attribute, only if it is of non-list type

Parameters:
attrName - The name of the attribute to be retrieved
Returns:
the boolean value found inside the JobAd
Throws:
javax.naming.directory.InvalidAttributeValueException - The specified attribute is of list type
java.lang.IllegalArgumentException - - The type of retrieved value is not allowed for the specified attribute name
java.lang.NoSuchFieldException - - The requested attribute has not been set yet
See Also:
Ad.getBooleanValue(java.lang.String)

getDouble

public double getDouble(java.lang.String attrName)
                 throws java.lang.NoSuchFieldException,
                        java.lang.IllegalArgumentException,
                        javax.naming.directory.InvalidAttributeValueException
Retrieve the value of the specified attribute, only if it is of non-list type

Parameters:
attrName - The name of the attribute to be retrieved
Returns:
the double value of the specified aqttribute as in the JobAd
Throws:
javax.naming.directory.InvalidAttributeValueException - The specified attribute is of list type
java.lang.IllegalArgumentException - - The type of retrieved value is not allowed for the specified attribute name
java.lang.NoSuchFieldException - - The requested attribute has not been set yet
See Also:
Ad.getDoubleValue(java.lang.String)

delAttribute

public void delAttribute(java.lang.String attrName)
                  throws java.lang.NoSuchFieldException
Delete an Attribute. It fails if the attribute doesn't exist

Overrides:
delAttribute in class Ad
Parameters:
attrName - The name of the attibute to be deleted
Throws:
java.lang.NoSuchFieldException - - The attribute has not been set yet

clear

public void clear()
Reset the JobAd Instance. All the previous existing attributes will be deleted

Overrides:
clear in class Ad

checkAll

public void checkAll()
              throws JobAdException
Check the JobAd instance for both syntax and semanthic errors. all attribute will be checked

Throws:
java.lang.IllegalArgumentException - - A value is not of the right type/format/value for an attribute name in the JobAd
java.lang.NoSuchFieldException - - Unable to find a JobAd mandatory attribute/value
JobAdException - - one or more values do not match with jobad semantic rule
See Also:
checkAll( String[] )

checkAll

public void checkAll(java.lang.String[] attributes)
              throws JobAdException
Check the JobAd instance for both syntax and semanthic errors

Parameters:
attributes - specify attributes to be checked
Throws:
java.lang.IllegalArgumentException - - A value is not of the right type/format/value for an attribute name in the JobAd
java.lang.NoSuchFieldException - - Unable to find a JobAd mandatory attribute/value
JobAdException - - one or more values do not match with jobad semantic rule
See Also:
checkAll( )

setSchema

public void setSchema(JobAdSchema schema)
Set the JobAd checking attributes utilised schema (Default Schema: Glue)


setDefaultRank

public void setDefaultRank(java.lang.String attrValue)
Rank default attribute initialisation


setDefaultRequirements

public void setDefaultRequirements(java.lang.String attrValue)
Requirements default attribute initialisation