Subversion Repository Public Repository

litesoft

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// This Source Code is in the Public Domain per: http://litesoft.org/License.txt
package org.litesoft.core.util;

import java.io.*;

import org.litesoft.commonfoundation.typeutils.*;

import java.util.*;

import org.litesoft.commonfoundation.typeutils.Objects;

public class Problem implements Serializable
{
    private static final long serialVersionUID = 1L;

    private /* final */ String mProblemCode;

    private /* final */ String[] mProblemSupportValues;

    @SuppressWarnings({"deprecation", "UnusedDeclaration"}) @Deprecated /** for Serialization */
    protected Problem()
    {
    }

    public Problem( Throwable pThrowable )
    {
        this( pThrowable, null, (String[]) null );
    }

    public Problem( String pProblemCode, String[] pProblemSupportValues )
    {
        this( null, pProblemCode, pProblemSupportValues );
    }

    public Problem( String pProblemCode )
    {
        this( null, pProblemCode, (String[]) null );
    }

    public Problem( String pProblemCode, String pProblemSupportValue )
    {
        this( null, pProblemCode, new String[]{pProblemSupportValue} );
    }

    public Problem( String pProblemCode, String pProblemSupportValue0, String pProblemSupportValue1 )
    {
        this( null, pProblemCode, new String[]{pProblemSupportValue0, pProblemSupportValue1} );
    }

    public Problem( String pProblemCode, String pProblemSupportValue0, String pProblemSupportValue1, String pProblemSupportValue2 )
    {
        this( null, pProblemCode, new String[]{pProblemSupportValue0, pProblemSupportValue1, pProblemSupportValue2} );
    }

    public Problem( String pProblemCode, String pProblemSupportValue0, String pProblemSupportValue1, String pProblemSupportValue2, String pProblemSupportValue3 )
    {
        this( null, pProblemCode, new String[]{pProblemSupportValue0, pProblemSupportValue1, pProblemSupportValue2, pProblemSupportValue3} );
    }

    public Problem( Throwable pThrowable, String pProblemCode )
    {
        this( pThrowable, pProblemCode, (String[]) null );
    }

    public Problem( Throwable pThrowable, String pProblemCode, String pProblemSupportValue )
    {
        this( pThrowable, pProblemCode, new String[]{pProblemSupportValue} );
    }

    public Problem( Throwable pThrowable, String pProblemCode, String pProblemSupportValue0, String pProblemSupportValue1 )
    {
        this( pThrowable, pProblemCode, new String[]{pProblemSupportValue0, pProblemSupportValue1} );
    }

    public Problem( Throwable pThrowable, String pProblemCode, String pProblemSupportValue0, String pProblemSupportValue1, String pProblemSupportValue2 )
    {
        this( pThrowable, pProblemCode, new String[]{pProblemSupportValue0, pProblemSupportValue1, pProblemSupportValue2} );
    }

    public Problem( Throwable pThrowable, String pProblemCode, String pProblemSupportValue0, String pProblemSupportValue1, String pProblemSupportValue2, String pProblemSupportValue3 )
    {
        this( pThrowable, pProblemCode, new String[]{pProblemSupportValue0, pProblemSupportValue1, pProblemSupportValue2, pProblemSupportValue3} );
    }

    /**
     * One of <code>pProblemCode</code> or <code>pThrowable</code> must be specified.
     *
     * @param pThrowable            a Throwable or <code>null</code>
     * @param pProblemCode
     * @param pProblemSupportValues additional info about <code>pProblemCode</code>, or <code>null</code>
     *
     * @throws IllegalArgumentException if <code>pProblemSupportValues</code> is
     *                                  specified without <code>pProblemCode</code>
     */
    public Problem( Throwable pThrowable, String pProblemCode, String[] pProblemSupportValues )
    {
        pProblemCode = Strings.noEmpty( pProblemCode );
        pProblemSupportValues = Strings.noEmpty( pProblemSupportValues );
        if ( (pThrowable == null) && (pProblemCode == null) )
        {
            throw new IllegalArgumentException( "Either the Throwable or the ProblemCode must not be null" );
        }
        if ( (pProblemCode == null) && (pProblemSupportValues != null) )
        {
            throw new IllegalArgumentException( "ProblemSupportValues not allowed when there is no ProblemCode" );
        }

        List<String> zProblemSupportValues = new ArrayList<String>();
        if ( pProblemSupportValues != null )
        {
            zProblemSupportValues.addAll( Arrays.asList( pProblemSupportValues ) );
        }
        if ( pThrowable != null )
        {
            if ( pProblemCode == null )
            {
                pProblemCode = pThrowable.getMessage();
            }
            else
            {
                zProblemSupportValues.add( pThrowable.getMessage() );
            }
            zProblemSupportValues.add( Throwables.printStackTraceToString( pThrowable ) );
        }
        mProblemCode = pProblemCode;
        mProblemSupportValues = new String[zProblemSupportValues.size()];
        for ( int i = 0; i < mProblemSupportValues.length; i++ )
        {
            mProblemSupportValues[i] = zProblemSupportValues.get( i );
        }
    }

    public String getProblemCode()
    {
        return mProblemCode;
    }

    public String[] getProblemSupportValues()
    {
        return mProblemSupportValues;
    }

    @Override
    public String toString()
    {
        StringBuilder sb = new StringBuilder();
        sb.append( mProblemCode );
        if ( mProblemSupportValues != null )
        {
            sb.append( Objects.toString( mProblemSupportValues, "\r\n" ) );
        }
        return (sb.length() == 0) ? "?" : sb.toString();
    }
}

Commits for litesoft/trunk/Java/core/Anywhere/src/org/litesoft/core/util/Problem.java

Diff revisions: vs.
Revision Author Commited Message
939 Diff Diff GeorgeS picture GeorgeS Mon 02 Jun, 2014 21:30:31 +0000

Extracting commonfoundation

917 Diff Diff GeorgeS picture GeorgeS Sun 08 Dec, 2013 20:49:56 +0000

1.7 prep & VersionedStaticContentFilter upgrade to new “/ver” model!

849 Diff Diff GeorgeS picture GeorgeS Tue 11 Sep, 2012 17:11:59 +0000

Clean up serialization

822 Diff Diff GeorgeS picture GeorgeS Sun 19 Aug, 2012 01:03:51 +0000
801 Diff Diff GeorgeS picture GeorgeS Wed 15 Aug, 2012 03:59:02 +0000
50 Diff Diff GeorgeS picture GeorgeS Tue 13 Apr, 2010 11:51:38 +0000
49 Diff Diff GeorgeS picture GeorgeS Mon 12 Apr, 2010 02:59:10 +0000

License Text

2 GeorgeS picture GeorgeS Sun 07 Feb, 2010 12:50:58 +0000