• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

If I use println to print out an input stream value, what should it look like?

 
Village Idiot
Posts: 484
jQuery Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Feel free to just answer my topic question or read on to get a more detailed version of what Im asking -



When I print out some values to see what they are I get:



The first line, responseBody is of the type InputStream
The second line deviceCollection of the type DeviceCollection, in teh deviceContainer - It is this line I am mainly concered with. It is a stream so I had no idea what to expect when I print it out, just as long as it wasnt null!! But I dont know what to make of printing deviceCollection: deviceContainer.DeviceCollection@1764be1 - does this mean I actually was able to bind the responseBody to deviceCollection as a stream? (through this line: deviceCollection = access.readXML(method.getResponseBodyAsStream(null));)

And the third line data is of the type TreeNode, but that line is pretty obvious



So Im unsure how to interpret this. The first line seems to suggest it is working correctly right, because it is calling an auto close method on the stream right? However when I change some things in that class and try to also print out responseBody as a String, I get:



I think this also might be OK though, because if Im right it is saying it received the data I wanted and printed it out as a string, but when it also tried to print it as the stream, the stream was already closed. I think this is what this means, please clear this up for me though. deviceCOllection form teh third line also changes to null when I do this, but I would guess that is also the result of the stream being auto closed right?

It is this second line that Im mainly concerned with. Im trying to bind the responseBody which is that xml to deviceCollection. It seems I was successful in that first bit up there right? Or am I misinterpreting?
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All I can tell from that is that there's a device collection--its validity can only be determined by someone that knows what's supposed to be in it, what it's supposed to do, etc.

I can create all manner of objects and get their default toString() representation--their internal state is a completely different issue.
 
Matt Kohanek
Village Idiot
Posts: 484
jQuery Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is the devicecollection class:



And the data that should be in deviceColelction is some xml froma web service:




I am trying to get it to this point, so I can then somehow bind the three nodes to a TreeNode, but I dont know hwo I am going to do so yet. One step at a time seeing as how Im learning a lot of this as I go


Is there a way I can see if the data contained therein is that xml I posted up there? I tried doing System.out.println("printing deviceCollection = access.readXML(method.getResponseBodyAsStream(null));: "
+ deviceCollection.toString());
but it gves me the exact same output as above. But I guess that is what you meant by it having a default toString representation. SO I guess I should say, is there a way for me to figure out what its internal state would be?
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Loop over the devices and print something known from each device?
 
Matt Kohanek
Village Idiot
Posts: 484
jQuery Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
EUreka I think it is working!



returnes:







Ok, so where does this leave me now?
So now I know deviceCollection contains the intended value...finally after three days
OK, so what am I needing it to do now...

I will have to type this out again to get my thoughts flowing..

So deviceCOllection is of type DeviceCollection, which is just private Collection<Device> devices; with setter and getter...
the value contained in deviceCollection is an InputStream and looks like:



I am needing to take the value of each child node and bind it to something (TreeNode I think) and then I can use that to populate my richfaces tree.

Hmm, so something similar to the code I used to check the values it was holding would seem appropriate since it did return the value I was wanting.

I think Im close now, its so nice. Such a love hate relationship with programming. Trying to figure it out your in the lowest lows but when something work it is the highest high
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic