my dog learned polymorphism*
The moose likes Java in General and the fly likes Trying to figure out why Im getting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Trying to figure out why Im getting "cannot be resolved" error" Watch "Trying to figure out why Im getting "cannot be resolved" error" New topic
Author

Trying to figure out why Im getting "cannot be resolved" error

Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

I have a class with the following:



Right now method is underlined and it says method cannot be resolved. So my first question I guess is what class should method be in? Is it going to be in either DeviceCollection or DeviceCOllectionXMLAO, or should it be in the class where I have the method from above. I have a few classes with method (method is an instance of httpclient getmethod btw) in it, bu not sure where it is wanting method to come from in the code above. Im assuming there is only going to be one option with method being where it is in that code.


True wisdom is in knowing you know nothing - Socrates
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

The way you are using "method", it can either be a local variable, a static variable, or the name of a class. It can't be resolved because it is none of those (that is in scope).

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

Any idea of how it intended to be used here lol?

my DeviceCollection is just a list<> of devices with setters and getters. readXML is my method to read some xml froma web service. So I would think method would be the name of a class here, because it looks like simplexml is reading the data from the GetMethod (method) as a Stream, and then binding it to the DeviceColelction list.

Trying to think this out by saying it, does it sound like Im on the right track with that? And if it is indeed supposed to be a class, where would that method class be? Would it be just a class I call method, or would it be a class within another class?
And how is my java supposed to know which class of method I am trying to use?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

Matt Kohanek wrote:Any idea of how it intended to be used here lol?


It is *your* program. You are supposed to design your application and then code it. It is silly to just code stuff, and then try to figure out what you originally intended to do.

Henry
Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

combined in reply
Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

Its a collaboration, actually - I did right the majority of code sure, but not this part...pretty silly I guess...

I mean I have a good idea of what it does. method is an instance of the httpclient getMethod, it is getting the response as a stream, then sent to the access object to parse. Then this value is set to deviceCollection.

Now I have a method called getDevice looking like this:



But I dont think that is what method is referring to here. What method is referring to is what I am trying to figure out. I know it has to be an instance of the getMethod, and I know that somehow it needs to use a url for the argument. So maybe it is this class?

Im gonna keep typing, maybe I can figure this out...

So method will have pre defined classes, such as .getResponseBodyAsStream...
So it is definitely an instance of GetMethod...
Now somehow it has to know that the getResponseBodyAsStream is getting this stream froma web service, that takes the form of xml...

OK, so that means there will have to be an instance of httpclient, and then an instance of GetMethod...
And then the GetMethod needs the url...

So maybe something like this:



That seems correct to me, it satisfies everything I just typed...
Now I cant figure out how to bind the deviceCollection to TreeNode data;
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Trying to figure out why Im getting "cannot be resolved" error