| 1 | |
|---|
| 2 | package com.hcarralero.toljava; |
|---|
| 3 | |
|---|
| 4 | import java.io.Serializable; |
|---|
| 5 | |
|---|
| 6 | /** |
|---|
| 7 | * Representa a un objeto TOL de tipo Text |
|---|
| 8 | * |
|---|
| 9 | * @author Humberto Andrés Carralero López (hcarralero@gmail.com) |
|---|
| 10 | * @version 1.0 |
|---|
| 11 | */ |
|---|
| 12 | public class TOLText extends TOLLObject implements Serializable { |
|---|
| 13 | |
|---|
| 14 | private String text= null; |
|---|
| 15 | |
|---|
| 16 | /** |
|---|
| 17 | * Construye un objeto de tipo TOLText |
|---|
| 18 | * |
|---|
| 19 | * @param text Texto que almacena el objeto |
|---|
| 20 | */ |
|---|
| 21 | public TOLText(String text) { |
|---|
| 22 | this.text = text; |
|---|
| 23 | } |
|---|
| 24 | |
|---|
| 25 | /** |
|---|
| 26 | * Retorna el texto almacenado |
|---|
| 27 | * |
|---|
| 28 | * @return el texto almacenado |
|---|
| 29 | */ |
|---|
| 30 | public String getText() { |
|---|
| 31 | return text; |
|---|
| 32 | } |
|---|
| 33 | |
|---|
| 34 | /** |
|---|
| 35 | * Cambia el texto almacenado por el nuevo texto |
|---|
| 36 | * |
|---|
| 37 | * @param text el nuevo texto |
|---|
| 38 | */ |
|---|
| 39 | public void setText(String text) { |
|---|
| 40 | this.text = text; |
|---|
| 41 | } |
|---|
| 42 | |
|---|
| 43 | /** |
|---|
| 44 | * Determina si el objeto corresponde al tipo Text de TOL |
|---|
| 45 | * |
|---|
| 46 | * @return <code>true</code> ya que el objeto corresponde al tipo Text de TOL |
|---|
| 47 | */ |
|---|
| 48 | @Override |
|---|
| 49 | public boolean isText() { |
|---|
| 50 | return true; |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | /** |
|---|
| 54 | * Compara a este objeto con otro |
|---|
| 55 | * |
|---|
| 56 | * @param obj el objeto con el que se comparará |
|---|
| 57 | * @return <code>true</code> si el objeto pasado como parámetro es de tipo |
|---|
| 58 | * <code>TOLText</code> y contiene un texto similar |
|---|
| 59 | */ |
|---|
| 60 | @Override |
|---|
| 61 | public boolean equals(Object obj) { |
|---|
| 62 | if (obj == null) { |
|---|
| 63 | return false; |
|---|
| 64 | } |
|---|
| 65 | if (getClass() != obj.getClass()) { |
|---|
| 66 | return false; |
|---|
| 67 | } |
|---|
| 68 | final TOLText other = (TOLText) obj; |
|---|
| 69 | if ((this.text == null) ? (other.text != null) : !this.text.equals(other.text)) { |
|---|
| 70 | return false; |
|---|
| 71 | } |
|---|
| 72 | return true; |
|---|
| 73 | } |
|---|
| 74 | |
|---|
| 75 | /** |
|---|
| 76 | * Calcula el código hash asignado al objeto |
|---|
| 77 | * |
|---|
| 78 | * @return el código hash asignado al objeto |
|---|
| 79 | */ |
|---|
| 80 | @Override |
|---|
| 81 | public int hashCode() { |
|---|
| 82 | int hash = 7; |
|---|
| 83 | hash = 97 * hash + (this.text != null ? this.text.hashCode() : 0); |
|---|
| 84 | return hash; |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | /** |
|---|
| 88 | * Obtiene una representación como cadena de texto del objeto |
|---|
| 89 | * |
|---|
| 90 | * @return la representación como cadena de texto del objeto |
|---|
| 91 | */ |
|---|
| 92 | @Override |
|---|
| 93 | public String toString() { |
|---|
| 94 | return this.text; |
|---|
| 95 | } |
|---|
| 96 | |
|---|
| 97 | } |
|---|