* Try to guess if the UOM is a URN or URL. We looks for character that are usually
* part of URI but not part of unit symbols, for example ':'. We can not search for
* '/' and '.' since they are part of UCUM representation.
*/
final Context context = Context.current();
final ValueConverter converter = Context.converter(context);
if (uom.indexOf(':') >= 0) {
final URI uri = converter.toURI(context, uom);
String part = uri.getFragment();
if (part != null) {
uom = part;
int i = uom.lastIndexOf("@gml:id=");
if (i >= 0) {
i += 8; // 8 is the length of "@gml:id="
for (final int length=uom.length(); i<length;) {
final int c = uom.codePointAt(i);
if (!Character.isWhitespace(c)) {
if (c == '\'') i++;
break;
}
i += Character.charCount(c);
}
final int stop = uom.lastIndexOf('\'');
uom = CharSequences.trimWhitespaces((stop > i) ? uom.substring(i, stop) : uom.substring(i));
}
} else if ((part = uri.getPath()) != null) {
uom = new File(part).getName();
}
}
unit = converter.toUnit(context, uom);
}