001/* ---------------------------------------------------------------------------- 002 The Kiwi Toolkit - A Java Class Library 003 Copyright (C) 1998-2004 Mark A. Lindner 004 005 This library is free software; you can redistribute it and/or 006 modify it under the terms of the GNU General Public License as 007 published by the Free Software Foundation; either version 2 of the 008 License, or (at your option) any later version. 009 010 This library is distributed in the hope that it will be useful, 011 but WITHOUT ANY WARRANTY; without even the implied warranty of 012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 General Public License for more details. 014 015 You should have received a copy of the GNU General Public License 016 along with this library; if not, write to the Free Software 017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 018 02111-1307, USA. 019 020 The author may be contacted at: mark_a_lindner@yahoo.com 021 ---------------------------------------------------------------------------- 022 $Log: StringHolder.java,v $ 023 Revision 1.12 2004/05/05 21:22:45 markl 024 Comment header updates. 025 026 Revision 1.11 2004/05/05 18:23:11 markl 027 rename of HolderObject to ValueHolder 028 029 Revision 1.10 2004/03/16 06:38:09 markl 030 LocaleManager method change 031 032 Revision 1.9 2003/01/19 09:42:39 markl 033 Javadoc & comment header updates. 034 035 Revision 1.8 2001/03/20 00:54:56 markl 036 Fixed deprecated calls. 037 038 Revision 1.7 2001/03/12 03:16:51 markl 039 *** empty log message *** 040 041 Revision 1.6 2000/06/09 01:47:40 markl 042 Modified to use Collator to compare strings. 043 044 Revision 1.5 1999/07/25 13:39:39 markl 045 Added a constructor that accepts a subtype. 046 047 Revision 1.4 1999/07/16 07:12:50 markl 048 Modified to subclass HolderObject. 049 050 Revision 1.3 1999/02/09 05:02:56 markl 051 added toString() method 052 053 Revision 1.2 1999/01/10 03:56:22 markl 054 added GPL header & RCS tag 055 ---------------------------------------------------------------------------- 056*/ 057 058package kiwi.util; 059 060/** A mutable holder for a <code>String</code> value. 061 * 062 * @author Mark Lindner 063 */ 064 065public class StringHolder extends ValueHolder 066 { 067 /** The current value. */ 068 protected String value; 069 070 /** Construct a new <code>StringHolder</code> with an initial value of 071 * <code>null</code> and default subtype of <code>0</code>. 072 */ 073 074 public StringHolder() 075 { 076 this(null, 0); 077 } 078 079 /** Construct a new <code>StringHolder</code> with a specified initial 080 * value and default subtype of <code>0</code>. 081 * 082 * @param value The initial value. 083 */ 084 085 public StringHolder(String value) 086 { 087 this(value, 0); 088 } 089 090 /** Construct a new <code>StringHolder</code> with a specified initial 091 * value and subtype. 092 * 093 * @param value The initial value. 094 * @param subtype The subtype for this value. 095 */ 096 097 public StringHolder(String value, int subtype) 098 { 099 super(subtype); 100 101 this.value = value; 102 } 103 104 /** Set the <code>StringHolder</code>'s value. 105 * 106 * @param value The new value. 107 */ 108 109 public final void setValue(String value) 110 { 111 this.value = value; 112 } 113 114 /** Get the <code>StringHolder</code>'s value. 115 * 116 * @return The current value. 117 */ 118 119 public final String getValue() 120 { 121 return(value); 122 } 123 124 /** Get a string representation for this object. */ 125 126 public String toString() 127 { 128 return(value); 129 } 130 131 /** Compare this holder object to another. */ 132 133 public int compareTo(Object other) 134 { 135 String v = ((StringHolder)other).getValue(); 136 137 if((v == null) && (value == null)) 138 return(0); 139 else if((v == null) && (value != null)) 140 return(1); 141 else if((v != null) && (value == null)) 142 return(-1); 143 else 144 return(value.compareTo(v)); 145 } 146 147 } 148 149/* end of source file */