FileDocCategorySizeDatePackage
ValueAccessorBase.javaAPI DocGlassfish v2 API5505Fri May 04 22:24:08 BST 2007com.sun.enterprise.admin.dottedname.valueaccessor

ValueAccessorBase

public abstract class ValueAccessorBase extends Object implements ValueAccessor

Fields Summary
final MBeanServerConnection
mConn
final char
ARRAY_ELEMENT_SEPARATOR
final char
ESCAPE_CHAR
Constructors Summary
public ValueAccessorBase(MBeanServerConnection conn)

		mConn	= conn;
	
Methods Summary
java.lang.ObjectcoerceToClass(java.lang.Class theClass, java.lang.String value)

		Object	result	= value;
		
		if ( theClass != String.class )
		{
			if ( ClassUtil.classIsArray( theClass ) )
			{
				final String	theClassName		= theClass.getName();
				final String	elementClassName	= ClassUtil.getArrayMemberClassName( theClassName );
				
				// convert the string to an array of strings
				result	= stringToArray( value, ClassUtil.getClassFromName( elementClassName ) );
			}
			else
			{
				boolean 	canCoerce	= true;
				
				final Class resultClass	= ClassUtil.PrimitiveClassToObjectClass( theClass );
				
				if ( resultClass == Boolean.class  )
				{
					// insist on "true" or "false" (case insensitive)
					canCoerce	= value.equalsIgnoreCase( "true" ) || value.equalsIgnoreCase( "false" );
				}
				
				if ( canCoerce )
				{
					result	= ClassUtil.InstantiateFromString( resultClass, value );
				}
			}
		}
		return( result );
	
java.lang.Object[]convert(java.lang.String[] stringValues, java.lang.Class elementClass)

		if ( elementClass == String.class )
		{
			return( stringValues );
		}
		
		if ( ClassUtil.classnameIsPrimitiveArray( elementClass.getName() ) )
		{
			throw new IllegalArgumentException(  );
		}
		
		final Object []	values	= (Object [])Array.newInstance( elementClass, stringValues.length );
		
		for( int i = 0; i < values.length; ++i )
		{
			values[ i ]	= ClassUtil.InstantiateFromString( elementClass, stringValues[ i ] );
		}
		
		return( values );
	
javax.management.MBeanServerConnectiongetMBS()

		return( mConn );
	
public abstract javax.management.AttributegetValue(javax.management.ObjectName objectName, java.lang.String valueName)

public abstract javax.management.AttributesetValue(javax.management.ObjectName objectName, javax.management.Attribute attr)

java.lang.Object[]stringToArray(java.lang.String s, java.lang.Class elementClass)

		final String []	stringValues	= stringToStringArray( s );
		
		final Object []	values	= convert( stringValues, elementClass );
		
		return( values );
	
java.lang.String[]stringToStringArray(java.lang.String s)

	
		 
	    
		 
	
		final String	delimiters		= "" + ARRAY_ELEMENT_SEPARATOR;
		final String	escapableChars	= "" + ARRAY_ELEMENT_SEPARATOR + ESCAPE_CHAR;
		
		final Tokenizer	tok	= new TokenizerImpl( s, delimiters, false, ESCAPE_CHAR, escapableChars );
		
		final String []	values	= tok.getTokens();
		
		return( values );