1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-03 09:49:19 +02:00

git-svn-id: https://only.mawhrin.net/repos/FBReaderJ/trunk@127 6a642e6f-84f6-412e-ac94-c4a38d5a04b0

This commit is contained in:
EugeniyVlasov 2007-11-13 18:29:14 +00:00
parent 5ed4b6c5c0
commit 58da4c45a1
15 changed files with 46 additions and 43 deletions

View file

@ -43,8 +43,8 @@ public final class ZLBoolean3Option extends ZLSimpleOption {
} }
} }
public ZLBoolean3Option(ZLConfig config, String category, String group, String optionName, ZLBoolean3 defaultValue){ public ZLBoolean3Option(String category, String group, String optionName, ZLBoolean3 defaultValue){
super(config, category, group, optionName); super(category, group, optionName);
myDefaultValue = defaultValue; myDefaultValue = defaultValue;
myValue = myDefaultValue; myValue = myDefaultValue;
} }

View file

@ -42,8 +42,8 @@ public final class ZLBooleanOption extends ZLSimpleOption {
} }
} }
public ZLBooleanOption (ZLConfig config, String category, String group, String optionName, boolean defaultValue){ public ZLBooleanOption (String category, String group, String optionName, boolean defaultValue){
super(config, category, group, optionName); super(category, group, optionName);
myDefaultValue = defaultValue; myDefaultValue = defaultValue;
myValue = myDefaultValue; myValue = myDefaultValue;
} }

View file

@ -41,8 +41,8 @@ public final class ZLColorOption extends ZLOption {
} }
} }
public ZLColorOption (ZLConfig config, String category, String group, String optionName, ZLColor defaultValue){ public ZLColorOption (String category, String group, String optionName, ZLColor defaultValue){
super(config, category, group, optionName); super(category, group, optionName);
myDefaultValue = defaultValue.getIntValue(); myDefaultValue = defaultValue.getIntValue();
myIntValue = myDefaultValue; myIntValue = myDefaultValue;
} }

View file

@ -38,8 +38,8 @@ public final class ZLDoubleOption extends ZLOption{
} }
} }
public ZLDoubleOption (ZLConfig config, String category, String group, String optionName, double defaultValue){ public ZLDoubleOption (String category, String group, String optionName, double defaultValue){
super(config, category, group, optionName); super(category, group, optionName);
myDefaultValue = defaultValue; myDefaultValue = defaultValue;
myValue = myDefaultValue; myValue = myDefaultValue;
} }

View file

@ -37,8 +37,8 @@ public final class ZLIntegerOption extends ZLOption{
} }
} }
public ZLIntegerOption (ZLConfig config, String category, String group, String optionName, long defaultValue){ public ZLIntegerOption (String category, String group, String optionName, long defaultValue){
super(config, category, group, optionName); super(category, group, optionName);
myDefaultValue = defaultValue; myDefaultValue = defaultValue;
myValue = myDefaultValue; myValue = myDefaultValue;
} }

View file

