Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

OOP Passing parameter back

 
Roberto Gonsales
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody, I need some help. I'm writing program which takes bunch of text files with different charset encoding and converts these files to another one charset. My program is almost done, but one key thing. How do I pass 'charset' parameter of Notify method in CharsetDetector class back to Converter class?



 
Greg Charles
Sheriff
Posts: 2984
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not clear on when or why your notify() method is called, but I think the most logical way to get the results of detectCharset() into your converter would be to return it from detectCharset().

A couple of extra suggestions:

1. Wrap your reader and writer in BufferedReader and BufferedWriter and you'll see a dramatic increase in performance.
2. Learn the capitalization conventions for Java. Classes and Interfaces should start with a capital. Methods and variables start with lowercase. Following conventions like these make your code much more readable.
 
Roberto Gonsales
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greg, thank you for reply. I changed code in accordance with your recommendations to use BufferedReader and BufferedWriter.
Interface nsICharsetDetectionObserver is part of jChardet library. nsDetector fires the Notify() method between nsDetector.DoIt() and nsDetector.DataEnd() calls. I changed CharsetDetector class to get result only in Notify() method. So how do I get the result back to Converter class?

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic