FileDocCategorySizeDatePackage
ConnectInfo.javaAPI DocGlassfish v2 API5394Fri May 04 22:24:50 BST 2007com.sun.cli.jmx.cmd

ConnectInfo

public final class ConnectInfo extends Object

Fields Summary
public final Map
mParams
public static final char
ESCAPE_CHAR
public static final char
VALUE_DELIM
public static final char
PAIR_DELIM
Constructors Summary
public ConnectInfo(String connectString)

		this( connectStringToParams( connectString ) );
	
public ConnectInfo(Map params)

		mParams	= params;
	
public ConnectInfo(ConnectInfo rhs)

		mParams	= new HashMap();
		mParams.putAll( rhs.mParams );
	
Methods Summary
static java.util.MapconnectStringToParams(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 booleanequals(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.StringescapeString(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.StringescapeString(java.lang.String value)

		String	escapedValue	= escapeString( PAIR_DELIM, value );
		escapedValue	= escapeString( VALUE_DELIM, escapedValue );
		
		return( escapedValue );
	
java.lang.StringgetParam(java.lang.String name)

		return( (String)mParams.get( name ) );
	
java.lang.StringparamsToString()

		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.StringtoString()

		return( paramsToString() );