Nur Dokumentation / Formatierungen

git-svn-id: https://svn.libreccm.org/ccm/trunk@1037 8810af33-2d31-482b-a856-94f89814c4df
master
pb 2011-07-31 13:54:56 +00:00
parent 4448038b62
commit 020cbd9dc7
31 changed files with 317 additions and 329 deletions

View File

@ -42,15 +42,11 @@ import org.apache.log4j.Logger;
* *
* @author Rafael H. Schloming <rhs@mit.edu> * @author Rafael H. Schloming <rhs@mit.edu>
* @version $Revision: #4 $ $Date: 2004/08/16 $ * @version $Revision: #4 $ $Date: 2004/08/16 $
* @version $Id: BaseCheck.java 736 2005-09-01 10:46:05Z sskracic
*/ */
abstract public class BaseCheck extends Check { abstract public class BaseCheck extends Check {
private static final Logger logger = Logger.getLogger(BaseCheck.class); private static final Logger logger = Logger.getLogger(BaseCheck.class);
public static final String versionId =
"$Id: BaseCheck.java 736 2005-09-01 10:46:05Z sskracic $" +
" by $Author: sskracic $, " +
"$DateTime: 2004/08/16 18:10:38 $";
public static final MessageMap s_messages = new MessageMap(); public static final MessageMap s_messages = new MessageMap();

View File

@ -24,7 +24,7 @@ import com.arsdigita.runtime.AbstractScript;
* The Check class provides a developer callback for performing * The Check class provides a developer callback for performing
* validation checks during various points in the package loading and * validation checks during various points in the package loading and
* server startup process. This functionality is accessed by creating * server startup process. This functionality is accessed by creating
* a <i>package-key</i>.checklist file in the src dir of the package * a <i>package-key</i> checklist file in the src dir of the package
* that wishes to add checks. This must be a valid xml file that * that wishes to add checks. This must be a valid xml file that
* conforms to the following format: * conforms to the following format:
* *
@ -65,15 +65,10 @@ import com.arsdigita.runtime.AbstractScript;
* *
* @author Rafael H. Schloming &lt;rhs@mit.edu&gt; * @author Rafael H. Schloming &lt;rhs@mit.edu&gt;
* @version $Revision: #5 $ $Date: 2004/08/16 $ * @version $Revision: #5 $ $Date: 2004/08/16 $
**/ * @version $Id: Check.java 736 2005-09-01 10:46:05Z sskracic $
*/
public abstract class Check extends AbstractScript { public abstract class Check extends AbstractScript {
public final static String versionId =
"$Id: Check.java 736 2005-09-01 10:46:05Z sskracic $" +
"by $Author: sskracic $, " +
"$DateTime: 2004/08/16 18:10:38 $";
public static final class Status { public static final class Status {
private String m_name; private String m_name;
@ -101,8 +96,7 @@ public abstract class Check extends AbstractScript {
* the Check class. * the Check class.
* *
* @param status The status, one of PASS, FAIL, or WARN. * @param status The status, one of PASS, FAIL, or WARN.
**/ */
protected void status(Status status) { protected void status(Status status) {
if (m_status == null) { if (m_status == null) {
m_status = status; m_status = status;
@ -116,8 +110,7 @@ public abstract class Check extends AbstractScript {
* #run(ScriptContext)} method. * #run(ScriptContext)} method.
* *
* @return The status, one of PASS, FAIL, or WARN. * @return The status, one of PASS, FAIL, or WARN.
**/ */
public Status getStatus() { public Status getStatus() {
return m_status; return m_status;
} }

View File

@ -32,23 +32,17 @@ import org.apache.log4j.Logger;
/** /**
* CheckDB * CheckDB is a helper class for the load command worker class Load, checks for
* helper class for the load command worker class Load, checks for * existence of a database and verifies accessibility.
* existence of a database and verifies accessibility
*
* Subject to change!
* *
* @author Rafael H. Schloming &lt;rhs@mit.edu&gt; * @author Rafael H. Schloming &lt;rhs@mit.edu&gt;
* @version $Revision: #7 $ $Date: 2004/08/16 $ * @version $Revision: #7 $ $Date: 2004/08/16 $
* @version $Id: DBCheck.java 736 2005-09-01 10:46:05Z sskracic $
*/ */
public class CheckDB extends BaseCheck { public class CheckDB extends BaseCheck {
private static final Logger logger = Logger.getLogger(CheckDB.class); private static final Logger logger = Logger.getLogger(CheckDB.class);
public final static String versionId =
"$Id: DBCheck.java 736 2005-09-01 10:46:05Z sskracic $" +
" by $Author: sskracic $, " +
"$DateTime: 2004/08/16 18:10:38 $";
// Integration of service class packaging.MessageMap. // Integration of service class packaging.MessageMap.
// Specifies a package specific message file overriding BaseCheck // Specifies a package specific message file overriding BaseCheck

View File

@ -35,15 +35,15 @@ import org.xml.sax.helpers.DefaultHandler;
* *
* @author Rafael H. Schloming &lt;rhs@mit.edu&gt; * @author Rafael H. Schloming &lt;rhs@mit.edu&gt;
* @version $Revision: #8 $ $Date: 2004/08/16 $ * @version $Revision: #8 $ $Date: 2004/08/16 $
**/ * @version $Id: Checklist.java 736 2005-09-01 10:46:05Z sskracic $
*/
class Checklist { class Checklist {
public final static String versionId = /**
"$Id: Checklist.java 736 2005-09-01 10:46:05Z sskracic $" + *
" by $Author: sskracic $, " + * @param pkg
"$DateTime: 2004/08/16 18:10:38 $"; * @return
*/
public static Checklist get(String pkg) { public static Checklist get(String pkg) {
ClassLoader ldr = Checklist.class.getClassLoader(); ClassLoader ldr = Checklist.class.getClassLoader();
InputStream is = ldr.getResourceAsStream(pkg + ".checklist"); InputStream is = ldr.getResourceAsStream(pkg + ".checklist");
@ -60,10 +60,21 @@ class Checklist {
private List m_groups = new ArrayList(); private List m_groups = new ArrayList();
/**
* Constructor
*
* @param is
*/
public Checklist(InputStream is) { public Checklist(InputStream is) {
XML.parse(is, new ChecklistHandler()); XML.parse(is, new ChecklistHandler());
} }
/**
*
* @param type
* @param ctx
* @return
*/
public boolean run(int type, ScriptContext ctx) { public boolean run(int type, ScriptContext ctx) {
boolean result = true; boolean result = true;
for (Iterator it = m_groups.iterator(); it.hasNext(); ) { for (Iterator it = m_groups.iterator(); it.hasNext(); ) {
@ -75,6 +86,9 @@ class Checklist {
return result; return result;
} }
/**
*
*/
private class Group { private class Group {
private int m_type; private int m_type;
@ -122,6 +136,9 @@ class Checklist {
private static final String CHECK = "check"; private static final String CHECK = "check";
private static final String CLASS = "class"; private static final String CLASS = "class";
/**
*
*/
private class ChecklistHandler extends DefaultHandler { private class ChecklistHandler extends DefaultHandler {
private Group m_group = null; private Group m_group = null;

View File

@ -30,27 +30,28 @@ import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.PosixParser; import org.apache.commons.cli.PosixParser;
/** /**
* Clear * Clear implements the command line interface to clear one or more values
* * in a CCM configuration database (registry).
* Implements the command line interface to clear one or more values
* in a CCM configuration database (registry)
* @author Justin Ross &lt;jross@redhat.com&gt; * @author Justin Ross &lt;jross@redhat.com&gt;
* @version $Id: Clear.java 736 2005-09-01 10:46:05Z sskracic $ * @version $Id: Clear.java 736 2005-09-01 10:46:05Z sskracic $
* @version $Id: Clear.java 736 2005-09-01 10:46:05Z sskracic $
*/ */
class Clear extends Command { class Clear extends Command {
public final static String versionId =
"$Id: Clear.java 736 2005-09-01 10:46:05Z sskracic $" +
"$Author: sskracic $" +
"$DateTime: 2004/08/16 18:10:38 $";
private static final Options s_options = getOptions(); private static final Options s_options = getOptions();
/**
* Constructor
*/
public Clear() { public Clear() {
super("clear", super("clear",
"Clear one or more values in a CCM configuration database"); "Clear one or more values in a CCM configuration database");
} }
/**
* Invoked from the central tool "MasterTool" to perform the clear process.
*/
public boolean run(final String[] args) { public boolean run(final String[] args) {
final CommandLine line; final CommandLine line;

View File

@ -31,8 +31,7 @@ import org.apache.commons.cli.Options;
* *
* @author Rafael H. Schloming &lt;rhs@mit.edu&gt; * @author Rafael H. Schloming &lt;rhs@mit.edu&gt;
* @version $Id: Command.java 1324 2006-09-21 22:13:16Z apevec $ * @version $Id: Command.java 1324 2006-09-21 22:13:16Z apevec $
**/ */
abstract class Command { abstract class Command {
private String m_name; private String m_name;

View File

@ -45,15 +45,11 @@ import java.util.Properties;
* *
* @author Rafael H. Schloming &lt;rhs@mit.edu&gt; * @author Rafael H. Schloming &lt;rhs@mit.edu&gt;
* @version $Revision: #7 $ $Date: 2004/08/16 $ * @version $Revision: #7 $ $Date: 2004/08/16 $
* @version $Id: Config.java 736 2005-09-01 10:46:05Z sskracic $
**/ **/
public final class Config extends ParameterMap { public final class Config extends ParameterMap {
public final static String versionId =
"$Id: Config.java 736 2005-09-01 10:46:05Z sskracic $" +
" by $Author: sskracic $, " +
"$DateTime: 2004/08/16 18:10:38 $";
private ConfigRegistry m_reg; private ConfigRegistry m_reg;
/** /**

View File

@ -1,52 +0,0 @@
/*
* Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.packaging;
import java.io.File;
import java.io.IOException;
/**
* Commonly used file utilities.
*
* @author Rafael H. Schloming &lt;rhs@mit.edu&gt;
* @version $Revision: #5 $ $Date: 2004/08/16 $
*
* @deprecated use com.arsdigita.util.Files
**/
final class Files {
public final static String versionId = "$Id: Files.java 736 2005-09-01 10:46:05Z sskracic $ by $Author: sskracic $, $DateTime: 2004/08/16 18:10:38 $";
private Files() {}
/**
* @deprecated use com.arsdigita.util.Files.delete(File file)
*/
public static void delete(File file) {
com.arsdigita.util.Files.delete(file);
}
/**
* @deprecated use com.arsdigita.util.Files.copy(File from, File to)
*/
public static void copy(File from, File to) throws IOException {
com.arsdigita.util.Files.copy(from, to);
}
}

View File

@ -40,23 +40,18 @@ import org.apache.commons.cli.PosixParser;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* Get * Get class implements the command line interface to list one or more values
*
* Implements the command line interface to list one or more values
* from a CCM configuration database (registry) * from a CCM configuration database (registry)
* *
* Called by ccm get command * Called by ccm get command
* *
* @author Rafael H. Schloming &lt;rhs@mit.edu&gt; * @author Rafael H. Schloming &lt;rhs@mit.edu&gt;
* @version $Revision: #6 $ $Date: 2004/08/16 $ * @version $Revision: #6 $ $Date: 2004/08/16 $
* @version $Id: Get.java 1324 2006-09-21 22:13:16Z apevec $
**/ **/
class Get extends Command { class Get extends Command {
public static final Logger logger = Logger.getLogger(Get.class); public static final Logger logger = Logger.getLogger(Get.class);
public final static String versionId =
"$Id: Get.java 1324 2006-09-21 22:13:16Z apevec $"
+ " by $Author: apevec $, "
+ "$DateTime: 2004/08/16 18:10:38 $";
private static final Options OPTIONS = getOptions(); private static final Options OPTIONS = getOptions();
static { static {
@ -72,11 +67,17 @@ class Get extends Command {
logger.debug("Static initalizer finished."); logger.debug("Static initalizer finished.");
} }
/**
* Constructor
*/
public Get() { public Get() {
super("get", "Print one or more values from a CCM " super("get", "Print one or more values from a CCM "
+ "configuration database"); + "configuration database");
} }
/**
* Invoked from the central tool "MasterTool" to perform get.
*/
public boolean run(String[] args) { public boolean run(String[] args) {
CommandLine line; CommandLine line;
try { try {
@ -162,6 +163,12 @@ class Get extends Command {
return true; return true;
} }
/**
*
* @param properties
* @param out
* @throws IOException
*/
private void write(Properties properties, PrintStream out) private void write(Properties properties, PrintStream out)
throws IOException { throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();

View File

@ -23,19 +23,20 @@ package com.arsdigita.packaging;
* *
* @author Rafael H. Schloming &lt;rhs@mit.edu&gt; * @author Rafael H. Schloming &lt;rhs@mit.edu&gt;
* @version $Revision: #4 $ $Date: 2004/08/16 $ * @version $Revision: #4 $ $Date: 2004/08/16 $
**/ * @version $Id: Help.java 287 2005-02-22 00:29:02Z sskracic $
*/
class Help extends Command { class Help extends Command {
public final static String versionId = /**
"$Id: Help.java 287 2005-02-22 00:29:02Z sskracic $" + * Constructor
" by $Author: sskracic $, " + */
"$DateTime: 2004/08/16 18:10:38 $";
public Help() { public Help() {
super("--help", "Print generic help"); super("--help", "Print generic help");
} }
/**
* Invoked from the central tool "MasterTool" to write help message.
*/
public boolean run(String[] args) { public boolean run(String[] args) {
// XXX: Should do something better eventually. // XXX: Should do something better eventually.
return new Usage().run(args); return new Usage().run(args);

View File

@ -67,15 +67,10 @@ import org.apache.log4j.Logger;
* *
* @author Rafael H. Schloming &lt;rhs@mit.edu&gt; * @author Rafael H. Schloming &lt;rhs@mit.edu&gt;
* @version $Revision: #16 $ $Date: 2004/08/16 $ * @version $Revision: #16 $ $Date: 2004/08/16 $
**/ * @version $Id: HostInit.java 736 2005-09-01 10:46:05Z sskracic $
*/
public class HostInit { public class HostInit {
public final static String versionId =
"$Id: HostInit.java 736 2005-09-01 10:46:05Z sskracic $" +
"by $Author: sskracic $, " +
"$DateTime: 2004/08/16 18:10:38 $";
private static final Logger s_log = private static final Logger s_log =
Logger.getLogger(HostInit.class); Logger.getLogger(HostInit.class);

View File

@ -26,23 +26,14 @@ import com.arsdigita.persistence.Session;
import com.arsdigita.persistence.SessionManager; import com.arsdigita.persistence.SessionManager;
import com.arsdigita.persistence.metadata.MetadataRoot; import com.arsdigita.persistence.metadata.MetadataRoot;
import com.arsdigita.persistence.pdl.PDLCompiler; import com.arsdigita.persistence.pdl.PDLCompiler;
// pboy (Jan.09): deprecated classes and methods removed,
// comments should be deleted after extensiv testing
// deprecated, no replacement specified by author,
// created InteractiveParameterReader analogous to CompoundParameterReader
//import com.arsdigita.runtime.InteractiveParameterLoader;
import com.arsdigita.runtime.InteractiveParameterReader; import com.arsdigita.runtime.InteractiveParameterReader;
import com.arsdigita.runtime.ConfigRegistry; import com.arsdigita.runtime.ConfigRegistry;
import com.arsdigita.runtime.RegistryConfig; import com.arsdigita.runtime.RegistryConfig;
import com.arsdigita.runtime.RuntimeConfig; import com.arsdigita.runtime.RuntimeConfig;
import com.arsdigita.runtime.Startup; import com.arsdigita.runtime.Startup;
import com.arsdigita.util.UncheckedWrapperException; import com.arsdigita.util.UncheckedWrapperException;
// deprecated, use c.ad.util.JavaPropertyReader instead
// import com.arsdigita.util.config.JavaPropertyLoader;
import com.arsdigita.util.JavaPropertyReader; import com.arsdigita.util.JavaPropertyReader;
import com.arsdigita.util.jdbc.Connections; import com.arsdigita.util.jdbc.Connections;
// deprecated:
// import com.arsdigita.util.parameter.CompoundParameterLoader;
import com.arsdigita.util.parameter.CompoundParameterReader; import com.arsdigita.util.parameter.CompoundParameterReader;
import com.arsdigita.util.parameter.Parameter; import com.arsdigita.util.parameter.Parameter;
import com.arsdigita.util.parameter.ParameterContext; import com.arsdigita.util.parameter.ParameterContext;
@ -76,9 +67,27 @@ import org.apache.log4j.Logger;
/** /**
* PackageTool worker class, implements the "load" command. * PackageTool worker class, implements the "load" command.
* *
* Loads the database schema and initial content. * It is called by class MasterTols and loads the database schema and initial
* content.
*
* MasterTool provides the following parameters (usually provided by an
* invokation script 'ccm')
*
* ccm load PACKAGE-KEYS [options]
* PACKAGE-KEYS one or more space separated names of modules (package-key, e.g.
* ccm-cms-types-event) which should be loaded into database and
* configuration registry
* Options: [-usage] Display a usage message for load command
* [-help|--help] Display a help message for load command
* [--recursive] Recursively load required packages
* [--data]
* [--config]
* [--interactive]
* [--schema]
* [--parameters KEY=VALUE ...]
* [--init]
* [--parameter-file FILE]
* *
* Called by PackageTool
* *
* @author Rafael H. Schloming &lt;rhs@mit.edu&gt; * @author Rafael H. Schloming &lt;rhs@mit.edu&gt;
* @version $Id: Load.java 736 2005-09-01 10:46:05Z sskracic $ * @version $Id: Load.java 736 2005-09-01 10:46:05Z sskracic $
@ -168,8 +177,8 @@ class Load extends Command {
* @return * @return
*/ */
public boolean run(String[] args) { public boolean run(String[] args) {
CommandLine line;
CommandLine line;
try { try {
line = new PosixParser().parse(OPTIONS, args); line = new PosixParser().parse(OPTIONS, args);
} catch (ParseException e) { } catch (ParseException e) {
@ -195,16 +204,15 @@ class Load extends Command {
|| line.hasOption("data") || line.hasOption("data")
|| line.hasOption("init")); || line.hasOption("init"));
// RegistryConfig contains a list of package-keys of packages to be // RegistryConfig contains a list of package-keys of loaded packages
// installed. RegistryConfig rc = new RegistryConfig(); // Create a new (empty) config object.
// Constructs a new and empty config object. rc.load(); // Load config values from file
RegistryConfig rc = new RegistryConfig(); List loaded = Arrays.asList(rc.getPackages()); // retrieve list of installed packages
rc.load();
List loaded = Arrays.asList(rc.getPackages());
Map loaders = new HashMap(); Map loaders = new HashMap();
List keys = new ArrayList(); List keys = new ArrayList();
keys.addAll(packages); keys.addAll(packages); // from command line parameters packages to be installed
boolean err = false; boolean err = false;
while (!keys.isEmpty()) { while (!keys.isEmpty()) {
String key = (String) keys.remove(0); String key = (String) keys.remove(0);

View File

@ -34,8 +34,6 @@ import com.arsdigita.runtime.ScriptContext;
import com.arsdigita.runtime.Startup; import com.arsdigita.runtime.Startup;
import com.arsdigita.util.Classes; import com.arsdigita.util.Classes;
import com.arsdigita.util.UncheckedWrapperException; import com.arsdigita.util.UncheckedWrapperException;
// ParameterLoader is deprecated
// import com.arsdigita.util.parameter.ParameterLoader;
import com.arsdigita.util.parameter.ParameterReader; import com.arsdigita.util.parameter.ParameterReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -56,7 +54,7 @@ import org.apache.log4j.Logger;
* @author Rafael H. Schloming &lt;rhs@mit.edu&gt; * @author Rafael H. Schloming &lt;rhs@mit.edu&gt;
* @version $Revision: #13 $ $Date: 2004/08/16 $ * @version $Revision: #13 $ $Date: 2004/08/16 $
* @version $Id: Loader.java 2115 2011-01-13 17:11:50Z pboy $ * @version $Id: Loader.java 2115 2011-01-13 17:11:50Z pboy $
**/ */
class Loader { class Loader {
private static final Logger s_log = Logger.getLogger(Loader.class); private static final Logger s_log = Logger.getLogger(Loader.class);

View File

@ -32,15 +32,10 @@ import org.xml.sax.helpers.DefaultHandler;
* *
* @author Rafael H. Schloming &lt;rhs@mit.edu&gt; * @author Rafael H. Schloming &lt;rhs@mit.edu&gt;
* @version $Revision: #6 $ $Date: 2004/08/16 $ * @version $Revision: #6 $ $Date: 2004/08/16 $
**/ * @version $Id: LoaderInfo.java 287 2005-02-22 00:29:02Z sskracic $
*/
class LoaderInfo { class LoaderInfo {
public final static String versionId =
"$Id: LoaderInfo.java 287 2005-02-22 00:29:02Z sskracic $" +
" by $Author: sskracic $, " +
"$DateTime: 2004/08/16 18:10:38 $";
private List m_requiredTables = new ArrayList(); private List m_requiredTables = new ArrayList();
private List m_providedTables = new ArrayList(); private List m_providedTables = new ArrayList();
private List m_requiredInitializers = new ArrayList(); private List m_requiredInitializers = new ArrayList();
@ -49,6 +44,10 @@ class LoaderInfo {
private List m_dataScripts = new ArrayList(); private List m_dataScripts = new ArrayList();
private List m_requiredPackages = new ArrayList(); private List m_requiredPackages = new ArrayList();
/**
* Constructor.
* @param is
*/
public LoaderInfo(InputStream is) { public LoaderInfo(InputStream is) {
XML.parse(is, new LoaderInfoHandler()); XML.parse(is, new LoaderInfoHandler());
} }

View File

@ -51,7 +51,8 @@ public class MasterTool {
out.println(" --help Display help"); out.println(" --help Display help");
out.println(" --usage Print this message"); out.println(" --usage Print this message");
out.println(); out.println();
out.println("To show debugging output set the CCM_TOOLS_DEBUG environmental variable"); out.println("To show debugging output set the CCM_TOOLS_DEBUG "+
"environmental variable");
out.println(); out.println();
out.println("Commands:"); out.println("Commands:");
out.print(cmds.getCommands()); out.print(cmds.getCommands());

View File

@ -33,15 +33,10 @@ import java.util.Map;
* *
* @author Rafael H. Schloming &lt;rhs@mit.edu&gt; * @author Rafael H. Schloming &lt;rhs@mit.edu&gt;
* @version $Revision: #6 $ $Date: 2004/08/16 $ * @version $Revision: #6 $ $Date: 2004/08/16 $
**/ * @version $Id: Menu.java 736 2005-09-01 10:46:05Z sskracic
*/
class Menu { class Menu {
public final static String versionId =
"$Id: Menu.java 736 2005-09-01 10:46:05Z sskracic $" +
" by $Author: sskracic $, " +
"$DateTime: 2004/08/16 18:10:38 $";
static final class Layout { static final class Layout {
private Layout() {} private Layout() {}
} }

View File

@ -30,16 +30,10 @@ import org.apache.log4j.Logger;
* Helper class which can be used by the packaging classes and others. Manages * Helper class which can be used by the packaging classes and others. Manages
* messages to be printed and makes it easier to handle multi line messages. * messages to be printed and makes it easier to handle multi line messages.
* *
* Subject to change.
*
* @author Justin Ross &lt;jross@redhat.com&gt; * @author Justin Ross &lt;jross@redhat.com&gt;
* @version $Id: MessageMap.java 287 2005-02-22 00:29:02Z sskracic $ * @version $Id: MessageMap.java 287 2005-02-22 00:29:02Z sskracic $
*/ */
public final class MessageMap { public final class MessageMap {
public static final String versionId =
"$Id: MessageMap.java 287 2005-02-22 00:29:02Z sskracic $" +
"$Author: sskracic $" +
"$DateTime: 2004/08/16 18:10:38 $";
private static final Logger s_log = Logger.getLogger(MessageMap.class); private static final Logger s_log = Logger.getLogger(MessageMap.class);

View File

@ -44,15 +44,10 @@ import java.util.Properties;
* *
* @author Rafael H. Schloming &lt;rhs@mit.edu&gt; * @author Rafael H. Schloming &lt;rhs@mit.edu&gt;
* @version $Revision: #8 $ $Date: 2004/08/16 $ * @version $Revision: #8 $ $Date: 2004/08/16 $
**/ * @version $Id: ParameterEditor.java 736 2005-09-01 10:46:05Z sskracic $
*/
class ParameterEditor { class ParameterEditor {
public final static String versionId =
"$Id: ParameterEditor.java 736 2005-09-01 10:46:05Z sskracic $" +
" by $Author: sskracic $, " +
"$DateTime: 2004/08/16 18:10:38 $";
private ParameterMap m_map; private ParameterMap m_map;
private BufferedReader m_in; private BufferedReader m_in;
private PrintStream m_out; private PrintStream m_out;
@ -63,6 +58,13 @@ class ParameterEditor {
private List m_topics; private List m_topics;
private Map m_help; private Map m_help;
/**
*
*
* @param map
* @param in
* @param out
*/
ParameterEditor(ParameterMap map, InputStream in, PrintStream out) { ParameterEditor(ParameterMap map, InputStream in, PrintStream out) {
m_map = map; m_map = map;
m_in = new BufferedReader(new InputStreamReader(in)); m_in = new BufferedReader(new InputStreamReader(in));
@ -209,6 +211,9 @@ class ParameterEditor {
loadHelp(); loadHelp();
} }
/**
*
*/
private void loadHelp() { private void loadHelp() {
Properties props = new Properties(); Properties props = new Properties();
InputStream is = InputStream is =
@ -352,8 +357,11 @@ class ParameterEditor {
return m_valid; return m_valid;
} }
// XXX: for testing /**
public static final void main(String[] args) { * Method main added for testing only!
* @param args
*/
public static void main(String[] args) {
ParameterMap map = new ParameterMap(); ParameterMap map = new ParameterMap();
map.addContext( com.arsdigita.runtime.RuntimeConfig.getConfig()); map.addContext( com.arsdigita.runtime.RuntimeConfig.getConfig());
map.addContext(new com.arsdigita.web.WebConfig()); map.addContext(new com.arsdigita.web.WebConfig());

View File

@ -36,15 +36,10 @@ import java.util.Map;
* *
* @author Rafael H. Schloming &lt;rhs@mit.edu&gt; * @author Rafael H. Schloming &lt;rhs@mit.edu&gt;
* @version $Revision: #4 $ $Date: 2004/08/16 $ * @version $Revision: #4 $ $Date: 2004/08/16 $
**/ * @version $Id: ParameterMap.java 736 2005-09-01 10:46:05Z sskracic
*/
class ParameterMap { class ParameterMap {
public final static String versionId =
"$Id: ParameterMap.java 736 2005-09-01 10:46:05Z sskracic $" +
" by $Author: sskracic $, " +
"$DateTime: 2004/08/16 18:10:38 $";
private List m_contexts = new ArrayList(); private List m_contexts = new ArrayList();
private List m_parameters = new ArrayList(); private List m_parameters = new ArrayList();
private Map m_containers = new HashMap(); private Map m_containers = new HashMap();

View File

@ -40,15 +40,11 @@ import org.apache.log4j.Logger;
* *
* @author Rafael H. Schloming &lt;rhs@mit.edu&gt; * @author Rafael H. Schloming &lt;rhs@mit.edu&gt;
* @version $Revision: #7 $ $Date: 2004/08/16 $ * @version $Revision: #7 $ $Date: 2004/08/16 $
**/ * @version $Id: Set.java 736 2005-09-01 10:46:05Z sskracic $
*/
class Set extends Command { class Set extends Command {
private final static Logger logger = Logger.getLogger(Set.class); private final static Logger logger = Logger.getLogger(Set.class);
public final static String versionId =
"$Id: Set.java 736 2005-09-01 10:46:05Z sskracic $" +
" by $Author: sskracic $, " +
"$DateTime: 2004/08/16 18:10:38 $";
private static final Options OPTIONS = getOptions(); private static final Options OPTIONS = getOptions();
@ -63,10 +59,18 @@ class Set extends Command {
logger.debug("Static initalizer finished."); logger.debug("Static initalizer finished.");
} }
/**
* Constructor
*/
public Set() { public Set() {
super("set", "Set one or more values in a CCM configuration database"); super("set", "Set one or more values in a CCM configuration database");
} }
/**
* Run script.
* @param args
* @return
*/
public boolean run(String[] args) { public boolean run(String[] args) {
CommandLine line; CommandLine line;
try { try {

View File

@ -29,19 +29,20 @@ import com.arsdigita.runtime.Startup;
* *
* @author Rafael H. Schloming &lt;rhs@mit.edu&gt; * @author Rafael H. Schloming &lt;rhs@mit.edu&gt;
* @version $Revision: #5 $ $Date: 2004/08/16 $ * @version $Revision: #5 $ $Date: 2004/08/16 $
**/ * @version $Id: Status.java 736 2005-09-01 10:46:05Z sskracic
*/
class Status extends Command { class Status extends Command {
public final static String versionId = /**
"$Id: Status.java 736 2005-09-01 10:46:05Z sskracic $" + * Constructor
" by $Author: sskracic $, " + */
"$DateTime: 2004/08/16 18:10:38 $";
public Status() { public Status() {
super("status", "Report on the status of a CCM instance"); super("status", "Report on the status of a CCM instance");
} }
/**
* Invoked from the central tool "MasterTool" to perform the status check.
*/
public boolean run(String[] args) { public boolean run(String[] args) {
String[] packages; String[] packages;
if (args.length == 0) { if (args.length == 0) {

View File

@ -36,15 +36,11 @@ import org.apache.log4j.Logger;
* *
* @author Rafael H. Schloming &lt;rhs@mit.edu&gt; * @author Rafael H. Schloming &lt;rhs@mit.edu&gt;
* @version $Revision: #6 $ $Date: 2004/08/16 $ * @version $Revision: #6 $ $Date: 2004/08/16 $
**/ * @version $Id: Unload.java 736 2005-09-01 10:46:05Z sskracic $
*/
class Unload extends Command { class Unload extends Command {
private static final Logger logger = Logger.getLogger(Unload.class); private static final Logger logger = Logger.getLogger(Unload.class);
public final static String versionId =
"$Id: Unload.java 736 2005-09-01 10:46:05Z sskracic $" +
" by $Author: sskracic $, " +
"$DateTime: 2004/08/16 18:10:38 $";
private static final Options OPTIONS = new Options(); private static final Options OPTIONS = new Options();
@ -69,10 +65,16 @@ class Unload extends Command {
logger.debug("Static initalizer finished."); logger.debug("Static initalizer finished.");
} }
/**
* Constructor
*/
public Unload() { public Unload() {
super("unload", "Unload configuration"); super("unload", "Unload configuration");
} }
/**
* Invoked from the central tool "MasterTool" to perform the unload process.
*/
public boolean run(String[] args) { public boolean run(String[] args) {
CommandLine line; CommandLine line;
try { try {

View File

@ -85,6 +85,9 @@ class Upgrade extends Command {
logger.debug("Static initalizer finished."); logger.debug("Static initalizer finished.");
} }
/**
* Constructor
*/
public Upgrade() { public Upgrade() {
super("upgrade", super("upgrade",
"Upgrade a CCM package"); "Upgrade a CCM package");
@ -92,6 +95,9 @@ class Upgrade extends Command {
m_scripts = new ArrayList(); m_scripts = new ArrayList();
} }
/**
* Invoked from the central tool "MasterTool" to perform the upgrade step.
*/
public boolean run(final String[] args) { public boolean run(final String[] args) {
final CommandLine line; final CommandLine line;
@ -228,6 +234,9 @@ class Upgrade extends Command {
return true; return true;
} }
/**
*
*/
private class Parser extends DefaultHandler { private class Parser extends DefaultHandler {
private String m_version; private String m_version;

View File

@ -23,19 +23,20 @@ package com.arsdigita.packaging;
* *
* @author Rafael H. Schloming &lt;rhs@mit.edu&gt; * @author Rafael H. Schloming &lt;rhs@mit.edu&gt;
* @version $Revision: #4 $ $Date: 2004/08/16 $ * @version $Revision: #4 $ $Date: 2004/08/16 $
**/ * @version $Id: Usage.java 287 2005-02-22 00:29:02Z sskracic $
*/
class Usage extends Command { class Usage extends Command {
public final static String versionId = /**
"$Id: Usage.java 287 2005-02-22 00:29:02Z sskracic $" + * Constructor
" by $Author: sskracic $, " + */
"$DateTime: 2004/08/16 18:10:38 $";
public Usage() { public Usage() {
super("--usage", "Print this message"); super("--usage", "Print this message");
} }
/**
* Invoked from the central tool "MasterTool" to display a usage message.
*/
public boolean run(String[] args) { public boolean run(String[] args) {
if (args.length > 0) { if (args.length > 0) {
System.err.print("unrecognized options:"); System.err.print("unrecognized options:");

View File

@ -37,10 +37,6 @@ import org.apache.log4j.Logger;
* @version $Id: Which.java 736 2005-09-01 10:46:05Z sskracic $ * @version $Id: Which.java 736 2005-09-01 10:46:05Z sskracic $
*/ */
class Which extends Command { class Which extends Command {
public static final String versionId =
"$Id: Which.java 736 2005-09-01 10:46:05Z sskracic $" +
"$Author: sskracic $" +
"$DateTime: 2004/08/16 18:10:38 $";
private static final Logger s_log = Logger.getLogger(Which.class); private static final Logger s_log = Logger.getLogger(Which.class);
@ -74,6 +70,9 @@ class Which extends Command {
return list; return list;
} }
/**
* Invoked from the central tool "MasterTool" to perform the which task.
*/
public boolean run(final String[] args) { public boolean run(final String[] args) {
CommandLine line; CommandLine line;
try { try {

View File

@ -1,7 +1,16 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<!-- /com/arsdigita/packaging/package.html --> <!-- /com/arsdigita/packaging/package.html -->
<html>
<head>
<title>Runtime APIs</title>
</head>
<body>
<p>
Set of classes which provide a command line interface to install, initialize Set of classes which provide a command line interface to install, initialize
and configure a CCM application instance with MasterTool.java as the central and configure a CCM application instance with MasterTool.java as the central
entry point. entry point.</p>
<p> <p>
Mastertool.java is the central entry point. It delegates the different tasks Mastertool.java is the central entry point. It delegates the different tasks
@ -12,3 +21,5 @@ The classes of this package are meant not to be called from within the
application running in a servlet container. They serve as a dedicated, application running in a servlet container. They serve as a dedicated,
separate external command line interface for set up and configuration. separate external command line interface for set up and configuration.
</p> </p>
</body>
</html>

View File

@ -111,25 +111,26 @@ public class ConfigRegistry {
} }
/** /**
* Invokes {@link #ConfigRegistry(URL, ClassLoader)} defaulting the * Convenience class which invokes {@link #ConfigRegistry(URL, ClassLoader)}
* loader to the context class loader. * defaulting the loader to the current context class loader.
*
* @param url The base url for registry locations.
* *
* @see Thread#getContextClassLoader() * @see Thread#getContextClassLoader()
**/ *
* @param url The base url for registry locations.
*/
public ConfigRegistry(URL url) { public ConfigRegistry(URL url) {
this(url, Thread.currentThread().getContextClassLoader()); this(url, Thread.currentThread().getContextClassLoader());
} }
/** /**
* Invokes {@link #ConfigRegistry(URL, ClassLoader)} defaulting the URL to * Convenience class which invokes {@link #ConfigRegistry(URL, ClassLoader)}
* defaulting the URL to
* <code>new File(System.getProperty("ccm.conf")).toURL()</code>. The value * <code>new File(System.getProperty("ccm.conf")).toURL()</code>. The value
* of the ccm.conf system property may or may not include a trailing slash. * of the ccm.conf system property may or may not include a trailing slash.
* *
* @param loader The ClassLoader to use when searching for * @param loader The ClassLoader to use when searching for
* registry configuration files. * registry configuration files.
**/ */
public ConfigRegistry(ClassLoader loader) { public ConfigRegistry(ClassLoader loader) {
this(CCMResourceManager.getConfigURL(), loader); this(CCMResourceManager.getConfigURL(), loader);
} }
@ -138,7 +139,7 @@ public class ConfigRegistry {
* Invokes {@link #ConfigRegistry(URL)} defaulting the URL to <code>new * Invokes {@link #ConfigRegistry(URL)} defaulting the URL to <code>new
* File(System.getProperty("ccm.conf")).toURL()</code>. The value of the * File(System.getProperty("ccm.conf")).toURL()</code>. The value of the
* ccm.conf system property may or may not include a trailing slash. * ccm.conf system property may or may not include a trailing slash.
**/ */
public ConfigRegistry() { public ConfigRegistry() {
this(CCMResourceManager.getConfigURL()); this(CCMResourceManager.getConfigURL());
} }

View File

@ -89,8 +89,7 @@ public class RegistryConfig extends AbstractConfig {
/** /**
* Constructs a new and empty config object. * Constructs a new and empty config object.
**/ */
public RegistryConfig() { public RegistryConfig() {
register(m_packages); register(m_packages);
register(m_parents); register(m_parents);
@ -100,8 +99,7 @@ public class RegistryConfig extends AbstractConfig {
* Returns the value of the waf.config.packages parameter. * Returns the value of the waf.config.packages parameter.
* *
* @return the value of the waf.config.packages parameter * @return the value of the waf.config.packages parameter
**/ */
public String[] getPackages() { public String[] getPackages() {
return (String[]) get(m_packages); return (String[]) get(m_packages);
} }
@ -110,8 +108,7 @@ public class RegistryConfig extends AbstractConfig {
* Returns the value of the waf.config.parents parameter. * Returns the value of the waf.config.parents parameter.
* *
* @return the value of the waf.config.parents parameter * @return the value of the waf.config.parents parameter
**/ */
public URL[] getParents() { public URL[] getParents() {
return (URL[]) get(m_parents); return (URL[]) get(m_parents);
} }

View File

@ -1,10 +1,10 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html> <html>
<head> <head>
<title>Runtime APIs</title> <title>Runtime APIs</title>
</head> </head>
<body bgcolor="white">
<body>
<p>The com.arsdigita.runtime package provides classses and interfaces <p>The com.arsdigita.runtime package provides classses and interfaces
for bootstrapping and manage the CCM runtime environment.</p> for bootstrapping and manage the CCM runtime environment.</p>
@ -19,6 +19,5 @@ for bootstrapping and manage the CCM runtime environment.</p>
<p>The classes in this package are used by the application running in a <p>The classes in this package are used by the application running in a
servlet container as well as by the installation and maintenance command line servlet container as well as by the installation and maintenance command line
utilities outside a servlet container. They don't rely on a servlet context.</p> utilities outside a servlet container. They don't rely on a servlet context.</p>
</body> </body>
</html> </html>

View File

@ -1,9 +1,9 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html> <html>
<head> <head>
<title>com.arsdigita.toolbox</title> <title>com.arsdigita.toolbox</title>
</head> </head>
<body bgcolor="white"> <body>
<p> <p>
A collection of high-level classes useful for general development. A collection of high-level classes useful for general development.
</p> </p>

View File

@ -65,7 +65,7 @@ public class StringUtils {
* @return <code>true</code> if <code>s</code> is null or empty; * @return <code>true</code> if <code>s</code> is null or empty;
* otherwise <code>false</code> * otherwise <code>false</code>
*/ */
public final static boolean emptyString(String s) { public static boolean emptyString(String s) {
boolean expr = (s == null || s.trim().length() == 0); boolean expr = (s == null || s.trim().length() == 0);
return expr; return expr;
} }
@ -76,7 +76,7 @@ public class StringUtils {
* @return <code>true</code> if <code>o</code> is null or empty; * @return <code>true</code> if <code>o</code> is null or empty;
* otherwise <code>false</code> * otherwise <code>false</code>
*/ */
public final static boolean emptyString(Object o) { public static boolean emptyString(Object o) {
boolean expr = boolean expr =
(o == null || (o instanceof String && ((String)o).length() ==0)); (o == null || (o instanceof String && ((String)o).length() ==0));
return expr; return expr;
@ -86,7 +86,7 @@ public class StringUtils {
* If the String is null, returns an empty string. Otherwise, * If the String is null, returns an empty string. Otherwise,
* returns the string unaltered * returns the string unaltered
*/ */
public final static String nullToEmptyString(String s) { public static String nullToEmptyString(String s) {
return (s == null) ? "" : s; return (s == null) ? "" : s;
} }
@ -96,7 +96,7 @@ public class StringUtils {
* @param s The plain-text string to quote * @param s The plain-text string to quote
* @return The string with special characters escpaed. * @return The string with special characters escpaed.
*/ */
public final static String quoteHtml(String s) { public static String quoteHtml(String s) {
if (s != null) { if (s != null) {
StringBuffer result = new StringBuffer(s.length() + 10); StringBuffer result = new StringBuffer(s.length() + 10);
for (int i = 0; i < s.length(); i++) { for (int i = 0; i < s.length(); i++) {
@ -132,7 +132,7 @@ public class StringUtils {
* @return A HTML string with blank lines coverted to <pre>&lt;p></pre> * @return A HTML string with blank lines coverted to <pre>&lt;p></pre>
* and ampersands/angle brackets escaped. * and ampersands/angle brackets escaped.
*/ */
public final static String textToHtml(String s) { public static String textToHtml(String s) {
s = quoteHtml(s); s = quoteHtml(s);
s = s_re.substitute("s/\r\n\r\n/<p>/g", s); s = s_re.substitute("s/\r\n\r\n/<p>/g", s);
s = s_re.substitute("s/\n\n/<p>/g", s); s = s_re.substitute("s/\n\n/<p>/g", s);
@ -148,7 +148,7 @@ public class StringUtils {
* more extensive conversion of HTML fragments to plain text * more extensive conversion of HTML fragments to plain text
* equivalents, see {@link HtmlToText}. * equivalents, see {@link HtmlToText}.
*/ */
public final static String htmlToText(String s) { public static String htmlToText(String s) {
if (s != null) { if (s != null) {
// first take out new-lines // first take out new-lines
s = s_re.substitute("s/\n//g", s); s = s_re.substitute("s/\n//g", s);
@ -201,7 +201,7 @@ public class StringUtils {
* &reg; * &reg;
* </ul> * </ul>
*/ */
public final static String smartTextToHtml(String s) { public static String smartTextToHtml(String s) {
ArrayList blocks = new ArrayList(); ArrayList blocks = new ArrayList();
s_re.split(blocks, "/\\r?\\n(\\r?\\n)+/", s); s_re.split(blocks, "/\\r?\\n(\\r?\\n)+/", s);
@ -353,7 +353,13 @@ public class StringUtils {
return s; return s;
} }
/**
*
* @param subst
* @param pattern
* @param s
* @return
*/
private static String smartTextReplace(Substitution subst, private static String smartTextReplace(Substitution subst,
String pattern, String pattern,
String s) { String s) {
@ -375,6 +381,9 @@ public class StringUtils {
return result.toString(); return result.toString();
} }
/**
*
*/
private static class TitledLinkSubstitution implements Substitution { private static class TitledLinkSubstitution implements Substitution {
private Map m_hash; private Map m_hash;
@ -401,6 +410,9 @@ public class StringUtils {
} }
} }
/**
*
*/
private static class UntitledLinkSubstitution implements Substitution { private static class UntitledLinkSubstitution implements Substitution {
private Map m_hash; private Map m_hash;
@ -427,6 +439,9 @@ public class StringUtils {
} }
} }
/**
*
*/
private static class UnobscureSubstitution implements Substitution { private static class UnobscureSubstitution implements Substitution {
private Map m_hash; private Map m_hash;
@ -449,7 +464,9 @@ public class StringUtils {
} }
} }
/**
*
*/
private static class EntitySubstitution implements Substitution { private static class EntitySubstitution implements Substitution {
public void appendSubstitution(StringBuffer appendBuffer, public void appendSubstitution(StringBuffer appendBuffer,
MatchResult match, MatchResult match,
@ -474,7 +491,7 @@ public class StringUtils {
* @param s string contains items separated by a separator character. * @param s string contains items separated by a separator character.
* @param sep separator character. * @param sep separator character.
* @return Array of items. * @return Array of items.
**/ */
public static String [] split(String s, char sep) { public static String [] split(String s, char sep) {
ArrayList al = new ArrayList(); ArrayList al = new ArrayList();
int start_pos, end_pos; int start_pos, end_pos;
@ -496,91 +513,88 @@ public class StringUtils {
return returned_array; return returned_array;
} }
/** /**
* <p> Given a string, split it into substrings matching a regular * <p> Given a string, split it into substrings matching a regular
* expression that you supply. Parts of the original string which * expression that you supply. Parts of the original string which
* don't match the regular expression also appear as substrings. The * don't match the regular expression also appear as substrings. The
* upshot of this is that the final substrings can be concatenated * upshot of this is that the final substrings can be concatenated
* to get the original string. </p> * to get the original string. </p>
* *
* <p> As an example, let's say the original string is: </p> * <p> As an example, let's say the original string is: </p>
* *
* <pre> * <pre>
* s = "/packages/foo/xsl/::vhost::/foo_::locale::.xsl"; * s = "/packages/foo/xsl/::vhost::/foo_::locale::.xsl";
* </pre> * </pre>
* *
* <p> We call the function like this: </p> * <p> We call the function like this: </p>
* *
* <pre> * <pre>
* output = splitUp (s, "/::\\w+::/"); * output = splitUp (s, "/::\\w+::/");
* </pre> * </pre>
* *
* <p> The result (<code>output</code>) will be the following list: </p> * <p> The result (<code>output</code>) will be the following list: </p>
* *
* <pre> * <pre>
* ("/packages/foo/xsl/", "::vhost::", "/foo_", "::locale::", ".xsl") * ("/packages/foo/xsl/", "::vhost::", "/foo_", "::locale::", ".xsl")
* </pre> * </pre>
* *
* <p> Notice the important property that concatenating all these * <p> Notice the important property that concatenating all these
* strings together will restore the original string. </p> * strings together will restore the original string. </p>
* *
* <p> Here is another useful example. To split up HTML into elements * <p> Here is another useful example. To split up HTML into elements
* and content, do: </p> * and content, do: </p>
* *
* <pre> * <pre>
* output = splitUp (html, "/<.*?>/"); * output = splitUp (html, "/<.*?>/");
* </pre> * </pre>
* *
* <p> You will end up with something like this: </p> * <p> You will end up with something like this: </p>
* *
* <pre> * <pre>
* ("The following text will be ", "<b>", "bold", "</b>", ".") * ("The following text will be ", "<b>", "bold", "</b>", ".")
* </pre> * </pre>
* *
* @param s The original string to split. * @param s The original string to split.
* @param re The regular expression in the format required by * @param re The regular expression in the format required by
* {@link org.apache.oro.text.perl.Perl5Util#match(String, String)}. * {@link org.apache.oro.text.perl.Perl5Util#match(String, String)}.
* @return List of substrings. * @return List of substrings.
* *
* @author Richard W.M. Jones * @author Richard W.M. Jones
* *
* <p> This is equivalent to the Perl "global match in array context", * <p> This is equivalent to the Perl "global match in array context",
* specifically: <code>@a = /(RE)|(.+)/g;</code> </p> * specifically: <code>@a = /(RE)|(.+)/g;</code> </p>
* *
*/ */
public static List splitUp (String s, String re) public static List splitUp (String s, String re)
{ {
Perl5Util p5 = new Perl5Util (); Perl5Util p5 = new Perl5Util ();
ArrayList list = new ArrayList (); ArrayList list = new ArrayList ();
while (s != null && s.length() > 0) while (s != null && s.length() > 0) {
{ // Find the next match.
// Find the next match. if (p5.match (re, s)) {
if (p5.match (re, s)) MatchResult result = p5.getMatch ();
{
MatchResult result = p5.getMatch ();
// String up to the start of the match. // String up to the start of the match.
if (result.beginOffset (0) > 0) if (result.beginOffset (0) > 0)
list.add (s.substring (0, result.beginOffset (0))); list.add (s.substring (0, result.beginOffset (0)));
// Matching part. // Matching part.
list.add (result.toString ()); list.add (result.toString ());
// Update s to be the remainder of the string. // Update s to be the remainder of the string.
s = s.substring (result.endOffset (0)); s = s.substring (result.endOffset (0));
} }
else else {
{ // Finished.
// Finished. list.add (s);
list.add (s);
s = null; s = null;
} }
} }
return list; return list;
} }
/** /**
* Converts an array of Strings into a single String separated by * Converts an array of Strings into a single String separated by
@ -594,7 +608,7 @@ public class StringUtils {
* @pre strings != null * @pre strings != null
* *
* @return Joined String * @return Joined String
**/ */
public static String join(String[] strings, char joinChar) { public static String join(String[] strings, char joinChar) {
StringBuffer result = new StringBuffer(); StringBuffer result = new StringBuffer();
final int lastIdx = strings.length - 1; final int lastIdx = strings.length - 1;
@ -607,6 +621,7 @@ public class StringUtils {
return result.toString(); return result.toString();
} }
/** /**
* Converts an array of Strings into a single String separated by * Converts an array of Strings into a single String separated by
* a given string. * a given string.
@ -619,7 +634,7 @@ public class StringUtils {
* @pre strings != null * @pre strings != null
* *
* @return Joined String * @return Joined String
**/ */
public static String join(String[] strings, String joinStr) { public static String join(String[] strings, String joinStr) {
StringBuffer result = new StringBuffer(); StringBuffer result = new StringBuffer();
final int lastIdx = strings.length - 1; final int lastIdx = strings.length - 1;
@ -632,6 +647,7 @@ public class StringUtils {
return result.toString(); return result.toString();
} }
/** /**
* Extract a parameter value from a packed list of parameter values. * Extract a parameter value from a packed list of parameter values.
* Example: * Example:
@ -652,7 +668,7 @@ public class StringUtils {
* @return the value corresponding to the key, or null if the key is not * @return the value corresponding to the key, or null if the key is not
* present. If the key appears in the list more than once, * present. If the key appears in the list more than once,
* the first value is returned. * the first value is returned.
**/ */
public static String getParameter(String key, String plist, char sep) { public static String getParameter(String key, String plist, char sep) {
int key_end; int key_end;
int key_start = 0; int key_start = 0;
@ -900,7 +916,7 @@ public class StringUtils {
* @param pattern the pattern String * @param pattern the pattern String
* @param repeatCount the number of time to repeat it * @param repeatCount the number of time to repeat it
*/ */
public final static String repeat(String pattern, int repeatCount) { public static String repeat(String pattern, int repeatCount) {
StringBuffer sb = new StringBuffer(repeatCount * pattern.length()); StringBuffer sb = new StringBuffer(repeatCount * pattern.length());
for (int i = 0; i < repeatCount; i++) { for (int i = 0; i < repeatCount; i++) {
sb.append(pattern); sb.append(pattern);
@ -915,7 +931,7 @@ public class StringUtils {
* @param pattern the pattern character * @param pattern the pattern character
* @param repeatCount the number of time to repeat it * @param repeatCount the number of time to repeat it
*/ */
public final static String repeat(char pattern, int repeatCount) { public static String repeat(char pattern, int repeatCount) {
return repeat(String.valueOf(pattern), repeatCount); return repeat(String.valueOf(pattern), repeatCount);
} }
@ -928,7 +944,7 @@ public class StringUtils {
* *
* @since 5.1.2 * @since 5.1.2
*/ */
public final static String wrap(String input) { public static String wrap(String input) {
return wrap(input,80); return wrap(input,80);
} }
@ -955,7 +971,7 @@ public class StringUtils {
* *
* @since 5.1.2 * @since 5.1.2
*/ */
public final static String wrap(String input, int maxLength) { public static String wrap(String input, int maxLength) {
final char SPACE = ' '; final char SPACE = ' ';
final char ENDL = '\n'; final char ENDL = '\n';
@ -1130,7 +1146,7 @@ public class StringUtils {
* *
* @pre find != null * @pre find != null
* @pre replace != null * @pre replace != null
**/ */
public static String replace(final String str, public static String replace(final String str,
final String find, final String find,
final String replace) { final String replace) {
@ -1187,6 +1203,9 @@ public class StringUtils {
/**
*
*/
private static class HashSubstitution implements Substitution { private static class HashSubstitution implements Substitution {
private Map m_hash; private Map m_hash;