Java Reference
In-Depth Information
description = text;
}
else if (event.getType() == Xml.END_TAG) {
parser.read (Xml.END_TAG, "", "story");
break;
}
else throw new RuntimeException ("unexpected event:
"+event);
}
}
if (title !=null){
descriptions.addElement
(description !=null ?description
:title);
newsList.append (title,null);
}
}
public void startApp() {
if (display == null) {
display = Display.getDisplay (this);
newsList.setCommandListener(this);
textBox.setCommandListener(this);
textBox.addCommand (backCmd);
new ReadThread().start();
}
display.setCurrent (newsList);
}
public void pauseApp() {
}
public void commandAction (Command c, Displayable d) {
if (c == List.SELECT_COMMAND) {
String text = (String) descriptions.elementAt
(newsList.getSelectedIndex());
if (textBox.getMaxSize() < text.length())
textBox.setMaxSize (text.length());
textBox.setString (text);
display.setCurrent (textBox);
}
else if (c == backCmd)
display.setCurrent (newsList);
}
public void destroyApp (boolean really) {
}
}
In the example, the run() method of the ReadThread class connects to the server and creates an
XmlParser object from the corresponding input stream. Then the XML processing instruction and
whitespace at the beginning of the document are skipped using the skip() method. After the
Search WWH ::




Custom Search