/** * Test this entry for equality to another. * <p/> * <p/> * Consistent with {@link #compareTo}, this method tests * for equality purely on the package name. * </p> * * @param thatObj The object to compare * @return <code>true</code> if the two objects are * semantically equivalent, otherwise <code>false</code>. */ public boolean equals( Object thatObj ) { Entry that = (Entry) thatObj; return getPackageName().equals( that.getPackageName() ); }
/** Import packages from another <code>ClassRealm</code>. * * <p> * Specific packages can be imported from another realm * instead of attempting to load them locally from this * one. When importing a package a realm defers <b>completely</b> * to the foreign realm to satisfy the package dependencies. * </p> * * @param realmId The realm id from which to import. * @param pkgName The package name to import. * * @throws NoSuchRealmException If the id of the realm from which * to import does not correspond to a foreign realm within * this realm's world. */ public void importFrom( String realmId, String pkgName ) throws NoSuchRealmException { this.imports.add( new Entry( getWorld().getRealmImpl( realmId ), pkgName ) ); }
/** Locate the <code>ClassRealm</code> that should * satisfy loading of a class. * * @param classname The name of the class to load. * * @return The appropriate realm. */ DefaultClassRealm locateSourceRealm( String classname ) { Iterator entryIter = this.imports.iterator(); while ( entryIter.hasNext() ) { Entry eachEntry = (Entry) entryIter.next(); if ( eachEntry.matches( classname ) ) { return eachEntry.getRealm(); } } return this; }
/** Determine if the classname matches the package * described by this entry. * * @param classname The class name to test. * * @return <code>true</code> if this entry matches the * classname, otherwise <code>false</code>. */ boolean matches(String classname) { return classname.startsWith( getPackageName() ); }
/** * Determine if the classname matches the package * described by this entry. * * @param classname The class name to test. * @return <code>true</code> if this entry matches the * classname, otherwise <code>false</code>. */ boolean matches( String classname ) { return classname.startsWith( getPackageName() ); }
/** * <p/> * Consistent with {@link #equals}, this method creates a hashCode * based on the packagename. * </p> */ public int hashCode() { return getPackageName().hashCode(); } }
/** * <p> * Consistent with {@link #equals}, this method creates a hashCode * based on the packagename. * </p> */ public int hashCode() { return getPackageName().hashCode(); } }
/** * Compare this entry to another for relative ordering. * <p/> * <p/> * The natural ordering of Entry objects is reverse-alphabetical * based upon package name. * </p> * * @param thatObj The object to compare. * @return -1 if this object sorts before that object, 0 * if they are equal, or 1 if this object sorts * after that object. */ public int compareTo( Object thatObj ) { Entry that = (Entry) thatObj; // We are reverse sorting this list, so that // we get longer matches first: // // com.werken.foo.bar // com.werken.foo // com.werken return ( getPackageName().compareTo( that.getPackageName() ) ) * -1; }
/** Test this entry for equality to another. * * <p> * Consistent with {@link #compareTo}, this method tests * for equality purely on the package name. * </p> * * @param thatObj The object to compare * * @return <code>true</code> if the two objects are * semantically equivalent, otherwise <code>false</code>. */ public boolean equals(Object thatObj) { Entry that = (Entry) thatObj; return getPackageName().equals( that.getPackageName() ); }
/** Compare this entry to another for relative ordering. * * <p> * The natural ordering of Entry objects is reverse-alphabetical * based upon package name. * </p> * * @param thatObj The object to compare. * * @return -1 if this object sorts before that object, 0 * if they are equal, or 1 if this object sorts * after that object. */ public int compareTo(Object thatObj) { Entry that = (Entry) thatObj; // We are reverse sorting this list, so that // we get longer matches first: // // com.werken.foo.bar // com.werken.foo // com.werken return ( getPackageName().compareTo( that.getPackageName() ) ) * -1; }