@ -146,7 +146,8 @@ public class MultiProtocolURI implements Serializable, Comparable<MultiProtocolU
}
}
// class variables
// class variables
protected String protocol , host , userInfo , path , quest , ref ;
protected final String protocol , userInfo ;
protected String host , path , quest , ref ;
protected int port ;
protected int port ;
/ * *
/ * *
@ -176,24 +177,9 @@ public class MultiProtocolURI implements Serializable, Comparable<MultiProtocolU
this . port = url . port ;
this . port = url . port ;
}
}
public MultiProtocolURI ( final String url ) throws MalformedURLException {
public MultiProtocolURI ( String url ) throws MalformedURLException {
if ( url = = null ) throw new MalformedURLException ( "url string is null" ) ;
if ( url = = null ) throw new MalformedURLException ( "url string is null" ) ;
parseURLString ( url ) ;
}
public static final boolean isHTTP ( String s ) { return s . startsWith ( "http://" ) ; }
public static final boolean isHTTPS ( String s ) { return s . startsWith ( "https://" ) ; }
public static final boolean isFTP ( String s ) { return s . startsWith ( "ftp://" ) ; }
public static final boolean isFile ( String s ) { return s . startsWith ( "file://" ) ; }
public static final boolean isSMB ( String s ) { return s . startsWith ( "smb://" ) | | s . startsWith ( "\\\\" ) ; }
public final boolean isHTTP ( ) { return this . protocol . equals ( "http" ) ; }
public final boolean isHTTPS ( ) { return this . protocol . equals ( "https" ) ; }
public final boolean isFTP ( ) { return this . protocol . equals ( "ftp" ) ; }
public final boolean isFile ( ) { return this . protocol . equals ( "file" ) ; }
public final boolean isSMB ( ) { return this . protocol . equals ( "smb" ) ; }
private void parseURLString ( String url ) throws MalformedURLException {
// identify protocol
// identify protocol
assert ( url ! = null ) ;
assert ( url ! = null ) ;
url = url . trim ( ) ;
url = url . trim ( ) ;
@ -263,7 +249,7 @@ public class MultiProtocolURI implements Serializable, Comparable<MultiProtocolU
port = - 1 ;
port = - 1 ;
quest = null ;
quest = null ;
ref = null ;
ref = null ;
} if ( protocol . equals ( "file" ) ) {
} else if ( protocol . equals ( "file" ) ) {
// parse file url
// parse file url
String h = url . substring ( p + 1 ) ;
String h = url . substring ( p + 1 ) ;
if ( h . startsWith ( "//" ) ) {
if ( h . startsWith ( "//" ) ) {
@ -315,6 +301,18 @@ public class MultiProtocolURI implements Serializable, Comparable<MultiProtocolU
} catch ( final PunycodeException e ) { }
} catch ( final PunycodeException e ) { }
}
}
public static final boolean isHTTP ( String s ) { return s . startsWith ( "http://" ) ; }
public static final boolean isHTTPS ( String s ) { return s . startsWith ( "https://" ) ; }
public static final boolean isFTP ( String s ) { return s . startsWith ( "ftp://" ) ; }
public static final boolean isFile ( String s ) { return s . startsWith ( "file://" ) ; }
public static final boolean isSMB ( String s ) { return s . startsWith ( "smb://" ) | | s . startsWith ( "\\\\" ) ; }
public final boolean isHTTP ( ) { return this . protocol . equals ( "http" ) ; }
public final boolean isHTTPS ( ) { return this . protocol . equals ( "https" ) ; }
public final boolean isFTP ( ) { return this . protocol . equals ( "ftp" ) ; }
public final boolean isFile ( ) { return this . protocol . equals ( "file" ) ; }
public final boolean isSMB ( ) { return this . protocol . equals ( "smb" ) ; }
public static MultiProtocolURI newURL ( final String baseURL , final String relPath ) throws MalformedURLException {
public static MultiProtocolURI newURL ( final String baseURL , final String relPath ) throws MalformedURLException {
if ( ( baseURL = = null ) | |
if ( ( baseURL = = null ) | |
isHTTP ( relPath ) | |
isHTTP ( relPath ) | |
@ -399,6 +397,9 @@ public class MultiProtocolURI implements Serializable, Comparable<MultiProtocolU
this . host = host ;
this . host = host ;
this . port = port ;
this . port = port ;
this . path = path ;
this . path = path ;
this . quest = "" ;
this . userInfo = "" ;
this . ref = "" ;
identRef ( ) ;
identRef ( ) ;
identQuest ( ) ;
identQuest ( ) ;
escape ( ) ;
escape ( ) ;