Skip to content

Commit

Permalink
redmonkey found a prob w/patterns and JDK 1.4. Also had to do some fu…
Browse files Browse the repository at this point in the history
…nky stuff to deal with some OSes (e.g. XP) doing filename expansion with runtime.exec()
  • Loading branch information
johncurrier committed Nov 28, 2006
1 parent 2089f57 commit 28943ae
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 15 deletions.
38 changes: 25 additions & 13 deletions src/net/sourceforge/schemaspy/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,12 @@ public List getRemainingParameters()
return options;
}

/**
* Options that are specific to a type of database. E.g. things like <code>host</code>,
* <code>port</code> or <code>db</code>.
*
* @param dbSpecificOptions
*/
public void setDbSpecificOptions(Map dbSpecificOptions) {
this.dbSpecificOptions = dbSpecificOptions;
this.originalDbSpecificOptions = new HashMap(dbSpecificOptions);
Expand Down Expand Up @@ -572,27 +578,33 @@ public boolean isDbTypeSpecific() {
* List
* @return List
*/
protected List fixupArgs(List args)
{
protected List fixupArgs(List args) {
List expandedArgs = new ArrayList();

Iterator iter = args.iterator();
while (iter.hasNext())
{
for (Iterator iter = args.iterator(); iter.hasNext(); ) {
String arg = iter.next().toString();
int indexOfEquals = arg.indexOf('=');
if (indexOfEquals != -1)
{
if (indexOfEquals != -1) {
expandedArgs.add(arg.substring(0, indexOfEquals));
expandedArgs.add(arg.substring(indexOfEquals + 1));
}
else
{
} else {
expandedArgs.add(arg);
}
}

return expandedArgs;
// some OSes/JVMs do filename expansion with runtime.exec() and some don't,
// so MultipleSchemaAnalyzer has to surround params with double quotes...
// strip them here for the OSes/JVMs that don't do anything with the params
List unquotedArgs = new ArrayList();

for (Iterator iter = expandedArgs.iterator(); iter.hasNext(); ) {
String arg = iter.next().toString();
if (arg.startsWith("\"") && arg.endsWith("\"")) // ".*" becomes .*
arg = arg.substring(1, arg.length() - 1);
unquotedArgs.add(arg);
}

return unquotedArgs;
}

/**
Expand Down Expand Up @@ -767,9 +779,9 @@ public List asList() throws IOException {
list.add(value);
}
list.add("-i");
list.add(getInclusions().toString());
list.add(getInclusions().pattern());
list.add("-x");
list.add(getExclusions().toString());
list.add(getExclusions().pattern());
list.add("-dbthreads");
list.add(String.valueOf(getMaxDbThreads()));
list.add("-maxdet");
Expand Down
4 changes: 3 additions & 1 deletion src/net/sourceforge/schemaspy/Main.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package net.sourceforge.schemaspy;

import java.util.*;


/**
* @author John Currier
*/
public class Main {
public static void main(String[] argv) throws Exception {
SchemaAnalyzer analyzer = new SchemaAnalyzer();

System.out.println(Arrays.asList(argv));
System.exit(analyzer.analyze(new Config(argv), argv));
}
}
2 changes: 1 addition & 1 deletion src/net/sourceforge/schemaspy/MultipleSchemaAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public int analyze(String dbName, DatabaseMetaData meta, String schemaSpec, List
command.add("-o");
command.add(new File(outputDir, schema).toString());
System.out.println("Analyzing " + schema);
System.out.println(command);
System.out.flush();
Process java = Runtime.getRuntime().exec((String[])command.toArray(new String[]{}));
new ProcessOutputReader(java.getInputStream(), System.out).start();
Expand Down Expand Up @@ -129,6 +128,7 @@ public void run() {
int ch;
while ((ch = processReader.read()) != -1) {
out.print((char)ch);
out.flush();
}
} catch (IOException ioException) {
ioException.printStackTrace();
Expand Down

0 comments on commit 28943ae

Please sign in to comment.