From e911eeb91e79211d64cb4b09d8549cf6d8e10433 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Mon, 6 Jan 2020 17:56:04 -0500 Subject: Rename EscapeException to DirectiveEscape This is because we already know it's an exception if we're throwing it; and the name of an exception should suggest both what's wrong, and perhaps imply what we should do about it --- .../java/bjc/utils/ioutils/format/CLFormatter.java | 2 +- .../bjc/utils/ioutils/format/DirectiveEscape.java | 33 ++++++++++++++++++++++ .../bjc/utils/ioutils/format/EscapeException.java | 33 ---------------------- .../format/directives/ConditionalDirective.java | 2 +- .../ioutils/format/directives/EscapeDirective.java | 2 +- .../format/directives/IterationDirective.java | 12 ++++---- .../format/directives/RecursiveDirective.java | 4 +-- 7 files changed, 44 insertions(+), 44 deletions(-) create mode 100644 clformat/src/main/java/bjc/utils/ioutils/format/DirectiveEscape.java delete mode 100644 clformat/src/main/java/bjc/utils/ioutils/format/EscapeException.java diff --git a/clformat/src/main/java/bjc/utils/ioutils/format/CLFormatter.java b/clformat/src/main/java/bjc/utils/ioutils/format/CLFormatter.java index d2dd82a..0aa2efe 100644 --- a/clformat/src/main/java/bjc/utils/ioutils/format/CLFormatter.java +++ b/clformat/src/main/java/bjc/utils/ioutils/format/CLFormatter.java @@ -357,7 +357,7 @@ public class CLFormatter { throw new IllegalArgumentException(msg); } } - } catch (EscapeException eex) { + } catch (DirectiveEscape eex) { if (!isToplevel) throw eex; } } diff --git a/clformat/src/main/java/bjc/utils/ioutils/format/DirectiveEscape.java b/clformat/src/main/java/bjc/utils/ioutils/format/DirectiveEscape.java new file mode 100644 index 0000000..c0908f0 --- /dev/null +++ b/clformat/src/main/java/bjc/utils/ioutils/format/DirectiveEscape.java @@ -0,0 +1,33 @@ +package bjc.utils.ioutils.format; + +/** + * An exception thrown to escape CL iteration directives. + * + * @author EVE + * + */ +public class DirectiveEscape extends RuntimeException { + private static final long serialVersionUID = -4552821131068559005L; + + /** + * Whether or not this exception should end iteration. + */ + public final boolean endIteration; + + /** + * Create a new directive escape. + */ + public DirectiveEscape() { + endIteration = false; + } + + /** + * Create a new directive escape. + * + * @param end + * Whether or not to end the iteration. + */ + public DirectiveEscape(boolean end) { + endIteration = end; + } +} \ No newline at end of file diff --git a/clformat/src/main/java/bjc/utils/ioutils/format/EscapeException.java b/clformat/src/main/java/bjc/utils/ioutils/format/EscapeException.java deleted file mode 100644 index 086f1cd..0000000 --- a/clformat/src/main/java/bjc/utils/ioutils/format/EscapeException.java +++ /dev/null @@ -1,33 +0,0 @@ -package bjc.utils.ioutils.format; - -/** - * An exception thrown to escape CL iteration directives. - * - * @author EVE - * - */ -public class EscapeException extends RuntimeException { - private static final long serialVersionUID = -4552821131068559005L; - - /** - * Whether or not this exception should end iteration. - */ - public final boolean endIteration; - - /** - * Create a new escape exception. - */ - public EscapeException() { - endIteration = false; - } - - /** - * Create a new escape exception. - * - * @param end - * Whether or not to end the iteration. - */ - public EscapeException(boolean end) { - endIteration = end; - } -} \ No newline at end of file diff --git a/clformat/src/main/java/bjc/utils/ioutils/format/directives/ConditionalDirective.java b/clformat/src/main/java/bjc/utils/ioutils/format/directives/ConditionalDirective.java index a1ed7a8..099c793 100644 --- a/clformat/src/main/java/bjc/utils/ioutils/format/directives/ConditionalDirective.java +++ b/clformat/src/main/java/bjc/utils/ioutils/format/directives/ConditionalDirective.java @@ -237,7 +237,7 @@ class ConditionalEdict implements Edict { throw new IllegalArgumentException("INTERNAL ERROR: ConditionalEdict mode " + condMode + " is not supported. This is a bug."); } - } catch (EscapeException eex) { + } catch (DirectiveEscape eex) { // Conditionals are transparent to iteration-escapes throw eex; } diff --git a/clformat/src/main/java/bjc/utils/ioutils/format/directives/EscapeDirective.java b/clformat/src/main/java/bjc/utils/ioutils/format/directives/EscapeDirective.java index e8e4eb8..5191c1a 100644 --- a/clformat/src/main/java/bjc/utils/ioutils/format/directives/EscapeDirective.java +++ b/clformat/src/main/java/bjc/utils/ioutils/format/directives/EscapeDirective.java @@ -132,7 +132,7 @@ class EscapeEdict implements Edict { } if (shouldExit) { - throw new EscapeException(terminateIteration); + throw new DirectiveEscape(terminateIteration); } } } diff --git a/clformat/src/main/java/bjc/utils/ioutils/format/directives/IterationDirective.java b/clformat/src/main/java/bjc/utils/ioutils/format/directives/IterationDirective.java index 995acc8..cdf047b 100644 --- a/clformat/src/main/java/bjc/utils/ioutils/format/directives/IterationDirective.java +++ b/clformat/src/main/java/bjc/utils/ioutils/format/directives/IterationDirective.java @@ -141,7 +141,7 @@ class IterationEdict implements Edict { } else { body.format(formCTX.writer, nParams); } - } catch (EscapeException eex) { + } catch (DirectiveEscape eex) { if (eex.endIteration) { if (formCTX.items.atEnd()) { throw eex; @@ -152,7 +152,7 @@ class IterationEdict implements Edict { formCTX.items.right(); iter = formCTX.items.item(); } while (formCTX.items.position() < formCTX.items.size()); - } catch (EscapeException eex) { + } catch (DirectiveEscape eex) { // Do nothing } break; @@ -170,7 +170,7 @@ class IterationEdict implements Edict { body.format(formCTX); } } - } catch (EscapeException eex) { + } catch (DirectiveEscape eex) { if (eex.endIteration) throw new UnsupportedOperationException("Colon mod not allowed on escape marker without colon mod on iteration"); } @@ -205,11 +205,11 @@ class IterationEdict implements Edict { } else { body.format(formCTX.writer, nParams); } - } catch (EscapeException eex) { + } catch (DirectiveEscape eex) { if(eex.endIteration && !itr.hasNext()) throw eex; } } - } catch (EscapeException eex) { + } catch (DirectiveEscape eex) { // Do nothing } break; @@ -234,7 +234,7 @@ class IterationEdict implements Edict { body.format(formCTX.writer, nParams); } } - } catch (EscapeException eex) { + } catch (DirectiveEscape eex) { if (eex.endIteration) throw new UnsupportedOperationException("Colon mod not allowed on escape marker without colon mod on iteration"); } diff --git a/clformat/src/main/java/bjc/utils/ioutils/format/directives/RecursiveDirective.java b/clformat/src/main/java/bjc/utils/ioutils/format/directives/RecursiveDirective.java index a52a3ba..c7dc200 100644 --- a/clformat/src/main/java/bjc/utils/ioutils/format/directives/RecursiveDirective.java +++ b/clformat/src/main/java/bjc/utils/ioutils/format/directives/RecursiveDirective.java @@ -45,7 +45,7 @@ class RecursiveEdict implements Edict { String bod = (String)body; fmt.doFormatString(bod, formCTX.writer, formCTX.items, true); - } catch (EscapeException eex) { + } catch (DirectiveEscape eex) { if (eex.endIteration) { throw new UnexpectedColonEscape(); } @@ -75,7 +75,7 @@ class RecursiveEdict implements Edict { // :DynamicString fmt.doFormatString(bod, formCTX.writer, newParams, true); - } catch (EscapeException eex) { + } catch (DirectiveEscape eex) { throw new UnexpectedColonEscape(); } } -- cgit v1.2.3