Re: accessing outer class variables

Jeroen van Rotterdam wrote:
> Hi,
> 
> As a workaround I tried to locally declare variables within the inner
> class by doing:
> 
> 
---- lines omitted
> 
> The problem with this workaround is that the variables that are passed to
> the constructor of the inner class are not properly typed.
> 
>      DOMBuilderFilter myfilter = new DOMBuilderFilterN1E(this, 1, 1, 2, 3 );
> 
> should be:
> 
>      DOMBuilderFilter myfilter = new DOMBuilderFilterN1E(this, (int)1,
> (short)1, (short)2, (short)3 ); >
> 
> Since 1 is by default int.
> 
> 
> Jeroen

That is not a workaround, that was the intended use of that construct. 
They only issue is that I did not anticipate the need to cast integer 
literals to shorts on the constructor.  I'll update the transform.  In 
the interim, if you define the class variables as 'int', you should 
avoid the inner class constructor issue and any casting to short inside 
the inner class body should occur automatically.  Alternatively, you 
could assign literals to test scoped variables before the inner class 
definition and use the test scoped variables as the values for the inner 
class variables.

     <var name="SHOW_ELEMENT" type="int" value="1"/>
     <var name="FILTER_ELEMENT" type="short" value="1"/>
 >   <var name="myfilter"         type="DOMBuilderFilter">
 >      <var name="name"            type="DOMString"/>
 >      <var name='SHOW_ELEMENT'    type='int'    value='SHOW_ELEMENT'/>
 >      <var name='FILTER_ELEMENT'    type='short' 
value='FILTER_ELEMENT'/>

Received on Sunday, 26 January 2003 15:46:58 UTC