|
From: <pe...@us...> - 2003-12-19 18:02:57
|
Update of /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons
In directory sc8-pr-cvs1:/tmp/cvs-serv5157/src/java/org/neuclear/commons
Modified Files:
LowLevelException.java Utility.java
Log Message:
Revamped a lot of exception handling throughout the framework, it has been simplified in most places:
- For most cases the main exception to worry about now is InvalidNamedObjectException.
- Most lowerlevel exception that cant be handled meaningful are now wrapped in the LowLevelException, a
runtime exception.
- Source and Store patterns each now have their own exceptions that generalizes the various physical
exceptions that can happen in that area.
Index: LowLevelException.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/LowLevelException.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** LowLevelException.java 19 Dec 2003 00:31:16 -0000 1.2
--- LowLevelException.java 19 Dec 2003 18:02:53 -0000 1.3
***************
*** 21,24 ****
--- 21,32 ----
$Id$
$Log$
+ Revision 1.3 2003/12/19 18:02:53 pelle
+ Revamped a lot of exception handling throughout the framework, it has been simplified in most places:
+ - For most cases the main exception to worry about now is InvalidNamedObjectException.
+ - Most lowerlevel exception that cant be handled meaningful are now wrapped in the LowLevelException, a
+ runtime exception.
+ - Source and Store patterns each now have their own exceptions that generalizes the various physical
+ exceptions that can happen in that area.
+
Revision 1.2 2003/12/19 00:31:16 pelle
Lots of usability changes through out all the passphrase agents and end user tools.
***************
*** 38,41 ****
--- 46,52 ----
public LowLevelException(Throwable e) {
super("LowLevelException in a sub system of NeuClear:\n"+e.getLocalizedMessage(), e);
+ }
+ public LowLevelException(String message) {
+ super("LowLevelException in a sub system of NeuClear:\n"+message);
}
}
Index: Utility.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-commons/src/java/org/neuclear/commons/Utility.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Utility.java 19 Dec 2003 00:31:16 -0000 1.4
--- Utility.java 19 Dec 2003 18:02:53 -0000 1.5
***************
*** 2,5 ****
--- 2,13 ----
* $Id$
* $Log$
+ * Revision 1.5 2003/12/19 18:02:53 pelle
+ * Revamped a lot of exception handling throughout the framework, it has been simplified in most places:
+ * - For most cases the main exception to worry about now is InvalidNamedObjectException.
+ * - Most lowerlevel exception that cant be handled meaningful are now wrapped in the LowLevelException, a
+ * runtime exception.
+ * - Source and Store patterns each now have their own exceptions that generalizes the various physical
+ * exceptions that can happen in that area.
+ *
* Revision 1.4 2003/12/19 00:31:16 pelle
* Lots of usability changes through out all the passphrase agents and end user tools.
***************
*** 135,142 ****
import org.neuclear.commons.NeuClearException;
! import java.io.PrintStream;
! import java.io.BufferedReader;
! import java.io.InputStreamReader;
! import java.io.IOException;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
--- 143,147 ----
import org.neuclear.commons.NeuClearException;
! import java.io.*;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
***************
*** 211,217 ****
* @return
*/
! public static boolean getAffirmative(final boolean def) throws IOException {
final String prompt = def?"(yes)/no":"yes/(no)";
String line=prompt(prompt).toLowerCase();
if (isEmpty(line))
return def;
--- 216,223 ----
* @return
*/
! public static boolean getAffirmative(final boolean def) {
final String prompt = def?"(yes)/no":"yes/(no)";
String line=prompt(prompt).toLowerCase();
+ System.out.println();
if (isEmpty(line))
return def;
***************
*** 219,229 ****
}
! public static String prompt(String prompt) throws IOException {
System.out.print(prompt);
return readLine();
}
! public static String readLine() throws IOException {
BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
! return reader.readLine();
}
--- 225,239 ----
}
! public static String prompt(String prompt) {
System.out.print(prompt);
return readLine();
}
! public static String readLine() {
BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
! try {
! return reader.readLine();
! } catch (IOException e) {
! throw new LowLevelException(e);
! }
}
***************
*** 233,276 ****
String classfile=m.replaceAll("/")+".class";
String url=reference.getClassLoader().getResource(classfile).toExternalForm();
! if (url.startsWith("jar:")) {
! Pattern r2=Pattern.compile(":([^:]*\\.jar)!");
! Matcher m2=r2.matcher(url);
! if(m2.matches()){
! String path=m2.group(1);
! String cd=System.getProperty("user.dir");
! if (path.startsWith(cd))
! return "$ java -jar "+path.substring(cd.length());
! return "$ java -jar "+path;
! }
}
! return "$ java "+reference.getName();
}
! /*
! public static String normalizeNeuURL(String url) throws MalformedURLException {
! boolean clearLastChar=url.endsWith("/");
! if (url.startsWith("/")) {
! if (clearLastChar)
! return "neu:/"+url.substring(0,url.length()-2);
! return "neu:/"+url;
! }
! if (url.startsWith("neu://")) {
! if (clearLastChar)
! return url.substring(0,url.length()-2);
! return url;
! }
! throw new MalformedURLException("NEU URL: "+url+" was malformed");
!
}
! */
!
! /* public static String deURLize(String url) {
! int i=url.indexOf("://");
! if (i>0)
! return url.substring(i+2);
! if (url.length()>0&&url.substring(0,1).equals("/"))
! return url;
! return "/"+url;
! }
! */
}
--- 243,261 ----
String classfile=m.replaceAll("/")+".class";
String url=reference.getClassLoader().getResource(classfile).toExternalForm();
! Pattern r2=Pattern.compile("^jar:file:(.*)!/.*$");
! Matcher m2=r2.matcher(url);
! if(m2.matches()){
! String path=m2.group(1);
! String cd=System.getProperty("user.dir");
! if (path.startsWith(cd))
! return SYSTEM_PROMPT+"java -jar "+path.substring(cd.length()+1);
! return SYSTEM_PROMPT+"java -jar "+path;
}
! return SYSTEM_PROMPT+"java "+reference.getName();
}
! private static String getSystemConsolePrompt(){
! return (File.separatorChar=='/')?(System.getProperty("user.name")+"$ "):("C:\\"+System.getProperty("user.dir")+">");
}
! final static public String SYSTEM_PROMPT=getSystemConsolePrompt();
}
|