jon 01/03/09 14:44:19
Modified: src/java/org/apache/ecs ECSDefaults.java
Log:
the version in there at the moment is the rewritten ECSDefaults class i
submitted (which prevents ECS dying when the properties can't be loaded). i'm a
bit of a CVS newbie so i probably didn't get that other change in (sorry.) i
think i've got CVS set up right now on my development machine.
here's a patch which allows the property file to be overridden by setting the
ecs.properties property.
Robert Burrell Donkin <[EMAIL PROTECTED]>
Revision Changes Path
1.4 +45 -6 jakarta-ecs/src/java/org/apache/ecs/ECSDefaults.java
Index: ECSDefaults.java
===================================================================
RCS file: /home/cvs/jakarta-ecs/src/java/org/apache/ecs/ECSDefaults.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ECSDefaults.java 2001/02/04 22:06:32 1.3
+++ ECSDefaults.java 2001/03/09 22:44:17 1.4
@@ -60,15 +60,20 @@
getting the default settings for ECS. This allows you to edit a
simple text file instead of having to edit the .java files and
recompile.
+ The property file can be specified via the 'ecs.properties' system property.
+ For example, java -Decs.properties="my.ecs.properties". If ecs.properties is
null
+ then the standard ecs.properties resource in the ECS jar is used.
If the property file cannot be loaded, a message is printed to standard
error and hard-coded defaults are used instead.
- @version $Id: ECSDefaults.java,v 1.3 2001/02/04 22:06:32 jon Exp $
+ @version $Id: ECSDefaults.java,v 1.4 2001/03/09 22:44:17 jon Exp $
*/
public final class ECSDefaults
{
- // this private instance allows the props to gracefully default in the
- // case of an error.
+ /**
+ This singleton allows the properties to gracefully default in the
+ case of an error.
+ */
private static ECSDefaults defaults = new ECSDefaults();
// now follows the private methods called by the
@@ -173,7 +178,7 @@
}
/**
- What codeset are we going to use the default is 8859_1
+ What codeset are we going to use the default is UTF-8.
*/
public static String getDefaultCodeset()
{
@@ -220,12 +225,21 @@
return defaults.pretty_print;
}
+ /**
+ This private constructor is used to create the singleton used in the public
static methods.
+ */
private ECSDefaults ()
{
try
{
- // at the moment, still use the original property bundle
- resource = ResourceBundle.getBundle("org.apache.ecs.ecs");
+ // if the ecs.properties system property is set, use that
+ String props=System.getProperty("ecs.properties");
+ if (props==null)
+ {
+ resource = ResourceBundle.getBundle("org.apache.ecs.ecs");
+ } else {
+ resource = new java.util.PropertyResourceBundle(new
java.io.FileInputStream(props));
+ }
// set up variables
filter_state = new
Boolean(resource.getString("filter_state")).booleanValue();
@@ -252,5 +266,30 @@
"ecs.properties being loaded:");
System.err.println(e.toString());
}
+ }
+
+ /**
+ This method returns a string showing the current values.
+ */
+ public static String debugString()
+ {
+ return
+ "ECSDefaults:" + '\n'
+ + '\t' + "DefaultFilterState=" + getDefaultFilterState() +'\n'
+ + '\t' + "DefaultFilterAttributeState=" +
getDefaultFilterAttributeState() +'\n'
+ + '\t' + "DefaultAttributeEqualitySign='" +
getDefaultAttributeEqualitySign() +"'\n"
+ + '\t' + "DefaultBeginStartModifier='" + getDefaultBeginStartModifier()
+ "'\n"
+ + '\t' + "DefaultEndStartModifier='" + getDefaultEndStartModifier() +
"'\n"
+ + '\t' + "DefaultBeginEndModifier='" + getDefaultBeginEndModifier() +
"'\n"
+ + '\t' + "DefaultEndEndModifier='" + getDefaultEndEndModifier() + "'\n"
+ + '\t' + "DefaultAttributeQuoteChar=" + getDefaultAttributeQuoteChar()
+ '\n'
+ + '\t' + "DefaultAttributeQuote=" + getDefaultAttributeQuote() +'\n'
+ + '\t' + "DefaultEndElement=" + getDefaultEndElement() +'\n'
+ + '\t' + "DefaultCodeset='" + getDefaultCodeset() + "'\n"
+ + '\t' + "DefaultPosition=" + getDefaultPosition() +'\n'
+ + '\t' + "DefaultCaseType=" + getDefaultCaseType() +'\n'
+ + '\t' + "DefaultStartTag='" + getDefaultStartTag() + "'\n"
+ + '\t' + "DefaultEndTag='" + getDefaultEndTag() + "'\n"
+ + '\t' + "DefaultPrettyPrint=" + getDefaultPrettyPrint();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]