Author: jerome
Date: 2008-08-16 10:24:19 +0200 (Sat, 16 Aug 2008)
New Revision: 1510
Added:
software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/IniFile.java
Modified:
software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/.classpath
software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/ConfInterface.java
Log:
*Added IniFile reader that allow to read the current Chatter Tux configuration.
Modified:
software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/.classpath
===================================================================
--- software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/.classpath
2008-08-16 06:55:16 UTC (rev 1509)
+++ software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/.classpath
2008-08-16 08:24:19 UTC (rev 1510)
@@ -3,5 +3,7 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/TuxAPI"/>
+ <classpathentry kind="lib" path="C:/Users/pc/Desktop/ini4j-0.3.2.jar"/>
+ <classpathentry kind="lib"
path="C:/Users/pc/Desktop/ini4j-0.3.2-jdk14.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Modified:
software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/ConfInterface.java
===================================================================
---
software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/ConfInterface.java
2008-08-16 06:55:16 UTC (rev 1509)
+++
software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/ConfInterface.java
2008-08-16 08:24:19 UTC (rev 1510)
@@ -20,13 +20,10 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-import javax.swing.AbstractListModel;
import javax.swing.BorderFactory;
-import javax.swing.ComboBoxModel;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
-import javax.swing.JTextField;
import javax.swing.JSpinner;
import javax.swing.JComboBox;
import javax.swing.SpinnerListModel;
@@ -61,6 +58,7 @@
List<String> installedTuxLanguages;
List<String> availableLocutors;
int currentPitch = 120;
+ IniFile ini;
//** Tux Object.
private TuxAPI api;
@@ -70,6 +68,9 @@
this.getFrame();
locale = Locale.getDefault(); //Getting language.
+ //Getting ini file.
+ this.ini = new IniFile(this.iniFile);
+
//Create tux api object.
this.api = new TuxAPI("127.0.0.1", 270);
api.event.handler.register("all", api, "onAllEvent");
Added:
software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/IniFile.java
===================================================================
---
software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/IniFile.java
(rev 0)
+++
software_suite_v2/software/tools/chatterTux/trunk/Chatter_tux/src/IniFile.java
2008-08-16 08:24:19 UTC (rev 1510)
@@ -0,0 +1,88 @@
+/* This file is part of "TuxDroid Chatter Tux tool".
+ * Copyright 2008, kysoh
+ * Author : Conan Jerome
+ * eMail : [EMAIL PROTECTED]
+ * Site : http://www.kysoh.com/
+ *
+ * "TuxDroid Chatter Tux tool" is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * "TuxDroid Chatter Tux tool" 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with "TuxDroid Control Center"; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Hashtable;
+import java.util.Vector;
+
+import org.ini4j.Ini;
+
+public class IniFile {
+
+ private File file;
+ private Ini ini;
+ private Hashtable keys;
+
+ public IniFile(File file){
+ this.file = file;
+ ini = new Ini();
+ try {
+ //ini.load(new URL(file.getAbsolutePath()));
+ this.keys = this.getKeys(this.file);
+ if(this.keys.size() > 0){
+ System.out.println("Hash table size: " +
this.keys.size());
+ }
+ } catch (Exception except){ except.printStackTrace(); }
+ }
+
+
+ public void parse(){
+
+ }
+
+
+ private Hashtable getKeys(File file) throws Exception{
+ Hashtable<String, Vector<String>> keys = new Hashtable<String,
Vector<String>>();
+ Vector<String> values = new Vector<String>();
+ String storedKeys = "";
+
+ //Read ini file to get keys.
+ InputStream ips = new FileInputStream(file);
+ InputStreamReader ipsr=new InputStreamReader(ips);
+ BufferedReader br=new BufferedReader(ipsr);
+ String ligne;
+ while ((ligne=br.readLine())!=null){
+
+ if(ligne.contains("[") && ligne.contains("]")){
+ //then it's a key.
+ storedKeys = ligne;
+ }
+ else if(ligne.contains("=")){
+ //then it's a key value.
+ values.add(ligne);
+ }
+ else{
+ keys.put(storedKeys, values);
+ //Then it's an unwrited ligne. So register new
Hash table value.
+ values.removeAllElements();
+ }
+ }
+
+ br.close();
+
+ return keys;
+ }
+}
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn