|
Re: Internally setting value of a property [message #130038 is a reply to message #130025] |
Thu, 17 August 2006 18:22 |
Eclipse User |
|
|
|
Originally posted by: jefmyers.us.ibm.com
Hung,
You can follow the pattern that's used to load images - by creating a
url that's relative to the location of the class. For instance you can
use composite.setInputFile(getClass().getResource("/input.txt")), then
use a URLInputStream to open that url to read the file. This has the
additional advantage of working if you package the resource along with
your classes into a jar file.
Hope this helps,
- Jeff
|
|
|
|
Re: Internally setting value of a property [message #130085 is a reply to message #130061] |
Thu, 17 August 2006 22:12 |
Eclipse User |
|
|
|
Originally posted by: richkulp.us.NO_SPAM.ibm.com
Don't worry about it. It just means that we can't evaluate the
setInputFile as a property. But since it isn't a property there isn't a
problem. It doesn't stop your code from working.
Hung Lam wrote:
> Thanks Jeff,
> That's a good idea....I'll try it out. I have another question though.
> Below are the sample code. MyComposite has setter/getter for
> inputFile, and what I want to do is to pass this common inputFile to
> each of the AnotherComposite. I can't get this to work b/c it
> complains that getInputFile() needs a receiver. If I replace it with
> this.getInputFile(), it says no such method in Composite class. Thanks.
>
>
> Class Composite1 extends MyComposite
> {
> private void initialize()
> {
> setInputFile("test.txt");
> ....
>
> AnotherComposite comp = new AnotherComposite(...);
> comp.setInputFile(getInputFile());
> ....
>
> AnotherComposite comp1 = new AnotherComposite1(...);
> comp1.setInputFile(getInputFile());
> }
> }
>
> class MyComposite extends Composite
> {
> public void setInputFile(..) {..}
>
> public String getInputFile() {....}
> }
>
> Jeff Myers wrote:
>
>> Hung,
>>
>> You can follow the pattern that's used to load images - by creating a
>> url that's relative to the location of the class. For instance you
>> can use composite.setInputFile(getClass().getResource("/input.txt")),
>> then use a URLInputStream to open that url to read the file. This has
>> the additional advantage of working if you package the resource along
>> with your classes into a jar file.
>>
>> Hope this helps,
>> - Jeff
--
Thanks,
Rich Kulp
|
|
|
|
Re: Internally setting value of a property [message #130206 is a reply to message #130109] |
Fri, 18 August 2006 14:15 |
Eclipse User |
|
|
|
Originally posted by: richkulp.us.NO_SPAM.ibm.com
It won't work. We don't "execute" the class being edited. We interpret
it. We can't run because it is being edited, you can only run a class
that is saved and compiled. Because of this we can't run arbitrary
methods in the class being edited. getInputFile() is an arbitrary
method. It isn't a bean that we know anything about.
If you dropped the class on another class then it would be executed
because we executed used classes since that class has been saved and
compiled.
--
Thanks,
Rich Kulp
|
|
|
|
|
Re: Internally setting value of a property [message #614553 is a reply to message #130061] |
Thu, 17 August 2006 22:12 |
Eclipse User |
|
|
|
Originally posted by: richkulp.us.NO_SPAM.ibm.com
Don't worry about it. It just means that we can't evaluate the
setInputFile as a property. But since it isn't a property there isn't a
problem. It doesn't stop your code from working.
Hung Lam wrote:
> Thanks Jeff,
> That's a good idea....I'll try it out. I have another question though.
> Below are the sample code. MyComposite has setter/getter for
> inputFile, and what I want to do is to pass this common inputFile to
> each of the AnotherComposite. I can't get this to work b/c it
> complains that getInputFile() needs a receiver. If I replace it with
> this.getInputFile(), it says no such method in Composite class. Thanks.
>
>
> Class Composite1 extends MyComposite
> {
> private void initialize()
> {
> setInputFile("test.txt");
> ....
>
> AnotherComposite comp = new AnotherComposite(...);
> comp.setInputFile(getInputFile());
> ....
>
> AnotherComposite comp1 = new AnotherComposite1(...);
> comp1.setInputFile(getInputFile());
> }
> }
>
> class MyComposite extends Composite
> {
> public void setInputFile(..) {..}
>
> public String getInputFile() {....}
> }
>
> Jeff Myers wrote:
>
>> Hung,
>>
>> You can follow the pattern that's used to load images - by creating a
>> url that's relative to the location of the class. For instance you
>> can use composite.setInputFile(getClass().getResource("/input.txt")),
>> then use a URLInputStream to open that url to read the file. This has
>> the additional advantage of working if you package the resource along
>> with your classes into a jar file.
>>
>> Hope this helps,
>> - Jeff
--
Thanks,
Rich Kulp
|
|
|
|
Re: Internally setting value of a property [message #614562 is a reply to message #130109] |
Fri, 18 August 2006 14:15 |
Eclipse User |
|
|
|
Originally posted by: richkulp.us.NO_SPAM.ibm.com
It won't work. We don't "execute" the class being edited. We interpret
it. We can't run because it is being edited, you can only run a class
that is saved and compiled. Because of this we can't run arbitrary
methods in the class being edited. getInputFile() is an arbitrary
method. It isn't a bean that we know anything about.
If you dropped the class on another class then it would be executed
because we executed used classes since that class has been saved and
compiled.
--
Thanks,
Rich Kulp
|
|
|
Powered by
FUDForum. Page generated in 0.03910 seconds