@Test public void testOgcCRS84() throws NoSuchAuthorityCodeException { final String urn_crs84 = "urn:ogc:def:crs:OGC:1.3:CRS84"; final URN_Parser parser = URN_Parser.buildParser(urn_crs84); assertEquals("crs", parser.type.name); assertEquals("CRS", parser.authority); assertEquals("1.3", parser.version.toString()); assertEquals("84", parser.code); assertEquals("CRS:84", parser.getAuthorityCode()); }
public static URN_Parser buildParser(final String urn) throws NoSuchAuthorityCodeException { final String code = urn.trim(); String type = urn; for (int i = 0; i < URN_BASES.length; i++) { final String urnBase = URN_BASES[i]; final int typeStart = urnBase.length(); if (code.regionMatches(true, 0, urnBase, 0, typeStart)) { final int typeEnd = code.indexOf(URN_SEPARATOR, typeStart); if (typeEnd >= 0) { type = code.substring(typeStart, typeEnd).trim(); final URI_Type candidate = URI_Type.get(type); if (candidate != null) { final int nameEnd = code.indexOf(URN_SEPARATOR, typeEnd + 1); if (nameEnd >= 0) { final int versionEnd = code.indexOf(URN_SEPARATOR, nameEnd + 1); final int lastEnd = code.lastIndexOf(URN_SEPARATOR); Version urnVersion; String urnAuthority; String urnCode; if (versionEnd != lastEnd && versionEnd != -1) { urnVersion = (lastEnd <= nameEnd) ? null : new Version( code.substring(nameEnd + 1, versionEnd)); urnAuthority = code.substring(typeEnd + 1, nameEnd); urnCode = code.substring(versionEnd + 1).trim(); urnCode = urnCode.replaceAll(String.valueOf(URN_SEPARATOR), ","); } else { urnVersion = (lastEnd <= nameEnd) ? null : new Version(code.substring(nameEnd + 1, lastEnd)); urnAuthority = code.substring(typeEnd + 1, nameEnd).trim(); urnCode = code.substring(lastEnd + 1).trim(); } urnVersion = (StringUtils.isEmpty(urnVersion)) ? null : urnVersion; if (urnCode.contains("CRS")) { urnAuthority = "CRS"; urnCode = urnCode.substring(3); } else if (urnCode.contains("AUTO")) { urnAuthority = "AUTO"; urnCode = urnCode.substring(4); } URI_Type urnType = candidate; return new URN_Parser(urn, urnType, urnAuthority, urnVersion, urnCode); } } } } } throw new NoSuchAuthorityCodeException( Errors.format(ErrorKeys.ILLEGAL_IDENTIFIER_$1, type), "urn:ogc:def", type); }
URN_Parser extends URI_Parser { public static URN_Parser buildParser(final String urn) throws NoSuchAuthorityCodeException { final String code = urn.trim(); String type = urn; for (int i = 0; i < URN_BASES.length; i++) { final String urnBase = URN_BASES[i]; final int typeStart = urnBase.length(); if (code.regionMatches(true, 0, urnBase, 0, typeStart)) { final int typeEnd = code.indexOf(URN_SEPARATOR, typeStart); if (typeEnd >= 0) { type = code.substring(typeStart, typeEnd).trim(); final URI_Type candidate = URI_Type.get(type); if (candidate != null) { final int nameEnd = code.indexOf(URN_SEPARATOR, typeEnd + 1); if (nameEnd >= 0) { final int versionEnd = code.indexOf(URN_SEPARATOR, nameEnd + 1); final int lastEnd = code.lastIndexOf(URN_SEPARATOR); Version urnVersion; String urnAuthority; String urnCode; if (versionEnd != lastEnd && versionEnd != -1) { urnVersion = (lastEnd <= nameEnd) ? null : new Version( code.substring(nameEnd + 1, versionEnd)); urnAuthority = code.substring(typeEnd + 1, nameEnd); urnCode = code.substring(versionEnd + 1).trim(); urnCode = urnCode.replaceAll(String.valueOf(URN_SEPARATOR), ","); } else { urnVersion = (lastEnd <= nameEnd) ? null : new Version(code.substring(nameEnd + 1, lastEnd)); urnAuthority = code.substring(typeEnd + 1, nameEnd).trim(); urnCode = code.substring(lastEnd + 1).trim(); } urnVersion = (StringUtils.isEmpty(urnVersion)) ? null : urnVersion; if (urnCode.contains("CRS")) { urnAuthority = "CRS"; urnCode = urnCode.substring(3); } else if (urnCode.contains("AUTO")) { urnAuthority = "AUTO"; urnCode = urnCode.substring(4); } URI_Type urnType = candidate; return new URN_Parser(urn, urnType, urnAuthority, urnVersion, urnCode); } } } } } throw new NoSuchAuthorityCodeException( Errors.format(ErrorKeys.ILLEGAL_IDENTIFIER_$1, type), "urn:ogc:def", type); } }
URN_Parser extends URI_Parser { public static URN_Parser buildParser(final String urn) throws NoSuchAuthorityCodeException { final String code = urn.trim(); String type = urn; for (int i = 0; i < URN_BASES.length; i++) { final String urnBase = URN_BASES[i]; final int typeStart = urnBase.length(); if (code.regionMatches(true, 0, urnBase, 0, typeStart)) { final int typeEnd = code.indexOf(URN_SEPARATOR, typeStart); if (typeEnd >= 0) { type = code.substring(typeStart, typeEnd).trim(); final URI_Type candidate = URI_Type.get(type); if (candidate != null) { final int nameEnd = code.indexOf(URN_SEPARATOR, typeEnd + 1); if (nameEnd >= 0) { final int versionEnd = code.indexOf(URN_SEPARATOR, nameEnd + 1); final int lastEnd = code.lastIndexOf(URN_SEPARATOR); Version urnVersion; String urnAuthority; String urnCode; if (versionEnd != lastEnd && versionEnd != -1) { urnVersion = (lastEnd <= nameEnd) ? null : new Version( code.substring(nameEnd + 1, versionEnd)); urnAuthority = code.substring(typeEnd + 1, nameEnd); urnCode = code.substring(versionEnd + 1).trim(); urnCode = urnCode.replaceAll(String.valueOf(URN_SEPARATOR), ","); } else { urnVersion = (lastEnd <= nameEnd) ? null : new Version(code.substring(nameEnd + 1, lastEnd)); urnAuthority = code.substring(typeEnd + 1, nameEnd).trim(); urnCode = code.substring(lastEnd + 1).trim(); } urnVersion = (StringUtils.isEmpty(urnVersion)) ? null : urnVersion; if (urnCode.contains("CRS")) { urnAuthority = "CRS"; urnCode = urnCode.substring(3); } else if (urnCode.contains("AUTO")) { urnAuthority = "AUTO"; urnCode = urnCode.substring(4); } URI_Type urnType = candidate; return new URN_Parser(urn, urnType, urnAuthority, urnVersion, urnCode); } } } } } throw new NoSuchAuthorityCodeException( Errors.format(ErrorKeys.ILLEGAL_IDENTIFIER_$1, type), "urn:ogc:def", type); } protected  URN_Parser(
            String urn, URI_Type type, String authority, Version version, String code); }
URN_Parser extends URI_Parser { public static URN_Parser buildParser(final String urn) throws NoSuchAuthorityCodeException { final String code = urn.trim(); String type = urn; for (int i = 0; i < URN_BASES.length; i++) { final String urnBase = URN_BASES[i]; final int typeStart = urnBase.length(); if (code.regionMatches(true, 0, urnBase, 0, typeStart)) { final int typeEnd = code.indexOf(URN_SEPARATOR, typeStart); if (typeEnd >= 0) { type = code.substring(typeStart, typeEnd).trim(); final URI_Type candidate = URI_Type.get(type); if (candidate != null) { final int nameEnd = code.indexOf(URN_SEPARATOR, typeEnd + 1); if (nameEnd >= 0) { final int versionEnd = code.indexOf(URN_SEPARATOR, nameEnd + 1); final int lastEnd = code.lastIndexOf(URN_SEPARATOR); Version urnVersion; String urnAuthority; String urnCode; if (versionEnd != lastEnd && versionEnd != -1) { urnVersion = (lastEnd <= nameEnd) ? null : new Version( code.substring(nameEnd + 1, versionEnd)); urnAuthority = code.substring(typeEnd + 1, nameEnd); urnCode = code.substring(versionEnd + 1).trim(); urnCode = urnCode.replaceAll(String.valueOf(URN_SEPARATOR), ","); } else { urnVersion = (lastEnd <= nameEnd) ? null : new Version(code.substring(nameEnd + 1, lastEnd)); urnAuthority = code.substring(typeEnd + 1, nameEnd).trim(); urnCode = code.substring(lastEnd + 1).trim(); } urnVersion = (StringUtils.isEmpty(urnVersion)) ? null : urnVersion; if (urnCode.contains("CRS")) { urnAuthority = "CRS"; urnCode = urnCode.substring(3); } else if (urnCode.contains("AUTO")) { urnAuthority = "AUTO"; urnCode = urnCode.substring(4); } URI_Type urnType = candidate; return new URN_Parser(urn, urnType, urnAuthority, urnVersion, urnCode); } } } } } throw new NoSuchAuthorityCodeException( Errors.format(ErrorKeys.ILLEGAL_IDENTIFIER_$1, type), "urn:ogc:def", type); } protected  URN_Parser(
            String urn, URI_Type type, String authority, Version version, String code); static URN_Parser buildParser(final String urn); }
URN_Parser extends URI_Parser { public static URN_Parser buildParser(final String urn) throws NoSuchAuthorityCodeException { final String code = urn.trim(); String type = urn; for (int i = 0; i < URN_BASES.length; i++) { final String urnBase = URN_BASES[i]; final int typeStart = urnBase.length(); if (code.regionMatches(true, 0, urnBase, 0, typeStart)) { final int typeEnd = code.indexOf(URN_SEPARATOR, typeStart); if (typeEnd >= 0) { type = code.substring(typeStart, typeEnd).trim(); final URI_Type candidate = URI_Type.get(type); if (candidate != null) { final int nameEnd = code.indexOf(URN_SEPARATOR, typeEnd + 1); if (nameEnd >= 0) { final int versionEnd = code.indexOf(URN_SEPARATOR, nameEnd + 1); final int lastEnd = code.lastIndexOf(URN_SEPARATOR); Version urnVersion; String urnAuthority; String urnCode; if (versionEnd != lastEnd && versionEnd != -1) { urnVersion = (lastEnd <= nameEnd) ? null : new Version( code.substring(nameEnd + 1, versionEnd)); urnAuthority = code.substring(typeEnd + 1, nameEnd); urnCode = code.substring(versionEnd + 1).trim(); urnCode = urnCode.replaceAll(String.valueOf(URN_SEPARATOR), ","); } else { urnVersion = (lastEnd <= nameEnd) ? null : new Version(code.substring(nameEnd + 1, lastEnd)); urnAuthority = code.substring(typeEnd + 1, nameEnd).trim(); urnCode = code.substring(lastEnd + 1).trim(); } urnVersion = (StringUtils.isEmpty(urnVersion)) ? null : urnVersion; if (urnCode.contains("CRS")) { urnAuthority = "CRS"; urnCode = urnCode.substring(3); } else if (urnCode.contains("AUTO")) { urnAuthority = "AUTO"; urnCode = urnCode.substring(4); } URI_Type urnType = candidate; return new URN_Parser(urn, urnType, urnAuthority, urnVersion, urnCode); } } } } } throw new NoSuchAuthorityCodeException( Errors.format(ErrorKeys.ILLEGAL_IDENTIFIER_$1, type), "urn:ogc:def", type); } protected  URN_Parser(
            String urn, URI_Type type, String authority, Version version, String code); static URN_Parser buildParser(final String urn);  }