FileDocCategorySizeDatePackage
DynEnumImpl.javaAPI DocJava SE 5 API5111Fri Aug 26 14:54:20 BST 2005com.sun.corba.se.impl.dynamicany

DynEnumImpl

public class DynEnumImpl extends DynAnyBasicImpl implements DynEnum

Fields Summary
int
currentEnumeratorIndex
Constructors Summary
private DynEnumImpl()


    //
    // Constructors
    //

      
        this(null, (Any)null, false);
    
protected DynEnumImpl(com.sun.corba.se.spi.orb.ORB orb, org.omg.CORBA.Any anAny, boolean copyValue)

        super(orb, anAny, copyValue);
        index = NO_INDEX;
        // The any doesn't have to be initialized. We have a default value in this case.
        try {
            currentEnumeratorIndex = any.extract_long();
        } catch (BAD_OPERATION e) { 
            // _REVISIT_: Fix Me
            currentEnumeratorIndex = 0;
            any.type(any.type());
            any.insert_long(0);
        }
    
protected DynEnumImpl(com.sun.corba.se.spi.orb.ORB orb, org.omg.CORBA.TypeCode typeCode)

        super(orb, typeCode);
        index = NO_INDEX;
        currentEnumeratorIndex = 0;
        any.insert_long(0);
    
Methods Summary
public intcomponent_count()

	return 0;
    
private intcomputeCurrentEnumeratorIndex(java.lang.String value)

        int memberCount = memberCount();
        for (int i=0; i<memberCount; i++) {
            if (memberName(i).equals(value)) {
                return i;
            }
        }
        return NO_INDEX;
    
public org.omg.DynamicAny.DynAnycurrent_component()

        if (status == STATUS_DESTROYED) {
	    throw wrapper.dynAnyDestroyed() ;
        }
        throw new TypeMismatch();
    
public java.lang.Stringget_as_string()

        if (status == STATUS_DESTROYED) {
	    throw wrapper.dynAnyDestroyed() ;
        }
	return memberName(currentEnumeratorIndex);
    
public intget_as_ulong()

        if (status == STATUS_DESTROYED) {
	    throw wrapper.dynAnyDestroyed() ;
        }
	return currentEnumeratorIndex;
    
private intmemberCount()

        int memberCount = 0;
        try {
            memberCount = any.type().member_count();
        } catch (BadKind bad) {
        }
        return memberCount;
    
private java.lang.StringmemberName(int i)

        String memberName = null;
        try {
            memberName = any.type().member_name(i);
        } catch (BadKind bad) {
        } catch (Bounds bounds) {
        }
        return memberName;
    
public voidset_as_string(java.lang.String value)

        if (status == STATUS_DESTROYED) {
	    throw wrapper.dynAnyDestroyed() ;
        }
	int newIndex = computeCurrentEnumeratorIndex(value);
        if (newIndex == NO_INDEX) {
            throw new InvalidValue();
        }
	currentEnumeratorIndex = newIndex;
        any.insert_long(newIndex);
    
public voidset_as_ulong(int value)

        if (status == STATUS_DESTROYED) {
	    throw wrapper.dynAnyDestroyed() ;
        }
        if (value < 0 || value >= memberCount()) {
            throw new InvalidValue();
        }
	currentEnumeratorIndex = value;
        any.insert_long(value);