00001
00025
package org.objectweb.cjdbc.common.util;
00026
00027
import java.util.ArrayList;
00028
import java.util.Enumeration;
00029
import java.util.Hashtable;
00030
00037 public class ReadWrite
00038 {
00039
00047 public static String
write(Hashtable table,
boolean prefix)
00048 {
00049
if (table == null)
00050
return "";
00051 StringBuffer buffer =
new StringBuffer();
00052 Enumeration e = table.keys();
00053 Object o;
00054
while (e.hasMoreElements())
00055 {
00056 o = e.nextElement();
00057
if (o.toString().indexOf(
".path") != -1)
00058 {
00059
00060 buffer.append(o +
" = " + System.getProperty(
"line.separator"));
00061 String substring = (String) table.get(o);
00062
int index;
00063
while (
true)
00064 {
00065 index = substring.indexOf(
':');
00066
if (index == -1)
00067
break;
00068
if (prefix)
00069 buffer.append(
"\t\t");
00070 buffer.append(substring.substring(0, index)
00071 + System.getProperty(
"line.separator"));
00072 substring = substring.substring(index + 1);
00073 }
00074
if (prefix)
00075 buffer.append(
"\t\t");
00076 buffer.append(substring + System.getProperty(
"line.separator"));
00077 }
00078
else
00079 {
00080 buffer.append(o +
" = " + table.get(o)
00081 + System.getProperty(
"line.separator"));
00082 }
00083 }
00084
return buffer.toString();
00085 }
00086
00095 public static String
write(ArrayList list, String listName,
00096
boolean writeCountKey)
00097 {
00098
if (list == null)
00099
return "";
00100 StringBuffer buffer =
new StringBuffer();
00101
int size = list.size();
00102
if (writeCountKey)
00103 buffer.append(listName +
".items.count=" + size
00104 + System.getProperty(
"line.separator"));
00105
for (
int i = 0; i < size; i++)
00106 buffer.append(listName +
"." + i +
"=" + list.get(i)
00107 + System.getProperty(
"line.separator"));
00108
return buffer.toString();
00109 }
00110 }