<s> package org . eclipse . jdt . internal . core ; import org . eclipse . jdt . core . * ; import org . eclipse . jdt . internal . core . util . MementoTokenizer ; public class ImportContainer extends SourceRefElement implements IImportContainer { protected ImportContainer ( CompilationUnit parent ) { super ( parent ) ; } public boolean equals ( Object o ) { if ( ! ( o instanceof ImportContainer ) ) return false ; return super . equals ( o ) ; } public int getElementType ( ) { return IMPORT_CONTAINER ; } public IJavaElement getHandleFromMemento ( String token , MementoTokenizer memento , WorkingCopyOwner workingCopyOwner ) { switch ( token . charAt ( 0 ) ) { case JEM_COUNT : return getHandleUpdatingCountFromMemento ( memento , workingCopyOwner ) ; case JEM_IMPORTDECLARATION : if ( memento . hasMoreTokens ( ) ) { String importName = memento . nextToken ( ) ; JavaElement importDecl = ( JavaElement ) getImport ( importName ) ; return importDecl . getHandleFromMemento ( memento , workingCopyOwner ) ; } else { return this ; } } return null ; } protected char getHandleMementoDelimiter ( ) { return JavaElement . JEM_IMPORTDECLARATION ; } public IImportDeclaration getImport ( String importName ) { int index = importName . indexOf ( ".*" ) ; boolean isOnDemand = index != - 1 ; if ( isOnDemand ) importName = new String ( importName . substring ( 0 , index ) ) ; return getImport ( importName , isOnDemand ) ; } protected IImportDeclaration getImport ( String importName , boolean isOnDemand ) { return new ImportDeclaration ( this , importName , isOnDemand ) ; } public IJavaElement getPrimaryElement ( boolean checkOwner ) { CompilationUnit cu = ( CompilationUnit ) this . parent ; if ( checkOwner && cu . isPrimary ( ) ) return this ; return cu . getImportContainer ( ) ; } public ISourceRange getSourceRange ( ) throws JavaModelException { IJavaElement [ ] imports = getChildren ( ) ; ISourceRange firstRange = ( ( ISourceReference ) imports [ 0 ] ) . getSourceRange ( ) ; ISourceRange lastRange = ( ( ISourceReference ) imports [ imports . length - 1 ] ) . getSourceRange ( ) ; SourceRange range = new SourceRange ( firstRange . getOffset ( ) , lastRange . getOffset ( ) + lastRange . getLength ( ) - firstRange . getOffset ( ) ) ; return range ; } public String readableName ( ) { return null ; } protected void toString ( int tab , StringBuffer buffer ) { Object info = JavaModelManager . getJavaModelManager ( ) . peekAtInfo ( this ) ; if ( info == null || ! ( info instanceof JavaElementInfo ) ) return ; IJavaElement [ ] children = ( ( JavaElementInfo ) info ) . getChildren ( ) ; for ( int i = 0 ; i < children . length ; i ++ ) { if ( i > 0 ) buffer . append ( "n" ) ; ( ( JavaElement ) children [ i ] ) . toString ( tab , buffer ) ; } } protected void toStringInfo ( int tab , StringBuffer buffer , Object info , boolean showResolvedInfo ) { buffer . append ( tabString ( tab ) ) ; buffer . append ( "" ) ; if ( info == null ) { buffer . append ( " (not open)" ) ; } } public ISourceRange getNameRange ( ) { return null ; } } </s>