Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Problem with a return with SAX

 
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I have an XML file that contains a file layout, say <fieldname> and <fieldsize>
Lets say I do my parsing in a class called FileLayout and in my main() - in another program - I do,
FileLayout fl = new FileLayout();
.
.
and then parse the file..
while parsing, I do
The nameTable and sizeTable are Vectors and in FileLayout, I have a getFieldNames that return nameTable
The problem is that unless I declare these two vectors static, the return statement returns null.
Whats going wrong here ?
 
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can you post the FileLayout class. Am not very clear as to why that should happen.
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
a small remark here that's probably not the solution to you original problem, but what the hell...
In SAX a DefaultHandler doesn't garantee to read the characters between a start and end tag in one go. For example, if you've got '<moviename>The Terminator</moviename>', depending on the parser implementation, you can have one characters()-event giving you "The Terminator" but you can just as well have 6 character()-events that give you "Th", "e T", "erm", "in", "a", "tor".
Bottom line: don't perform your string adding in the characters()event but just append it to a StringBuffer there and the process the content of the buffer in the endElement()-event.
Just something I wanted to say,
Raf
The Angry Belgian
 
Maky Chopra
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Karthik, here's the class..
 
Our first order of business must be this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic