[FOray-commit] SF.net SVN: foray: [8013] trunk/foray
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2006-09-09 19:16:11
|
Revision: 8013
http://svn.sourceforge.net/foray/?rev=8013&view=rev
Author: victormote
Date: 2006-09-09 12:16:04 -0700 (Sat, 09 Sep 2006)
Log Message:
-----------
Remove magic numbers.
Modified Paths:
--------------
trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java
trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java
trunk/foray/scripts/checkstyle-suppressions.xml
Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java
===================================================================
--- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-09-09 18:59:26 UTC (rev 8012)
+++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-09-09 19:16:04 UTC (rev 8013)
@@ -65,6 +65,14 @@
*/
public class FOrayPretty extends DefaultHandler2 {
+ public static final byte STATUS_WRONG_QTY_ARGUMENTS = 1;
+ public static final byte STATUS_FILE_NOT_FOUND = 2;
+ public static final byte STATUS_PARSING_ERROR = 3;
+
+ private static final byte DEFAULT_LINE_LENGTH = 80;
+ private static final byte MIN_CL_ARGUMENTS = 2;
+ private static final byte MAX_CL_ARGUMENTS = 3;
+
InputSource input;
OutputStream output;
@@ -124,7 +132,7 @@
private int indent = 2;
/** The maximum number of characters desired on each line. */
- private int desiredLineLength = 80;
+ private int desiredLineLength = DEFAULT_LINE_LENGTH;
/**
* Block elements are started on a new line. However, if they are inside
@@ -907,13 +915,17 @@
* Argument 2 is the location of the output file.
* Argument 3 is an optional location of an OASIS-compliant catalog file
* that can be used to locate local DTDs.
+ * Return status is one of 0 (success),
+ * 1 (wrong quantity of arguments),
+ * 2 (file not found), or
+ * 3 (parsing error).
*/
public static void main(final String[] args) {
if (args == null
- || args.length < 2
- || args.length > 3) {
+ || args.length < MIN_CL_ARGUMENTS
+ || args.length > MAX_CL_ARGUMENTS) {
System.out.print("Wrong number of arguments.");
- System.exit(1);
+ System.exit(STATUS_WRONG_QTY_ARGUMENTS);
}
final String input = args[0];
final String output = args[1];
@@ -928,7 +940,7 @@
inputStream = new BufferedInputStream(fis);
} catch (final FileNotFoundException e) {
System.err.println("File not found: " + input);
- System.exit(2);
+ System.exit(STATUS_FILE_NOT_FOUND);
}
final InputSource inputSource = new InputSource(inputStream);
OutputStream outputStream = null;
@@ -937,7 +949,7 @@
outputStream = new BufferedOutputStream(fos);
} catch (final FileNotFoundException e1) {
System.err.println("File not found: " + output);
- System.exit(3);
+ System.exit(STATUS_FILE_NOT_FOUND);
}
final FOrayPretty processor = new FOrayPretty(inputSource, outputStream,
catalog);
@@ -946,7 +958,7 @@
} catch (final Exception e) {
System.out.print("Error parsing input.");
e.printStackTrace();
- System.exit(4);
+ System.exit(STATUS_PARSING_ERROR);
}
}
Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java
===================================================================
--- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java 2006-09-09 18:59:26 UTC (rev 8012)
+++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java 2006-09-09 19:16:04 UTC (rev 8013)
@@ -54,6 +54,11 @@
*/
public class FOrayXDiff {
+ public static final byte STATUS_SUCCESS = 0;
+ public static final byte STATUS_MALFORMED_URL = 1;
+ public static final byte STATUS_PARSING_ERROR = 2;
+ public static final byte STATUS_DIFFERENCE_FOUND = 3;
+
private XMLStreamReader[] readers;
/** Caches the best description that we can find of the input source for
@@ -484,6 +489,10 @@
/**
* Command-line interface for {@link FOrayXDiff}.
+ * Return values are 0 (success, no differences found),
+ * 1 (malformed URL),
+ * 2 (parsing error),
+ * and 3 (differences found between the two input files).
* @param args Two or more URLs that should be compared.
*/
public static void main(final String[] args) {
@@ -500,7 +509,7 @@
url = URLFactory.createURL(context, args[i]);
} catch (final MalformedURLException e) {
System.out.println("Malformed URL: " + args[i]);
- System.exit(1);
+ System.exit(STATUS_MALFORMED_URL);
}
urlsToCompare[i] = url;
}
@@ -509,15 +518,15 @@
final boolean equivalent = processor.equivalent();
if (equivalent) {
System.out.println("All XML Streams are equivalent.");
- System.exit(0);
+ System.exit(STATUS_SUCCESS);
} else {
System.out.println("Differences(s) in XML Streams found.");
- System.exit(3);
+ System.exit(STATUS_DIFFERENCE_FOUND);
}
} catch (final Exception e) {
System.out.println("Error parsing input.");
System.out.println(e.getMessage());
- System.exit(2);
+ System.exit(STATUS_PARSING_ERROR);
}
}
Modified: trunk/foray/scripts/checkstyle-suppressions.xml
===================================================================
--- trunk/foray/scripts/checkstyle-suppressions.xml 2006-09-09 18:59:26 UTC (rev 8012)
+++ trunk/foray/scripts/checkstyle-suppressions.xml 2006-09-09 19:16:04 UTC (rev 8013)
@@ -26,8 +26,6 @@
<suppress checks="MagicNumber"
files="org.foray.pioneer.*"/>
<suppress checks="MagicNumber"
- files="org.foray.pretty.*"/>
- <suppress checks="MagicNumber"
files="org.foray.ps.*"/>
<suppress checks="MagicNumber"
files="org.foray.render.*"/>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|