|
From: <de...@us...> - 2003-08-07 08:46:39
|
Update of /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/config/light
In directory sc8-pr-cvs1:/tmp/cvs-serv25753/modules/core/src/com/babeldoc/core/config/light
Modified Files:
LightConfigCommand.java
Log Message:
Implementing Holywood principle
Index: LightConfigCommand.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/config/light/LightConfigCommand.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** LightConfigCommand.java 5 Aug 2003 23:13:44 -0000 1.1
--- LightConfigCommand.java 7 Aug 2003 08:46:35 -0000 1.2
***************
*** 1,105 ****
! package com.babeldoc.core.config.light;
!
! import com.babeldoc.core.*;
! import org.apache.commons.cli.Options;
! import org.apache.commons.cli.OptionBuilder;
! import org.apache.commons.cli.CommandLine;
!
! import java.net.URL;
! import java.io.IOException;
! import java.util.Properties;
!
! /**
! */
! public class LightConfigCommand extends BabeldocCommand{
! public static final String SPACER = " ";
!
! /**
! * process the class
! *
! * @param args DOCUMENT ME!
! */
! public LightConfigCommand(String[] args) {
! super("lightconfig", I18n.get("core.config.light.command.desc"), args);
! }
!
!
! /**
! * Execute the command
! *
! * @param commandLine The command line.
! */
! public void execute(CommandLine commandLine) {
! super.execute(commandLine);
!
! if(commandLine.hasOption('l')) {
! String trackKey = null;
! if(commandLine.hasOption('t')) {
! trackKey = commandLine.getOptionValue('t');
! }
! listConfigFiles(commandLine.getOptionValue('l'), trackKey);
! }
! }
!
! /**
! * list the configuration information.
! *
! * @param configName name of the configuration file to list
! * @param trackKey option key in the configuration file to track
! */
! public void listConfigFiles(String configName, String trackKey) {
!
! // NOTE: copied from LightConfigService.mergePropertiesFileFromUserSearchPath
! configName = LightConfigService.getPropertyFileName(configName);
! // get all the 'config.properties' files that are/will be loaded
! URL[] urls = ResourceLoader.getMatchingUrlsInSearchPath(configName, EnvironmentLoader.getSearchPaths());
!
! // display the name and contents of each config file
! System.out.println(I18n.get("core.config.light.command.list", configName));
! for (int i = urls.length - 1; i >= 0; --i) {
! URL url = urls[i];
! System.out.println(i+": " + url);
!
! if(trackKey!=null) {
! Properties properties = new Properties();
! try {
! properties.load(url.openStream());
! } catch (IOException e) {
! LogService.getInstance().logError(e);
! }
! if(properties.containsKey(trackKey)) {
! System.out.println(I18n.get("core.config.light.command.defined", trackKey,
! properties.getProperty(trackKey)));
! } else {
! System.out.println(I18n.get("core.config.light.command.notdefined", trackKey));
! }
! }
! }
! }
!
!
! /**
! * setup the options on the command line.
! *
! * @param options the options to access
! */
! public void setupCommandLine(Options options) {
! super.setupCommandLine(options);
!
! options.addOption(OptionBuilder.isRequired().hasArg()
! .withDescription(I18n.get("core.config.light.command.option.l"))
! .withLongOpt("list").create("l"));
! options.addOption(OptionBuilder.hasArg()
! .withDescription(I18n.get("core.config.light.command.option.t"))
! .withLongOpt("track").create("t"));
! }
!
! /**
! * Main entry point
! *
! * @param args the name of the stage and the name=value pairs
! */
! public static void main(String[] args) {
! new LightConfigCommand(args);
! }
! }
--- 1,105 ----
! package com.babeldoc.core.config.light;
!
! import com.babeldoc.core.*;
! import org.apache.commons.cli.Options;
! import org.apache.commons.cli.OptionBuilder;
! import org.apache.commons.cli.CommandLine;
!
! import java.net.URL;
! import java.io.IOException;
! import java.util.Properties;
!
! /**
! */
! public class LightConfigCommand extends BabeldocCommand{
! public static final String SPACER = " ";
!
! /**
! * process the class
! *
! * @param args DOCUMENT ME!
! */
! public LightConfigCommand(String[] args) {
! super("lightconfig", I18n.get("core.config.light.command.desc"), args);
! }
!
!
! /**
! * Execute the command
! *
! * @param commandLine The command line.
! */
! public void execute(CommandLine commandLine) {
! //super.execute(commandLine);
!
! if(commandLine.hasOption('l')) {
! String trackKey = null;
! if(commandLine.hasOption('t')) {
! trackKey = commandLine.getOptionValue('t');
! }
! listConfigFiles(commandLine.getOptionValue('l'), trackKey);
! }
! }
!
! /**
! * list the configuration information.
! *
! * @param configName name of the configuration file to list
! * @param trackKey option key in the configuration file to track
! */
! public void listConfigFiles(String configName, String trackKey) {
!
! // NOTE: copied from LightConfigService.mergePropertiesFileFromUserSearchPath
! configName = LightConfigService.getPropertyFileName(configName);
! // get all the 'config.properties' files that are/will be loaded
! URL[] urls = ResourceLoader.getMatchingUrlsInSearchPath(configName, EnvironmentLoader.getSearchPaths());
!
! // display the name and contents of each config file
! System.out.println(I18n.get("core.config.light.command.list", configName));
! for (int i = urls.length - 1; i >= 0; --i) {
! URL url = urls[i];
! System.out.println(i+": " + url);
!
! if(trackKey!=null) {
! Properties properties = new Properties();
! try {
! properties.load(url.openStream());
! } catch (IOException e) {
! LogService.getInstance().logError(e);
! }
! if(properties.containsKey(trackKey)) {
! System.out.println(I18n.get("core.config.light.command.defined", trackKey,
! properties.getProperty(trackKey)));
! } else {
! System.out.println(I18n.get("core.config.light.command.notdefined", trackKey));
! }
! }
! }
! }
!
!
! /**
! * setup the options on the command line.
! *
! * @param options the options to access
! */
! public void setupCommandLine(Options options) {
! super.setupCommandLine(options);
!
! options.addOption(OptionBuilder.isRequired().hasArg()
! .withDescription(I18n.get("core.config.light.command.option.l"))
! .withLongOpt("list").create("l"));
! options.addOption(OptionBuilder.hasArg()
! .withDescription(I18n.get("core.config.light.command.option.t"))
! .withLongOpt("track").create("t"));
! }
!
! /**
! * Main entry point
! *
! * @param args the name of the stage and the name=value pairs
! */
! public static void main(String[] args) {
! new LightConfigCommand(args);
! }
! }
|