01: /*
02: $Header: /cvsroot/xorm/xorm/tools/src/org/xorm/tools/editor/Action.java,v 1.3 2002/04/26 22:01:04 wbiggs Exp $
03:
04: This file is part of XORM.
05:
06: XORM is free software; you can redistribute it and/or modify
07: it under the terms of the GNU General Public License as published by
08: the Free Software Foundation; either version 2 of the License, or
09: (at your option) any later version.
10:
11: XORM is distributed in the hope that it will be useful,
12: but WITHOUT ANY WARRANTY; without even the implied warranty of
13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: GNU General Public License for more details.
15:
16: You should have received a copy of the GNU General Public License
17: along with Foobar; if not, write to the Free Software
18: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19: */
20: package org.xorm.tools.editor;
21:
22: import javax.jdo.PersistenceManager;
23: import java.io.*;
24:
25: public abstract class Action {
26: protected PersistenceManager mgr;
27:
28: protected Action(PersistenceManager mgr) {
29: this .mgr = mgr;
30: }
31:
32: public abstract Object go();
33:
34: protected String readLine() {
35: try {
36: BufferedReader br = new BufferedReader(
37: new InputStreamReader(System.in));
38: return br.readLine();
39: } catch (IOException e) {
40: return null;
41: }
42: }
43:
44: protected Class readClass() {
45: String className = readLine();
46: if (className.indexOf('.') == -1) {
47: className = System.getProperty("package") + "." + className;
48: }
49: Class clazz = null;
50: try {
51: clazz = Class.forName(className);
52: } catch (Exception e) {
53: System.out.println("Class named " + className
54: + " not found.");
55: }
56: return clazz;
57: }
58: }
|