コード例 #1
0
ファイル: GroupImpl.java プロジェクト: ronshapiro/j86
  //
  // This function is the recursive search of groups for this
  // implementation of the Group. The search proceeds building up
  // a vector of already seen groups. Only new groups are considered,
  // thereby avoiding loops.
  //
  boolean isMemberRecurse(Principal member, Vector<Group> alreadySeen) {
    Enumeration<? extends Principal> e = members();
    while (e.hasMoreElements()) {
      boolean mem = false;
      Principal p = (Principal) e.nextElement();

      // if the member is in this collection, return true
      if (p.equals(member)) {
        return true;
      } else if (p instanceof GroupImpl) {
        //
        // if not recurse if the group has not been checked already.
        // Can call method in this package only if the object is an
        // instance of this class. Otherwise call the method defined
        // in the interface. (This can lead to a loop if a mixture of
        // implementations form a loop, but we live with this improbable
        // case rather than clutter the interface by forcing the
        // implementation of this method.)
        //
        GroupImpl g = (GroupImpl) p;
        alreadySeen.addElement(this);
        if (!alreadySeen.contains(g)) mem = g.isMemberRecurse(member, alreadySeen);
      } else if (p instanceof Group) {
        Group g = (Group) p;
        if (!alreadySeen.contains(g)) mem = g.isMember(member);
      }

      if (mem) return mem;
    }
    return false;
  }
コード例 #2
0
ファイル: GroupImpl.java プロジェクト: ronshapiro/j86
 /**
  * This function returns true if the group passed matches the group represented in this interface.
  *
  * @param another The group to compare this group to.
  */
 public boolean equals(Object obj) {
   if (this == obj) {
     return true;
   }
   if (obj instanceof Group == false) {
     return false;
   }
   Group another = (Group) obj;
   return group.equals(another.toString());
 }