<s> package org . eclipse . jdt . internal . compiler . lookup ; import org . eclipse . jdt . core . compiler . CharOperation ; import org . eclipse . jdt . internal . compiler . util . HashtableOfPackage ; import org . eclipse . jdt . internal . compiler . util . HashtableOfType ; public class PackageBinding extends Binding implements TypeConstants { public long tagBits = 0 ; public char [ ] [ ] compoundName ; PackageBinding parent ; public LookupEnvironment environment ; HashtableOfType knownTypes ; HashtableOfPackage knownPackages ; protected PackageBinding ( ) { } public PackageBinding ( char [ ] topLevelPackageName , LookupEnvironment environment ) { this ( new char [ ] [ ] { topLevelPackageName } , null , environment ) ; } public PackageBinding ( char [ ] [ ] compoundName , PackageBinding parent , LookupEnvironment environment ) { this . compoundName = compoundName ; this . parent = parent ; this . environment = environment ; this . knownTypes = null ; this . knownPackages = new HashtableOfPackage ( 3 ) ; } public PackageBinding ( LookupEnvironment environment ) { this ( CharOperation . NO_CHAR_CHAR , null , environment ) ; } private void addNotFoundPackage ( char [ ] simpleName ) { this . knownPackages . put ( simpleName , LookupEnvironment . TheNotFoundPackage ) ; } private void addNotFoundType ( char [ ] simpleName ) { if ( this . knownTypes == null ) this . knownTypes = new HashtableOfType ( 25 ) ; this . knownTypes . put ( simpleName , LookupEnvironment . TheNotFoundType ) ; } void addPackage ( PackageBinding element ) { if ( ( element . tagBits & TagBits . HasMissingType ) == 0 ) clearMissingTagBit ( ) ; this . knownPackages . put ( element . compoundName [ element . compoundName . length - 1 ] , element ) ; } void addType ( ReferenceBinding element ) { if ( ( element . tagBits & TagBits . HasMissingType ) == 0 ) clearMissingTagBit ( ) ; if ( this . knownTypes == null ) this . knownTypes = new HashtableOfType ( 25 ) ; this . knownTypes . put ( element . compoundName [ element . compoundName . length - 1 ] , element ) ; } void clearMissingTagBit ( ) { PackageBinding current = this ; do { current . tagBits &= ~ TagBits . HasMissingType ; } while ( ( current = current . parent ) != null ) ; } public char [ ] computeUniqueKey ( boolean isLeaf ) { return CharOperation . concatWith ( this . compoundName , '/' ) ; } private PackageBinding findPackage ( char [ ] name ) { if ( ! this . environment . isPackage ( this . compoundName , name ) ) return null ; char [ ] [ ] subPkgCompoundName = CharOperation . arrayConcat ( this . compoundName , name ) ; PackageBinding subPackageBinding = new PackageBinding ( subPkgCompoundName , this , this . environment ) ; addPackage ( subPackageBinding ) ; return subPackageBinding ; } PackageBinding getPackage ( char [ ] name ) { PackageBinding binding = getPackage0 ( name ) ; if ( binding != null ) { if ( binding == LookupEnvironment . TheNotFoundPackage ) return null ; else return binding ; } if ( ( binding = findPackage ( name ) ) != null ) return binding ; addNotFoundPackage ( name ) ; return null ; } PackageBinding getPackage0 ( char [ ] name ) { return this . knownPackages . get ( name ) ; } ReferenceBinding getType ( char [ ] name ) { ReferenceBinding referenceBinding = getType0 ( name ) ; if ( referenceBinding == null ) { if ( ( referenceBinding = this . environment . askForType ( this , name ) ) == null ) { addNotFoundType ( name ) ; return null ; } } if ( referenceBinding == LookupEnvironment . TheNotFoundType ) return null ; referenceBinding = ( ReferenceBinding ) BinaryTypeBinding . resolveType ( referenceBinding , this . environment , false ) ; if ( referenceBinding . isNestedType ( ) ) return new ProblemReferenceBinding ( new char [ ] [ ] { name } , referenceBinding , ProblemReasons . InternalNameProvided ) ; return referenceBinding ; } ReferenceBinding getType0 ( char [ ] name ) { if ( this . knownTypes == null ) return null ; return this . knownTypes . get ( name ) ; } public Binding getTypeOrPackage ( char [ ] name ) { ReferenceBinding referenceBinding = getType0 ( name ) ; if ( referenceBinding != null && referenceBinding != LookupEnvironment . TheNotFoundType ) { referenceBinding = ( ReferenceBinding ) BinaryTypeBinding . resolveType ( referenceBinding , this . environment , false ) ; if ( referenceBinding . isNestedType ( ) ) { return new ProblemReferenceBinding ( new char [ ] [ ] { name } , referenceBinding , ProblemReasons . InternalNameProvided ) ; } if ( ( referenceBinding . tagBits & TagBits . HasMissingType ) == 0 ) { return referenceBinding ; } } PackageBinding packageBinding = getPackage0 ( name ) ; if ( packageBinding != null && packageBinding != LookupEnvironment . TheNotFoundPackage ) { return packageBinding ; } if ( referenceBinding == null ) { if ( ( referenceBinding = this . environment . askForType ( this , name ) ) != null ) { if ( referenceBinding . isNestedType ( ) ) { return new ProblemReferenceBinding ( new char [ ] [ ] { name } , referenceBinding , ProblemReasons . InternalNameProvided ) ; } return referenceBinding ; } addNotFoundType ( name ) ; } if ( packageBinding == null ) { if ( ( packageBinding = findPackage ( name ) ) != null ) { return packageBinding ; } if ( referenceBinding != null && referenceBinding != LookupEnvironment . TheNotFoundType ) { return referenceBinding ; } addNotFoundPackage ( name ) ; } return null ; } public final boolean isViewedAsDeprecated ( ) { if ( ( this . tagBits & TagBits . DeprecatedAnnotationResolved ) == 0 ) { this . tagBits |= TagBits . DeprecatedAnnotationResolved ; if ( this . compoundName != CharOperation . NO_CHAR_CHAR ) { ReferenceBinding packageInfo = this . getType ( TypeConstants . PACKAGE_INFO_NAME ) ; if ( packageInfo != null ) { packageInfo . initializeDeprecatedAnnotationTagBits ( ) ; this . tagBits |= packageInfo . tagBits & TagBits . AllStandardAnnotationsMask ; } } } return ( this . tagBits & TagBits . AnnotationDeprecated ) != 0 ; } public final int kind ( ) { return Binding . PACKAGE ; } public int problemId ( ) { if ( ( this . tagBits & TagBits . HasMissingType ) != 0 ) return ProblemReasons . NotFound ; return ProblemReasons . NoError ; } public char [ ] readableName ( ) { return CharOperation . concatWith ( this . compoundName , '.' ) ; } public String toString ( ) { String str ; if ( this . compoundName == CharOperation . NO_CHAR_CHAR ) { str = "" ; } else { str = "package " + ( ( this . compoundName != null ) ? CharOperation . toString ( this . compoundName ) : "UNNAMED" ) ; } if ( ( this . tagBits & TagBits . HasMissingType ) != 0 ) { str += "[MISSING]" ; } return str ; } } </s>