1 package fr.in2p3.jsaga.helpers;
2
3 import java.util.regex.Matcher;
4 import java.util.regex.Pattern;
5
6 import org.ogf.saga.error.BadParameterException;
7 import org.ogf.saga.url.URL;
8
9 public class SAGAId {
10
11
12
13
14
15
16
17
18
19 public static String idFromSagaId(String sagaId) throws BadParameterException {
20 Pattern p = Pattern.compile("(\\[.*]-\\[)(.+)(])");
21 Matcher m = p.matcher(sagaId);
22 if (m.find()) {
23 return m.group(2);
24 }
25 throw new BadParameterException();
26 }
27
28 public static String idToSagaId(URL url, String nativeId) {
29 return "[" + url.getString() + "]-[" + nativeId + "]";
30 }
31 }