Monday, July 17, 2006
Wednesday, July 12, 2006
Webapplication Unit Tests - Watij
start - Watij: "Watij (pronounced wattage) stands for Web Application Testing in Java. Watij is a pure Java API created to allow for the automation of web applications. Based on the simplicity of Watir and enhanced by the power of Java, Watij automates functional testing of web applications through a real browser. Currently Watij supports automating Internet Explorer on Windows only. Future plans are in place to support others like Mozilla. "
Thursday, July 06, 2006
Commons VFS - Commons Virtual File System
Commons�VFS - Commons Virtual File System: "Commons VFS provides a single API for accessing various different file systems. It presents a uniform view of the files from various different sources, such as the files on local disk, on an HTTP server, or inside a Zip archive."
Tuesday, July 04, 2006
EJBCA - The J2EE Certificate Authority - Welcome
EJBCA - The J2EE Certificate Authority - Welcome: "EJBCA is a fully functional Certificate Authority. Based on J2EE technology it constitutes a robust, high performance and component based CA. Both flexible and platform independent, EJBCA can be used standalone or integrated in any J2EE application.
EJBCA is an enterprise class PKI, meaning that you can use EJBCA to build a complete PKI infrastructure for your organisation. If you only want to issue a few single certificates for testing, there are probably options that will get you started quicker, but if you want a serious PKI we recommend EJBCA.
You can use EJBCA to issue certificates for different purposes such as:
* Strong authentication for users accessing your intranet/extranet/internet resources.
* Secure communication with SSL servers and SSL clients.
* Smart card based login to Windows and/or Linux.
* Signing and enrypting email.
* VPN connections by issuing certificates to your VPN routers such as OpenVPN, Cisco, Juniper etc.
* Client VPN access with certificates in users VPN clients.
* Single sign-on by using a single certificate to secure logon to web applications.
* Creating signed documents.
* Issue citizen certificates for access to government resourses, used in passports etc.
* ... and many many more ..."
EJBCA is an enterprise class PKI, meaning that you can use EJBCA to build a complete PKI infrastructure for your organisation. If you only want to issue a few single certificates for testing, there are probably options that will get you started quicker, but if you want a serious PKI we recommend EJBCA.
You can use EJBCA to issue certificates for different purposes such as:
* Strong authentication for users accessing your intranet/extranet/internet resources.
* Secure communication with SSL servers and SSL clients.
* Smart card based login to Windows and/or Linux.
* Signing and enrypting email.
* VPN connections by issuing certificates to your VPN routers such as OpenVPN, Cisco, Juniper etc.
* Client VPN access with certificates in users VPN clients.
* Single sign-on by using a single certificate to secure logon to web applications.
* Creating signed documents.
* Issue citizen certificates for access to government resourses, used in passports etc.
* ... and many many more ..."
Sunday, July 02, 2006
contineo - Open Source Document Management
contineo - Open Source Document Management: "Contineo in a few words...
Contineo is a web based document management system. It supports its users by managing documents in most popular formats. Contineo aims to fulfill all phases of document lifecycle. You can create and develop documents by using office software. With contineo itself, you can publish, search, and manage the versions of documents. Further, you can communicate with some other users directly or via e-mail.
Contineo was founded as a pure Java project in 2003. It is the attempt of the conversion of an easy to use und easy to extend document management system. That's why contineo is developed under an open source license.
At the moment contineo finally exists in version 2.0. Version 2.1 will be coming soon."
Contineo is a web based document management system. It supports its users by managing documents in most popular formats. Contineo aims to fulfill all phases of document lifecycle. You can create and develop documents by using office software. With contineo itself, you can publish, search, and manage the versions of documents. Further, you can communicate with some other users directly or via e-mail.
Contineo was founded as a pure Java project in 2003. It is the attempt of the conversion of an easy to use und easy to extend document management system. That's why contineo is developed under an open source license.
At the moment contineo finally exists in version 2.0. Version 2.1 will be coming soon."
Friday, June 30, 2006
atleap: Blandware AtLeap - multilingual free Java CMS with full text search
atleap: Blandware AtLeap - multilingual free Java CMS with full text search: "Blandware AtLeap is a multilingual free Java CMS (Content Management System) with full-text search engine. Blandware AtLeap is a framework which allows you to rapidly start your own Web application.
The idea of the AtLeap project is based on my many years’ experience of management in the area of the site development. Blandware AtLeap is destined to creating both content-based sites and web applications with complicated business logic.
The most part of the site development and maintenance processes is the content (mainly texts) modifications in accordance with changeable customer requirements. There is CMS necessity which can allow shifting this routine work from technical to content specialists (advertising manager, linguist, translator etc.) who usually has not HTML knowledge or even to the customer representative who possesses most up-to-date and precise information in application domain."
The idea of the AtLeap project is based on my many years’ experience of management in the area of the site development. Blandware AtLeap is destined to creating both content-based sites and web applications with complicated business logic.
The most part of the site development and maintenance processes is the content (mainly texts) modifications in accordance with changeable customer requirements. There is CMS necessity which can allow shifting this routine work from technical to content specialists (advertising manager, linguist, translator etc.) who usually has not HTML knowledge or even to the customer representative who possesses most up-to-date and precise information in application domain."
Alfresco Community Network - Open Source Content Management
Alfresco Community Network - Open Source Content Management: "The Alfresco Community Network is designed for developers to have access to the latest Enterprise Content Management technology. It is a freely downloadable version of the leading open source Enterprise Content Management system. It is supported by an active community of open source developers. Alfresco Community Network is for:"
Sunday, June 25, 2006
DataVision Home
DataVision Home: "DataVision is an Open Source reporting tool similar to Crystal Reports. Reports can be designed using a drag-and-drop GUI. They may be run, viewed, and printed from the application or exported as HTML, XML, PDF, LaTeX2e, DocBook, or tab- or comma-delimited text files. The output files produced by LaTeX2e and DocBook can in turn be used to produce PDF, text, HTML, PostScript, and more.
DataVision is written in Java and runs almost anywhere. It can generate reports from databases or text data files. Any database with an available JDBC driver should work: Oracle, PostgreSQL, MySQL, Informix, hsqldb, Microsoft Access, Progress, and more. Columns read from text files can be separated by any character.
Report descriptions are stored as XML files. This means you can not only use the DataVision GUI but you may also edit reports using your favorite text editor."
DataVision is written in Java and runs almost anywhere. It can generate reports from databases or text data files. Any database with an available JDBC driver should work: Oracle, PostgreSQL, MySQL, Informix, hsqldb, Microsoft Access, Progress, and more. Columns read from text files can be separated by any character.
Report descriptions are stored as XML files. This means you can not only use the DataVision GUI but you may also edit reports using your favorite text editor."
validation: Home
validation: Home: "The JGoodies Validation helps you validate user input in Swing applications and report validation errors and warnings. It has been designed to work with different architectures and programming flavors."
Saturday, June 24, 2006
JCCKit
JCCKit: "The JCCKit is a small (< 100Kb) library and a very flexible framework for creating scientific charts and plots.
JCCKit is written for the JDK™ 1.1.8 platform (except of a Graphics2D renderer). Thus, it is suitable for scientific Applets and for PDA's running a PersonalJava™ implementation."
JCCKit is written for the JDK™ 1.1.8 platform (except of a Graphics2D renderer). Thus, it is suitable for scientific Applets and for PDA's running a PersonalJava™ implementation."
Tuesday, June 20, 2006
Saturday, June 17, 2006
Google Answers: Protect/encrypt java class (jar) files from theft
Google Answers: Protect/encrypt java class (jar) files from theft: "Obfuscator can not help protect your Java code from decompilers. Obfuscator can hide valuable names but not hide your logic or algorithms. There are a number of Java de-compiler products on the market that do this task such as Mocha, DJ Java Decompiler, Jad, WingDis, DejaVu, open source decompiler Jreverse Pro, Cavaj Java Decompiler, JCavaj Java Decompiler, Decafe Pro, SourceAgain ... etc. They produce readable source code even though your classes have been obfuscated. http://www.excelsior-usa.com/jetprotection.html Excelsior JET JVM offers a solution but actually it recompile your java source code and that is not Java program anymore. The only solution is to create a java secure class loader which does encrypting/ decrypting classes in the memory. We got the solution and is preparing patent it. The secure class loader already apply to SETECS products written in JAVA. It is proven as secure and efficient solution so far."
Friday, June 16, 2006
Wednesday, June 14, 2006
JavaNCSS - A Source Measurement Suite for Java
JavaNCSS - A Source Measurement Suite for Java: "Ever wondered how many lines of code or how many classes there are in the Sun JDK? Curious about the size of your own projects - or do you want to keep track of your work-progress. That's what JavaNCSS is for.
JavaNCSS is a simple command line utility which measures two standard source code metrics for the Java programming language. The metrics are collected globally, for each class and/or for each function.
Here is an example about what JavaNCSS prints out for the Sun JDK 1.1.5 java.* source tree (update: JDK 1.5 api source tree consists of 569'830 ncss).
JavaNCSS can optionally present its output with a little graphical user interface. To interactively select Java source files for counting, Jacob (a Java class browser and project manager) can be used for this purpose.
JavaNCSS can also be used out of an Ant build.xml script as it comes bundled with an Ant task written by Steve Jernigan. The JavaNCSS Ant Task is documented on a separate page.
You can always find the newest version of this page at: http://www.kclee.de/clemens/java/javancss/"
JavaNCSS is a simple command line utility which measures two standard source code metrics for the Java programming language. The metrics are collected globally, for each class and/or for each function.
Here is an example about what JavaNCSS prints out for the Sun JDK 1.1.5 java.* source tree (update: JDK 1.5 api source tree consists of 569'830 ncss).
JavaNCSS can optionally present its output with a little graphical user interface. To interactively select Java source files for counting, Jacob (a Java class browser and project manager) can be used for this purpose.
JavaNCSS can also be used out of an Ant build.xml script as it comes bundled with an Ant task written by Steve Jernigan. The JavaNCSS Ant Task is documented on a separate page.
You can always find the newest version of this page at: http://www.kclee.de/clemens/java/javancss/"
Monday, June 05, 2006
Saturday, June 03, 2006
Checkstyle - Checkstyle 4.1
Checkstyle - Checkstyle 4.1: "Checkstyle is a development tool to help programmers write Java code that adheres to a coding standard. It automates the process of checking Java code to spare humans of this boring (but important) task. This makes it ideal for projects that want to enforce a coding standard.
Checkstyle is highly configurable and can be made to support almost any coding standard. An example configuration file is supplied supporting the Sun Code Conventions. As well, other sample configuration files are supplied for other well known conventions.
A good example of a report that can be produced using Checkstyle and Maven can be seen here."
Checkstyle is highly configurable and can be made to support almost any coding standard. An example configuration file is supplied supporting the Sun Code Conventions. As well, other sample configuration files are supplied for other well known conventions.
A good example of a report that can be produced using Checkstyle and Maven can be seen here."
JGAP: Java Genetic Algorithms Package
JGAP: Java Genetic Algorithms Package
JGAP (pronounced "jay-gap") is a genetic algorithms component written in the form of a Java framework. It provides basic genetic mechanisms that can be easily used to apply evolutionary principles to problem solutions. The next version will introduce Genetic Programming!
JGAP has been written to be very easy to use "out of the box," while also designed to be highly modular so that more adventurous users can easily plug-in custom genetic operators and other sub-components.
JGAP (pronounced "jay-gap") is a genetic algorithms component written in the form of a Java framework. It provides basic genetic mechanisms that can be easily used to apply evolutionary principles to problem solutions. The next version will introduce Genetic Programming!
JGAP has been written to be very easy to use "out of the box," while also designed to be highly modular so that more adventurous users can easily plug-in custom genetic operators and other sub-components.
Thursday, June 01, 2006
Home Page of Jad - the fast Java decompiler
Home Page of Jad - the fast Java decompiler
Die Homepage des Java Decompilers is offensichtlich von Tripod hierher umgezogen.
Die Homepage des Java Decompilers is offensichtlich von Tripod hierher umgezogen.
Wednesday, May 31, 2006
DBCopy Plugin Home Page
DBCopy Plugin Home Page: "DB Copy Plugin is a plugin for the SQuirreL SQL Client (1.2beta6 and 2.0 RC1 )
that allows copying database objects (schema def and data) from one session window to another.
The source and destination sessions can be different database vendors (Hibernate is
used internally for data type translation)."
that allows copying database objects (schema def and data) from one session window to another.
The source and destination sessions can be different database vendors (Hibernate is
used internally for data type translation)."
HelpSetMaker - Ein Programm zur Erstellung von Online-Hilfe-Systemen
HelpSetMaker - Ein Programm zur Erstellung von Online-Hilfe-Systemen: "HelpSetMaker - Ein Programm zur Erstellung von Online-Hilfe-Systemen
Hinweis: HelpSetMaker richtet sich grunds�tzlich an Muttersprachler verschiedener Sprachen. Das Programm ist momentan mit deutscher und englischer Benutzeroberfl�che ausgestattet. Die Online-Hilfe und die Seiten bei SourceForge sind aber nur in Englisch verf�gbar."
Hinweis: HelpSetMaker richtet sich grunds�tzlich an Muttersprachler verschiedener Sprachen. Das Programm ist momentan mit deutscher und englischer Benutzeroberfl�che ausgestattet. Die Online-Hilfe und die Seiten bei SourceForge sind aber nur in Englisch verf�gbar."
JHelpDev
JHelpDev
This is an overview of all features that have been implemented in the respective current version of JHelpDev. The requested features section provides an outlook for the future.
Implemented
* creates the map file from existing HTML files in a directory including targets
* convenient TOC editor with a tree view, image support
* smart automatic TOC generation searches HTML files for "title-like" entries and preserves existing entries
* powerful index editor allowing for quickly jumping to the location in the helpset
* two synchronized views for convenient index creation
* HS Editor for the views and labels of the JHelpNavigator
* list of recently visited projects, starts browsing in last directory
* support of subhelpsets
* easy to use preview with the original helpviewer
* one click creation of search database
* a context-sensitive helpsystem created with JHelpDev
* configuration changes are stored in an XML format
This is an overview of all features that have been implemented in the respective current version of JHelpDev. The requested features section provides an outlook for the future.
Implemented
* creates the map file from existing HTML files in a directory including targets
* convenient TOC editor with a tree view, image support
* smart automatic TOC generation searches HTML files for "title-like" entries and preserves existing entries
* powerful index editor allowing for quickly jumping to the location in the helpset
* two synchronized views for convenient index creation
* HS Editor for the views and labels of the JHelpNavigator
* list of recently visited projects, starts browsing in last directory
* support of subhelpsets
* easy to use preview with the original helpviewer
* one click creation of search database
* a context-sensitive helpsystem created with JHelpDev
* configuration changes are stored in an XML format
Monday, May 29, 2006
Monday, May 22, 2006
XMLmind: Aptconvert
XMLmind: Aptconvert: "Aptconvert is a command-line tool that can be used to convert the APT format to HTML, XHTML, PDF, PostScript, (MS Word loadable) RTF, DocBook SGML and DocBook XML."
Terracotta - Enterprise-class clustering for Java
Terracotta - Enterprise-class clustering for Java: "Clustering the JVM, Not the Application
Terracotta DSO is a runtime solution for clustering JVMs, instead of the application. By extending the Java heap, Terracotta DSO creates one “clustered” JVM that shares object state and behavior. Tuning the clustering behavior can now be done at runtime without code changes. Developers can focus on business logic, not infrastructure."
Terracotta DSO is a runtime solution for clustering JVMs, instead of the application. By extending the Java heap, Terracotta DSO creates one “clustered” JVM that shares object state and behavior. Tuning the clustering behavior can now be done at runtime without code changes. Developers can focus on business logic, not infrastructure."
Marthon User Guide
Marthon User Guide: "Marathon is a general purpose tool for both running and authoring acceptance tests geared at the applications developed using Java and Swing. Included with marathon is a rich suite of components to help you interact with your application at the User Interface Level (GUI).
Marathon tests are scripted using Jython, a 100% pure java implementation of the programming language Python -- the emphasis being on a extremely simple, highly readable syntax that customers, analysts, testers and developers can all be comfortable with. But don't let the simplicity fool you. Python is a mature, full-featured programming language, so testers and developers don't need to sacrafice anything in terms of the power and creativity with which they can express their tests.
To aid with the regression testing of existing applications, Marathon comes bundled with a recorder to capture events as you use and interact with your application. These events are then converted into a valid Marathon test which can subsequently be played back."
Marathon tests are scripted using Jython, a 100% pure java implementation of the programming language Python -- the emphasis being on a extremely simple, highly readable syntax that customers, analysts, testers and developers can all be comfortable with. But don't let the simplicity fool you. Python is a mature, full-featured programming language, so testers and developers don't need to sacrafice anything in terms of the power and creativity with which they can express their tests.
To aid with the regression testing of existing applications, Marathon comes bundled with a recorder to capture events as you use and interact with your application. These events are then converted into a valid Marathon test which can subsequently be played back."
Thursday, May 18, 2006
jGuru: JaVaCC Grammar modification required.
jGuru: JaVaCC Grammar modification required.
JaVaCC Grammar modification required.
Topic: JavaLanguage
Vijendra Singh, Mar 14, 2006
Hi, If someone has good command over writing .jj or.jjt files. I need some help in writing code. I need to incorporate in my sqlParser.jj and ultimately sqlParser.java files; so that they can read and parse :- "create view as select * from tablename" statement. This sqlParser.jj files are generating ASCII_char_stream instead Simple_char_stream, but i don't think it will create any problem. So just like it parsers create table...statement,delete,alster tables etc. It sholud also parse view without giving any error. I am giving this file with some modification i tried to do for views but grammar is mistaken please give me some useful way to solve this Thanks VijendraNew Page 1
/**
* Creation date: July 19th, 2000
* This is the JavaCC grammar definition file for the DDL dialect used by
* ZeroCode.
*/
// options {
// DEBUG_PARSER = true;
// }
PARSER_BEGIN(SqlParser)
package zerocode.sqlParser;
import com.sun.java.util.collections.*;
import java.io.*;
import java.util.Enumeration;
import zerocode.dbSupport.*;
import zerocode.core.*;
/**
* The SqlParser class encapsulates parsing of SQL DDL statements to enable
* zeroCode to construct the schema-related data structures. Most of its
* implementation is generated using the
* JavaCC
* application.
*/
public class SqlParser {
public interface ConstraintType {
public static final int UNIQUE = 1;
public static final int PRIMARY_KEY = 2;
}
public static void main (String args[]) throws Exception {
Schema dbSchema = buildSchema (new InputStreamReader (System.in));
System.out.println (dbSchema.toString());
}
public static synchronized Schema buildSchema (Reader stream)
throws ZcException {
_fkConstraints = new ArrayList();
_errorList = new Vector();
_dbSchema = new Schema ("ZeroCodeSchema");
if (_parser == null)
_parser = new SqlParser (stream);
else
_parser.ReInit (stream);
try {
_parser.ddlSequence ();
} catch (ParseException e) {
throw new ZcException
(ErrorCode.INVALID_SCHEMA, "SQL syntax error: " + e.getMessage());
}
_dbSchema.setConstraints (_fkConstraints);
if (_errorList.size() > 0)
throw new ZcException
(ErrorCode.INVALID_SCHEMA,
"Schema errors:\n" + StringUtils.join (_errorList, "\n"));
return _dbSchema;
}
private static void addTable (DbTable table) {
_dbSchema.addTable (table);
}
private static void addSequence (String sequenceName) {
_dbSchema.addSequence (sequenceName);
}
private static int convertToken (String message)
throws ZcException {
try {
int val = Integer.parseInt (token.toString());
return val;
} catch (NumberFormatException e) {
throw new ZcException
(ErrorCode.INVALID_SCHEMA,
message + "token '" + token.toString() + "' line " +
token.beginLine + " column " + token.beginColumn);
}
}
private static void setConstraint (DbTable table, String constraintName,
int constraintType,
StringSet columnNameSet) {
if (constraintType == ConstraintType.PRIMARY_KEY) {
int nCols = columnNameSet.size();
if (nCols > 1) {
// _errorList.add ("Table " + table.name() + ": must have " +
// "exactly one column as primary key.");
// We set the pri key anyway, to inhibit the subsequent
// "No primary key defined" error message.
table.setPrimaryKey (columnNameSet);
} else if (nCols <= 0) {
// _errorList.add ("Table " + table.name() + ": must have " +
// "a primary key.");
} else {
String colName = (String) columnNameSet.asArray()[0];
DbColumn col = table.columnWithName (colName);
if (col == null)
_errorList.add ("Table " + table.name() + ": Column '" +
colName + "', specified in primary key " +
"constraint, is not a declared column.");
else
table.setPrimaryKey (col.name());
}
} else {
// It should be a UNIQUE constraint
table.addUniqueConstraint
(new UniqueConstraint (constraintName, table, columnNameSet));
}
}
private static void addForeignKeyConstraint (String constraintName,
DbTable table,
StringSet columnNameSet,
String toTableName,
String toColName) {
if (columnNameSet.size() != 1) {
// We now silently ignore this problem -- MAS 1/7/2003
// _errorList.add ("Table " + table.name() + ": must have " +
// "exactly one column in foreign key.");
return;
}
String fkColName = columnNameSet.asArray()[0];
DbColumn fkCol = table.columnWithName (fkColName);
if (fkCol == null) {
_errorList.add ("Table " + table.name() +
": Cannot add foreign key constraint: no " +
"foreign key column named '" + fkColName + "'");
return;
}
DbTable toTable = _dbSchema.tableWithName (toTableName);
if (toTable == null) {
_errorList.add ("Table '" + toTableName + "' not found in schema.");
return;
}
DbColumn toColumn = toTable.columnWithName (toColName);
if (toColumn == null) {
_errorList.add ("Attempting to add foreign key from " +
table.name() + "(" +
columnNameSet.joinString(",") + ") to table '" +
toTableName + "': the latter has no column " +
"named '" + toColName + "'");
} else {
String constraintId = constraintName != null
? constraintName
: ("zcFkConstraint" + (++zcFkCount));
ForeignKeyConstraint constraint = new ForeignKeyConstraint
(constraintId, fkCol, toColumn, _fkConstraints.size());
_fkConstraints.add (constraint);
}
}
private static Schema _dbSchema;
private static Vector _errorList;
private static List _fkConstraints;
private static SqlParser _parser;
private static int zcFkCount = 0;
}
PARSER_END(SqlParser)
SKIP :
{
" "
|
"\t"
|
"\n"
|
"\r"
|
"--" : IN_LINE_COMMENT
|
"/*" : IN_COMMENT
}
SKIP:
{
"\n" : DEFAULT
}
MORE:
{
< ~[] >
}
SKIP:
{
"*/" : DEFAULT
}
MORE:
{
< ~[] >
}
TOKEN [IGNORE_CASE] :
{
< ADD: "add" >
| < ALL: "all" >
| < ALTER: "alter" >
| < AND: "and" >
| < ANY: "any" >
| < AS : "as" >
| < ASC: "asc" >
| < BY: "by" >
| < CACHE: "cache" >
| < CASCADE: "cascade" >
| < CHECK: "check" >
| < COLUMN: "column" >
| < COMMENT: "comment" >
| < CONSTRAINT: "constraint" >
| < CONSTRAINTS: "constraints" >
| < CREATE: "create" >
| < CYCLE: "cycle" >
| < DEFAULT_TOK: "default" >
| < DELETE: "delete" >
| < DESC: "desc" >
| < DROP: "drop" >
| < FOREIGN: "foreign" >
| < IDENTITY: "identity" >
| < IN: "in" >
| < INCREMENT: "increment" >
| < INDEX: "index" >
| < IS: "is" >
| < KEY: "key" >
| < MAXVALUE: "maxvalue" >
| < MINVALUE: "minvalue" >
| < NOCACHE: "nocache" >
| < NOCYCLE: "nocycle" >
| < NOMAXVALUE: "nomaxvalue" >
| < NOMINVALUE: "nominvalue" >
| < NOORDER: "noorder" >
| < NOT: "not" >
| < NULL: "null" >
| < ON: "on" >
| < OR: "or" >
| < ORDER: "order" >
| < PRIMARY: "primary" >
| < REFERENCES: "references" >
| < SELECT: "select" >
| < SEQUENCE: "sequence" >
| < SOME: "some" >
| < START: "start" >
| < TABLE: "table" >
| < UNIQUE : "unique" >
| < UPDATE : "update" >
| < VIEW : "view" >
| < WITH: "with" >
| < COMMA: "," >
| < DOT: "." >
| < IDENTIFIER: ["a"-"z","A"-"Z", "_"] (["a"-"z", "_", "0"-"9", "$", "#"])* >
| < LPAREN: "(" >
| < NUMBER: (["0"-"9"])+ >
| < RPAREN: ")" >
| < SEMICOLON: ";" >
| < SLASH: "/" >
| < STRING_LITERAL:
(
"'"
(~["'","\\","\n","\r"])*
"'"
)+
>
}
String allowedColumnName () :
{}
{
(
LOOKAHEAD(2)
< IDENTIFIER >
| < ANY >
| < AS >
| < ASC >
| < BY >
| < CACHE >
| < CASCADE >
| < CHECK >
| < COLUMN >
| < COMMENT >
| < CONSTRAINTS >
| < CREATE >
| < CYCLE >
| < DEFAULT_TOK >
| < DELETE >
| < DESC >
| < DROP >
| < FOREIGN >
| < IDENTITY >
| < IN >
| < INCREMENT >
| < INDEX >
| < IS >
| < KEY >
| < MAXVALUE >
| < MINVALUE >
| < NOCACHE >
| < NOCYCLE >
| < NOMAXVALUE >
| < NOMINVALUE >
| < NOORDER >
| < NOT >
| < NULL >
| < ON >
| < OR >
| < ORDER >
| < PRIMARY >
| < REFERENCES >
| < SELECT >
| < SEQUENCE >
| < SOME >
| < START >
| < TABLE >
| < UNIQUE >
| < UPDATE >
| < VIEW >
| < WITH >
) { return token.toString(); }
}
void ddlSequence () throws ZcException :
{
DbTable table;
String sequenceName;
}
{
(
(
comment()
|
(
(
table = tableDefinition () {
addTable (table);
}
|
indexDefinition ()
|
sequenceName = sequenceDefinition ()
{
addSequence (sequenceName);
}
)
)
|
(
(
view = viewDefinition ()
)
)
|
alterTable ()
|
dropTable()
)
(
|
)+
)+
}
void comment () :
{ }
{
(
(
JaVaCC Grammar modification required.
Topic: JavaLanguage
Vijendra Singh, Mar 14, 2006
Hi, If someone has good command over writing .jj or.jjt files. I need some help in writing code. I need to incorporate in my sqlParser.jj and ultimately sqlParser.java files; so that they can read and parse :- "create view as select * from tablename" statement. This sqlParser.jj files are generating ASCII_char_stream instead Simple_char_stream, but i don't think it will create any problem. So just like it parsers create table...statement,delete,alster tables etc. It sholud also parse view without giving any error. I am giving this file with some modification i tried to do for views but grammar is mistaken please give me some useful way to solve this Thanks Vijendra
/**
* Creation date: July 19th, 2000
* This is the JavaCC grammar definition file for the DDL dialect used by
* ZeroCode.
*/
// options {
// DEBUG_PARSER = true;
// }
PARSER_BEGIN(SqlParser)
package zerocode.sqlParser;
import com.sun.java.util.collections.*;
import java.io.*;
import java.util.Enumeration;
import zerocode.dbSupport.*;
import zerocode.core.*;
/**
* The SqlParser class encapsulates parsing of SQL DDL statements to enable
* zeroCode to construct the schema-related data structures. Most of its
* implementation is generated using the
* JavaCC
* application.
*/
public class SqlParser {
public interface ConstraintType {
public static final int UNIQUE = 1;
public static final int PRIMARY_KEY = 2;
}
public static void main (String args[]) throws Exception {
Schema dbSchema = buildSchema (new InputStreamReader (System.in));
System.out.println (dbSchema.toString());
}
public static synchronized Schema buildSchema (Reader stream)
throws ZcException {
_fkConstraints = new ArrayList();
_errorList = new Vector();
_dbSchema = new Schema ("ZeroCodeSchema");
if (_parser == null)
_parser = new SqlParser (stream);
else
_parser.ReInit (stream);
try {
_parser.ddlSequence ();
} catch (ParseException e) {
throw new ZcException
(ErrorCode.INVALID_SCHEMA, "SQL syntax error: " + e.getMessage());
}
_dbSchema.setConstraints (_fkConstraints);
if (_errorList.size() > 0)
throw new ZcException
(ErrorCode.INVALID_SCHEMA,
"Schema errors:\n" + StringUtils.join (_errorList, "\n"));
return _dbSchema;
}
private static void addTable (DbTable table) {
_dbSchema.addTable (table);
}
private static void addSequence (String sequenceName) {
_dbSchema.addSequence (sequenceName);
}
private static int convertToken (String message)
throws ZcException {
try {
int val = Integer.parseInt (token.toString());
return val;
} catch (NumberFormatException e) {
throw new ZcException
(ErrorCode.INVALID_SCHEMA,
message + "token '" + token.toString() + "' line " +
token.beginLine + " column " + token.beginColumn);
}
}
private static void setConstraint (DbTable table, String constraintName,
int constraintType,
StringSet columnNameSet) {
if (constraintType == ConstraintType.PRIMARY_KEY) {
int nCols = columnNameSet.size();
if (nCols > 1) {
// _errorList.add ("Table " + table.name() + ": must have " +
// "exactly one column as primary key.");
// We set the pri key anyway, to inhibit the subsequent
// "No primary key defined" error message.
table.setPrimaryKey (columnNameSet);
} else if (nCols <= 0) {
// _errorList.add ("Table " + table.name() + ": must have " +
// "a primary key.");
} else {
String colName = (String) columnNameSet.asArray()[0];
DbColumn col = table.columnWithName (colName);
if (col == null)
_errorList.add ("Table " + table.name() + ": Column '" +
colName + "', specified in primary key " +
"constraint, is not a declared column.");
else
table.setPrimaryKey (col.name());
}
} else {
// It should be a UNIQUE constraint
table.addUniqueConstraint
(new UniqueConstraint (constraintName, table, columnNameSet));
}
}
private static void addForeignKeyConstraint (String constraintName,
DbTable table,
StringSet columnNameSet,
String toTableName,
String toColName) {
if (columnNameSet.size() != 1) {
// We now silently ignore this problem -- MAS 1/7/2003
// _errorList.add ("Table " + table.name() + ": must have " +
// "exactly one column in foreign key.");
return;
}
String fkColName = columnNameSet.asArray()[0];
DbColumn fkCol = table.columnWithName (fkColName);
if (fkCol == null) {
_errorList.add ("Table " + table.name() +
": Cannot add foreign key constraint: no " +
"foreign key column named '" + fkColName + "'");
return;
}
DbTable toTable = _dbSchema.tableWithName (toTableName);
if (toTable == null) {
_errorList.add ("Table '" + toTableName + "' not found in schema.");
return;
}
DbColumn toColumn = toTable.columnWithName (toColName);
if (toColumn == null) {
_errorList.add ("Attempting to add foreign key from " +
table.name() + "(" +
columnNameSet.joinString(",") + ") to table '" +
toTableName + "': the latter has no column " +
"named '" + toColName + "'");
} else {
String constraintId = constraintName != null
? constraintName
: ("zcFkConstraint" + (++zcFkCount));
ForeignKeyConstraint constraint = new ForeignKeyConstraint
(constraintId, fkCol, toColumn, _fkConstraints.size());
_fkConstraints.add (constraint);
}
}
private static Schema _dbSchema;
private static Vector _errorList;
private static List _fkConstraints;
private static SqlParser _parser;
private static int zcFkCount = 0;
}
PARSER_END(SqlParser)
SKIP :
{
" "
|
"\t"
|
"\n"
|
"\r"
|
"--" : IN_LINE_COMMENT
|
"/*" : IN_COMMENT
}
{
"\n" : DEFAULT
}
{
< ~[] >
}
{
"*/" : DEFAULT
}
{
< ~[] >
}
TOKEN [IGNORE_CASE] :
{
< ADD: "add" >
| < ALL: "all" >
| < ALTER: "alter" >
| < AND: "and" >
| < ANY: "any" >
| < AS : "as" >
| < ASC: "asc" >
| < BY: "by" >
| < CACHE: "cache" >
| < CASCADE: "cascade" >
| < CHECK: "check" >
| < COLUMN: "column" >
| < COMMENT: "comment" >
| < CONSTRAINT: "constraint" >
| < CONSTRAINTS: "constraints" >
| < CREATE: "create" >
| < CYCLE: "cycle" >
| < DEFAULT_TOK: "default" >
| < DELETE: "delete" >
| < DESC: "desc" >
| < DROP: "drop" >
| < FOREIGN: "foreign" >
| < IDENTITY: "identity" >
| < IN: "in" >
| < INCREMENT: "increment" >
| < INDEX: "index" >
| < IS: "is" >
| < KEY: "key" >
| < MAXVALUE: "maxvalue" >
| < MINVALUE: "minvalue" >
| < NOCACHE: "nocache" >
| < NOCYCLE: "nocycle" >
| < NOMAXVALUE: "nomaxvalue" >
| < NOMINVALUE: "nominvalue" >
| < NOORDER: "noorder" >
| < NOT: "not" >
| < NULL: "null" >
| < ON: "on" >
| < OR: "or" >
| < ORDER: "order" >
| < PRIMARY: "primary" >
| < REFERENCES: "references" >
| < SELECT: "select" >
| < SEQUENCE: "sequence" >
| < SOME: "some" >
| < START: "start" >
| < TABLE: "table" >
| < UNIQUE : "unique" >
| < UPDATE : "update" >
| < VIEW : "view" >
| < WITH: "with" >
| < COMMA: "," >
| < DOT: "." >
| < IDENTIFIER: ["a"-"z","A"-"Z", "_"] (["a"-"z", "_", "0"-"9", "$", "#"])* >
| < LPAREN: "(" >
| < NUMBER: (["0"-"9"])+ >
| < RPAREN: ")" >
| < SEMICOLON: ";" >
| < SLASH: "/" >
| < STRING_LITERAL:
(
"'"
(~["'","\\","\n","\r"])*
"'"
)+
>
}
String allowedColumnName () :
{}
{
(
LOOKAHEAD(2)
< IDENTIFIER >
| < ANY >
| < AS >
| < ASC >
| < BY >
| < CACHE >
| < CASCADE >
| < CHECK >
| < COLUMN >
| < COMMENT >
| < CONSTRAINTS >
| < CREATE >
| < CYCLE >
| < DEFAULT_TOK >
| < DELETE >
| < DESC >
| < DROP >
| < FOREIGN >
| < IDENTITY >
| < IN >
| < INCREMENT >
| < INDEX >
| < IS >
| < KEY >
| < MAXVALUE >
| < MINVALUE >
| < NOCACHE >
| < NOCYCLE >
| < NOMAXVALUE >
| < NOMINVALUE >
| < NOORDER >
| < NOT >
| < NULL >
| < ON >
| < OR >
| < ORDER >
| < PRIMARY >
| < REFERENCES >
| < SELECT >
| < SEQUENCE >
| < SOME >
| < START >
| < TABLE >
| < UNIQUE >
| < UPDATE >
| < VIEW >
| < WITH >
) { return token.toString(); }
}
void ddlSequence () throws ZcException :
{
DbTable table;
String sequenceName;
}
{
(
(
comment()
|
(
(
table = tableDefinition () {
addTable (table);
}
|
indexDefinition ()
|
sequenceName = sequenceDefinition ()
{
addSequence (sequenceName);
}
)
)
|
(
(
view = viewDefinition ()
)
)
|
alterTable ()
|
dropTable()
)
(
|
)+
)+
}
void comment () :
{ }
{
(
(