/** * Same as {@link #setBaseUrl(URL)} except that a * {@link MalformedURLException} may occur when creating the {@link URL} * instance from the given parameters. * * @param aScheme The {@link Scheme} (e.g. {@link Scheme#HTTP} or * {@link Scheme#HTTPS}) to be used for the base {@link URL}. * * @param aHost The host to which the base {@link URL} is to point to. * * @param aPort The port to be used when connecting to the host. * * @throws MalformedURLException in case the parameters cannot be * converted to a valid (accepted) {@link URL}. */ default void setBaseUrl( Scheme aScheme, String aHost, int aPort ) throws MalformedURLException { setBaseUrl( new URL( aScheme.getName(), aHost, aPort, "" ) ); }
/** * {@inheritDoc} */ @Override public String toProtocol() { if ( _scheme != null ) { return _scheme.toProtocol(); } return _protocol; }
/** * {@inheritDoc} */ @Override public void setProtocol( String aProtocol ) { Scheme theScheme = Scheme.fromProtocol( aProtocol ); if ( theScheme != null ) { _scheme = theScheme; _protocol = null; } else { _scheme = null; _protocol = aProtocol; } }
/** * Determines the parent JAR file's URL for your running application (not * including the "!" which is required to address a file within that JAR). * * @return The parrent's JAR file URL or null if the application does not * seem to reside in a JAR. */ public static URL toParentJarUrl() { URL theUrl = FileUtility.class.getProtectionDomain().getCodeSource().getLocation(); if ( !theUrl.getProtocol().equals( Scheme.JAR.getName() ) ) return null; try { String theJarPath = URLDecoder.decode( theUrl.getFile(), Encoding.UTF_8.getCode() ); theJarPath = Scheme.JAR.toUrl( theJarPath ); return new URL( theJarPath ); } catch ( UnsupportedEncodingException | MalformedURLException e ) { return null; } }
if ( !aJarUrl.getProtocol().equals( Scheme.JAR.getName() ) ) return null; List<String> theList = new ArrayList<String>(); try { String theJarPath = URLDecoder.decode( aJarUrl.getFile(), Encoding.UTF_8.getCode() ); String eJarFile; int i = Scheme.JAR.firstMarkerIndex( theJarPath ); while ( i != -1 ) { eJarFile = theJarPath.substring( 0, i ); i = Scheme.JAR.firstMarkerIndex( theJarPath );
if ( baseClass == null ) baseClass = RuntimeUtility.class; String basePath = baseClass.getProtectionDomain().getCodeSource().getLocation().getPath(); if ( basePath.startsWith( Scheme.FILE.toProtocol() ) ) { basePath = basePath.substring( Scheme.FILE.toProtocol().length() ); index = eProtocol.firstMarkerIndex( basePath.toLowerCase() ); if ( index != -1 ) break;
String theUrl = aUrl; Scheme theScheme = Scheme.fromScheme( theUrl ); if ( theScheme != null ) { setScheme( theScheme ); theUrl = theUrl.substring( theScheme.toProtocol().length() );
Scheme theScheme = Scheme.fromName( aUrl.getProtocol() ); if ( theScheme == null ) { theScheme = Scheme.fromProtocol( aUrl.getProtocol() );
theProbedFiles.add( theResource != null ? theResource.toExternalForm() : Scheme.JAR.getMarker() + aFilePath + "@" + aResourceClass.getName() );
/** * Opens the HTTPS sever connection (socket) at the given port allowing the * given number of maximum connections at the same time using the provided * HTTPS configuration parameters. * * @param aScheme The {@link Scheme} to use, e.g. {@link Scheme#HTTPS} * defaults to "TLS". * * @param aStoreDescriptor The store descriptor describing your * {@link KeyStore} required for HTTPS. * * @param aPort The port on which to listen for requests. * * @param aMaxConnections The number of maximum connections at the same * time. * * @throws OpenException thrown in case something went wrong such as the * port being already in use. */ default void open( Scheme aScheme, KeyStoreDescriptor aStoreDescriptor, int aPort, int aMaxConnections ) throws OpenException { open( aScheme.name(), aStoreDescriptor, aPort, aMaxConnections ); }
String theHttpProxy = aFromEnvProxy.getValue(); if ( theHttpProxy != null ) { if ( theHttpProxy.toLowerCase().startsWith( aProtocol.getMarker().toLowerCase() ) ) { int index = theHttpProxy.lastIndexOf( Delimiter.URL_PORT.getChar() ); if ( index != -1 ) {
/** * Builder method for * {@link BaseUrlMutator#setBaseUrl(Scheme, String, int)}. * * @param aScheme The {@link Scheme} (e.g. {@link Scheme#HTTP} or * {@link Scheme#HTTPS}) to be used for the base {@link URL}. * * @param aHost The host to which the base {@link URL} is to point to. * * @param aPort The port to be used when connecting to the host. * * @return The builder for applying multiple build operations. * * @throws MalformedURLException in case the parameters cannot be * converted to a valid (accepted) {@link URL}. */ default B withBaseUrl( Scheme aScheme, String aHost, int aPort ) throws MalformedURLException { return withBaseUrl( new URL( aScheme.getName(), aHost, aPort, "" ) ); }
/** * {@inheritDoc} */ @Override public String toProtocol() { if ( _scheme != null ) { return _scheme.toProtocol(); } return _protocol; }
/** * {@inheritDoc} */ @Override public void setProtocol( String aProtocol ) { Scheme theScheme = Scheme.fromProtocol( aProtocol ); if ( theScheme != null ) { _scheme = theScheme; _protocol = null; } else { _protocol = aProtocol; _scheme = null; } }
/** * Same as {@link #setBaseUrl(URL)} except that a * {@link MalformedURLException} may occur when creating the {@link URL} * instance from the given parameters. * * @param aScheme The {@link Scheme} (e.g. {@link Scheme#HTTP} or * {@link Scheme#HTTPS}) to be used for the base {@link URL}. * * @param aHost The host to which the base {@link URL} is to point to. * * @param aPort The port to be used when connecting to the host. * * @param aPath The path on the host to which the base {@link URL} is to * point to. * * @throws MalformedURLException in case the parameters cannot be * converted to a valid (accepted) {@link URL}. */ default void setBaseUrl( Scheme aScheme, String aHost, int aPort, String aPath ) throws MalformedURLException { setBaseUrl( new URL( aScheme.getName(), aHost, aPort, aPath ) ); } }
/** * {@inheritDoc} */ @Override public String toProtocol() { return _scheme != null ? _scheme.toProtocol() : _protocol; }
/** * {@inheritDoc} */ @Override public void setProtocol( String aProtocol ) { Scheme theScheme = Scheme.fromProtocol( aProtocol ); if ( theScheme != null ) { _scheme = theScheme; _protocol = null; } else { _protocol = aProtocol; _scheme = null; } }
/** * Builder method for * {@link BaseUrlMutator#setBaseUrl(Scheme, String, int, String)}. * * @param aScheme The {@link Scheme} (e.g. {@link Scheme#HTTP} or * {@link Scheme#HTTPS}) to be used for the base {@link URL}. * * @param aHost The host to which the base {@link URL} is to point to. * * @param aPort The port to be used when connecting to the host. * * @param aPath The path on the host to which the base {@link URL} is to * point to. * * @return The builder for applying multiple build operations. * * @throws MalformedURLException in case the parameters cannot be * converted to a valid (accepted) {@link URL}. */ default B withBaseUrl( Scheme aScheme, String aHost, int aPort, String aPath ) throws MalformedURLException { return withBaseUrl( new URL( aScheme.getName(), aHost, aPort, aPath ) ); } }
/** * Tests if the provided location represents an absolute URL or not. * * @param aLocation The location to be tested. * * @return True in case of an absolute URL, false in case of a relative * URL. */ private boolean isAbsoluteUrl( String aLocation ) { String theLocation = aLocation.toLowerCase(); if ( theLocation.startsWith( Scheme.HTTP.toProtocol().toLowerCase() ) ) return true; if ( theLocation.startsWith( Scheme.HTTPS.toProtocol().toLowerCase() ) ) return true; return false; } }
Scheme theScheme = Scheme.fromProtocol( aProtocol ); if ( theScheme == Scheme.HTTPS ) { aProtocol = TransportLayerProtocol.TLS.name();