Return-Path: Delivered-To: apmail-avalon-cvs-archive@www.apache.org Received: (qmail 7501 invoked from network); 24 Feb 2004 15:25:02 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 24 Feb 2004 15:25:02 -0000 Received: (qmail 34004 invoked by uid 500); 24 Feb 2004 15:24:56 -0000 Delivered-To: apmail-avalon-cvs-archive@avalon.apache.org Received: (qmail 33957 invoked by uid 500); 24 Feb 2004 15:24:56 -0000 Mailing-List: contact cvs-help@avalon.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Avalon CVS List" Reply-To: "Avalon Developers List" Delivered-To: mailing list cvs@avalon.apache.org Received: (qmail 33940 invoked from network); 24 Feb 2004 15:24:56 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 24 Feb 2004 15:24:56 -0000 Received: (qmail 7420 invoked by uid 1438); 24 Feb 2004 15:25:00 -0000 Date: 24 Feb 2004 15:25:00 -0000 Message-ID: <20040224152500.7419.qmail@minotaur.apache.org> From: mcconnell@apache.org To: avalon-cvs@apache.org Subject: cvs commit: avalon/meta/api/src/java/org/apache/avalon/meta/info PermissionDescriptor.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N mcconnell 2004/02/24 07:25:00 Added: meta/api/src/java/org/apache/avalon/meta/info PermissionDescriptor.java Log: Add immutable PermissionDescriptor. Revision Changes Path 1.1 avalon/meta/api/src/java/org/apache/avalon/meta/info/PermissionDescriptor.java Index: PermissionDescriptor.java =================================================================== /* * Copyright 2004 Apache Software Foundation * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or * implied. * * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.avalon.meta.info; import java.io.Serializable; import java.util.StringTokenizer; import java.util.ArrayList; /** * A descriptor that describes a value that must be placed * in components Context. It contains information about; *
    *
  • key: the key that component uses to look up entry
  • *
  • classname: the class/interface of the entry
  • *
  • isOptional: true if entry is optional rather than required
  • *
* * @author Avalon Development Team * @version $Revision: 1.1 $ $Date: 2004/02/24 15:25:00 $ */ public final class PermissionDescriptor implements Serializable { /** * The permission classname. */ private final String m_classname; /** * The permission name (saantics relative to the permission classname). */ private final String m_name; /** * Permission actions. */ private final String[] m_actions; /** * Construct a new PermissionDescriptor * @param class the permission class * @param name the permission name * @param actions the permission actions */ public PermissionDescriptor( final String classname, final String name, final String actions ) { if ( null == classname ) { throw new NullPointerException( "classname" ); } m_classname = classname; m_name = name; m_actions = expandActions( actions ); } /** * Return the classname of the permission. * * @return the classname */ public String getClassname() { return m_classname; } /** * Return the permission name. The value returned is relative to * the permission class. If no permission name is declared a null * value will be returned. * * @return the name */ public String getName() { return m_name; } /** * Return the set of actions associated with the permission. * * @return a string array representing the actions assigned to * this permission */ public String[] getActions() { return m_actions; } /** * Test is the supplied object is equal to this object. * @param other the object to compare with this instance * @return true if the object are equivalent */ public boolean equals( Object other ) { boolean isEqual = other instanceof PermissionDescriptor; if ( isEqual ) { PermissionDescriptor permission = (PermissionDescriptor) other; isEqual = isEqual && m_classname.equals( permission.m_classname ); if ( null == m_name ) { isEqual = isEqual && null == permission.m_name; } else { isEqual = isEqual && m_name.equals( permission.m_name ); } isEqual = isEqual && m_actions.length == permission.m_actions.length; if( isEqual ) { for( int i=0; i>>= 13; hash ^= m_classname.hashCode(); hash >>>= 13; hash ^= ( null != m_name ) ? m_name.hashCode() : 0; hash >>>= 13; for( int i=0; i>>= 13; } return hash; } private static String[] expandActions( String arg ) { if( null == arg ) return new String[0]; ArrayList list = new ArrayList(); StringTokenizer tokenizer = new StringTokenizer( arg, "," ); while( tokenizer.hasMoreTokens() ) { list.add( tokenizer.nextToken() ); } return (String[]) list.toArray( new String[0] ); } } --------------------------------------------------------------------- To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org For additional commands, e-mail: cvs-help@avalon.apache.org