--- experimental/server/ACL/ACL.java 2001/12/23 00:29:33 1.4 +++ experimental/server/ACL/ACL.java 2001/12/24 04:17:29 1.6 @@ -16,7 +16,7 @@ import java.io.Serializable; * the relevant check method. * * @author $Author: tdb $ - * @version $Id: ACL.java,v 1.4 2001/12/23 00:29:33 tdb Exp $ + * @version $Id: ACL.java,v 1.6 2001/12/24 04:17:29 tdb Exp $ */ public class ACL implements Serializable { @@ -25,7 +25,7 @@ public class ACL implements Serializable { /** * The current CVS revision of this class */ - public static final String REVISION = "$Revision: 1.4 $"; + public static final String REVISION = "$Revision: 1.6 $"; /** * static to be used when adding an ALLOW rule to the ACL. @@ -121,45 +121,26 @@ public class ACL implements Serializable { } /** - * Gets the ACL as a String for debugging. + * Gives a String representation of this ACL. * * @return A String representation of this ACL. */ - public String getStringACL() { - String acl = ""; + public String toString() { + StringBuffer acl = new StringBuffer(); + acl.append("{"); for(int i=0; i < _acl.size(); i++) { - ACLRule rule = (ACLRule) _acl.get(i); - if(rule._allow) { - acl += "ALLOW:" + rule._expression + " "; - } - else { - acl += "DENY:" + rule._expression + " "; - } + acl.append((ACLRule) _acl.get(i)); + acl.append(","); } if(_defaultMode) { - acl += "DEFAULT:ALLOW"; + acl.append("DEFAULT=ALLOW"); } else { - acl += "DEFAULT:DENY"; + acl.append("DEFAULT=DENY"); } - return acl; + acl.append("}"); + return acl.toString(); } - - /** - * Overrides the {@link java.lang.Object#toString() Object.toString()} - * method to provide clean logging (every class should have this). - * - * This uses the uk.org.iscream.cms.server.util.FormatName class - * to format the toString() - * - * @return the name of this class and its CVS revision - */ - public String toString() { - return FormatName.getName( - _name, - getClass().getName(), - REVISION); - } //---PRIVATE METHODS--- @@ -206,6 +187,20 @@ public class ACL implements Serializable { private ACLRule(boolean allow, String expression) { _allow = allow; _expression = expression; + } + + /** + * Returns a String representation of this rule. + * + * @return A String representation of this rule. + */ + public String toString() { + if(_allow) { + return _expression + "=ALLOW"; + } + else { + return _expression + "=DENY"; + } } /**