1 // Copyright 2000-2005 the Contributors, as shown in the revision logs.
2 // Licensed under the Apache Public Source License 2.0 ("the License").
3 // You may not use this file except in compliance with the License.
6 import org.ibex.util.*;
8 import org.ibex.mail.target.*;
9 import org.ibex.mail.protocol.*;
12 import com.skaringa.javaxml.*;
13 import javax.xml.transform.stream.*;
15 public class SkaringaFile {
17 //private transient File file;
18 //private transient String path;
19 //private transient boolean exists;
20 private static WeakHashMap cache = new WeakHashMap();
23 public void delete() throws IOException {
25 cache.remove(path, this);
30 public static Object read(File file) throws Exception {
31 FileInputStream in = null;
33 ObjectTransformer trans = ObjectTransformerFactory.getInstance().getImplementation();
34 in = new FileInputStream(file);
35 return trans.deserialize(new StreamSource(in));
37 if (in!=null) in.close();
41 public void write(File file) throws Exception {
42 ObjectTransformer trans = ObjectTransformerFactory.getInstance().getImplementation();
43 trans.setProperty(javax.xml.transform.OutputKeys.INDENT, "yes");
44 trans.setProperty("{http://xml.apache.org/xalan}indent-amount", "2");
45 FileOutputStream out = new FileOutputStream(file);
46 trans.serialize(this, new StreamResult(out));