Methods Summary |
---|
static java.util.Map | connectStringToParams(java.lang.String connectString)
/*
A connect string consists of a series of name/value pairs eg:
host=myhost,port=9993,user=foo
*/
final Map m = new java.util.HashMap();
final ArgParserImpl.ParseChars parseChars = new ArgParserImpl.ParseChars();
parseChars.mArgDelim = PAIR_DELIM;
final ArgParserImpl parser = new ArgParserImpl();
final String [] pairs = parser.ParseNames( connectString );
for( int i = 0; i < pairs.length; ++i )
{
final String pair = pairs[ i ];
final int delimIndex = pair.indexOf( VALUE_DELIM );
if ( delimIndex <= 0 )
{
throw new IllegalArgumentException( "Illegal connect string: " + connectString );
}
final String name = pair.substring( 0, delimIndex );
final String value = pair.substring( delimIndex + 1, pair.length() );
m.put( name, value );
}
return( m );
|
public boolean | equals(java.lang.Object o)
if ( o == this )
{
return( true );
}
if ( ! (o instanceof ConnectInfo ) )
{
return( false );
}
final ConnectInfo rhs = (ConnectInfo)o;
return( mParams.equals( rhs.mParams ) );
|
static java.lang.String | escapeString(char charToEscape, java.lang.String stringToEscape)
String result = stringToEscape;
if ( result.indexOf( charToEscape ) >= 0 )
{
result = result.replaceAll( "" + charToEscape,
ESCAPE_CHAR + "" + charToEscape );
}
return( result );
|
static java.lang.String | escapeString(java.lang.String value)
String escapedValue = escapeString( PAIR_DELIM, value );
escapedValue = escapeString( VALUE_DELIM, escapedValue );
return( escapedValue );
|
java.lang.String | getParam(java.lang.String name)
return( (String)mParams.get( name ) );
|
java.lang.String | paramsToString()
final java.util.Iterator iter = mParams.keySet().iterator();
StringBuffer buf = new StringBuffer();
while ( iter.hasNext() )
{
final String key = (String)iter.next();
final String value =(String)mParams.get( key );
final String pair = key + VALUE_DELIM + escapeString( value );
buf.append( PAIR_DELIM + pair );
}
String result = buf.toString();
if ( result.length() != 0 )
{
// strip leading ":"
result = result.substring( 1, result.length() );
}
return( result );
|
public java.lang.String | toString()
return( paramsToString() );
|