Index | Special Tags | Predefined Tags | Implementation | Home |
Implementation of PReP
| |
PReP consists of a PReP class with the main method, a MainPReP class which holds all important methods several PRePTag classes and some help classes like a database connection class or a format class.
![]() Config Class, PReP Class, PRePServlet Class, InputServlet Class, PRePHandler Class, PRePMain Class, PRePException Class, PRePPreparse Class, PRePTagDatabase Class, PRePTag Class, PReTagText Class, PRePTagCode Class, PRePTagObject Class, PRePTagArg Class, PRePTagCount Class, ExceptionHandler Class, ExceptionList Class, Session Class, TagList Class, SQLServe Class, Store Class, PRePTagBOOLEAN Class, PRePTagCALCULATE Class, PRePTagDATE Class, PRePTagDBMS Class, PRePTagDEF Class, PRePTagEXCEPTION Class, PRePTagEXEC Class, PRePTagFOREACHARG Class, PRePTagIF Class, PRePTagIFDEF Class, PRePTagIMG Class, PRePTagLIST Class, PRePTagLISTITEM Class, PRePTagNBSP Class, PRePTagPARSE Class, PRePTagTAGLIST Class, |
|
The config file
| |
The config file was made to improve the security level. However it can contain also some configuration details as for example the settings of the database. Mainly it consists of the FILE and the SECURITY tag. We may not want to allow the user to read from all the files in our filesystem. Therefor we are going to create a config file which includes a list of files and a security flag with one can turn the security on and off. This file is to be read right on the beginning and every time a file is added. There should be a possibility to reload this file. The *FILE in the config file includes all names and nicknames of the files which are readable by the user. They are written like the following:
name::filename The names left of the two colons are the nicknames and the key for a hashtable at the same time. If the nickname is "default", this file will be loaded as standard file. If no default is defined, nothing will be done. The *SECURITY includes all tags which do not have to be secure. For instance if we want to allow the user to see all of the files, without any restrictions, we set the flag to "off": FILE::off We are able to extend the security later. We have a hashtable for the list of the files and one for the list of the security flags. These are stored in a hashtable again. If the flag in the *SECURITY is on, then it gets every line of the *FILE part and takes it into key and value and put it in the hashtable. The *DB may be used to set the details for the database. Please use following keys:
JDBCDRIVER::your_jdbc_driver It is possible to reload the config file without disconnecting the servlet. Just provide a tag RELOAD=yes and the servlet will automatically get the new config file. (Please do not use RELOAD=no, it is not necessary.) |
|
Implementation of ExceptionHandler
| |
This is an interface and provides the method handleException(Exception exception) which are used right now in the PRePTagDBMS and in the PRePTagObject. |
|
Implementation of ExceptionList
| |
This is subclass from the java.util.Vector class. It stores PRePExceptions which consists of an exception and an errorlevel. Constructor:
ExceptionList() Methods:
outErrorlevel(PrintWriter pwriter, int iErrorlevel)
outExceptionList(PrintWriter pwriter) |
|
Implementation of InputServlet
| |
InputServlet is nothing but a subclass of the PRePServlet and does not provide any further methods. It was created because we have some programs which still run under this class. Constructor: default constructor |
|
Class information of PReP
| |
The PReP class reads arguments from the commandline which are either tags and values or input files and an output file and stores them into a TagList, compiles it and outputs the result in the PrintWriter. It contains the main method. To create a subclass, it is important to know, if you need a database connection. You may specify it in the setDBConnection() where you also can specify how many connections you want. For this is the commandline version, you may want only one connection, because you can only use one. This is actually more important for the servlet version.
![]() Constructor:
public PReP(String[] strArgs) Methods:
protected PRePHandler provideHandler()
protected void fillSpecialArgs(Arguments arguments)
protected void setDBConnection()
public void handleNormalArg(Argument argument, Arguments arguments)
![]()
public void handleSpecialArg(Argument argument, Arguments arguments)
![]()
public boolean handleArgInList(int iKey, Arguments args)
protected void handleFileArg(Arguments arguments, Argument argument)
protected void handleOutputFileArg(Arguments arguments)
protected void handleDBTag(Arguments args)
![]()
protected void printHelp()
public static void main(String argv[]) |
|
Implementation of PRePException
| |
Consists of the class which caused the exception, the exception itself and a number (errorlevel). The default errorlevel is 1. A list of PRePExceptions is stored in session Constructor:
PRePException(Object objclass, Object objException) Methods:
outException()
getCausingClass()
getException()
getErrorlevel() |
|
Implementation of PRePHandler
| |
The PRePHandler class is a helper class which allows to deal between the Servlet and the PRePMain class as well as between a commandline version of PReP and the PRePMain - without having any knowledge of JSDK. It configurates the data coming from the servlet or commandline version of PReP.
Constructor: default constructor Methods:
setDatabaseConnection()
setDatabaseConnection(String JDBCDriver, String URL, String UID, String PWD)
setDatabaseConnection(String JDBCDriver, String URL, String UID, String PWD, int iConnections)
getPRePMain()
setPrintWriter(PRePMain, PrintWriter)
putPRePTags(PRePMain)
putField(PRePMain, String strName, String strValue)
putField(PRePMain, PRePTag)
getNewCookies(PRePMain)
loginOk(PRePMain)
loginNotOk(PRePMain)
finishHandle(PRePMain)
putFile(File file)
destroy() |
|
Implementation of PRePMain
| |
The PRePMain stays mostly in its old structure.There are some methods which are not used anymore, removed (as for instance the method setDatabaseConnection()) and some other may be slightly changed. Constructor: default constructor, which creates a Session object Methods:
setPrintWriter(PrintWriter pWriter)
getSession()
putFile(File file)
putField(String name, String value)
putField(PRePTag)
output(PrintWriter pwClient)
output()
getValue(String strTagName) |
|
Implementation of PRePPreparse
| |
Removes all the comments in the prep file (@@) Constructor: default constructor Methods:
preparse(BufferedReader, Session) |
|
Implementation of PRePServlet
| |
First of all the init() method of the PRePServlet will be called from the servletrunner. There a new PRePHandler (providePRePHandler()) will be created as well as the ConnectionPool initialised (default values). You may specify (if you create a subclass) how many connections you will need for your servlet. The default size is 5. As soon as a request from the servletrunner arrives, the handle() method of the PRePServlet is called. This method handles the request and does everything from setting the PrintWriter to the login and finally output of the PRePFile. It is build out of different methods which all work over the PRePHandler. The PRePHandler is unique - unlike the PRePMain which is given to the PRePServlet at the beginning. It will be deleted after the handle() method finished. If the servletrunner closes, it calls the destroy() method of the PRePServlet class which itself calls the destroy() method of the PRePHandler class. The ConnectionPool will be destroyed and its connection closed one for one. Constructor:
Methods:
init(ServletConfig servletConfig)
![]()
handle(HttpServletRequest req, HttpServletResponse res)
![]()
getPRePMain()
setPrintWriter(Instance instance)
putPRePTags(Instance instance)
setParams(Instance instance)
setCookies(Instance instance)
setContext(Instance instance)
getNewCookies(Instance instance)
loginOk(Instance instance)
loginNotOk(Instance instance)
finishHandle(Instance instance)
destroy()
![]() |
|
|
Other information about PRePServlet |
Implementation of PRePTag
| |
This is the super class of all the PRePTags. It is abstract and consists of a tag name and a value. Constructor:
PRePTag(String sTagName) Methods:
compile(Session)
compile(Session session, PrintWriter pw)
debugOutput()
getAllValue()
getName()
getValue()
setValue(Object)
toString() |
|
Implementation of PRePTagArg
| |
This is a subclass of PRePTagText. It is a tag for temporary stored arguments which are given with two colons (e.g. ). For more information see the chapter "How to work with arguments". Constructor:
PRePTagArg(String sTagName)
PRePTagArg(String sTagName, String arg, Session session) Methods:
compile(PrintWriter, TagList)
|
|
Implementation of PRePTagBOOLEAN
| |
It can be very useful to check if something is true or false. This is possible with the BOOLEAN tag. With that you can compare to numbers and compile either the true_output or the false_output. Constructor:
PRePTagBOOLEAN() Methods:
compile(Session) |
|
|
How the BOOLEAN Tag works |
Implementation of PRePTagCALCULATE
| |
this tag can add, substract, divide, multiply, calculate the mod and the power of two arguments which are floats. Constructor:
PRePTagCALCULATE() Methods:
compile(Session)
|
|
|
How the CALCULATE Tag works |
Implementation of
| |
Constructor:
PRePTagCode(String sTagName) |
|
Implementation of PRePTagCount
| |
This is a subclass of PRePTagArg. It counts all ARGs (arguments) which are temporarily stored in the TagList. This tag is used for validating the number of arguments of a predefined tag. Constructor:
PRePTagCount() Methods:
getIntValue()
setCount(int) |
|
Implementation of PRePTagDatabase
| |
A superclass for all tags which use a database connection and have to execute a SQL statement. It creates a store object which represents the result. PReP works with a Connectionpool - for more information about this and also about how to use and change it have a look at the package itself (com.delec.global.dbms). Constructor:
PRePTagDatabase() Methods:
checkSQLServe(Session, SQLServe)
executeSQL(String SQLStatement, Session session)
executeUPDATE(String SQLStatement, Session session)
handleException(Exception) |
|
Implementation of PRePTagDATE
| |
This is a subclass of PRePTagCode. This predefined tag gets the actual date or calculates with date formats. For further information see chapter "The DATE tag". Constructor:
PRePTagDATE() Methods:
compile(Session) |
|
|
How the DATE Tag works |
Implementation of PRePTagDBMS
| |
This is a subclass of PRePTagCode which implements an ExceptionHandler. With the ExceptionHandler it is possible to keep the handling of any exception more flexible. The connection of the database must be predefined with the DB tag which may be given with the call of the PReP program. The methods specific for the database (e.g. connection() or close()) are provided in another class (SQLServe) and the result is stored in a Store object. The DBMS tag also needs an OUTPUT tag which will format the result and outputs it in a specified matter. For further information please see chapter "The DBMS tag". Constructor:
PRePTagDBMS() Methods:
compile(Session)
handleException(Exception exception) |
|
|
How the DBMS Tag works |
Implementation of PRePTagDEF
| |
This is a subclass of PRePTagCode which defines the DEF tag. It must have two arguments. For further information see chapter "The DEF tag". Constructor:
PRePTagDEF() Methods:
compile(Session)
|
|
|
How the DEF Tag works |
Implementation of PRePTagEXCEPTION
| |
This is a subclass of PRePTagCode which defines the EXCEPTION tag. With this tag you may retrieve any exceptions with a specified errorlevel. For more informations see chapter "The EXCEPTION tag". Constructor:
PRePTagEXCEPTION() Methods:
compile(Session)
|
|
|
How the EXCEPTION Tag works |
Implementation of PRePTagEXEC
| |
This is a subclass of PRePTagCode which will call a DOS batch file with a specified argument. It will examine the errorcode the DOS program returned with. It needs four arguments. For further information see chapter "The EXEC tag". Constructor:
PRePTagEXEC() Methods:
compile(Session)
fileMaker(Session session, String strPrefix, String strSuffix, File fileDirectory)
writeTextToFile(PRePTag prepTag, Session session, File file) |
|
|
How the EXEC Tag works |
Implementation of FOREACHARG
| |
This is a subclass of PRePTagCode which will call another PRePTag with as many arguments as wanted to. For further information see chapter "The FOREACHARG tag". Constructor:
PRePTagFOREACHARG() Methods:
compile(Session) |
|
|
How the FOREACHARG Tag works |
Implementation of PRePTagIF
| |
This is a subclass of PRePTagCode which defines the IF tag. It will examine the specified PRePTag (given as first argument) whether it has the specified value (given as second argument). It needs at least three arguments, but maximum four. Constructor:
PRePTagIF() Methods:
compile(Session) |
|
|
How the IF Tag works |
Implementation of PRePTagIFDEF
| |
This is a subclass of PRePTagCode which defines the IFDEF tag. It is similar to the IF tag but it just examines whether the specified PRePTag exists or not. Constructor:
PRePTagIFDEF() Methods:
compile(Session) |
|
|
How the IFDEF Tag works |
Implementation of PRePTagNBSP
| |
This is a subclass of PRePTagCode which defines the NBSP tag. It gets the first argument and changes the whitespaces there with an HTML " ". If there is a second argument it should be an integer and represents the number of " " which should replace the tabs in the first argument ('\t'). Constructor:
PRePTagNBSP() Methods:
compile(Session) |
|
|
How the NBSP Tag works |
Implementation of PRePTagObject
| |
This is a subclass of PRePTag. It gets a format order as argument and formats its value in this way (for more information see the part about the OUTPUT tag in the DBMS tag chapter). Constructor:
PRePTagObject(String sTagName) Methods:
compile(Session)
format(PrintWriter, String, ExceptionHandler)
getObjectValue()
getValue()
handleException(Exception exception)
setValue(double)
setValue(int)
setValue(Object)
setValue(char)
setValue(float) |
|
Implementation of PRePTagPARSE
| |
This is a subclass of PRePTagCode which defines the PARSE tag. The PARSE tag opens a specified file, parses this file and compiles a certain tag. After that the taglist is resized to the normal size. Constructor:
PRePTagPARSE() Methods:
compile(Session)
|
|
|
How the PARSE Tag works |
Implementation of PRePTagTAGLIST
| |
This is a subclass of PRePTagCode which defines the TAGLIST tag. It outputs the actual tag list in an HTML format. Constructor:
PRePTagTAGLIST() Methods:
compile(Session) |
|
|
How the TAGLIST Tag works |
Implementation of PRePTagText
| |
This is a subclass of PRePTag and compiles by printing the value with the PrintWriter. If the noparse flag is set (like: *MAIN:noparse) then the tag is just print the way it looks (without any formats or substitutes) Constructor:
PRePTagText(String sTagName) Methods:
compile(Session)
debugOutput()
getAllValue()
getValue()
setValue(String) |
|
Implementation of Session
| |
The session object encapsulates all objects that are used for a session (one execution) of the PReP environment. This is needed to allow a multithreaded execution of PReP. It also provides the TagList, User and PrintWriter object which are stored separately and have to be set and retrieved with special methods. Constructor:
Session() Methods:
put(Object key, Object value)
Object get(Object key)
Object remove(Object)
toString()
setTagList(TagList)
getTagList()
setUser(Object)
getUser()
setPrintWriter(PrintWriter)
getPrintWriter()
setExceptionList(ExceptionList)
getExceptionList() |
|
Implementation of SQLServe
| |
This class provides all methods which are necessary to build a database connection. It also handles the SQL statements and returns a Store object in which the result of a SQL statement is stored. Constructor:
SQLServe() Methods:
public static Connection getConnection(ConnectionPool connectionPool)
public static void recoverConnection()
public static CallableStatement getCallableStatement(String strCallableStmt, Connection dbmsCon)
public static CallableStatement loopThroughResultSet(CallableStatement callableStmt, boolean hasResultSet, ResultSet rs)
execStmtStore(String sqlStatement, Session session, ExceptionHandler exceptionHandler)
execStmtStore(String sqlStatement, int i MaxRows, Session session, ExceptionHandler exceptionHandler)
execSpStore(String)
execUpdate(String) |
|
Implementation of Store
| |
Object to store tables from a database received with a specified SQL statement. It is necessary to handle more than one access with a SQL statement. Constructor:
Store() Methods:
addName(String, int)
addValue (PRePTagObject)
getValue(String)
getValue(int)
values()
moveTo(int)
getNbrOfColumns()
getLabel(int)
push(Session)
compileFields(Session, PRePTag, int)
compileFields(Session, PRePTag) Inner Class:
HeaderInfo
used for output label and type
Constructor of Inner class:
HeaderInfo(String label, int type) |
|
Implementation of TagList
| |
This is a subclass of java.util.Vector which stores all PRePTags. The predefined PRePTags are stored when the TagList is created. The argument tags (ARGs) are stored only temporarily. Constructor:
TagList() Methods:
compile(String name, Session session)
find(String name)
outTag()
outTag(PrintWriter pwriter) |
|