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
package com.temp.shared.utils;

public class Validate
{
    public static void notNull( String what, Object toCheck )
    {
        if ( toCheck == null )
        {
            throw new IllegalArgumentException( what + " Not Allowed to be Null" );
        }
    }

    public static String noEmpty( String what, String toCheck )
    {
        toCheck = StringUtils.noEmpty( toCheck );
        if ( toCheck == null )
        {
            throw new IllegalArgumentException( what + " Not Allowed to be Null or Empty" );
        }
        return toCheck;
    }

    public static String noEmptyIdentifier( String what, String toCheck )
    {
        toCheck = noEmpty( what, toCheck );
        if ( toCheck != null )
        {
            int errorIndex = StringUtils.checkIdentifier( toCheck );
            if ( errorIndex == 0 )
            {
                throw new IllegalArgumentException( "First Character Unacceptable for an Identifier: '" + toCheck + "'" );
            }
            if ( errorIndex != -1 )
            {
                throw new IllegalArgumentException( "Character (" + (errorIndex + 1) + ":'" + toCheck.charAt( errorIndex ) + "') Unacceptable for an Identifier: '" + toCheck + "'" );
            }
        }
        return toCheck;
    }

    public static Integer optionalLength( String what, Integer length )
    {
        if ( length != null )
        {
            length( what, length );
        }
        return length;
    }

    public static int length( String what, int length )
    {
        if ( length < 1 )
        {
            throw new IllegalArgumentException( what + " Must be at least 1" );
        }
        return length;
    }
}

Commits for litesoft/trunk/GWT_Sandbox/FormEngine/src/com/temp/shared/utils/Validate.java

Diff revisions: vs.
Revision Author Commited Message
600 Diff Diff GeorgeS picture GeorgeS Sun 05 Feb, 2012 18:55:58 +0000

Sync-n

594 Diff Diff GeorgeS picture GeorgeS Sat 21 Jan, 2012 00:40:54 +0000
591 GeorgeS picture GeorgeS Fri 20 Jan, 2012 01:57:31 +0000

New FormEngine