Ignore:
Timestamp:
06/26/14 18:18:01 (10 years ago)
Author:
olhsha@mpi.nl
Message:

testing, debugging, fixing randomuuid-ncname issue

File:
1 edited

Legend:

Unmodified
Added
Removed
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/Helpers.java

    r5266 r5393  
    2323import java.io.InputStream;
    2424import java.util.Map;
     25import java.util.UUID;
    2526import javax.xml.parsers.DocumentBuilder;
    2627import javax.xml.parsers.DocumentBuilderFactory;
     
    3233import org.w3c.dom.ls.LSSerializer;
    3334import org.xml.sax.SAXException;
    34 
     35import java.util.Random;
    3536/**
    3637 *
     
    4041
    4142    //exception messages
    42     final static public String INVALID_BODY_EXCEPTION = "Invalide annotation body: both, text and xml options, are null.";
    43 
     43    //final static public String INVALID_BODY_EXCEPTION = "Invalide annotation body: both, text and xml options, are null.";
     44    final static String hexa = "ABCDEabcde";
     45    final static int hexan= hexa.length();
     46   
    4447    public static String replace(String text, Map<String, ?> pairs) {
    4548        StringBuilder result = new StringBuilder(text);
     
    119122        return encoder.encodePassword(pswd, salt);
    120123    }
     124   
     125    public static UUID generateUUID(){
     126        UUID result = UUID.randomUUID();
     127        char[] chars = result.toString().toCharArray();
     128        if (chars[0] >= 'a'  && chars[0] <='z') {
     129            return result;
     130        } else {
     131            Random r = new Random();
     132            chars[0] = hexa.charAt(r.nextInt(hexan));
     133            result = UUID.fromString(new String(chars));
     134            return result;
     135        }       
     136    }
    121137}
Note: See TracChangeset for help on using the changeset viewer.