Project

General

Profile

Download (1.2 KB) Statistics
| Branch: | Tag: | Revision:
1
package org.bgbm.biovel.drf.utils;
2

    
3
import java.net.MalformedURLException;
4
import java.util.UUID;
5

    
6
import com.ibm.lsid.MalformedLSIDException;
7
import com.ibm.lsid.client.LSIDAuthority;
8
import com.sun.jndi.toolkit.url.Uri;
9

    
10
public class IdentifierUtils {
11

    
12
    public static boolean checkInteger(String value){
13

    
14
        try {
15
            Integer.valueOf(value);
16
        } catch (NumberFormatException e) {
17
            return false;
18
        }
19
        return true;
20
    }
21

    
22
    public static boolean checkUUID(String value){
23

    
24
        try {
25
            UUID.fromString(value);
26
        } catch (IllegalArgumentException e) {
27
            return false;
28
        }
29
        return true;
30
    }
31

    
32
    @SuppressWarnings("unused")
33
    public static boolean checkLSID(String value){
34

    
35
        try {
36
           new LSIDAuthority(value);
37
        } catch (MalformedLSIDException e) {
38
            return false;
39
        }
40
        return true;
41
    }
42

    
43
    /**
44
     * @param id
45
     * @param idBaseUri
46
     * @return
47
     */
48
    @SuppressWarnings("unused")
49
    public static boolean checkURI(String id) {
50
        try {
51
            new Uri(id);
52
        } catch (MalformedURLException e) {
53
            return false;
54
        }
55
        return true;
56
    }
57

    
58
}
(4-4/10)