53 |
int dot = uri.lastIndexOf('.'); |
int dot = uri.lastIndexOf('.'); |
54 |
int comma = uri.lastIndexOf(','); |
int comma = uri.lastIndexOf(','); |
55 |
|
|
56 |
|
if(!uri.startsWith(PREFIX) |
57 |
|
|| dot < 0 || comma < 0 // URN must contain . and , |
58 |
|
|| dot - comma != 32 + 1 // SHA1 part must be 32 chars |
59 |
|
|| uri.length() - dot != 39 + 1 // TigerTree part must be 39 chars |
60 |
|
) |
61 |
|
throw new IllegalArgumentException("Bad block URN: "+uri); |
62 |
|
|
63 |
contentType = uri.substring(PREFIX_LEN, comma); |
contentType = uri.substring(PREFIX_LEN, comma); |
64 |
checkContentType(contentType); |
checkContentType(contentType); |
65 |
|
|
|
if(!uri.startsWith(PREFIX) || dot < 0 || |
|
|
comma < 0 || dot < comma) |
|
|
throw new IllegalArgumentException("Bad block URN: "+uri); |
|
|
|
|
66 |
sha1 = Base32.decode(uri.substring(comma+1, dot)); |
sha1 = Base32.decode(uri.substring(comma+1, dot)); |
67 |
tigertree = Base32.decode(uri.substring(dot+1)); |
tigertree = Base32.decode(uri.substring(dot+1)); |
68 |
} |
} |