You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by ja...@apache.org on 2008/04/02 00:03:21 UTC
svn commit: r643612 -
/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/WikiPrincipal.java
Author: jalkanen
Date: Tue Apr 1 15:03:20 2008
New Revision: 643612
URL: http://svn.apache.org/viewvc?rev=643612&view=rev
Log:
Now implements Comparable for easy sorting.
Modified:
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/WikiPrincipal.java
Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/WikiPrincipal.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/WikiPrincipal.java?rev=643612&r1=643611&r2=643612&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/WikiPrincipal.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/WikiPrincipal.java Tue Apr 1 15:03:20 2008
@@ -1,21 +1,22 @@
/*
- JSPWiki - a JSP-based WikiWiki clone.
+ JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001-2004 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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 com.ecyrd.jspwiki.auth;
@@ -32,11 +33,10 @@
* or hash code; two WikiPrincipals with the same name but different types are still
* considered equal.
*
- * @author Janne Jalkanen
* @author Andrew Jaquith
* @since 2.2
*/
-public final class WikiPrincipal implements Principal
+public final class WikiPrincipal implements Principal, Comparable
{
/**
@@ -154,6 +154,24 @@
public final String toString()
{
return "[WikiPrincipal (" + m_type + "): " + getName() + "]";
+ }
+
+ /**
+ * Allows comparisons to any other Principal objects. Primary sorting
+ * order is by the principal name, as returned by getName().
+ *
+ * @param o {@inheritDoc}
+ * @return {@inheritDoc}
+ * @since 2.7.0
+ */
+ public int compareTo(Object o)
+ {
+ if( o instanceof Principal )
+ {
+ return getName().compareTo( ((Principal)o).getName() );
+ }
+
+ throw new ClassCastException( "WikiPrincipal can only be compared to other Principals" );
}