public static String toSURT(String input) { if(input.startsWith("(")) { return input; } try { // String tmp = input; // if(tmp == null) { // throw new URIException(); // } String tmp = SURTTokenizer.prefixKey(input); if(tmp.contains("/")) { return tmp; } return tmp + ","; } catch (URIException e) { LOG.warning("URI Exception for(" + input + "):" + e.getLocalizedMessage()); // e.printStackTrace(); return input; } } public static void main(String[] args) {
public static String toSURT(String input) { if(input.startsWith("(")) { return input; } try { // String tmp = input; // if(tmp == null) { // throw new URIException(); // } String tmp = SURTTokenizer.prefixKey(input); if(tmp.contains("/")) { return tmp; } return tmp + ","; } catch (URIException e) { LOG.warning("URI Exception for(" + input + "):" + e.getLocalizedMessage()); // e.printStackTrace(); return input; } } public static void main(String[] args) {
public static String toSURT(String input) { if(input.startsWith("(")) { return input; } try { // String tmp = input; // if(tmp == null) { // throw new URIException(); // } String tmp = SURTTokenizer.prefixKey(input); if(tmp.contains("/")) { return tmp; } return tmp + ","; } catch (URIException e) { LOG.warning("URI Exception for(" + input + "):" + e.getLocalizedMessage()); // e.printStackTrace(); return input; } } public static void main(String[] args) {
/** * Find and return the parent directory of the URL argument * @param url to find the parent directory of * @return parent directory of URL, or null, if either the url argument is * invalid, or if the url is the root of the authority. */ public static String getUrlParentDir(String url) { try { UsableURI uri = UsableURIFactory.getInstance(url); String path = uri.getPath(); if(path.length() > 1) { int startIdx = path.length()-1; if(path.charAt(path.length()-1) == '/') { startIdx--; } int idx = path.lastIndexOf('/',startIdx); if(idx >= 0) { uri.setPath(path.substring(0,idx+1)); uri.setQuery(null); return uri.toUnicodeHostString(); } } } catch (URIException e) { LOGGER.warning(e.getLocalizedMessage() + ": " + url); } return null; }
/** * Find and return the parent directory of the URL argument * @param url to find the parent directory of * @return parent directory of URL, or null, if either the url argument is * invalid, or if the url is the root of the authority. */ public static String getUrlParentDir(String url) { try { UsableURI uri = UsableURIFactory.getInstance(url); String path = uri.getPath(); if(path.length() > 1) { int startIdx = path.length()-1; if(path.charAt(path.length()-1) == '/') { startIdx--; } int idx = path.lastIndexOf('/',startIdx); if(idx >= 0) { uri.setPath(path.substring(0,idx+1)); uri.setQuery(null); return uri.toUnicodeHostString(); } } } catch (URIException e) { LOGGER.warning(e.getLocalizedMessage() + ": " + url); } return null; }
return UsableURIFactory.getInstance(url).getEscapedURI(); } catch (URIException e) { LOGGER.warning(e.getLocalizedMessage() + ": " + url); resolvedURI = UsableURIFactory.getInstance(absBaseURI, url); } catch (URIException e) { LOGGER.warning(e.getLocalizedMessage() + ": " + url); return defaultValue;
return UsableURIFactory.getInstance(url).getEscapedURI(); } catch (URIException e) { LOGGER.warning(e.getLocalizedMessage() + ": " + url); resolvedURI = UsableURIFactory.getInstance(absBaseURI, url); } catch (URIException e) { LOGGER.warning(e.getLocalizedMessage() + ": " + url); return defaultValue;
private SURTTokenizer toSurtT(final String u) { SURTTokenizer tok = null; try { tok = new SURTTokenizer(u, false); } catch (URIException e) { e.printStackTrace(); assertFalse("URL Exception " + e.getLocalizedMessage(),true); } return tok; }