Package edu.isi.pegasus.planner.parser
Class TransformationCatalogTextParser
- java.lang.Object
-
- edu.isi.pegasus.planner.parser.TransformationCatalogTextParser
-
public class TransformationCatalogTextParser extends java.lang.Object
Parses the input stream and generates the TransformationStore as output. This parser is able to parse the Transformation Catalog specification in the following formattr example::keg:1.0 { #specify profiles that apply for all the sites for the transformation #in each site entry the profile can be overriden profile env "APP_HOME" "/tmp/karan" profile env "JAVA_HOME" "/bin/java.1.5" site isi { profile env "me" "with" profile condor "more" "test" profile env "JAVA_HOME" "/bin/java.1.6" pfn "/path/to/keg" arch "x86" os "linux" osrelease "fc" osversion "4" type "installed" } site wind { profile env "me" "with" profile condor "more" "test" pfn "/path/to/keg" arch "x86" os "linux" osrelease "fc" osversion "4" type "STAGEABLE" } }
- Version:
- $Revision$
- Author:
- Karan Vahi, Jens Vöckler
- See Also:
TransformationCatalogTextScanner
-
-
Field Summary
Fields Modifier and Type Field Description private LogManager
mLogger
The transformation to the logger used to log messages.private Token
mLookAhead
Stores the look-ahead symbol.private TransformationCatalogTextScanner
mScanner
The access to the lexical scanner is stored here.
-
Constructor Summary
Constructors Constructor Description TransformationCatalogTextParser(java.io.Reader r, LogManager logger)
Initializes the parser with an input stream to read from.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private Profile
getProfile()
Parses a single line and returns a profile.private Profiles
getProfilesForTransformation()
Returns a list of profiles that have to be applied to the entries for all the sites corresponding to a transformation.private java.lang.String
getQuotedValue(java.lang.String key)
Parses a quoted value and strips out the enclosing quotes.private java.lang.String
getSite()
Returns the site transformation for a site, and moves the scanner to hold the nextTransformationCatalogReservedWord
.private java.lang.String
getTransformation()
Returns the transformation name, and moves the scanner to hold the nextTransformationCatalogReservedWord
.private TransformationCatalogEntry
getTransformationCatalogEntry(java.lang.String transformation, Profiles profiles, boolean modifyFileURL)
Constructs a single transformation catalog entry and returns it.static void
main(java.lang.String[] args)
Test function.java.lang.String
niceString(java.lang.String input)
Remove potential leading and trainling quotes from a string.TransformationStore
parse(boolean modifyFileURL)
Parses the complete input stream, into the PoolConfig data object that holds the contents of all the sites referred to in the stream.
-
-
-
Field Detail
-
mScanner
private TransformationCatalogTextScanner mScanner
The access to the lexical scanner is stored here.
-
mLookAhead
private Token mLookAhead
Stores the look-ahead symbol.
-
mLogger
private LogManager mLogger
The transformation to the logger used to log messages.
-
-
Constructor Detail
-
TransformationCatalogTextParser
public TransformationCatalogTextParser(java.io.Reader r, LogManager logger) throws java.io.IOException, ScannerException
Initializes the parser with an input stream to read from.- Parameters:
r
- is the stream opened for reading.logger
- the transformation to the logger.- Throws:
java.io.IOException
ScannerException
-
-
Method Detail
-
parse
public TransformationStore parse(boolean modifyFileURL) throws java.io.IOException, ScannerException
Parses the complete input stream, into the PoolConfig data object that holds the contents of all the sites referred to in the stream.- Parameters:
modifyFileURL
- Boolean indicating whether to modify the file URL or not- Returns:
- TransformationStore
- Throws:
java.io.IOException
ScannerException
java.lang.Exception
- See Also:
org.griphyn.cPlanner.classes.PoolConfig
-
niceString
public java.lang.String niceString(java.lang.String input)
Remove potential leading and trainling quotes from a string.- Parameters:
input
- is a string which may have leading and trailing quotes- Returns:
- a string that is either identical to the input, or a substring thereof.
-
getTransformationCatalogEntry
private TransformationCatalogEntry getTransformationCatalogEntry(java.lang.String transformation, Profiles profiles, boolean modifyFileURL) throws java.io.IOException, ScannerException
Constructs a single transformation catalog entry and returns it.- Parameters:
entry
- theTransformationCatalogEntry
object that is to be populated.
profiles
- the profiles that apply to all the entriesmodifyFileURL
- Boolean indicating whether to modify the file URL or not- Returns:
- the transformation catalog entry object.
- Throws:
even
- more mysteryjava.io.IOException
ScannerException
-
getTransformation
private java.lang.String getTransformation() throws java.io.IOException, ScannerException
Returns the transformation name, and moves the scanner to hold the nextTransformationCatalogReservedWord
.- Returns:
- the transformation name
- Throws:
plenty
java.io.IOException
ScannerException
-
getSite
private java.lang.String getSite() throws java.io.IOException, ScannerException
Returns the site transformation for a site, and moves the scanner to hold the nextTransformationCatalogReservedWord
.- Returns:
- the transformation name
- Throws:
plenty
java.io.IOException
ScannerException
-
getProfilesForTransformation
private Profiles getProfilesForTransformation() throws java.io.IOException, ScannerException
Returns a list of profiles that have to be applied to the entries for all the sites corresponding to a transformation.- Returns:
- Profiles specified
- Throws:
java.io.IOException
ScannerException
-
getProfile
private Profile getProfile() throws ScannerException, java.io.IOException
Parses a single line and returns a profile.- Returns:
- Profile
- Throws:
ScannerException
java.io.IOException
-
getQuotedValue
private java.lang.String getQuotedValue(java.lang.String key) throws java.io.IOException
Parses a quoted value and strips out the enclosing quotes.- Parameters:
key
- the key for which we need to associated the quoted value- Returns:
- quoted value.
- Throws:
java.io.IOException
-
main
public static void main(java.lang.String[] args) throws ScannerException
Test function.- Parameters:
args
-- Throws:
ScannerException
-
-