/** * @see org.apache.excalibur.source.URIAbsolutizer#absolutize(java.lang.String, java.lang.String) */ public String absolutize(String baseURI, String location) { return SourceUtil.absolutize(baseURI, location, true); }
/** * Get the scheme of an absolute URI. * * @param uri the absolute URI * @return the URI scheme */ public static String getScheme(String uri) { int pos = indexOfSchemeColon(uri); return (pos == -1) ? null : uri.substring(0, pos); }
if (getScheme(url2) != null) return url2; String[] url1Parts = parseUrl(url1); String[] url2Parts = parseUrl(url2); return absolutizeWithoutAuthority(url1Parts, url2Parts); return makeUrl(url1Parts[SCHEME], url1Parts[AUTHORITY], url1Parts[PATH], url1Parts[QUERY], url2Parts[FRAGMENT]); return makeUrl(url1Parts[SCHEME], url2Parts[AUTHORITY], url2Parts[PATH], url2Parts[QUERY], url2Parts[QUERY]); return makeUrl(url1Parts[SCHEME], url1Parts[AUTHORITY], url2Parts[PATH], url2Parts[QUERY], url2Parts[QUERY]); String path = stripLastSegment(url1Path); path = path + (path.endsWith("/") ? "" : "/") + url2Path; if (normalizePath) path = normalize(path); return makeUrl(url1Parts[SCHEME], url1Parts[AUTHORITY], path, url2Parts[QUERY], url2Parts[FRAGMENT]);
/** * Builds a FileSource given an URI, which doesn't necessarily have to start with "file:" * @param uri * @throws SourceException * @throws MalformedURLException */ public FileSource(String uri) throws SourceException, MalformedURLException { int pos = SourceUtil.indexOfSchemeColon(uri); if (pos == -1) { throw new MalformedURLException("Invalid URI : " + uri); } String scheme = uri.substring(0, pos); String fileName = uri.substring(pos + 1); fileName = SourceUtil.decodePath(fileName); this.init(scheme, new File(fileName)); }
/** * Move the source to a specified destination. * * @param source Source of the source. * @param destination Destination of the source. * * @throws SourceException If an exception occurs during * the move. */ static public void move(Source source, Source destination) throws SourceException { if (source instanceof MoveableSource && source.getClass().equals(destination.getClass())) { ((MoveableSource)source).moveTo(destination); } else if (source instanceof ModifiableSource) { copy(source, destination); ((ModifiableSource) source).delete(); } else { throw new SourceException("Source '"+source.getURI()+ "' is not writeable"); } }
if (m_url.getProtocol().startsWith("http") && userInfo != null) m_connection.setRequestProperty("Authorization", "Basic " + SourceUtil.encodeBASE64(userInfo)); while (values.hasNext() == true) value = SourceUtil.encode((String) values.next(), m_encoding); if (first == false) buffer.append('&');
/** * Build a query string and encode each parameter value. * The query string can e.g. be used for http connections. * @return A query string which contains for each parameter/value pair * a part, like "parameter=value" separated by "&". * If no parameter is defined <CODE>null</CODE> is returned. */ public String getEncodedQueryString() { StringBuffer result = new StringBuffer(); Iterator iter = this.names.keySet().iterator(); Iterator listIterator; String key; String value; boolean first = true; while( iter.hasNext() == true ) { key = (String)iter.next(); listIterator = ( (ArrayList)names.get( key ) ).iterator(); while( listIterator.hasNext() == true ) { if( first == false ) result.append( '&' ); value = (String)listIterator.next(); result.append( key ).append( '=' ).append( SourceUtil.encode( value ) ); first = false; } } return ( result.length() == 0 ? null : result.toString() ); }
/** * BASE 64 encoding. * See also RFC 1421 */ public static String encodeBASE64( String s ) { return encodeBASE64( s.getBytes() ); }
/** * @see org.apache.excalibur.source.MoveableSource#copyTo(org.apache.excalibur.source.Source) */ public void copyTo(Source destination) throws SourceException { try { SourceUtil.copy(this.getInputStream(), ((ModifiableSource) destination).getOutputStream()); } catch (IOException ioe) { throw new SourceException("Couldn't copy " + this.getURI() + " to " + destination.getURI(), ioe); } }
.append( current ) .append( '=' ) .append( SourceUtil.encode( (String)values.next() ) ); separator = '&';
String userInfo = getUserInfo(); if (m_url.getProtocol().startsWith("http") && userInfo != null){ m_connection.setRequestProperty("Authorization", "Basic " + SourceUtil.encodeBASE64(userInfo));
/** * Calls absolutize(url1, url2, false). */ public static String absolutize(String url1, String url2) { return absolutize(url1, url2, false, true); }
/** * Get the scheme-specific part of an absolute URI. Note that this includes everything * after the separating colon, including the fragment, if any (RFC 2396 separates it * from the scheme-specific part). * * @param uri the absolute URI * @return the scheme-specific part of the URI */ public static String getSpecificPart(String uri) { int pos = indexOfSchemeColon(uri); return (pos == -1) ? null : uri.substring(pos+1); }
.append( current ) .append( '=' ) .append( SourceUtil.encode( parameters.getParameter( current, null ) ) ); separator = '&';
/** * @see org.apache.excalibur.source.URIAbsolutizer#absolutize(java.lang.String, java.lang.String) */ public String absolutize(String baseURI, String location) { return SourceUtil.absolutize(baseURI, location, true); } }
public ResourceSource( final String systemId ) throws MalformedURLException { final int pos = SourceUtil.indexOfSchemeColon(systemId); if (pos == -1 || ! systemId.startsWith("://", pos)) { throw new MalformedURLException("Invalid format for ResourceSource : " + systemId); } setSystemId(systemId); m_location = getClassLoader().getResource(systemId.substring( pos + 3 )); setScheme(systemId.substring(0, pos)); }
SourceUtil.copy(src, dest); } finally { resolver.release(src);
.append( current ) .append( '=' ) .append( SourceUtil.encode( parameters.getParameter( current, null ) ) ); separator = '&';