001    package de.mospace.lang;
002    
003    /* Mp3dings - manage mp3 meta-information
004     * Copyright (C) 2003 Moritz Ringler
005     * $Id: FullTextString.java 12 2007-07-27 09:48:53Z ringler $
006     *
007     * This program is free software; you can redistribute it and/or
008     * modify it under the terms of the GNU General Public License
009     * as published by the Free Software Foundation; either version 2
010     * of the License, or (at your option) any later version.
011     *
012     * This program is distributed in the hope that it will be useful,
013     * but WITHOUT ANY WARRANTY; without even the implied warranty of
014     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
015     * GNU General Public License for more details.
016     *
017     * You should have received a copy of the GNU General Public License
018     * along with this program; if not, write to the Free Software
019     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
020     */
021     import java.io.Serializable;
022    
023    /**
024     * An immutable String with multiple lines. Since it is not allowed in Java to
025     * subclass
026     * String I had to use this pretty ugly construct which is nothing more than
027     * a wrapper around a String (needed for JTable where cell renderer and cell
028     * editor are determined from the column class.)
029     * @author Moritz Ringler
030     * @version $Revision: 12 $ ($Date: 2007-07-27 11:48:53 +0200 (Fr, 27 Jul 2007) $)
031     **/
032    public final class FullTextString implements Serializable{
033        private final String me;
034        static final long serialVersionUID = 1432403406576665372L;
035    
036        /** Constructs a new instance of this class.
037         * @param fts the (multi-line) String that will be returned by the toString() method
038         * @see #toString()
039         **/
040        public FullTextString(String fts){
041            me = fts;
042        }
043    
044        /** Clones an existing FullTextString.
045         *  @param fts the FullTextString to clone
046         **/
047        public FullTextString(FullTextString fts){
048            me = fts.toString();
049        }
050    
051        /** Returns a reference to the internal String. Manipulating the returned
052         * String will change the state of this object.
053         * @return the FullTextString as a String
054         **/
055        public String toString(){
056            return me;
057        }
058    
059        public boolean equals(Object o){
060            if(this == o){
061                return true;
062            } else if(o instanceof FullTextString){
063                return me.equals(o.toString());
064            } else {
065                return false;
066            }
067        }
068    
069        public int hashCode(){
070            return me.hashCode();
071        }
072    }