From 01016e623673af20c05c81ab28dd819ae8e536eb Mon Sep 17 00:00:00 2001 From: hns Date: Wed, 16 Apr 2003 13:31:10 +0000 Subject: [PATCH] Be more specific in declaration of thrown Exceptions --- src/helma/objectmodel/IDatabase.java | 22 +++++++++++++--------- src/helma/objectmodel/db/XmlDatabase.java | 11 +++++++---- src/helma/objectmodel/dom/IDGenParser.java | 2 +- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/helma/objectmodel/IDatabase.java b/src/helma/objectmodel/IDatabase.java index 2ea5c6f6..a9a7e2da 100644 --- a/src/helma/objectmodel/IDatabase.java +++ b/src/helma/objectmodel/IDatabase.java @@ -18,6 +18,9 @@ package helma.objectmodel; import helma.objectmodel.INode; import helma.objectmodel.db.IDGenerator; +import java.io.IOException; +import org.xml.sax.SAXException; +import javax.xml.parsers.ParserConfigurationException; /** * Interface that is implemented by Database wrappers @@ -36,10 +39,10 @@ public interface IDatabase { * * @return ... * - * @throws Exception ... + * @throws IOException ... */ public IDGenerator getIDGenerator(ITransaction transaction) - throws Exception; + throws IOException, ObjectNotFoundException; /** * @@ -47,14 +50,15 @@ public interface IDatabase { * @param transaction ... * @param idgen ... * - * @throws Exception ... + * @throws IOException ... */ public void saveIDGenerator(ITransaction transaction, IDGenerator idgen) - throws Exception; + throws IOException; // node-related public INode getNode(ITransaction transaction, String key) - throws Exception; + throws IOException, ObjectNotFoundException, + SAXException, ParserConfigurationException; /** * @@ -63,10 +67,10 @@ public interface IDatabase { * @param key ... * @param node ... * - * @throws Exception ... + * @throws IOException ... */ public void saveNode(ITransaction transaction, String key, INode node) - throws Exception; + throws IOException; /** * @@ -74,10 +78,10 @@ public interface IDatabase { * @param transaction ... * @param key ... * - * @throws Exception ... + * @throws IOException ... */ public void deleteNode(ITransaction transaction, String key) - throws Exception; + throws IOException; // transaction-related public ITransaction beginTransaction(); diff --git a/src/helma/objectmodel/db/XmlDatabase.java b/src/helma/objectmodel/db/XmlDatabase.java index d7cd5499..f72bf1b2 100644 --- a/src/helma/objectmodel/db/XmlDatabase.java +++ b/src/helma/objectmodel/db/XmlDatabase.java @@ -22,6 +22,8 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; import java.io.*; import java.util.Date; +import javax.xml.parsers.ParserConfigurationException; +import org.xml.sax.SAXException; /** * A simple XML-database @@ -138,7 +140,7 @@ public final class XmlDatabase implements IDatabase { * @throws Exception ... */ public void saveIDGenerator(ITransaction txn, IDGenerator idgen) - throws Exception { + throws IOException { File file = new File(dbBaseDir, "idgen.xml"); IDGenParser.saveIDGenerator(idgen, file); @@ -157,7 +159,8 @@ public final class XmlDatabase implements IDatabase { * @throws ObjectNotFoundException ... */ public INode getNode(ITransaction txn, String kstr) - throws Exception { + throws IOException, ObjectNotFoundException, + ParserConfigurationException, SAXException { File f = new File(dbBaseDir, kstr + ".xml"); if (!f.exists()) { @@ -185,7 +188,7 @@ public final class XmlDatabase implements IDatabase { * @throws Exception ... */ public void saveNode(ITransaction txn, String kstr, INode node) - throws Exception { + throws IOException { XmlWriter writer = null; File file = new File(dbBaseDir, kstr + ".xml"); @@ -211,7 +214,7 @@ public final class XmlDatabase implements IDatabase { * @throws Exception ... */ public void deleteNode(ITransaction txn, String kstr) - throws Exception { + throws IOException { File f = new File(dbBaseDir, kstr + ".xml"); f.delete(); diff --git a/src/helma/objectmodel/dom/IDGenParser.java b/src/helma/objectmodel/dom/IDGenParser.java index bedb8fa3..f6cfd3f8 100644 --- a/src/helma/objectmodel/dom/IDGenParser.java +++ b/src/helma/objectmodel/dom/IDGenParser.java @@ -64,7 +64,7 @@ public class IDGenParser { * @throws Exception ... */ public static IDGenerator saveIDGenerator(IDGenerator idgen, File file) - throws Exception { + throws IOException { OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(file)); out.write("\n");