FileDocCategorySizeDatePackage
ParseResult.javaAPI DocGlassfish v2 API5526Fri May 04 22:24:52 BST 2007com.sun.cli.jmx.support

ParseResult

public final class ParseResult extends Object

Fields Summary
static final int
LITERAL_STRING
static final int
OTHER
static final int
ARRAY
int
mType
String
mTypeCast
String
mName
Object
mData
Constructors Summary
ParseResult(int type, Object data)

	

	    
	
		mType		= type;
		mTypeCast	= null;
		mName		= null;
		mData		= data;
	
ParseResult(int type, Object data, String typecast)

		mType		= type;
		mTypeCast	= typecast;
		mName		= null;
		mData		= data;
	
ParseResult(int type, Object data, String typecast, String name)

		mType		= type;
		mTypeCast	= typecast;
		mName		= name;
		mData		= data;
	
Methods Summary
public static booleancheckEqualArrays(com.sun.cli.jmx.support.ParseResult[] lhs, com.sun.cli.jmx.support.ParseResult[] rhs)

		if ( lhs == rhs )
			return( true );
			
		boolean	equal	= lhs.length == rhs.length;
		
		if ( equal )
		{
			for( int i = 0; i < lhs.length; ++i )
			{
				equal	= lhs[ i ].mData.equals( rhs[ i ].mData );
				if ( ! equal )
					break;
			}
		}
		
		return( equal );
	
booleanequalString(java.lang.String s1, java.lang.String s2)

		if ( s1 == s2 )
			return( true );
		
		// they can't both be null now
		
		if ( s1 != null )
		{
			return( s1.equals( s2 ) );
		}
		
		// s2 != null
		return( s2.equals( s1 ) );
	
public booleanequals(java.lang.Object o)

		if ( o == this )
			return( true );
		if ( ! (o instanceof ParseResult) )
			return( false );
		
		
		final ParseResult	rhs	= (ParseResult)o;
		
		boolean	dataEqual	= false;
		
		if ( mData instanceof ParseResult [] )
		{
			dataEqual	= checkEqualArrays( (ParseResult [])mData, (ParseResult [])rhs.mData);
		}
		else
		{
			dataEqual	= mData.equals( rhs.mData );
		}
		
		final boolean equal	=
			mType == rhs.mType &&
			dataEqual &&
			equalString( mName, rhs.mName ) &&
			equalString( mTypeCast, rhs.mTypeCast );
		
			
		return( equal );
	
public java.lang.ObjectgetData()

		return( mData );
	
public java.lang.StringgetName()

		return( mName );
	
public intgetType()

		return( mType );
	
public java.lang.StringgetTypeCast()

		return( mTypeCast );
	
public voidsetData(java.lang.Object data)

		mData	= data;
	
public voidsetName(java.lang.String name)

		mName	= name;
	
public voidsetType(int type)

		mType	= type;
		if ( ! (mData instanceof String) )
		{
			throw new IllegalArgumentException(
				"can't set non-String to type LITERAL_STRING: " + mData.getClass().getName());
		}
	
public voidsetTypeCast(java.lang.String typeCast)

		mTypeCast	= typeCast;
	
public java.lang.StringtoString()

		return( this.toString( '," ) );
	
public java.lang.StringtoString(char delim)

		final int 		type	= getType();
		final Object	data	= getData();
		
		String	result	= "";
		
		if ( type == ParseResult.LITERAL_STRING )
		{
			result	= (String)data;
		}
		else if ( type == ParseResult.OTHER )
		{
			result	= (String)data;
		}
		else if ( type == ParseResult.ARRAY )
		{
			final ParseResult []	contents	= (ParseResult [])data;
			
			result	= "{" + ArrayStringifier.stringify( contents, "" + delim ) + "}";
		}
		else
		{
			assert( false );
		}
		
		final String typeCast	= getTypeCast();
		if ( typeCast != null )
		{
			result	= "(" + typeCast + ")" + result;
		}
		
		final String	name	= getName();
		if ( name != null )
		{
			result	= name + "=" + result;
		}
		
		return( result );