org.directwebremoting.extend
Class InboundContext

java.lang.Object
  extended by org.directwebremoting.extend.InboundContext

public final class InboundContext
extends java.lang.Object

InboundContext is the context for set of inbound conversions. Since a data set may be recursive parts of some data members may refer to others so we need to keep track of who is converted for what.

Author:
Joe Walker [joe at getahead dot ltd dot uk]

Constructor Summary
InboundContext()
           
 
Method Summary
 void addConverted(InboundVariable iv, java.lang.Class<?> type, java.lang.Object bean)
          Add to the (temporary) list of converted objects
 void clearConverted()
          Clear the list of converted objects.
 InboundVariable createArrayWrapper(int callNum, int destParamCount)
          This is very nasty - we need to create an array for varargs.
 void createInboundVariable(int callNum, java.lang.String key, java.lang.String type, FormField value)
          Create an inbound file variable.
 void createInboundVariable(int callNum, java.lang.String key, java.lang.String type, java.lang.String value)
          Create an inbound variable.
 void dereference()
          When we are sure we have finished parsing the input, we can begin to fix all cross-references.
 java.lang.Object getConverted(InboundVariable iv, java.lang.Class<?> type)
          Check to see if the conversion has already been done
 Property getCurrentProperty()
           
 InboundVariable getInboundVariable(java.lang.String name)
          Method to allow entries to resolve references
 java.util.Iterator<java.lang.String> getInboundVariableNames()
          A debug method so people can get a list of all the variable names
 InboundVariable getParameter(int callNum, int index)
          Get a parameter by index
 int getParameterCount()
          How many parameters are there?
 int getParameterCount(int callNum)
          Count the arguments (including method and script params) for a given call number.
 void popContext()
          Someone wants to tell us about a finished conversion context.
 void pushContext(Property context)
          Someone wants to tell us about a new conversion context.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InboundContext

public InboundContext()
Method Detail

dereference

public void dereference()
                 throws ConversionException
When we are sure we have finished parsing the input, we can begin to fix all cross-references.

Throws:
ConversionException - If cross-references don't add up

pushContext

public void pushContext(Property context)
Someone wants to tell us about a new conversion context.

Parameters:
context - The current conversion context

popContext

public void popContext()
Someone wants to tell us about a finished conversion context.


getCurrentProperty

public Property getCurrentProperty()
Returns:
The method that we are currently converting data for

createInboundVariable

public void createInboundVariable(int callNum,
                                  java.lang.String key,
                                  java.lang.String type,
                                  java.lang.String value)
Create an inbound variable. Usually called by a query parser to setup a list of known variables. This method also checks to see if the new variable is a parameter and if it is it updates the count of parameters

Parameters:
callNum - The call number to work on
key - The name of the variable
type - The javascript type of the variable
value - The value of the variable

createInboundVariable

public void createInboundVariable(int callNum,
                                  java.lang.String key,
                                  java.lang.String type,
                                  FormField value)
Create an inbound file variable. Usually called by a query parser to setup a list of known variables. This method also checks to see if the new variable is a parameter and if it is it updates the count of parameters

Parameters:
callNum - The call number to work on
key - The name of the variable
type - The javascript type of the variable
value - The value of the file

getInboundVariable

public InboundVariable getInboundVariable(java.lang.String name)
Method to allow entries to resolve references

Parameters:
name - The name of the variable to lookup
Returns:
The found variable

clearConverted

public void clearConverted()
Clear the list of converted objects. If the conversion attempt for a given method failed, we may want to try another so we will need to ditch the list of converted objects because the next method could well have different parameter types.


addConverted

public void addConverted(InboundVariable iv,
                         java.lang.Class<?> type,
                         java.lang.Object bean)
Add to the (temporary) list of converted objects

Parameters:
iv - The converted object
type - The type that we converted the object to
bean - The converted version

getConverted

public java.lang.Object getConverted(InboundVariable iv,
                                     java.lang.Class<?> type)
Check to see if the conversion has already been done

Parameters:
iv - The inbound data to check
type - The type that we want the object converted to
Returns:
The converted data or null if it has not been converted

getParameterCount

public int getParameterCount()
How many parameters are there?

Returns:
The parameter count

getParameterCount

public int getParameterCount(int callNum)
Count the arguments (including method and script params) for a given call number.

Parameters:
callNum - The Call number to count the parameters of
Returns:
The parameter count for a given Call

getParameter

public InboundVariable getParameter(int callNum,
                                    int index)
Get a parameter by index

Parameters:
callNum - The call number to work on
index - The parameter index
Returns:
The found parameter

createArrayWrapper

public InboundVariable createArrayWrapper(int callNum,
                                          int destParamCount)
This is very nasty - we need to create an array for varargs. The correct solution is to have ArrayConverter (and MapConverter) part of dwrp and not implementations of Converter. This would resolve a number of problems however for now we will have to create a mock InboundVariable to make it look to our ArrayConverter that the client passed in an array all along

Parameters:
callNum - The call number to work on
destParamCount - The number of parameters to the method that we are calling, from which we can work out the size of the varargs array

getInboundVariableNames

public java.util.Iterator<java.lang.String> getInboundVariableNames()
A debug method so people can get a list of all the variable names

Returns:
an iterator over the known variable names

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

Copyright 2008