Subversion Repository Public Repository

litesoft

Diff Revisions 947 vs 948 for /trunk/GWT_Sandbox/FormEngine/src/com/temp/shared/utils/ContextThrowables.java

Diff revisions: vs.
  @@ -1,8 +1,7 @@
1 1 package com.temp.shared.utils;
2 2
3 - import java.io.PrintStream;
4 - import java.util.ArrayList;
5 - import java.util.List;
3 + import java.io.*;
4 + import java.util.*;
6 5
7 6 /**
8 7 * Collect all the Issues/Throwables for a particular "Context"
  @@ -13,19 +12,19 @@
13 12 private final String context;
14 13 private final List<Throwable> throwables = new ArrayList<Throwable>();
15 14
16 - public ContextThrowables(String context, Throwable... throwables) {
17 - this.context = StringUtils.deNull(context).trim();
18 - add(throwables);
19 - if (this.throwables.isEmpty()) { // Validate that there is at least one Throwable!
20 - throw new IllegalArgumentException("No Throwable");
15 + public ContextThrowables( String context, Throwable... throwables ) {
16 + this.context = StringUtils.deNull( context ).trim();
17 + add( throwables );
18 + if ( this.throwables.isEmpty() ) { // Validate that there is at least one Throwable!
19 + throw new IllegalArgumentException( "No Throwable" );
21 20 }
22 21 }
23 22
24 - public void add(Throwable... throwables) {
25 - if (throwables != null) {
26 - for (Throwable throwable : throwables) {
27 - if (throwable != null) {
28 - this.throwables.add(throwable);
23 + public void add( Throwable... throwables ) {
24 + if ( throwables != null ) {
25 + for ( Throwable throwable : throwables ) {
26 + if ( throwable != null ) {
27 + this.throwables.add( throwable );
29 28 }
30 29 }
31 30 }
  @@ -36,12 +35,12 @@
36 35 }
37 36
38 37 public Throwable[] getThrowables() {
39 - return throwables.toArray(new Throwable[throwables.size()]);
38 + return throwables.toArray( new Throwable[throwables.size()] );
40 39 }
41 40
42 41 @Override
43 - public int compareTo(ContextThrowables them) {
44 - return this.context.compareTo(them.context);
42 + public int compareTo( ContextThrowables them ) {
43 + return this.context.compareTo( them.context );
45 44 }
46 45
47 46 @Override
  @@ -50,26 +49,27 @@
50 49 }
51 50
52 51 @Override
53 - public boolean equals(Object obj) {
54 - return (this == obj) || ((obj instanceof ContextThrowables) && equals((ContextThrowables) obj));
52 + public boolean equals( Object obj ) {
53 + return (this == obj) || ((obj instanceof ContextThrowables) && equals( (ContextThrowables) obj ));
55 54 }
56 55
57 - public boolean equals(ContextThrowables them) {
58 - return (this == them) || ((them != null) && this.context.equals(them.context));
56 + public boolean equals( ContextThrowables them ) {
57 + return (this == them) || ((them != null) && this.context.equals( them.context ));
59 58 }
60 59
61 60 @Override
62 61 public String toString() {
63 - return appendTo(new StringBuilder(), 0).toString();
62 + return appendTo( new StringBuilder(), 0 ).toString();
64 63 }
65 64
66 - public StringBuilder appendTo(StringBuilder sb, int indent) {
67 - sb.append(StringUtils.indent(indent)).append((context.length() != 0) ? context : "No Context");
68 - if (!throwables.isEmpty()) {
69 - sb.append(':');
65 + public StringBuilder appendTo( StringBuilder sb, int indent ) {
66 + sb.append( StringUtils.indent( indent ) ).append( (context.length() != 0) ? context : "No Context" );
67 + if ( !throwables.isEmpty() ) {
68 + sb.append( ':' );
70 69 indent++;
71 - for (Throwable throwable : throwables) {
72 - sb.append('\n').append(StringUtils.indent(indent)).append(StringUtils.simpleClassNameFor(throwable)).append(": ").append(throwable.getMessage());
70 + for ( Throwable throwable : throwables ) {
71 + sb.append( '\n' ).append( StringUtils.indent( indent ) ).append( StringUtils.simpleClassNameFor( throwable ) ).append( ": " )
72 + .append( throwable.getMessage() );
73 73 }
74 74 }
75 75 return sb;
  @@ -78,27 +78,27 @@
78 78 /**
79 79 * @param stream - note in GWT only println Object & String are implemented
80 80 */
81 - public void dumpToAsHTML(PrintStream stream, boolean fullStackTrace) {
81 + public void dumpToAsHTML( PrintStream stream, boolean fullStackTrace ) {
82 82 boolean anyThrowables = !throwables.isEmpty();
83 83 String header = (context.length() != 0) ? context : "No Context";
84 - if (!anyThrowables) {
85 - stream.println(header);
84 + if ( !anyThrowables ) {
85 + stream.println( header );
86 86 } else {
87 - stream.println(header + ":");
88 - stream.println("<ul>");
89 - for (Throwable throwable : throwables) {
90 - if (fullStackTrace) {
91 - throwable.printStackTrace(stream);
87 + stream.println( header + ":" );
88 + stream.println( "<ul>" );
89 + for ( Throwable throwable : throwables ) {
90 + if ( fullStackTrace ) {
91 + throwable.printStackTrace( stream );
92 92 } else {
93 93 String message = throwable.getMessage();
94 - if (message != null) {
94 + if ( message != null ) {
95 95 message = ": " + message;
96 96 }
97 - stream.println(ObjectUtils.getSimpleClassName(throwable) + message);
97 + stream.println( ObjectUtils.getSimpleClassName( throwable ) + message );
98 98 }
99 - stream.println("");
99 + stream.println( "" );
100 100 }
101 - stream.println("</ul>");
101 + stream.println( "</ul>" );
102 102 }
103 103 }
104 104 }