adopted input statement - SystemProperties moved to helma.util.
This commit is contained in:
parent
55e58ab509
commit
96abb621ec
1 changed files with 205 additions and 116 deletions
|
@ -2,17 +2,44 @@ package helma.doc;
|
|||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import helma.objectmodel.*;
|
||||
import helma.util.SystemProperties;
|
||||
|
||||
/**
|
||||
* Description of the Class
|
||||
*
|
||||
*@author Stefan Pollach
|
||||
*@created August 20, 2001
|
||||
*/
|
||||
public class DocRun {
|
||||
|
||||
/**
|
||||
* Description of the Field
|
||||
*/
|
||||
public static String propfile;
|
||||
/**
|
||||
* Description of the Field
|
||||
*/
|
||||
public static SystemProperties sysProps, dbProps;
|
||||
/**
|
||||
* Description of the Field
|
||||
*/
|
||||
public static String actionExtension;
|
||||
/**
|
||||
* Description of the Field
|
||||
*/
|
||||
public static String scriptExtension;
|
||||
/**
|
||||
* Description of the Field
|
||||
*/
|
||||
public static String templateExtension;
|
||||
/**
|
||||
* Description of the Field
|
||||
*/
|
||||
public static String skinExtension = ".skin";
|
||||
|
||||
/**
|
||||
* Description of the Field
|
||||
*/
|
||||
public static String hopHomeDir;
|
||||
|
||||
private static Hashtable options;
|
||||
|
@ -20,6 +47,60 @@ public class DocRun {
|
|||
String appName;
|
||||
DocApplication app;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for the DocRun object
|
||||
*
|
||||
*@param appDir Description of Parameter
|
||||
*@exception DocException Description of Exception
|
||||
*/
|
||||
public DocRun(String appDir) throws DocException {
|
||||
File d = new File(appDir);
|
||||
if (!d.exists()) {
|
||||
throw new DocException(d.toString() + " doesn't exist");
|
||||
}
|
||||
if (!d.isDirectory()) {
|
||||
throw new DocException(d.toString() + " is not a directory");
|
||||
}
|
||||
log("parsing application " + d.getName() + " located in " + d.getAbsolutePath());
|
||||
log("writing output to " + getOption("-d", new File(hopHomeDir, "/appdocs/" + d.getName()).getAbsolutePath()));
|
||||
app = new DocApplication(d.getName(), d.getAbsolutePath());
|
||||
DocWriter.start(getOption("-d", new File(hopHomeDir, "/appdocs/" + d.getName()).getAbsolutePath()), app);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the option attribute of the DocRun class
|
||||
*
|
||||
*@param name Description of Parameter
|
||||
*@return The option value
|
||||
*/
|
||||
public static String getOption(String name) {
|
||||
return getOption(name, "");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the option attribute of the DocRun class
|
||||
*
|
||||
*@param name Description of Parameter
|
||||
*@param def Description of Parameter
|
||||
*@return The option value
|
||||
*/
|
||||
public static String getOption(String name, String def) {
|
||||
if (options.containsKey(name)) {
|
||||
return (String) options.get(name);
|
||||
} else {
|
||||
return (def);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Description of the Method
|
||||
*
|
||||
*@param args Description of Parameter
|
||||
*/
|
||||
public static void main(String args[]) {
|
||||
boolean usageError = false;
|
||||
// parse options from command line
|
||||
|
@ -29,18 +110,20 @@ public class DocRun {
|
|||
for (int i = 0; i < args.length; i++) {
|
||||
if (args[i].startsWith("-")) {
|
||||
if (i > 0) {
|
||||
if ( buf.toString().length()==0 )
|
||||
if (buf.toString().length() == 0) {
|
||||
usageError = true;
|
||||
else
|
||||
} else {
|
||||
options.put(name, buf.toString());
|
||||
}
|
||||
}
|
||||
name = args[i];
|
||||
buf = new StringBuffer();
|
||||
} else {
|
||||
buf.append(((buf.toString().length() > 0) ? " " : "") + args[i]);
|
||||
}
|
||||
}
|
||||
options.put(name,buf.toString()); // include last option
|
||||
options.put(name, buf.toString());
|
||||
// include last option
|
||||
// now check parameter
|
||||
if (options.containsKey("-h")) {
|
||||
hopHomeDir = (String) options.get("-h");
|
||||
|
@ -65,6 +148,10 @@ public class DocRun {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Description of the Method
|
||||
*/
|
||||
public static void help() {
|
||||
System.out.println("usage: java helma.doc.DocApplication -a appdir [-f] [-h hopdir] [-d docdir] [-i ignore]");
|
||||
System.out.println(" -a appdir Specify source directory");
|
||||
|
@ -76,20 +163,33 @@ public class DocRun {
|
|||
System.out.println("\n");
|
||||
}
|
||||
|
||||
public static boolean prototypeAllowed(String name) {
|
||||
String ig = " " + getOption("-i").toLowerCase() + " ";
|
||||
if ( ig.equals("") ) return true;
|
||||
name = name.toLowerCase();
|
||||
if ( ig.indexOf(" "+name+" ")>-1 )
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* reads server.properties, apps.properties and db.properties from hop-home-directory
|
||||
* TBD: should be cleaned up to work exactly like the helma server
|
||||
* @param homeDir hop-home-directory with server.properties-file
|
||||
* Description of the Method
|
||||
*
|
||||
*@param name Description of Parameter
|
||||
*@return Description of the Returned Value
|
||||
*/
|
||||
public static boolean prototypeAllowed(String name) {
|
||||
String ig = " " + getOption("-i").toLowerCase() + " ";
|
||||
if (ig.equals("")) {
|
||||
return true;
|
||||
}
|
||||
name = name.toLowerCase();
|
||||
if (ig.indexOf(" " + name + " ") > -1) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* reads server.properties, apps.properties and db.properties from
|
||||
* hop-home-directory TBD: should be cleaned up to work exactly like the
|
||||
* helma server
|
||||
*
|
||||
*@param hopHomeDir Description of Parameter
|
||||
*/
|
||||
public static void readHopProperties(String hopHomeDir) {
|
||||
propfile = new File(hopHomeDir, "server.properties").getAbsolutePath();
|
||||
|
@ -100,34 +200,24 @@ public class DocRun {
|
|||
templateExtension = sysProps.getProperty("templateExtension", ".hsp");
|
||||
}
|
||||
|
||||
public DocRun (String appDir) throws DocException {
|
||||
File d = new File(appDir);
|
||||
if ( !d.exists() )
|
||||
throw new DocException( d.toString() + " doesn't exist");
|
||||
if ( !d.isDirectory() )
|
||||
throw new DocException( d.toString() + " is not a directory");
|
||||
log ( "parsing application " + d.getName() + " located in " + d.getAbsolutePath() );
|
||||
log ( "writing output to " + getOption("-d", new File(hopHomeDir,"/appdocs/"+d.getName()).getAbsolutePath()) );
|
||||
app = new DocApplication(d.getName(),d.getAbsolutePath() );
|
||||
DocWriter.start( getOption("-d", new File(hopHomeDir,"/appdocs/"+d.getName()).getAbsolutePath()), app);
|
||||
}
|
||||
|
||||
public static String getOption(String name) {
|
||||
return getOption(name,"");
|
||||
}
|
||||
|
||||
public static String getOption(String name, String def) {
|
||||
if ( options.containsKey(name) )
|
||||
return(String)options.get(name);
|
||||
else
|
||||
return(def);
|
||||
}
|
||||
|
||||
/**
|
||||
* Description of the Method
|
||||
*
|
||||
*@param msg Description of Parameter
|
||||
*/
|
||||
public static void debug(String msg) {
|
||||
if ( options.containsKey("-debug") )
|
||||
if (options.containsKey("-debug")) {
|
||||
System.out.println(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Description of the Method
|
||||
*
|
||||
*@param msg Description of Parameter
|
||||
*/
|
||||
public static void log(String msg) {
|
||||
System.out.println(msg);
|
||||
}
|
||||
|
@ -135,4 +225,3 @@ public class DocRun {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue