Be more specific in declaration of thrown Exceptions

This commit is contained in:
hns 2003-04-16 13:31:10 +00:00
parent a9aab2798a
commit 01016e6236
3 changed files with 21 additions and 14 deletions

View file

@ -18,6 +18,9 @@ package helma.objectmodel;
import helma.objectmodel.INode; import helma.objectmodel.INode;
import helma.objectmodel.db.IDGenerator; 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 * Interface that is implemented by Database wrappers
@ -36,10 +39,10 @@ public interface IDatabase {
* *
* @return ... * @return ...
* *
* @throws Exception ... * @throws IOException ...
*/ */
public IDGenerator getIDGenerator(ITransaction transaction) public IDGenerator getIDGenerator(ITransaction transaction)
throws Exception; throws IOException, ObjectNotFoundException;
/** /**
* *
@ -47,14 +50,15 @@ public interface IDatabase {
* @param transaction ... * @param transaction ...
* @param idgen ... * @param idgen ...
* *
* @throws Exception ... * @throws IOException ...
*/ */
public void saveIDGenerator(ITransaction transaction, IDGenerator idgen) public void saveIDGenerator(ITransaction transaction, IDGenerator idgen)
throws Exception; throws IOException;
// node-related // node-related
public INode getNode(ITransaction transaction, String key) public INode getNode(ITransaction transaction, String key)
throws Exception; throws IOException, ObjectNotFoundException,
SAXException, ParserConfigurationException;
/** /**
* *
@ -63,10 +67,10 @@ public interface IDatabase {
* @param key ... * @param key ...
* @param node ... * @param node ...
* *
* @throws Exception ... * @throws IOException ...
*/ */
public void saveNode(ITransaction transaction, String key, INode node) public void saveNode(ITransaction transaction, String key, INode node)
throws Exception; throws IOException;
/** /**
* *
@ -74,10 +78,10 @@ public interface IDatabase {
* @param transaction ... * @param transaction ...
* @param key ... * @param key ...
* *
* @throws Exception ... * @throws IOException ...
*/ */
public void deleteNode(ITransaction transaction, String key) public void deleteNode(ITransaction transaction, String key)
throws Exception; throws IOException;
// transaction-related // transaction-related
public ITransaction beginTransaction(); public ITransaction beginTransaction();

View file

@ -22,6 +22,8 @@ import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import java.io.*; import java.io.*;
import java.util.Date; import java.util.Date;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.SAXException;
/** /**
* A simple XML-database * A simple XML-database
@ -138,7 +140,7 @@ public final class XmlDatabase implements IDatabase {
* @throws Exception ... * @throws Exception ...
*/ */
public void saveIDGenerator(ITransaction txn, IDGenerator idgen) public void saveIDGenerator(ITransaction txn, IDGenerator idgen)
throws Exception { throws IOException {
File file = new File(dbBaseDir, "idgen.xml"); File file = new File(dbBaseDir, "idgen.xml");
IDGenParser.saveIDGenerator(idgen, file); IDGenParser.saveIDGenerator(idgen, file);
@ -157,7 +159,8 @@ public final class XmlDatabase implements IDatabase {
* @throws ObjectNotFoundException ... * @throws ObjectNotFoundException ...
*/ */
public INode getNode(ITransaction txn, String kstr) public INode getNode(ITransaction txn, String kstr)
throws Exception { throws IOException, ObjectNotFoundException,
ParserConfigurationException, SAXException {
File f = new File(dbBaseDir, kstr + ".xml"); File f = new File(dbBaseDir, kstr + ".xml");
if (!f.exists()) { if (!f.exists()) {
@ -185,7 +188,7 @@ public final class XmlDatabase implements IDatabase {
* @throws Exception ... * @throws Exception ...
*/ */
public void saveNode(ITransaction txn, String kstr, INode node) public void saveNode(ITransaction txn, String kstr, INode node)
throws Exception { throws IOException {
XmlWriter writer = null; XmlWriter writer = null;
File file = new File(dbBaseDir, kstr + ".xml"); File file = new File(dbBaseDir, kstr + ".xml");
@ -211,7 +214,7 @@ public final class XmlDatabase implements IDatabase {
* @throws Exception ... * @throws Exception ...
*/ */
public void deleteNode(ITransaction txn, String kstr) public void deleteNode(ITransaction txn, String kstr)
throws Exception { throws IOException {
File f = new File(dbBaseDir, kstr + ".xml"); File f = new File(dbBaseDir, kstr + ".xml");
f.delete(); f.delete();

View file

@ -64,7 +64,7 @@ public class IDGenParser {
* @throws Exception ... * @throws Exception ...
*/ */
public static IDGenerator saveIDGenerator(IDGenerator idgen, File file) public static IDGenerator saveIDGenerator(IDGenerator idgen, File file)
throws Exception { throws IOException {
OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(file)); OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(file));
out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");