@ -51,8 +51,8 @@ public final class ZLIntegerRangeOption extends ZLOption {
} }
} }
public ZLIntegerRangeOption (ZLConfig config, String category, String group, String optionName, long minValue, long maxValue, long defaultValue){ public ZLIntegerRangeOption (String category, String group, String optionName, long minValue, long maxValue, long defaultValue){
super(config, category, group, optionName); super(category, group, optionName);
myMinValue = minValue; myMinValue = minValue;
myMaxValue = maxValue; myMaxValue = maxValue;
//страхуемся от ошибки программиста =) //страхуемся от ошибки программиста =)

View file

@ -1,11 +1,13 @@
package org.zlibrary.options; package org.zlibrary.options;
import org.zlibrary.options.config.ZLConfigInstance;
public abstract class ZLOption { public abstract class ZLOption {
public static final String LOOK_AND_FEEL_CATEGORY = "ui"; public static final String LOOK_AND_FEEL_CATEGORY = "ui";
public static final String CONFIG_CATEGORY = "options"; public static final String CONFIG_CATEGORY = "options";
public static final String STATE_CATEGORY = "state"; public static final String STATE_CATEGORY = "state";
protected ZLConfig myConfig; protected ZLConfig myConfig = ZLConfigInstance.getInstance();
protected String myCategory; protected String myCategory;
protected String myGroup; protected String myGroup;
protected String myOptionName; protected String myOptionName;
@ -19,11 +21,10 @@ public abstract class ZLOption {
* @param group * @param group
* @param optionName * @param optionName
*/ */
protected ZLOption (ZLConfig config, String category, String group, String optionName){ protected ZLOption (String category, String group, String optionName){
myCategory = category; myCategory = category;
myGroup = group; myGroup = group;
myOptionName = optionName; myOptionName = optionName;
myConfig = config;
} }
/** /**

View file

@ -18,7 +18,7 @@ abstract class ZLSimpleOption extends ZLOption {
* конструктор. создается так же как и любая опция * конструктор. создается так же как и любая опция
* @see ZLOption * @see ZLOption
*/ */
public ZLSimpleOption(ZLConfig config, String category, String group, String optionName){ public ZLSimpleOption(String category, String group, String optionName){
super(config, category, group, optionName); super(category, group, optionName);
} }
} }

View file

@ -10,8 +10,8 @@ public final class ZLStringOption extends ZLSimpleOption {
private String myValue; private String myValue;
private String myDefaultValue; private String myDefaultValue;
public ZLStringOption(ZLConfig config, String category, String group, String optionName, String defaultValue){ public ZLStringOption(String category, String group, String optionName, String defaultValue){
super(config, category, group, optionName); super(category, group, optionName);
myDefaultValue = defaultValue; myDefaultValue = defaultValue;
myValue = myDefaultValue; myValue = myDefaultValue;
} }

View file

@ -1,7 +0,0 @@
package org.zlibrary.options.config;
public class ZLConfigFactory {
public static ZLConfigImpl createConfig(){
return new ZLConfigImpl();
}
}

View file

@ -0,0 +1,10 @@
package org.zlibrary.options.config;
public class ZLConfigInstance {
private static final ZLConfigImpl myConfig = new ZLConfigImpl();
public static ZLConfigImpl getInstance(){
return myConfig;
}
}

View file

@ -8,11 +8,11 @@ import org.xml.sax.helpers.*;
import org.zlibrary.options.ZLConfig; import org.zlibrary.options.ZLConfig;
import org.zlibrary.options.config.*; import org.zlibrary.options.config.*;
/*package*/ class ZLConfigReader implements ZLReadable{ /*package*/ class ZLConfigReader implements ZLReader{
private XMLReader myXMLReader; private XMLReader myXMLReader;
private ZLConfig myConfig = ZLConfigFactory.createConfig(); private ZLConfig myConfig;
private String myCategory = ""; private String myCategory = "";
private class ConfigContentHandler extends DefaultHandler{ private class ConfigContentHandler extends DefaultHandler{
@ -59,15 +59,16 @@ import org.zlibrary.options.config.*;
} }
public ZLConfigReader () { public ZLConfigReader () {
myConfig = ZLConfigInstance.getInstance();
try { try {
myXMLReader = XMLReaderFactory.createXMLReader(); myXMLReader = XMLReaderFactory.createXMLReader();
myXMLReader.setContentHandler(new ConfigContentHandler()); myXMLReader.setContentHandler(new ConfigContentHandler());
} catch (SAXException e) { } catch (SAXException e) {
System.err.println(e.getMessage()); System.out.println(e.getMessage());
} }
} }
/** Ďđî÷čňŕňü äŕííűĺ čç ďîňîęŕ â XML */ /** Ïðî÷èòàòü äàííûå èç ôàéëà XML */
public ZLConfig readFile (File file) { public ZLConfig readFile (File file) {
try { try {
InputStream input = new FileInputStream(file); InputStream input = new FileInputStream(file);

View file

@ -1,7 +1,7 @@
package org.zlibrary.options.config.reader; package org.zlibrary.options.config.reader;
public class ZLConfigReaderFactory { public class ZLConfigReaderFactory {
public ZLReadable createConfigReader(){ public ZLReader createConfigReader(){
return new ZLConfigReader(); return new ZLConfigReader();
} }
} }

View file

@ -4,6 +4,6 @@ import java.io.File;
import org.zlibrary.options.ZLConfig; import org.zlibrary.options.ZLConfig;
public interface ZLReadable { public interface ZLReader {
public ZLConfig readFile(File file); public ZLConfig readFile(File file);
} }

View file

@ -2,7 +2,6 @@ package org.test.zlibrary.options;
import junit.framework.*; import junit.framework.*;
import org.zlibrary.options.*; import org.zlibrary.options.*;
import org.zlibrary.options.config.*;
import org.zlibrary.options.util.*; import org.zlibrary.options.util.*;
/** /**
@ -31,20 +30,19 @@ public class ModelTests extends TestCase{
private final boolean myDefaultBoolean = true; private final boolean myDefaultBoolean = true;
private final String myDefaultString = "Hello World"; private final String myDefaultString = "Hello World";
private final double myDefaultDouble = 1.2; private final double myDefaultDouble = 1.2;
private final ZLConfig myConfig = ZLConfigFactory.createConfig();
public void setUp(){ public void setUp(){
myColorOption = new ZLColorOption(myConfig, "","","my Color", new ZLColor (176, 255, 0)); myColorOption = new ZLColorOption("","","my Color", new ZLColor (176, 255, 0));
myDoubleOption = new ZLDoubleOption(myConfig, "","","My Double", myDefaultDouble); myDoubleOption = new ZLDoubleOption("","","My Double", myDefaultDouble);
myIntegerOption = new ZLIntegerOption(myConfig, "","","I", myDefaultInt); myIntegerOption = new ZLIntegerOption("","","I", myDefaultInt);
myIntegerRangeOption = new ZLIntegerRangeOption(myConfig, "","","IR", -90L, 90L, myDefaultIntRange); myIntegerRangeOption = new ZLIntegerRangeOption("","","IR", -90L, 90L, myDefaultIntRange);
myBoolean3Option = new ZLBoolean3Option(myConfig, "","","my Boolean 3", myDefaultBoolean3); myBoolean3Option = new ZLBoolean3Option("","","my Boolean 3", myDefaultBoolean3);
myBooleanOption = new ZLBooleanOption(myConfig, "","","my Boolean", myDefaultBoolean); myBooleanOption = new ZLBooleanOption("","","my Boolean", myDefaultBoolean);
myStringOption = new ZLStringOption(myConfig, "qw","qwe","my String", myDefaultString); myStringOption = new ZLStringOption("qw","qwe","my String", myDefaultString);
} }
public void test00_equals(){ public void test00_equals(){
ZLOption zlc = new ZLStringOption(myConfig, "qw", "qwe", "my String", "fire"); ZLOption zlc = new ZLStringOption("qw", "qwe", "my String", "fire");
assertTrue(zlc.equals(myStringOption)); assertTrue(zlc.equals(myStringOption));
} }
@ -110,7 +108,7 @@ public class ModelTests extends TestCase{
public void test02_integerRangeWrong(){ public void test02_integerRangeWrong(){
myIntegerRangeOption.setValue(10000000L); myIntegerRangeOption.setValue(10000000L);
assertEquals(myIntegerRangeOption.getValue(), 75L); assertEquals(myIntegerRangeOption.getValue(), -1L);
} }
public void test02_boolean3(){ public void test02_boolean3(){