/** * @param baseURL an base URL for relative URLs */ public void setBaseUrl(String baseURL) { try { baseUrl = UsableURIFactory.getInstance(baseURL); } catch (URIException ex) { // XXX ex.printStackTrace(); } }
/** * @param element to examine and lowercase if non-null. * @return Null if passed null or an empty string otherwise * <code>element</code> lowercased. */ private String checkUriElementAndLowerCase(String element) { String tmp = checkUriElement(element); return (tmp != null)? tmp.toLowerCase(): tmp; } }
/** * @param uri URI as string. * @return An instance of UURI * @throws URIException */ public static UsableURI getInstance(String uri) throws URIException { return UsableURIFactory.factory.create(uri); }
/** * @param uri URI as string. * @param charset Original encoding of the string. * @return Instance of UURI. * @throws URIException */ protected UsableURI create(String uri, String charset) throws URIException { UsableURI uuri = makeOne(fixup(uri, null, charset), true, charset); if (logger.isLoggable(Level.FINE)) { logger.fine("URI " + uri + " PRODUCT " + uuri.toString() + " CHARSET " + charset); } return validityCheck(uuri); }
uri = escapeWhitespace(uri); String uriScheme = checkUriElementAndLowerCase(matcher.group(2)); String uriSchemeSpecificPart = checkUriElement(matcher.group(3)); String uriAuthority = checkUriElement(matcher.group(5)); String uriPath = checkUriElement(matcher.group(6)); String uriQuery = checkUriElement(matcher.group(8)); checkHttpSchemeSpecificPartSlashPrefix(base, uriScheme, uriSchemeSpecificPart); uriAuthority = fixupAuthority(uriAuthority,charset); if (uriScheme != null && uriScheme.length() > 0 && uriScheme.equals(HTTP)) { uriAuthority = checkPort(uriAuthority); uriAuthority = stripTail(uriAuthority, HTTP_PORT); } else if (uriScheme != null && uriScheme.length() > 0 && uriScheme.equals(HTTPS)) { uriAuthority = checkPort(uriAuthority); uriAuthority = stripTail(uriAuthority, HTTPS_PORT); uriAuthority = stripTail(uriAuthority, DOT); uriAuthority = stripPrefix(uriAuthority, DOT); } else { uriPath = ensureMinimalEscaping(uriPath, charset); uriQuery = ensureMinimalEscaping(uriQuery, charset, LaxURLCodec.QUERY_SAFE);
if(atIndex<0 && portColonIndex<0) { return fixupDomainlabel(uriAuthority); } else if (atIndex<0 && portColonIndex>-1) { String domain = fixupDomainlabel(uriAuthority.substring(0,portColonIndex)); String port = uriAuthority.substring(portColonIndex); return domain + port; } else if (atIndex>-1 && portColonIndex<0) { String userinfo = ensureMinimalEscaping(uriAuthority.substring(0,atIndex+1),charset); String domain = fixupDomainlabel(uriAuthority.substring(atIndex+1)); return userinfo + domain; } else { String userinfo = ensureMinimalEscaping(uriAuthority.substring(0,atIndex+1),charset); String domain = fixupDomainlabel(uriAuthority.substring(atIndex+1,portColonIndex)); String port = uriAuthority.substring(portColonIndex); return userinfo + domain + port;
/** * Ensure that there all characters needing escaping * in the passed-in String are escaped. Stray '%' characters * are *not* escaped, as per browser behavior. * * @param u String to escape * @param charset * @return string with any necessary escaping applied */ private String ensureMinimalEscaping(String u, final String charset) { return ensureMinimalEscaping(u, charset, LaxURLCodec.EXPANDED_URI_SAFE); }
String uriScheme = checkUriElementAndLowerCase(matcher.group(2)); String uriSchemeSpecificPart = checkUriElement(matcher.group(3)); String uriAuthority = checkUriElement(matcher.group(5)); String uriPath = checkUriElement(matcher.group(6)); String uriQuery = checkUriElement(matcher.group(8)); checkHttpSchemeSpecificPartSlashPrefix(base, uriScheme, uriSchemeSpecificPart); uriAuthority = fixupAuthority(uriAuthority,charset); if (uriScheme != null && uriScheme.length() > 0 && uriScheme.equals(HTTP)) { uriAuthority = checkPort(uriAuthority); uriAuthority = stripTail(uriAuthority, HTTP_PORT); } else if (uriScheme != null && uriScheme.length() > 0 && uriScheme.equals(HTTPS)) { uriAuthority = checkPort(uriAuthority); uriAuthority = stripTail(uriAuthority, HTTPS_PORT); uriAuthority = stripTail(uriAuthority, DOT); uriAuthority = stripPrefix(uriAuthority, DOT); } else { uriPath = ensureMinimalEscaping(uriPath, charset); uriQuery = ensureMinimalEscaping(uriQuery, charset, LaxURLCodec.QUERY_SAFE); + 1 // '?'
/** * @param uri URI as string. * @param charset Original encoding of the string. * @return Instance of UURI. * @throws URIException */ protected UsableURI create(String uri, String charset) throws URIException { UsableURI uuri = makeOne(fixup(uri, null, charset), true, charset); if (logger.isLoggable(Level.FINE)) { logger.fine("URI " + uri + " PRODUCT " + uuri.toString() + " CHARSET " + charset); } return validityCheck(uuri); }
if(atIndex<0 && portColonIndex<0) { return fixupDomainlabel(uriAuthority); } else if (atIndex<0 && portColonIndex>-1) { String domain = fixupDomainlabel(uriAuthority.substring(0,portColonIndex)); String port = uriAuthority.substring(portColonIndex); return domain + port; } else if (atIndex>-1 && portColonIndex<0) { String userinfo = ensureMinimalEscaping(uriAuthority.substring(0,atIndex+1),charset); String domain = fixupDomainlabel(uriAuthority.substring(atIndex+1)); return userinfo + domain; } else { String userinfo = ensureMinimalEscaping(uriAuthority.substring(0,atIndex+1),charset); String domain = fixupDomainlabel(uriAuthority.substring(atIndex+1,portColonIndex)); String port = uriAuthority.substring(portColonIndex); return userinfo + domain + port;
/** * Ensure that there all characters needing escaping * in the passed-in String are escaped. Stray '%' characters * are *not* escaped, as per browser behavior. * * @param u String to escape * @param charset * @return string with any necessary escaping applied */ private String ensureMinimalEscaping(String u, final String charset) { return ensureMinimalEscaping(u, charset, LaxURLCodec.EXPANDED_URI_SAFE); }
String uriScheme = checkUriElementAndLowerCase(matcher.group(2)); String uriSchemeSpecificPart = checkUriElement(matcher.group(3)); String uriAuthority = checkUriElement(matcher.group(5)); String uriPath = checkUriElement(matcher.group(6)); String uriQuery = checkUriElement(matcher.group(8)); checkHttpSchemeSpecificPartSlashPrefix(base, uriScheme, uriSchemeSpecificPart); uriAuthority = fixupAuthority(uriAuthority,charset); if (uriScheme != null && uriScheme.length() > 0 && uriScheme.equals(HTTP)) { uriAuthority = checkPort(uriAuthority); uriAuthority = stripTail(uriAuthority, HTTP_PORT); } else if (uriScheme != null && uriScheme.length() > 0 && uriScheme.equals(HTTPS)) { uriAuthority = checkPort(uriAuthority); uriAuthority = stripTail(uriAuthority, HTTPS_PORT); uriAuthority = stripTail(uriAuthority, DOT); uriAuthority = stripPrefix(uriAuthority, DOT); } else { uriPath = ensureMinimalEscaping(uriPath, charset); uriQuery = ensureMinimalEscaping(uriQuery, charset, LaxURLCodec.QUERY_SAFE); + 1 // '?'
public SWFUrlRewriter(ResultURIConverter converter, URL baseUrl, String datespec) { this.datespec = datespec; this.converter = converter; try { this.baseUrl = UsableURIFactory .getInstance(baseUrl.toExternalForm()); } catch (URIException e) { e.printStackTrace(); } }
/** * @param uri URI as string. * @param charset Original encoding of the string. * @return Instance of UURI. * @throws URIException */ protected UsableURI create(String uri, String charset) throws URIException { UsableURI uuri = makeOne(fixup(uri, null, charset), true, charset); if (logger.isLoggable(Level.FINE)) { logger.fine("URI " + uri + " PRODUCT " + uuri.toString() + " CHARSET " + charset); } return validityCheck(uuri); }
/** * @param uri URI as string. * @return An instance of UURI * @throws URIException */ public static UsableURI getInstance(String uri) throws URIException { return UsableURIFactory.factory.create(uri); }
if(atIndex<0 && portColonIndex<0) { return fixupDomainlabel(uriAuthority); } else if (atIndex<0 && portColonIndex>-1) { String domain = fixupDomainlabel(uriAuthority.substring(0,portColonIndex)); String port = uriAuthority.substring(portColonIndex); return domain + port; } else if (atIndex>-1 && portColonIndex<0) { String userinfo = ensureMinimalEscaping(uriAuthority.substring(0,atIndex+1),charset); String domain = fixupDomainlabel(uriAuthority.substring(atIndex+1)); return userinfo + domain; } else { String userinfo = ensureMinimalEscaping(uriAuthority.substring(0,atIndex+1),charset); String domain = fixupDomainlabel(uriAuthority.substring(atIndex+1,portColonIndex)); String port = uriAuthority.substring(portColonIndex); return userinfo + domain + port;
/** * Ensure that there all characters needing escaping * in the passed-in String are escaped. Stray '%' characters * are *not* escaped, as per browser behavior. * * @param u String to escape * @param charset * @return string with any necessary escaping applied */ private String ensureMinimalEscaping(String u, final String charset) { return ensureMinimalEscaping(u, charset, LaxURLCodec.EXPANDED_URI_SAFE); }
/** * @param element to examine and lowercase if non-null. * @return Null if passed null or an empty string otherwise * <code>element</code> lowercased. */ private String checkUriElementAndLowerCase(String element) { String tmp = checkUriElement(element); return (tmp != null)? tmp.toLowerCase(): tmp; } }
/** * @param baseURL an base URL for relative URLs */ public void setBaseUrl(String baseURL) { try { baseUrl = UsableURIFactory.getInstance(baseURL); } catch (URIException ex) { // XXX ex.printStackTrace(); } }
/** * @param base UURI to use as a base resolving <code>relative</code>. * @param relative Relative URI. * @return Instance of UURI. * @throws URIException */ protected UsableURI create(UsableURI base, String relative) throws URIException { UsableURI relativeUURI = makeOne(fixup(relative, base, base.getProtocolCharset()), true, base.getProtocolCharset()); UsableURI uuri = makeOne(base, relativeUURI); if (logger.isLoggable(Level.FINE)) { logger.fine(" URI " + relative + " PRODUCT " + uuri.toString() + " CHARSET " + base.getProtocolCharset() + " BASE " + base); } return validityCheck(uuri); }