1 package com
.swabunga
.spell
.engine
;
4 import java
.io
.FileNotFoundException
;
5 import java
.io
.FileOutputStream
;
6 import java
.io
.IOException
;
7 import java
.io
.InputStream
;
9 import java
.util
.Properties
;
15 * To change this generated comment edit the template variable "typecomment":
16 * Window>Preferences>Java>Templates.
17 * To enable and disable the creation of type comments go to
18 * Window>Preferences>Java>Code Generation.
20 public class PropertyConfiguration
extends Configuration
{
22 public Properties prop
;
25 public PropertyConfiguration() {
26 prop
= new Properties();
29 //original initalization code
30 filename = getClass().getClassLoader().getResource("com/swabunga/spell/engine/configuration.properties");
31 InputStream in = filename.openStream();
34 // new constructor code so that this works within JAR files (Howard Kistler)
35 InputStream is
= this.getClass().getResourceAsStream("configuration.properties");
37 } catch (Exception e
) {
38 System
.out
.println("Could not load Properties file :\n" + e
);
43 * @see com.swabunga.spell.engine.Configuration#getBoolean(String)
45 public boolean getBoolean(String key
) {
46 // return Boolean.getBoolean(prop.getProperty(key));
47 // original breaks inside applets due to security, this version works fine (Howard Kistler)
48 return prop
.getProperty(key
).equalsIgnoreCase("true");
52 * @see com.swabunga.spell.engine.Configuration#getInteger(String)
54 public int getInteger(String key
) {
55 return Integer
.parseInt(prop
.getProperty(key
));
59 * @see com.swabunga.spell.engine.Configuration#setBoolean(String, boolean)
61 public void setBoolean(String key
, boolean value
) {
68 prop
.setProperty(key
, string
);
73 * @see com.swabunga.spell.engine.Configuration#setInteger(String, int)
75 public void setInteger(String key
, int value
) {
76 prop
.setProperty(key
,Integer
.toString(value
));
82 File file
= new File(filename
.getFile());
83 FileOutputStream fout
= new FileOutputStream(file
);
84 prop
.store(fout
,"HEADER");
85 } catch (FileNotFoundException e
) {
86 } catch (IOException e
) {