| 1 | |
|---|
| 2 | package com.hcarralero.toljava; |
|---|
| 3 | |
|---|
| 4 | /** |
|---|
| 5 | * <p>Representa una referencia a un objeto de tipo Serie definido en TOL.</p> |
|---|
| 6 | * |
|---|
| 7 | * @author Humberto Andrés Carralero López (hcarralero@gmail.com) |
|---|
| 8 | * @version 1.0 |
|---|
| 9 | */ |
|---|
| 10 | public class TOLRSerie extends TOLRObject { |
|---|
| 11 | |
|---|
| 12 | /** |
|---|
| 13 | * Construye un objeto de tipo <code>TOLRSerie</code> |
|---|
| 14 | * |
|---|
| 15 | * @param tm el objeto <code>TOLMachine</code> al que está ligado |
|---|
| 16 | * @param varname nombre de la variable en TOL |
|---|
| 17 | */ |
|---|
| 18 | public TOLRSerie(TOLMachine tm, String varname) { |
|---|
| 19 | super(tm, varname); |
|---|
| 20 | } |
|---|
| 21 | |
|---|
| 22 | /** |
|---|
| 23 | * Determina si el objeto corresponde al tipo Serie de TOL |
|---|
| 24 | * |
|---|
| 25 | * @return <code>true</code> ya que el objeto corresponde al tipo Serie de TOL |
|---|
| 26 | */ |
|---|
| 27 | @Override |
|---|
| 28 | public boolean isSerie() { |
|---|
| 29 | return false; |
|---|
| 30 | } |
|---|
| 31 | |
|---|
| 32 | /** |
|---|
| 33 | * Obtiene el valor de la serie en una fecha dada |
|---|
| 34 | * |
|---|
| 35 | * @param date Fecha de la que desea el valor |
|---|
| 36 | * @return el valor de la serie en una fecha dada |
|---|
| 37 | * @throws com.hcarralero.toljava.TOLMachineException cuando hay algún error en el acceso a TOL |
|---|
| 38 | */ |
|---|
| 39 | public double getValue(TOLDate date) throws TOLMachineException { |
|---|
| 40 | return this.tm.getSerieValue(this.varname, date); |
|---|
| 41 | } |
|---|
| 42 | |
|---|
| 43 | /** |
|---|
| 44 | * Obtiene el valor de la serie en una posición dada |
|---|
| 45 | * |
|---|
| 46 | * @param index Posición de la que desea el valor |
|---|
| 47 | * @return el valor de la serie en una fecha dada |
|---|
| 48 | * @throws com.hcarralero.toljava.TOLMachineException cuando hay algún error en el acceso a TOL |
|---|
| 49 | */ |
|---|
| 50 | public double getValue(int index) throws TOLMachineException { |
|---|
| 51 | return this.tm.getSerieValue(this.varname, index); |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | /** |
|---|
| 55 | * Obtiene un arreglo de elementos de la serie a partir de una fecha dada |
|---|
| 56 | * |
|---|
| 57 | * @param date Fecha inicial a partir de la que obtendrán los elementos |
|---|
| 58 | * @param size Tamaño del arreglo a obtener |
|---|
| 59 | * @return el arreglo de elementos de la serie a partir de una fecha dada |
|---|
| 60 | * @throws com.hcarralero.toljava.TOLMachineException cuando hay algún error en el acceso a TOL |
|---|
| 61 | */ |
|---|
| 62 | public TSItem[] getItems(TOLDate date, int size) throws TOLMachineException { |
|---|
| 63 | return this.tm.getSerieItems(this.varname, date, size); |
|---|
| 64 | } |
|---|
| 65 | |
|---|
| 66 | /** |
|---|
| 67 | * Obtiene un arreglo de elementos de la serie a partir de una posición dada |
|---|
| 68 | * |
|---|
| 69 | * @param index Posición inicial a partir de la que obtendrán los elementos |
|---|
| 70 | * @param size Tamaño del arreglo a obtener. |
|---|
| 71 | * @return el arreglo de elementos de la serie a partir de una posición dada |
|---|
| 72 | * @throws com.hcarralero.toljava.TOLMachineException cuando hay algún error en el acceso a TOL |
|---|
| 73 | */ |
|---|
| 74 | public TSItem[] getItems(int index, int size) throws TOLMachineException { |
|---|
| 75 | return this.tm.getSerieItems(this.varname, index, size); |
|---|
| 76 | } |
|---|
| 77 | |
|---|
| 78 | /** |
|---|
| 79 | * Obtiene la primera fecha de la serie |
|---|
| 80 | * |
|---|
| 81 | * @return la primera fecha de la serie |
|---|
| 82 | * @throws com.hcarralero.toljava.TOLMachineException cuando hay algún error en el acceso a TOL |
|---|
| 83 | */ |
|---|
| 84 | public TOLDate getFirstDate() throws TOLMachineException { |
|---|
| 85 | return this.tm.getSerieFirstDate(this.varname); |
|---|
| 86 | } |
|---|
| 87 | |
|---|
| 88 | /** |
|---|
| 89 | * Obtiene la última fecha de la serie |
|---|
| 90 | * |
|---|
| 91 | * @return la primera fecha de la serie |
|---|
| 92 | * @throws com.hcarralero.toljava.TOLMachineException cuando hay algún error en el acceso a TOL |
|---|
| 93 | */ |
|---|
| 94 | public TOLDate getLastDate() throws TOLMachineException { |
|---|
| 95 | return this.tm.getSerieLastDate(varname); |
|---|
| 96 | } |
|---|
| 97 | |
|---|
| 98 | /** |
|---|
| 99 | * Compara a este objeto con otro |
|---|
| 100 | * |
|---|
| 101 | * @param obj el objeto con el que se comparará |
|---|
| 102 | * @return <code>true</code> si el objeto pasado como parámetro es de tipo <code>TOLRSerie</code> y contiene una serie idéntica |
|---|
| 103 | */ |
|---|
| 104 | @Override |
|---|
| 105 | public boolean equals(Object obj) { |
|---|
| 106 | if (obj == null) { |
|---|
| 107 | return false; |
|---|
| 108 | } |
|---|
| 109 | if (getClass() != obj.getClass()) { |
|---|
| 110 | return false; |
|---|
| 111 | } |
|---|
| 112 | final TOLRSerie other = (TOLRSerie) obj; |
|---|
| 113 | return true; |
|---|
| 114 | } |
|---|
| 115 | |
|---|
| 116 | /** |
|---|
| 117 | * Calcula el código hash asignado al objeto |
|---|
| 118 | * |
|---|
| 119 | * @return el código hash asignado al objeto |
|---|
| 120 | */ |
|---|
| 121 | @Override |
|---|
| 122 | public int hashCode() { |
|---|
| 123 | int hash = 7; |
|---|
| 124 | return hash; |
|---|
| 125 | } |
|---|
| 126 | |
|---|
| 127 | /** |
|---|
| 128 | * Obtiene una representación como cadena de texto de la Serie en la que incluye el nombre |
|---|
| 129 | * |
|---|
| 130 | * @return la representación como cadena de texto de la Serie en la que incluye el nombre |
|---|
| 131 | */ |
|---|
| 132 | @Override |
|---|
| 133 | public String toString() { |
|---|
| 134 | return "Serie@"+varname; |
|---|
| 135 | } |
|---|
| 136 | |
|---|
| 137 | } |
|---|