dirkv 2004/03/21 13:10:42
Modified: scaffold/src/java/org/apache/commons/scaffold/lang
BaseException.java ChainedException.java
ParameterException.java PopulateException.java
PropertiesException.java ResourceException.java
TestData.java
Log:
Bugzilla Bug 27689: [scaffold] changing to the Apache 2.0 license removed source
file contents.
Revision Changes Path
1.4 +23 -3
jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/lang/BaseException.java
Index: BaseException.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/lang/BaseException.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- BaseException.java 28 Feb 2004 03:35:44 -0000 1.3
+++ BaseException.java 21 Mar 2004 21:10:42 -0000 1.4
@@ -1,6 +1,3 @@
-package org.apache.commons.scaffold.lang;
-
-
/*
* Copyright 2001,2004 The Apache Software Foundation.
*
@@ -16,3 +13,26 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+package org.apache.commons.scaffold.lang;
+
+
+/**
+ * Base exception for additional subclasses.
+ *
+ * @author Ted Husted
+ * @version $Revision$ $Date$
+ * @todo Add message bundle to package and localized messages.
+ */
+public class BaseException extends ChainedException {
+
+ public BaseException (String message) {
+ super (message);
+ }
+
+ public BaseException (String message, Throwable cause) {
+ super (message, cause);
+ }
+
+}
+
1.3 +90 -0
jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/lang/ChainedException.java
Index: ChainedException.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/lang/ChainedException.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ChainedException.java 28 Feb 2004 03:35:44 -0000 1.2
+++ ChainedException.java 21 Mar 2004 21:10:42 -0000 1.3
@@ -13,3 +13,93 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+package org.apache.commons.scaffold.lang;
+
+import org.apache.commons.scaffold.text.ConvertUtils;
+
+
+ /**
+ * Mimicks new functionality in 1.4
+ * http://www.javaworld.com/javaworld/jw-08-2001/jw-0803-exceptions.html
+ * @author Brian Geotz
+ * @version $Revision$ $Date$
+ */
+ public class ChainedException extends Exception {
+
+ private static final String CAUSED_BY = "Caused by: ";
+
+ private Throwable cause;
+
+ public ChainedException() {
+ super();
+ }
+
+ public ChainedException(String message) {
+ super(message);
+ }
+
+ public ChainedException(String message, Throwable cause) {
+ super(message);
+ this.cause = cause;
+ }
+
+ public ChainedException(Throwable cause) {
+ super();
+ this.cause = cause;
+ }
+
+ public Throwable getCause() {
+ return this.cause;
+ }
+
+ public boolean isCause() {
+ return (this.cause!=null);
+ }
+
+ public String getCauseMessage() {
+ if (this.cause==null)
+ return null;
+ return this.cause.getMessage();
+ }
+
+ public void getMessage(StringBuffer sb) {
+ sb.append(super.getMessage());
+ sb.append(ConvertUtils.LINE_FEED);
+ if (cause != null) {
+ sb.append(CAUSED_BY);
+ if (cause instanceof ChainedException) {
+ ChainedException chainedCause = (ChainedException) cause;
+ chainedCause.getMessage(sb);
+ }
+ else {
+ sb.append(cause.getMessage());
+ }
+ }
+ }
+
+ public void printStackTrace() {
+ super.printStackTrace();
+ if (cause != null) {
+ System.err.println(CAUSED_BY);
+ cause.printStackTrace();
+ }
+ }
+
+ public void printStackTrace(java.io.PrintStream ps) {
+ super.printStackTrace(ps);
+ if (cause != null) {
+ ps.println(CAUSED_BY);
+ cause.printStackTrace(ps);
+ }
+ }
+
+ public void printStackTrace(java.io.PrintWriter pw) {
+ super.printStackTrace(pw);
+ if (cause != null) {
+ pw.println(CAUSED_BY);
+ cause.printStackTrace(pw);
+ }
+ }
+ }
+
1.4 +34 -3
jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/lang/ParameterException.java
Index: ParameterException.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/lang/ParameterException.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ParameterException.java 28 Feb 2004 03:35:44 -0000 1.3
+++ ParameterException.java 21 Mar 2004 21:10:42 -0000 1.4
@@ -1,6 +1,3 @@
-package org.apache.commons.scaffold.lang;
-
-
/*
* Copyright 2001,2004 The Apache Software Foundation.
*
@@ -16,3 +13,37 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+package org.apache.commons.scaffold.lang;
+
+
+/**
+ * Exception for error accessing a resource needed for a model
+ * (index file, data file).
+ *
+ * @author Ted Husted
+ * @version $Revision$ $Date$
+ */
+public class ParameterException extends BaseException {
+
+ public static final String MESSAGE =
+ "ParameterException: Required input is missing or invalid.";
+
+ public ParameterException (String message) {
+ super (message);
+ }
+
+ public ParameterException (String message, Throwable cause) {
+ super (message, cause);
+ }
+
+ public ParameterException (Throwable cause) {
+ super (MESSAGE,cause);
+ }
+
+ public ParameterException () {
+ super (MESSAGE);
+ }
+
+}
+
1.4 +33 -3
jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/lang/PopulateException.java
Index: PopulateException.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/lang/PopulateException.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- PopulateException.java 28 Feb 2004 03:35:44 -0000 1.3
+++ PopulateException.java 21 Mar 2004 21:10:42 -0000 1.4
@@ -1,6 +1,3 @@
-package org.apache.commons.scaffold.lang;
-
-
/*
* Copyright 2001,2004 The Apache Software Foundation.
*
@@ -16,3 +13,36 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+package org.apache.commons.scaffold.lang;
+
+
+/**
+ * Exception for error populating object.
+ *
+ * @author Ted Husted
+ * @version $Revision$ $Date$
+ */
+public class PopulateException extends BaseException {
+
+ public static final String MESSAGE =
+ "Unable to transfer data";
+
+ public PopulateException (String message) {
+ super (message);
+ }
+
+ public PopulateException (String message, Throwable cause) {
+ super (message, cause);
+ }
+
+ public PopulateException (Throwable cause) {
+ super (MESSAGE,cause);
+ }
+
+ public PopulateException () {
+ super (MESSAGE);
+ }
+
+}
+
1.5 +33 -3
jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/lang/PropertiesException.java
Index: PropertiesException.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/lang/PropertiesException.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- PropertiesException.java 28 Feb 2004 03:35:44 -0000 1.4
+++ PropertiesException.java 21 Mar 2004 21:10:42 -0000 1.5
@@ -1,6 +1,3 @@
-package org.apache.commons.scaffold.lang;
-
-
/*
* Copyright 2001,2004 The Apache Software Foundation.
*
@@ -16,3 +13,36 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+package org.apache.commons.scaffold.lang;
+
+
+/**
+ * Exception for error populating object.
+ *
+ * @author Ted Husted
+ * @version $Revision$ $Date$
+ */
+public class PropertiesException extends ResourceException {
+
+ public static final String MESSAGE =
+ "PropertiesException: Property not found.";
+
+ public PropertiesException (String message) {
+ super (message);
+ }
+
+ public PropertiesException (String message, Throwable cause) {
+ super (message, cause);
+ }
+
+ public PropertiesException (Throwable cause) {
+ super (MESSAGE,cause);
+ }
+
+ public PropertiesException () {
+ super (MESSAGE);
+ }
+
+}
+
1.4 +34 -3
jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/lang/ResourceException.java
Index: ResourceException.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/lang/ResourceException.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ResourceException.java 28 Feb 2004 03:35:44 -0000 1.3
+++ ResourceException.java 21 Mar 2004 21:10:42 -0000 1.4
@@ -1,6 +1,3 @@
-package org.apache.commons.scaffold.lang;
-
-
/*
* Copyright 2001,2004 The Apache Software Foundation.
*
@@ -16,3 +13,37 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+package org.apache.commons.scaffold.lang;
+
+
+/**
+ * Exception for error accessing a resource needed for a model
+ * (index file, data file).
+ *
+ * @author Ted Husted
+ * @version $Revision$ $Date$
+ */
+public class ResourceException extends BaseException {
+
+ public static final String MESSAGE =
+ "ResourceException: A required resource is not available.";
+
+ public ResourceException (String message) {
+ super (message);
+ }
+
+ public ResourceException (String message, Throwable cause) {
+ super (message, cause);
+ }
+
+ public ResourceException (Throwable cause) {
+ super (MESSAGE,cause);
+ }
+
+ public ResourceException () {
+ super (MESSAGE);
+ }
+
+}
+
1.3 +77 -3
jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/lang/TestData.java
Index: TestData.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/lang/TestData.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TestData.java 28 Feb 2004 03:35:44 -0000 1.2
+++ TestData.java 21 Mar 2004 21:10:42 -0000 1.3
@@ -1,6 +1,3 @@
-package org.apache.commons.scaffold.lang;
-
-
/*
* Copyright 2001,2004 The Apache Software Foundation.
*
@@ -17,3 +14,80 @@
* limitations under the License.
*/
+package org.apache.commons.scaffold.lang;
+
+/**
+ * Statics for use in test classes.
+ */
+public class TestData {
+
+ // ------------------------------------------------------------- Integers
+
+ /**
+ * Integers for fields with a count, 0..2.
+ */
+ public final static Integer[] INTEGER_COUNT = {
+ new Integer(123),
+ new Integer(456),
+ new Integer(789)
+ };
+
+ /**
+ * Integers for fields with an id, 0..2.
+ */
+ public final static Integer[] INTEGER_ID = {
+ new Integer(1),
+ new Integer(2),
+ new Integer(3)
+ };
+
+ // -------------------------------------------------------------- Strings
+
+ /**
+ * EmailAddress Format.
+ */
+ public final static String[] EMAIL_ADDRESS = {
+ new String("[EMAIL PROTECTED]"),
+ new String("[EMAIL PROTECTED]"),
+ new String("[EMAIL PROTECTED]")
+ };
+
+ /**
+ * Short, 5-character strings, 0..2.
+ */
+ public final static String[] STRING_5 = {
+ new String("aaaaa"),
+ new String("bbbbb"),
+ new String("ccccc")
+ };
+
+ /**
+ * Medium, 10-character strings, 0..2.
+ */
+ public final static String[] STRING_10 = {
+ new String("aaaaaaaaaa"),
+ new String("bbbbbbbbbb"),
+ new String("cccccccccc")
+ };
+
+ /**
+ * Long, 20-character strings, 0..2.
+ */
+ public final static String[] STRING_20 = {
+ new String("aaaaaaaaaaaaaaaaaaaa"),
+ new String("bbbbbbbbbbbbbbbbbbbb"),
+ new String("cccccccccccccccccccc")
+ };
+
+ // ---------------------------------------------------------------- Dates
+
+ /**
+ * Date type
+ */
+ public final static String[] DATE = {
+ new String("2002-01-31"),
+ new String("2002-02-28"),
+ new String("2002-03-31")
+ };
+
+} // end TestData
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]