com.hcarralero.toljava
Class TOLMachine

java.lang.Object
  extended by com.hcarralero.toljava.TOLMachine

public class TOLMachine
extends java.lang.Object

Representa a una instancia de la Máquina Virtual de TOL.

See Also:
TOLMachineException

Constructor Summary
TOLMachine()
          Crea una instancia de la Máquina Virtual de TOL y la inicializa
 
Method Summary
 TOLObject callCode(java.lang.String codeName, java.lang.Object[] parameters)
          Hace una llamada a una función asignada a una variable de tipo Code
 java.lang.Object[] execute(java.lang.String code)
          Ejecuta en la Máquina Virtual de TOL el código pasado por parámetro
 TOLVariable[] getCodeVariables()
          Obtiene un arreglo con todas las variables de tipo Code
 TOLVariable[] getComplexVariables()
          Obtiene un arreglo con todas las variables de tipo Complex
 TOLVariable[] getDateVariables()
          Obtiene un arreglo con todas las variables de tipo Date
 TOLVariable[] getMatrixVariables()
          Obtiene un arreglo con todas las variables de tipo Matrix
 TOLNameBlock[] getNameBlocks()
          Obtiene un arreglo con todas los NameBlocks definidos en TOL
 TOLVariable[] getPolynVariables()
          Obtiene un arreglo con todas las variables de tipo Polyn
 TOLVariable[] getRatioVariables()
          Obtiene un arreglo con todas las variables de tipo Ratio
 TOLVariable[] getRealVariables()
          Obtiene un arreglo con todas las variables de tipo Real
 TOLDate getSerieFirstDate(java.lang.String varname)
          Obtiene la primera fecha de una serie
 TSItem[] getSerieItems(java.lang.String varname, int index, int size)
          Obtiene un arreglo de items de una serie a partir de una posición dada
 TSItem[] getSerieItems(java.lang.String varname, TOLDate date, int size)
          Obtiene un arreglo de items de una serie a partir de una fecha dada
 TOLDate getSerieLastDate(java.lang.String varname)
          Obtiene la última fecha de una serie
 double getSerieValue(java.lang.String varname, int index)
          Obtiene el valor de una serie en una posición dada
 double getSerieValue(java.lang.String varname, TOLDate date)
          Obtiene el valor de una serie en una fecha dada
 TOLVariable[] getSerieVariables()
          Obtiene un arreglo con todas las variables de tipo Serie
 TOLObject getSetElement(java.lang.String varname, int index)
          Obtiene el elemento de la posición index en un Set
 TOLObject[] getSetElements(java.lang.String varname)
          Obtiene un arreglo todos los elementos de un Set
 int getSetSize(java.lang.String varname)
          Obtiene el tamaño (número de elementos) de un Set
 TOLVariable[] getSetVariables()
          Obtiene un arreglo con todas las variables de tipo Set
 TOLVariable[] getTextVariables()
          Obtiene un arreglo con todas las variables de tipo Text
 TOLDate[] getTimeSetDates(java.lang.String varname, TOLDate date, int size)
          Obtiene un arreglo de fechas de un TimeSet a partir de una fecha dada
 TOLDate getTimeSetNextDate(java.lang.String varname, TOLDate date)
          Obtiene la fecha siguiente a una dada en un TimeSet
 TOLDate getTimeSetPrevDate(java.lang.String varname, TOLDate date)
          Obtiene la fecha previa a una dada en un TimeSet
 TOLVariable[] getTimeSetVariables()
          Obtiene un arreglo con todas las variables de tipo TimeSet
 TOLVariable getVariable(java.lang.String varName)
          Determina el valor de una variable dado su nombre como parámetro
 TOLVariable[] getVMatrixVariables()
          Obtiene un arreglo con todas las variables de tipo VMatrix
 void initTOL()
          Inicializa la Máquina Virtual de TOL.
 void setVariableValue(java.lang.String varName, TOLLObject varValue)
          Cambia el valor de la variable cuyo nombre se indica por el valor pasado como parámetro
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TOLMachine

public TOLMachine()
Crea una instancia de la Máquina Virtual de TOL y la inicializa

Method Detail

initTOL

public void initTOL()
Inicializa la Máquina Virtual de TOL.


execute

public java.lang.Object[] execute(java.lang.String code)
Ejecuta en la Máquina Virtual de TOL el código pasado por parámetro

Parameters:
code - código TOL a ejecutarse
Returns:
un arreglo de objetos cuyo primer elemento es el número de errores que se han producido tanto en la compilación como en la ejecución, el resto de los elementos son los mensajes generados por la Máquina Virtual de TOL, lo cual es variable. (Consulte la documentación de TOL para revisar el formato de los mensajes producidos y poder procesarlos)

callCode

public TOLObject callCode(java.lang.String codeName,
                          java.lang.Object[] parameters)
                   throws TOLMachineException
Hace una llamada a una función asignada a una variable de tipo Code

Parameters:
codeName - nombre de la variable tipo Code a la que se hace la llamada
parameters - arreglo contiendo los parámetros que se deben pasar a la función que se llama; cada elemento de este arreglo puede ser un objeto perteneciente a una clase derivada de TOLLObject o una cadena con el nombre de una variable definida en TOL
Returns:
un objeto con el valor retornado por la función que se ha invocado
Throws:
TOLMachineException - cuando algún parámetro no es correcto, el nombre de la función a invocar no se ha encontrado u ocurre alguna otra anomalía en la evaluación

getVariable

public TOLVariable getVariable(java.lang.String varName)
                        throws TOLMachineException
Determina el valor de una variable dado su nombre como parámetro

Parameters:
varName - nombre de la variable en la Máquina Virtual de TOL
Returns:
una variable instanciada con los datos obtenidos de TOL
Throws:
TOLMachineException - cuando la variable NO SE ENCONTRÓ

setVariableValue

public void setVariableValue(java.lang.String varName,
                             TOLLObject varValue)
                      throws TOLMachineException
Cambia el valor de la variable cuyo nombre se indica por el valor pasado como parámetro

Parameters:
varName - nombre de la variable
varValue - nuevo valor de la variable
Throws:
TOLMachineException - cuando no se encuentra la variable o se intenta asignar un valor de un tipo erróneo

getTextVariables

public TOLVariable[] getTextVariables()
Obtiene un arreglo con todas las variables de tipo Text

Returns:
el arreglo con todas las variables de tipo Text

getRealVariables

public TOLVariable[] getRealVariables()
Obtiene un arreglo con todas las variables de tipo Real

Returns:
el arreglo con todas las variables de tipo Real

getDateVariables

public TOLVariable[] getDateVariables()
Obtiene un arreglo con todas las variables de tipo Date

Returns:
el arreglo con todas las variables de tipo Date

getComplexVariables

public TOLVariable[] getComplexVariables()
Obtiene un arreglo con todas las variables de tipo Complex

Returns:
el arreglo con todas las variables de tipo Complex

getMatrixVariables

public TOLVariable[] getMatrixVariables()
Obtiene un arreglo con todas las variables de tipo Matrix

Returns:
el arreglo con todas las variables de tipo Matrix

getVMatrixVariables

public TOLVariable[] getVMatrixVariables()
Obtiene un arreglo con todas las variables de tipo VMatrix

Returns:
el arreglo con todas las variables de tipo VMatrix

getPolynVariables

public TOLVariable[] getPolynVariables()
Obtiene un arreglo con todas las variables de tipo Polyn

Returns:
el arreglo con todas las variables de tipo Polyn

getRatioVariables

public TOLVariable[] getRatioVariables()
Obtiene un arreglo con todas las variables de tipo Ratio

Returns:
el arreglo con todas las variables de tipo Ratio

getCodeVariables

public TOLVariable[] getCodeVariables()
Obtiene un arreglo con todas las variables de tipo Code

Returns:
el arreglo con todas las variables de tipo Code

getSerieVariables

public TOLVariable[] getSerieVariables()
Obtiene un arreglo con todas las variables de tipo Serie

Returns:
el arreglo con todas las variables de tipo Serie

getTimeSetVariables

public TOLVariable[] getTimeSetVariables()
Obtiene un arreglo con todas las variables de tipo TimeSet

Returns:
el arreglo con todas las variables de tipo TimeSet

getSetVariables

public TOLVariable[] getSetVariables()
Obtiene un arreglo con todas las variables de tipo Set

Returns:
el arreglo con todas las variables de tipo Set

getNameBlocks

public TOLNameBlock[] getNameBlocks()
Obtiene un arreglo con todas los NameBlocks definidos en TOL

Returns:
el arreglo con todas los NameBlocks definidos en TOL

getSerieValue

public double getSerieValue(java.lang.String varname,
                            TOLDate date)
                     throws TOLMachineException
Obtiene el valor de una serie en una fecha dada

Parameters:
varname - nombre de la serie en TOL
date - fecha en al que se quiere el valor
Returns:
el valor de la serie en la fecha dada
Throws:
TOLMachineException - si ocurre algún error accediendo a la Serie en TOL

getSerieValue

public double getSerieValue(java.lang.String varname,
                            int index)
                     throws TOLMachineException
Obtiene el valor de una serie en una posición dada

Parameters:
varname - nombre de la Serie en TOL
index - posición del elemento en la serie
Returns:
el valor de la serie en la posición dada
Throws:
TOLMachineException - si ocurre algún error accediendo a la Serie en TOL

getSerieItems

public TSItem[] getSerieItems(java.lang.String varname,
                              TOLDate date,
                              int size)
                       throws TOLMachineException
Obtiene un arreglo de items de una serie a partir de una fecha dada

Parameters:
varname - nombre de la Serie en TOL
date - fecha a partir de la cual se obtendrán los elementos
size - tamaño del arreglo que se obtiene
Returns:
el arreglo de items de la serie a partir de la fecha dada
Throws:
TOLMachineException - si ocurre algún error accediendo a la Serie en TOL

getSerieItems

public TSItem[] getSerieItems(java.lang.String varname,
                              int index,
                              int size)
                       throws TOLMachineException
Obtiene un arreglo de items de una serie a partir de una posición dada

Parameters:
varname - nombre de la Serie en TOL
index - posición del primer elemento en la serie
size - tamaño del arreglo que se obtiene
Returns:
el arreglo de items de la serie a partir de la posición dada
Throws:
TOLMachineException - si ocurre algún error accediendo a la Serie en TOL

getSerieFirstDate

public TOLDate getSerieFirstDate(java.lang.String varname)
                          throws TOLMachineException
Obtiene la primera fecha de una serie

Parameters:
varname - nombre de la Serie en TOL
Returns:
la primera fecha de la serie
Throws:
TOLMachineException - si ocurre algún error accediendo a la Serie en TOL

getSerieLastDate

public TOLDate getSerieLastDate(java.lang.String varname)
                         throws TOLMachineException
Obtiene la última fecha de una serie

Parameters:
varname - nombre de la Serie en TOL
Returns:
la última fecha de la serie
Throws:
TOLMachineException - si ocurre algún error accediendo a la Serie en TOL

getTimeSetPrevDate

public TOLDate getTimeSetPrevDate(java.lang.String varname,
                                  TOLDate date)
                           throws TOLMachineException
Obtiene la fecha previa a una dada en un TimeSet

Parameters:
varname - nombre del TimeSet en TOL
date - fecha de la cual se obtendrá la previa
Returns:
la fecha previa a la dada en el TimeSet
Throws:
TOLMachineException - si ocurre algún error accediendo al TimeSet en TOL

getTimeSetNextDate

public TOLDate getTimeSetNextDate(java.lang.String varname,
                                  TOLDate date)
                           throws TOLMachineException
Obtiene la fecha siguiente a una dada en un TimeSet

Parameters:
varname - nombre del TimeSet en TOL
date - fecha de la cual se obtendrá la siguiente
Returns:
la fecha siguiente a la dada en el TimeSet
Throws:
TOLMachineException - si ocurre algún error accediendo al TimeSet en TOL

getTimeSetDates

public TOLDate[] getTimeSetDates(java.lang.String varname,
                                 TOLDate date,
                                 int size)
                          throws TOLMachineException
Obtiene un arreglo de fechas de un TimeSet a partir de una fecha dada

Parameters:
varname - nombre del TimeSet en TOL
date - fecha inicial en el arreglo
size - tamaño del arreglo
Returns:
el arreglo de fechas del TimeSet a partir de la fecha dada
Throws:
TOLMachineException - si ocurre algún error accediendo al TimeSet en TOL

getSetSize

public int getSetSize(java.lang.String varname)
               throws TOLMachineException
Obtiene el tamaño (número de elementos) de un Set

Parameters:
varname - nombre del Set en TOL
Returns:
el tamaño (número de elementos) del Set
Throws:
TOLMachineException - si ocurre algún error accediendo al Set en TOL

getSetElements

public TOLObject[] getSetElements(java.lang.String varname)
                           throws TOLMachineException
Obtiene un arreglo todos los elementos de un Set

Parameters:
varname - nombre del Set en TOL
Returns:
el arreglo todos los elementos de un Set
Throws:
TOLMachineException - si ocurre algún error accediendo al Set en TOL

getSetElement

public TOLObject getSetElement(java.lang.String varname,
                               int index)
                        throws TOLMachineException
Obtiene el elemento de la posición index en un Set

Parameters:
varname - nombre del Set en TOL
index - posición del elemento en el Set
Returns:
el elemento de la posición index en el Set
Throws:
TOLMachineException - si ocurre algún error accediendo al Set en TOL