[Nodal-cvs] nodal/j-src/org/nodal/nav DirElementOp.java,1.14,1.15 AsDirectoryOp.java,1.9,1.10 Opaque
Status: Pre-Alpha
Brought to you by:
leei
From: Lee I. <le...@us...> - 2005-01-08 00:51:56
|
Update of /cvsroot/nodal/nodal/j-src/org/nodal/nav In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv969/org/nodal/nav Modified Files: DirElementOp.java AsDirectoryOp.java OpaqueFragmentOp.java Paths.java Path.java NodeOp.java Log Message: Major refactoring around AbstractNode.Backend interface. Index: Paths.java =================================================================== RCS file: /cvsroot/nodal/nodal/j-src/org/nodal/nav/Paths.java,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** Paths.java 2 Sep 2004 23:21:43 -0000 1.42 --- Paths.java 8 Jan 2005 00:51:09 -0000 1.43 *************** *** 21,24 **** --- 21,25 ---- import org.nodal.model.Getter; import org.nodal.model.Node; + import org.nodal.nav.Path.Failure; import org.nodal.util.CacheMap; import org.nodal.util.GetterUtil; *************** *** 732,734 **** --- 733,751 ---- return RangeOp.create(start, end); } + + /** + * A version of {@link #parse(String)} that returns null on Failure. + * This should only be + * used in circumstances where we know that the parse will not fail. + * + * @param string a Path string + * @return a parsed Path or null if failed + */ + public static Path safeParse(String string) { + try { + return Paths.parse(string); + } catch (Failure e) { + return null; + } + } } \ No newline at end of file Index: AsDirectoryOp.java =================================================================== RCS file: /cvsroot/nodal/nodal/j-src/org/nodal/nav/AsDirectoryOp.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** AsDirectoryOp.java 21 Jun 2004 20:06:20 -0000 1.9 --- AsDirectoryOp.java 8 Jan 2005 00:51:09 -0000 1.10 *************** *** 10,13 **** --- 10,15 ---- package org.nodal.nav; + import java.io.IOException; + import org.nodal.Nodal; import org.nodal.Types; *************** *** 136,140 **** } // If that doesn't work, then go directly to the Document. ! Document doc = Nodal.openDocument(pg); if (doc != null && doc.asDirectory() != null) { return new NodeGetter(pg, doc.docNode()); --- 138,147 ---- } // If that doesn't work, then go directly to the Document. ! Document doc; ! try { ! doc = Nodal.openDocument(pg); ! } catch (IOException e) { ! throw new Path.Failure ("Unable to bind: ", e); ! } if (doc != null && doc.asDirectory() != null) { return new NodeGetter(pg, doc.docNode()); Index: Path.java =================================================================== RCS file: /cvsroot/nodal/nodal/j-src/org/nodal/nav/Path.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Path.java 25 Aug 2004 22:07:45 -0000 1.18 --- Path.java 8 Jan 2005 00:51:09 -0000 1.19 *************** *** 140,143 **** --- 140,151 ---- super(s); } + + /** + * @param s + * @param e + */ + public Failure(String s, Exception e) { + super (s, e); + } } Index: DirElementOp.java =================================================================== RCS file: /cvsroot/nodal/nodal/j-src/org/nodal/nav/DirElementOp.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** DirElementOp.java 17 Jul 2004 18:01:58 -0000 1.14 --- DirElementOp.java 8 Jan 2005 00:51:09 -0000 1.15 *************** *** 10,13 **** --- 10,14 ---- package org.nodal.nav; + import java.io.IOException; import java.util.WeakHashMap; import org.nodal.Nodal; *************** *** 127,131 **** } // If that doesn't work, then go directly to the Document. ! Document doc = Nodal.openDocument(pg); if (doc != null) { return new NodeGetter(pg, doc.docNode()); --- 128,137 ---- } // If that doesn't work, then go directly to the Document. ! Document doc; ! try { ! doc = Nodal.openDocument(pg); ! } catch (IOException e) { ! throw new Path.Failure ("Unable to bind: ", e); ! } if (doc != null) { return new NodeGetter(pg, doc.docNode()); Index: NodeOp.java =================================================================== RCS file: /cvsroot/nodal/nodal/j-src/org/nodal/nav/NodeOp.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** NodeOp.java 25 Aug 2004 22:07:45 -0000 1.10 --- NodeOp.java 8 Jan 2005 00:51:09 -0000 1.11 *************** *** 9,12 **** --- 9,14 ---- package org.nodal.nav; + import java.io.IOException; + import org.nodal.Nodal; import org.nodal.filesystem.Document; *************** *** 38,43 **** } ! public Getter bindFrom (Path path) { ! Document doc = Nodal.openDocument(path); return Paths.NodeGetter.create(doc.nodeNamed(nid)); } --- 40,50 ---- } ! public Getter bindFrom (Path path) throws Path.Failure { ! Document doc; ! try { ! doc = Nodal.openDocument(path); ! } catch (IOException e) { ! throw new Path.Failure ("Unable to bind: ", e); ! } return Paths.NodeGetter.create(doc.nodeNamed(nid)); } Index: OpaqueFragmentOp.java =================================================================== RCS file: /cvsroot/nodal/nodal/j-src/org/nodal/nav/OpaqueFragmentOp.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** OpaqueFragmentOp.java 25 Aug 2004 22:07:45 -0000 1.3 --- OpaqueFragmentOp.java 8 Jan 2005 00:51:09 -0000 1.4 *************** *** 9,12 **** --- 9,14 ---- package org.nodal.nav; + import java.io.IOException; + import org.nodal.Nodal; import org.nodal.filesystem.Document; *************** *** 104,108 **** */ public Getter bindFrom(Path pg) throws Path.Failure { ! Document doc = Nodal.openDocument(pg); if (doc != null) { DocumentFormat format = doc.format(); --- 106,115 ---- */ public Getter bindFrom(Path pg) throws Path.Failure { ! Document doc; ! try { ! doc = Nodal.openDocument(pg); ! } catch (IOException e) { ! throw new Path.Failure ("Unable to bind: ", e); ! } if (doc != null) { DocumentFormat format = doc.format(); |