cds.simbad
Class SesameCommand

java.lang.Object
  extended bycds.simbad.SesameCommand

public class SesameCommand
extends java.lang.Object

Contains one sesame command and its different regular expressions and strings.

Such a command is made of

a condition, defining the identifiers that should be treated. Absence of condition means that the command should be applied to any identifier

a substitution command made of a regular expression (or a simple string) defining what should be substituted, and a string defining the new character. This string may contain references to parts of the regular expression.

Version:
1.0 April 2003 adapted from the C version
Author:
Wenger Marc/CDS

Field Summary
private  int cmdnum
           
private  java.util.regex.Pattern pCond
           
private  java.util.regex.Pattern pFind
           
private  java.lang.String sReplace
           
 
Constructor Summary
SesameCommand(java.lang.String cond, java.lang.String condOpt, java.lang.String find, java.lang.String findOpt, java.lang.String replace, int num)
          Create a SesameCommand from its elements
 
Method Summary
private  java.lang.String getFlags(int flags)
          returns a string containing the existing flags
private  int setFlags(java.lang.String str)
          Defines the flag integer from a list of flags in an ascii string.
 java.lang.String substitute(java.lang.String id)
          Applies the substitution part of the sesame object to the identifier if the condition is matched
 java.lang.String toString()
          Display a SesameCommand object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

cmdnum

private int cmdnum

pCond

private java.util.regex.Pattern pCond

pFind

private java.util.regex.Pattern pFind

sReplace

private java.lang.String sReplace
Constructor Detail

SesameCommand

public SesameCommand(java.lang.String cond,
                     java.lang.String condOpt,
                     java.lang.String find,
                     java.lang.String findOpt,
                     java.lang.String replace,
                     int num)
              throws SesameException
Create a SesameCommand from its elements

Parameters:
cond - the condition, regular expression defining if an identifier should be treated by this command or not
condOpt - options string for the cond r.e. ('i' for case insensitive)
find - the string to find in the identifier (it can be a regular expression), to be substituded
findOpt - options string for the find r.e. ('i' for case insensitive)
replace - string to replace the 'find' part in the identifier
num - a number identifying the sesame command. It can usefully be the line number in the file from which the sesame command are found
Method Detail

setFlags

private int setFlags(java.lang.String str)
Defines the flag integer from a list of flags in an ascii string.

Parameters:
str - String containing the reg. expr. flags
Returns:
the flags as an integer or -1 if an unknown flag occured

getFlags

private java.lang.String getFlags(int flags)
returns a string containing the existing flags

Parameters:
flags - regular expression flags
Returns:
the corresponding string

substitute

public java.lang.String substitute(java.lang.String id)
Applies the substitution part of the sesame object to the identifier if the condition is matched

Parameters:
id - identifier to transform if the sesame condition matches
Returns:
the transformed identifier

toString

public java.lang.String toString()
Display a SesameCommand object

Returns:
the string to display