home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / modules / edtplug / classes / netscape / plugin / composer / io / Text.java < prev    next >
Encoding:
Java Source  |  1998-04-08  |  2.2 KB  |  75 lines

  1. /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. package netscape.plugin.composer.io;
  20.  
  21. /** A token for the text of an html document.
  22.  */
  23. public class Text extends Token {
  24.     /** Create a Text object from a given string.
  25.      * @param text the text.
  26.      */
  27.     public Text(String text){
  28.         this.text = text;
  29.     }
  30.     /** Set the text.
  31.      * @param text the text.
  32.      */
  33.     public void setText(String text){
  34.         this.text = text;
  35.     }
  36.     /** Get the text.
  37.      * @return the text.
  38.      */
  39.     public String getText(){
  40.         return text;
  41.     }
  42.     /** Convert the text to its html representation.
  43.      * @return the html representation of the text.
  44.      */
  45.     public String toString() {
  46.         return text;
  47.     }
  48.     /** Returns true if this text is a solitary newline
  49.      * character.
  50.      */
  51.     public boolean isNewline() {
  52.         return text.equals(NEWLINE);
  53.     }
  54.     /** Calculate the hash code for this object.
  55.      * @return the hash code for this object.
  56.      */
  57.     public int hashCode() {
  58.         return text.hashCode();
  59.     }
  60.     /** Check for equality.
  61.      * @param other the object to compare.
  62.      * @return true if other has the same text as this.
  63.      */
  64.  
  65.     public boolean equals(Object other) {
  66.         if ((other != null) && (other instanceof Text)) {
  67.             return text.equals(((Text)other).text);
  68.         }
  69.         return false;
  70.     }
  71.  
  72.     private String text;
  73.     private static final String NEWLINE = new String("\n");
  74. }
  75.