FileDocCategorySizeDatePackage
InnerClassesAttribute_info.javaAPI DocAndroid 1.5 API5017Wed May 06 22:41:16 BST 2009com.vladium.jcd.cls.attribute

InnerClassesAttribute_info

public final class InnerClassesAttribute_info extends Attribute_info
author
Vlad Roubtsov, (C) 2003

Fields Summary
private List
m_classes
Constructors Summary
InnerClassesAttribute_info(int attribute_name_index, long attribute_length, com.vladium.jcd.lib.UDataInputStream bytes)

        super (attribute_name_index, attribute_length);
        
        final int class_count = bytes.readU2 ();
        final List/* InnerClass_info */ classes = new ArrayList (class_count);
        
        for (int i = 0; i < class_count; ++ i)
        {
            classes.add (new InnerClass_info (bytes));
        }
        
        m_classes = classes;
    
Methods Summary
public voidaccept(IAttributeVisitor visitor, java.lang.Object ctx)

        visitor.visit (this, ctx);
    
public java.lang.Objectclone()
Performs a deep copy.

        final InnerClassesAttribute_info _clone = (InnerClassesAttribute_info) super.clone ();
        
        final List/* InnerClass_info */ classes = m_classes;
        
        // do deep copy:
        final int class_count = classes.size (); // use size() if class becomes non-final
        _clone.m_classes = new ArrayList (class_count);
        for (int e = 0; e < class_count; ++ e)
        {
            _clone.m_classes.add (((InnerClass_info) classes.get (e)).clone ());
        }
        
        return _clone;
    
public final InnerClass_infoget(int offset)
Returns {@link InnerClass_info} descriptor at a given offset.

param
offset inner class entry offset [must be in [0, size()) range; input not checked]
return
InnerClass_info descriptor [never null]
throws
IndexOutOfBoundsException if 'offset' is outside of valid range

        return (InnerClass_info) m_classes.get (offset);
    
public final longlength()

        return 8 + (m_classes.size () << 3); // use size() if class becomes non-final
    
public booleanmakesClassNested(int class_index, int[] nestedAccessFlags)

        if (class_index > 0)
        {
            // TODO: avoid linear loop by keeping all class indices in a bitset
            
            for (int i = 0, iLimit = size (); i < iLimit; ++ i)
            {
                final InnerClass_info info = get (i);
                
                if (info.m_inner_class_index == class_index)
                {
                    nestedAccessFlags [0] = info.m_inner_access_flags;
                    return true;
                }
            }
        }
        
        return false;
    
public final intsize()
Returns the number of descriptors in this collection [can be 0].

        return m_classes.size ();
    
public java.lang.StringtoString()

        final StringBuffer s = new StringBuffer ("InnerClassesAttribute_info: [attribute_name_index = " + m_name_index + ", attribute_length = " + length () + "]\n");

        for (int l = 0; l < size (); ++ l)
        {
            s.append ("            " + get (l));
            s.append ("\n"); // TODO: proper EOL const
        }
        
        return s.toString ();
    
public voidwriteInClassFormat(com.vladium.jcd.lib.UDataOutputStream out)

        super.writeInClassFormat (out);
        
        final List/* InnerClass_info */ classes = m_classes;
        
        final int class_count = classes.size (); // use size() if class becomes non-final
        out.writeU2 (class_count);
        
        for (int l = 0; l < class_count; ++ l)
        {
            ((InnerClass_info) classes.get (l)).writeInClassFormat (out);
        }