@ -88,7 +88,7 @@ public class MultiProtocolURI implements Serializable, Comparable<MultiProtocolU
// class variables
protected final String protocol , userInfo ;
protected String host , path , quest, ref ;
protected String host , path , searchpart, anchor ;
protected int port ;
protected InetAddress hostAddress ;
protected ContentDomain contentDomain ;
@ -102,8 +102,8 @@ public class MultiProtocolURI implements Serializable, Comparable<MultiProtocolU
this . hostAddress = null ;
this . userInfo = null ;
this . path = null ;
this . ques t = null ;
this . ref = null ;
this . searchpar t = null ;
this . ancho r = null ;
this . contentDomain = null ;
this . port = - 1 ;
}
@ -118,8 +118,8 @@ public class MultiProtocolURI implements Serializable, Comparable<MultiProtocolU
this . hostAddress = null ;
this . userInfo = url . userInfo ;
this . path = url . path ;
this . quest = url . ques t;
this . ref = url . ref ;
this . searchpart = url . searchpar t;
this . ancho r = url . ancho r;
this . contentDomain = null ;
this . port = url . port ;
}
@ -187,8 +187,8 @@ public class MultiProtocolURI implements Serializable, Comparable<MultiProtocolU
if ( this . host . indexOf ( '&' ) > = 0 ) throw new MalformedURLException ( "invalid '&' in host" ) ;
this . path = resolveBackpath ( this . path ) ;
identPort ( url , ( isHTTP ( ) ? 80 : ( isHTTPS ( ) ? 443 : ( isFTP ( ) ? 21 : ( isSMB ( ) ? 445 : - 1 ) ) ) ) ) ;
ident Ref ( ) ;
ident Ques t( ) ;
ident Anchor ( ) ;
ident Searchpar t( ) ;
escape ( ) ;
} else {
// this is not a http or ftp url
@ -202,8 +202,8 @@ public class MultiProtocolURI implements Serializable, Comparable<MultiProtocolU
this . host = url . substring ( q + 1 ) ;
this . path = null ;
this . port = - 1 ;
this . ques t = null ;
this . ref = null ;
this . searchpar t = null ;
this . ancho r = null ;
} else if ( this . protocol . equals ( "file" ) ) {
// parse file url
final String h = url . substring ( p + 1 ) ;
@ -229,8 +229,8 @@ public class MultiProtocolURI implements Serializable, Comparable<MultiProtocolU
}
this . userInfo = null ;
this . port = - 1 ;
this . ques t = null ;
this . ref = null ;
this . searchpar t = null ;
this . ancho r = null ;
} else {
throw new MalformedURLException ( "unknown protocol: " + url ) ;
}
@ -352,12 +352,12 @@ public class MultiProtocolURI implements Serializable, Comparable<MultiProtocolU
}
}
}
this . quest = baseURL . ques t;
this . ref = baseURL . ref ;
this . searchpart = baseURL . searchpar t;
this . ancho r = baseURL . ancho r;
this . path = resolveBackpath ( this . path ) ;
ident Ref ( ) ;
ident Ques t( ) ;
ident Anchor ( ) ;
ident Searchpar t( ) ;
escape ( ) ;
}
@ -368,11 +368,11 @@ public class MultiProtocolURI implements Serializable, Comparable<MultiProtocolU
this . host = host ;
this . port = port ;
this . path = path ;
this . ques t = null ;
this . searchpar t = null ;
this . userInfo = null ;
this . ref = null ;
ident Ref ( ) ;
ident Ques t( ) ;
this . ancho r = null ;
ident Anchor ( ) ;
ident Searchpar t( ) ;
escape ( ) ;
}
@ -401,8 +401,8 @@ public class MultiProtocolURI implements Serializable, Comparable<MultiProtocolU
* /
private void escape ( ) {
if ( this . path ! = null & & this . path . indexOf ( '%' ) = = - 1 ) escapePath ( ) ;
if ( this . quest ! = null & & this . ques t. indexOf ( '%' ) = = - 1 ) escape Ques t( ) ;
if ( this . ref ! = null & & this . ref . indexOf ( '%' ) = = - 1 ) escape Ref ( ) ;
if ( this . searchpart ! = null & & this . searchpar t. indexOf ( '%' ) = = - 1 ) escape Searchpar t( ) ;
if ( this . ancho r ! = null & & this . ancho r. indexOf ( '%' ) = = - 1 ) escape Anchor ( ) ;
}
private void escapePath ( ) {
@ -415,13 +415,13 @@ public class MultiProtocolURI implements Serializable, Comparable<MultiProtocolU
this . path = ptmp . substring ( ( ptmp . length ( ) > 0 ) ? 1 : 0 ) ;
}
private void escape Ref ( ) {
this . ref = escape ( this . ref ) . toString ( ) ;
private void escape Anchor ( ) {
this . ancho r = escape ( this . ancho r) . toString ( ) ;
}
private void escape Ques t( ) {
final String [ ] questp = patternAmp . split ( this . ques t, - 1 ) ;
final StringBuilder qtmp = new StringBuilder ( this . ques t. length ( ) + 10 ) ;
private void escape Searchpar t( ) {
final String [ ] questp = patternAmp . split ( this . searchpar t, - 1 ) ;
final StringBuilder qtmp = new StringBuilder ( this . searchpar t. length ( ) + 10 ) ;
for ( final String element : questp ) {
if ( element . indexOf ( '=' ) ! = - 1 ) {
qtmp . append ( '&' ) ;
@ -433,7 +433,7 @@ public class MultiProtocolURI implements Serializable, Comparable<MultiProtocolU
qtmp . append ( escape ( element ) ) ;
}
}
this . ques t = qtmp . substring ( ( qtmp . length ( ) > 0 ) ? 1 : 0 ) ;
this . searchpar t = qtmp . substring ( ( qtmp . length ( ) > 0 ) ? 1 : 0 ) ;
}
private final static String [ ] hex = {
@ -610,24 +610,24 @@ public class MultiProtocolURI implements Serializable, Comparable<MultiProtocolU
}
}
private void ident Ref ( ) {
private void ident Anchor ( ) {
// identify ref in file
final int r = this . path . indexOf ( '#' ) ;
if ( r < 0 ) {
this . ref = null ;
this . ancho r = null ;
} else {
this . ref = this . path . substring ( r + 1 ) ;
this . ancho r = this . path . substring ( r + 1 ) ;
this . path = this . path . substring ( 0 , r ) ;
}
}
private void ident Ques t( ) {
private void ident Searchpar t( ) {
// identify quest in file
final int r = this . path . indexOf ( '?' ) ;
if ( r < 0 ) {
this . ques t = null ;
this . searchpar t = null ;
} else {
this . ques t = this . path . substring ( r + 1 ) ;
this . searchpar t = this . path . substring ( r + 1 ) ;
this . path = this . path . substring ( 0 , r ) ;
}
}
@ -640,25 +640,25 @@ public class MultiProtocolURI implements Serializable, Comparable<MultiProtocolU
// this is the path plus quest plus ref
// if there is no quest and no ref the result is identical to getPath
// this is defined according to http://java.sun.com/j2se/1.4.2/docs/api/java/net/URL.html#getFile()
if ( this . ques t = = null ) {
if ( excludeReference | | this . ref = = null ) return this . path ;
if ( this . searchpar t = = null ) {
if ( excludeReference | | this . ancho r = = null ) return this . path ;
final StringBuilder sb = new StringBuilder ( 120 ) ;
sb . append ( this . path ) ;
sb . append ( '#' ) ;
sb . append ( this . ref ) ;
sb . append ( this . ancho r) ;
return sb . toString ( ) ;
}
String q = this . ques t;
String q = this . searchpar t;
if ( removeSessionID ) {
for ( final String sid : sessionIDnames . keySet ( ) ) {
if ( q . toLowerCase ( ) . startsWith ( sid . toLowerCase ( ) + "=" ) ) {
final int p = q . indexOf ( '&' ) ;
if ( p < 0 ) {
if ( excludeReference | | this . ref = = null ) return this . path ;
if ( excludeReference | | this . ancho r = = null ) return this . path ;
final StringBuilder sb = new StringBuilder ( 120 ) ;
sb . append ( this . path ) ;
sb . append ( '#' ) ;
sb . append ( this . ref ) ;
sb . append ( this . ancho r) ;
return sb . toString ( ) ;
}
q = q . substring ( p + 1 ) ;
@ -678,9 +678,9 @@ public class MultiProtocolURI implements Serializable, Comparable<MultiProtocolU
sb . append ( this . path ) ;
sb . append ( '?' ) ;
sb . append ( q ) ;
if ( excludeReference | | this . ref = = null ) return sb . toString ( ) ;
if ( excludeReference | | this . ancho r = = null ) return sb . toString ( ) ;
sb . append ( '#' ) ;
sb . append ( this . ref ) ;
sb . append ( this . ancho r) ;
return sb . toString ( ) ;
}
@ -758,11 +758,11 @@ public class MultiProtocolURI implements Serializable, Comparable<MultiProtocolU
}
public String getRef ( ) {
return this . ref ;
return this . ancho r;
}
public void removeRef ( ) {
this . ref = null ;
this . ancho r = null ;
}
/ * *
@ -773,8 +773,20 @@ public class MultiProtocolURI implements Serializable, Comparable<MultiProtocolU
return this . userInfo ;
}
public String getQuery ( ) {
return this . quest ;
public String getSearchpart ( ) {
return this . searchpart ;
}
public Map < String , String > getSearchpartMap ( ) {
if ( this . searchpart = = null ) return null ;
this . searchpart = this . searchpart . replaceAll ( "&" , "&" ) ;
String [ ] parts = this . searchpart . split ( "&" ) ;
Map < String , String > map = new LinkedHashMap < String , String > ( ) ;
for ( String part : parts ) {
int p = part . indexOf ( '=' ) ;
if ( p > 0 ) map . put ( part . substring ( 0 , p ) , part . substring ( p + 1 ) ) ; else map . put ( part , "" ) ;
}
return map ;
}
@Override
@ -926,7 +938,7 @@ public class MultiProtocolURI implements Serializable, Comparable<MultiProtocolU
( ( this . host = = null & & other . host = = null ) | | ( this . host ! = null & & other . host ! = null & & this . host . equals ( other . host ) ) ) & &
( ( this . userInfo = = null & & other . userInfo = = null ) | | ( this . userInfo ! = null & & other . userInfo ! = null & & this . userInfo . equals ( other . userInfo ) ) ) & &
( ( this . path = = null & & other . path = = null ) | | ( this . path ! = null & & other . path ! = null & & this . path . equals ( other . path ) ) ) & &
( ( this . quest = = null & & other . ques t = = null ) | | ( this . quest ! = null & & other . quest ! = null & & this . quest . equals ( other . ques t) ) ) & &
( ( this . searchpart = = null & & other . searchpar t = = null ) | | ( this . searchpart ! = null & & other . searchpart ! = null & & this . searchpart . equals ( other . searchpar t) ) ) & &
this . port = = other . port ;
}
@ -936,7 +948,7 @@ public class MultiProtocolURI implements Serializable, Comparable<MultiProtocolU
}
public boolean isPOST ( ) {
return ( this . ques t ! = null ) & & ( this . ques t. length ( ) > 0 ) ;
return ( this . searchpar t ! = null ) & & ( this . searchpar t. length ( ) > 0 ) ;
}
public final boolean isCGI ( ) {