RoleValueCollection.java
Upload User: gdxydsw
Upload Date: 2019-01-29
Package Size: 16721k
Code Size: 3k
Category:

Java Develop

Development Platform:

Java

  1. /*
  2.  * Copyright (c) JForum Team
  3.  * All rights reserved.
  4.  * Redistribution and use in source and binary forms, 
  5.  * with or without modification, are permitted provided 
  6.  * that the following conditions are met:
  7.  * 1) Redistributions of source code must retain the above 
  8.  * copyright notice, this list of conditions and the 
  9.  * following  disclaimer.
  10.  * 2)  Redistributions in binary form must reproduce the 
  11.  * above copyright notice, this list of conditions and 
  12.  * the following disclaimer in the documentation and/or 
  13.  * other materials provided with the distribution.
  14.  * 3) Neither the name of "Rafael Steil" nor 
  15.  * the names of its contributors may be used to endorse 
  16.  * or promote products derived from this software without 
  17.  * specific prior written permission.
  18.  * 
  19.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT 
  20.  * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
  21.  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 
  22.  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
  23.  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
  24.  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 
  25.  * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 
  26.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
  27.  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
  28.  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
  29.  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
  30.  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
  31.  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 
  32.  * IN CONTRACT, STRICT LIABILITY, OR TORT 
  33.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
  34.  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
  35.  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
  36.  * 
  37.  * This file creation date: 08/01/2004 / 21:41:11
  38.  * The JForum Project
  39.  * http://www.jforum.net
  40.  */
  41. package net.jforum.security;
  42. import java.io.Serializable;
  43. import java.util.Collection;
  44. import java.util.Iterator;
  45. import java.util.LinkedHashSet;
  46. /**
  47.  * @author Rafael Steil
  48.  * @version $Id: RoleValueCollection.java,v 1.9 2006/08/24 01:07:01 rafaelsteil Exp $
  49.  */
  50. public class RoleValueCollection extends LinkedHashSet implements Serializable 
  51. {
  52. /**
  53.  * Gets a <code>RoleValue</code> by its name.
  54.  * 
  55.  * @param valueName The <code>RoleValue</code> name
  56.  * @return The <code>RoleValue</code> object if found, or <code>null</code> if not found
  57.  */
  58. public RoleValue get(String valueName)
  59. {
  60. for (Iterator iter = this.iterator(); iter.hasNext(); ) {
  61. RoleValue v = (RoleValue)iter.next();
  62. if (v.getValue().equals(valueName)) {
  63. return v;
  64. }
  65. }
  66. return null;
  67. }
  68. /** 
  69.  * @see java.util.HashSet#contains(java.lang.Object)
  70.  */
  71. public boolean contains(Object o) 
  72. {
  73. boolean c = super.contains(o);
  74. return c;
  75. }
  76. /** 
  77.  * @see java.util.ArrayList#add(java.lang.Object)
  78.  */
  79. public boolean add(Object o) 
  80. {
  81. if (!(o instanceof RoleValue)) {
  82. throw new IllegalArgumentException("Object passed as parameter is not a RoleValue type");
  83. }
  84. return super.add(o);
  85. }
  86. /** 
  87.  * @see java.util.Collection#addAll(java.util.Collection)
  88.  */
  89. public boolean addAll(Collection c) 
  90. {
  91. boolean status = true;
  92. for (Iterator iter = c.iterator(); iter.hasNext(); ) {
  93. status = this.add(iter.next());
  94. }
  95. return status;
  96. }
  97. }