001 // jademx - JADE management using JMX
002 // Copyright 2005 Caboodle Networks, Inc.
003 //
004 // This library is free software; you can redistribute it and/or
005 // modify it under the terms of the GNU Lesser General Public
006 // License as published by the Free Software Foundation; either
007 // version 2.1 of the License, or (at your option) any later version.
008 //
009 // This library is distributed in the hope that it will be useful,
010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 // Lesser General Public License for more details.
013 //
014 // You should have received a copy of the GNU Lesser General Public
015 // License along with this library; if not, write to the Free Software
016 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
017
018 package jade.jademx.agent;
019
020 /**
021 * a class to show usage of construction with a string argument
022 * @author David Bernstein, <a href="http://www.caboodlenetworks.com"
023 * >Caboodle Networks, Inc.</a>
024 */
025 public class Arg {
026
027 /** keep copy of constructor argument string */
028 private String val;
029
030 /**
031 * construct a new Arg
032 * @param val the string for construction
033 */
034 public Arg( String val ) {
035 this.val = val;
036 }
037
038 /**
039 * return the constructor parameter
040 * @return the constructor parameter
041 */
042 public String getVal() {
043 return val;
044 }
045
046
047 /* (non-Javadoc)
048 * @see java.lang.Object#equals(java.lang.Object)
049 */
050 public boolean equals( Object o ) {
051 boolean eq = o instanceof Arg;
052 if ( eq ) {
053 String oVal = ((Arg)o).getVal();
054 if ( ( null == oVal ) && ( null == val ) ) {
055 // yes, they're equal
056 }
057 else if ( ( null != oVal) && ( null != val ) ) {
058 eq = val.equals( oVal );
059 }
060 else {
061 eq = false;
062 }
063 }
064 return eq;
065 }
066
067 /* (non-Javadoc)
068 * @see java.lang.Object#toString()
069 */
070 public String toString() {
071 return getClass()+"[val="+val+"]";
072 }
073
074 }