<s> package org . eclipse . jdt . internal . core ; import java . util . HashMap ; import org . eclipse . jdt . core . * ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . env . ISourceField ; import org . eclipse . jdt . internal . compiler . env . ISourceImport ; import org . eclipse . jdt . internal . compiler . env . ISourceMethod ; import org . eclipse . jdt . internal . compiler . env . ISourceType ; public class SourceTypeElementInfo extends AnnotatableInfo implements ISourceType { protected static final ISourceImport [ ] NO_IMPORTS = new ISourceImport [ 0 ] ; protected static final InitializerElementInfo [ ] NO_INITIALIZERS = new InitializerElementInfo [ 0 ] ; protected static final SourceField [ ] NO_FIELDS = new SourceField [ 0 ] ; protected static final SourceMethod [ ] NO_METHODS = new SourceMethod [ 0 ] ; protected static final SourceType [ ] NO_TYPES = new SourceType [ 0 ] ; protected IJavaElement [ ] children = JavaElement . NO_ELEMENTS ; protected char [ ] superclassName ; protected char [ ] [ ] superInterfaceNames ; protected IType handle = null ; protected ITypeParameter [ ] typeParameters = TypeParameter . NO_TYPE_PARAMETERS ; protected HashMap categories ; protected void addCategories ( IJavaElement element , char [ ] [ ] elementCategories ) { if ( elementCategories == null ) return ; if ( this . categories == null ) this . categories = new HashMap ( ) ; this . categories . put ( element , CharOperation . toStrings ( elementCategories ) ) ; } public HashMap getCategories ( ) { return this . categories ; } public IJavaElement [ ] getChildren ( ) { return this . children ; } public ISourceType getEnclosingType ( ) { IJavaElement parent = this . handle . getParent ( ) ; if ( parent != null && parent . getElementType ( ) == IJavaElement . TYPE ) { try { return ( ISourceType ) ( ( JavaElement ) parent ) . getElementInfo ( ) ; } catch ( JavaModelException e ) { return null ; } } else { return null ; } } public ISourceField [ ] getFields ( ) { SourceField [ ] fieldHandles = getFieldHandles ( ) ; int length = fieldHandles . length ; ISourceField [ ] fields = new ISourceField [ length ] ; for ( int i = 0 ; i < length ; i ++ ) { try { ISourceField field = ( ISourceField ) fieldHandles [ i ] . getElementInfo ( ) ; fields [ i ] = field ; } catch ( JavaModelException e ) { } } return fields ; } public SourceField [ ] getFieldHandles ( ) { int length = this . children . length ; if ( length == 0 ) return NO_FIELDS ; SourceField [ ] fields = new SourceField [ length ] ; int fieldIndex = 0 ; for ( int i = 0 ; i < length ; i ++ ) { IJavaElement child = this . children [ i ] ; if ( child instanceof SourceField ) fields [ fieldIndex ++ ] = ( SourceField ) child ; } if ( fieldIndex == 0 ) return NO_FIELDS ; if ( fieldIndex < length ) System . arraycopy ( fields , 0 , fields = new SourceField [ fieldIndex ] , 0 , fieldIndex ) ; return fields ; } public char [ ] getFileName ( ) { return this . handle . getPath ( ) . toString ( ) . toCharArray ( ) ; } public IType getHandle ( ) { return this . handle ; } public InitializerElementInfo [ ] getInitializers ( ) { int length = this . children . length ; if ( length == 0 ) return NO_INITIALIZERS ; InitializerElementInfo [ ] initializers = new InitializerElementInfo [ length ] ; int initializerIndex = 0 ; for ( int i = 0 ; i < length ; i ++ ) { IJavaElement child = this . children [ i ] ; if ( child instanceof Initializer ) { try { InitializerElementInfo initializer = ( InitializerElementInfo ) ( ( Initializer ) child ) . getElementInfo ( ) ; initializers [ initializerIndex ++ ] = initializer ; } catch ( JavaModelException e ) { } } } if ( initializerIndex == 0 ) return NO_INITIALIZERS ; System . arraycopy ( initializers , 0 , initializers = new InitializerElementInfo [ initializerIndex ] , 0 , initializerIndex ) ; return initializers ; } public char [ ] [ ] getInterfaceNames ( ) { if ( this . handle . getElementName ( ) . length ( ) == 0 ) { return null ; } return this . superInterfaceNames ; } public ISourceType [ ] getMemberTypes ( ) { SourceType [ ] memberTypeHandles = getMemberTypeHandles ( ) ; int length = memberTypeHandles . length ; ISourceType [ ] memberTypes = new ISourceType [ length ] ; for ( int i = 0 ; i < length ; i ++ ) { try { ISourceType type = ( ISourceType ) memberTypeHandles [ i ] . getElementInfo ( ) ; memberTypes [ i ] = type ; } catch ( JavaModelException e ) { } } return memberTypes ; } public SourceType [ ] getMemberTypeHandles ( ) { int length = this . children . length ; if ( length == 0 ) return NO_TYPES ; SourceType [ ] memberTypes = new SourceType [ length ] ; int typeIndex = 0 ; for ( int i = 0 ; i < length ; i ++ ) { IJavaElement child = this . children [ i ] ; if ( child instanceof SourceType ) memberTypes [ typeIndex ++ ] = ( SourceType ) child ; } if ( typeIndex == 0 ) return NO_TYPES ; if ( typeIndex < length ) System . arraycopy ( memberTypes , 0 , memberTypes = new SourceType [ typeIndex ] , 0 , typeIndex ) ; return memberTypes ; } public ISourceMethod [ ] getMethods ( ) { SourceMethod [ ] methodHandles = getMethodHandles ( ) ; int length = methodHandles . length ; ISourceMethod [ ] methods = new ISourceMethod [ length ] ; int methodIndex = 0 ; for ( int i = 0 ; i < length ; i ++ ) { try { ISourceMethod method = ( ISourceMethod ) methodHandles [ i ] . getElementInfo ( ) ; methods [ methodIndex ++ ] = method ; } catch ( JavaModelException e ) { } } return methods ; } public SourceMethod [ ] getMethodHandles ( ) { int length = this . children . length ; if ( length == 0 ) return NO_METHODS ; SourceMethod [ ] methods = new SourceMethod [ length ] ; int methodIndex = 0 ; for ( int i = 0 ; i < length ; i ++ ) { IJavaElement child = this . children [ i ] ; if ( child instanceof SourceMethod ) methods [ methodIndex ++ ] = ( SourceMethod ) child ; } if ( methodIndex == 0 ) return NO_METHODS ; if ( methodIndex < length ) System . arraycopy ( methods , 0 , methods = new SourceMethod [ methodIndex ] , 0 , methodIndex ) ; return methods ; } public char [ ] getName ( ) { return this . handle . getElementName ( ) . toCharArray ( ) ; } public char [ ] getSuperclassName ( ) { if ( this . handle . getElementName ( ) . length ( ) == 0 ) { char [ ] [ ] interfaceNames = this . superInterfaceNames ; if ( interfaceNames != null && interfaceNames . length > 0 ) { return interfaceNames [ 0 ] ; } } return this . superclassName ; } public char [ ] [ ] [ ] getTypeParameterBounds ( ) { int length = this . typeParameters . length ; char [ ] [ ] [ ] typeParameterBounds = new char [ length ] [ ] [ ] ; for ( int i = 0 ; i < length ; i ++ ) { try { TypeParameterElementInfo info = ( TypeParameterElementInfo ) ( ( JavaElement ) this . typeParameters [ i ] ) . getElementInfo ( ) ; typeParameterBounds [ i ] = info . bounds ; } catch ( JavaModelException e ) { } } return typeParameterBounds ; } public char [ ] [ ] getTypeParameterNames ( ) { int length = this . typeParameters . length ; if ( length == 0 ) return CharOperation . NO_CHAR_CHAR ; char [ ] [ ] typeParameterNames = new char [ length ] [ ] ; for ( int i = 0 ; i < length ; i ++ ) { typeParameterNames [ i ] = this . typeParameters [ i ] . getElementName ( ) . toCharArray ( ) ; } return typeParameterNames ; } public boolean isBinaryType ( ) { return false ; } public boolean isAnonymousMember ( ) { return false ; } protected void setHandle ( IType handle ) { this . handle = handle ; } protected void setSuperclassName ( char [ ] superclassName ) { this . superclassName = superclassName ; } protected void setSuperInterfaceNames ( char [ ] [ ] superInterfaceNames ) { this . superInterfaceNames = superInterfaceNames ; } public String toString ( ) { return "Info for " + this . handle . toString ( ) ; } } </s>