?? prescriptionxmlparser.java
字號:
package bible.ejb.message.prescription;
import org.xml.sax.*;
import org.xml.sax.helpers.*;
import java.io.*;
import java.util.*;
import java.text.ParseException;
//import common.*;
public class PrescriptionXmlParser extends DefaultHandler {
private Prescription prescription = new Prescription();
// Buffer for collecting data from
// the "characters" SAX event.
private CharArrayWriter contents = new CharArrayWriter();
public void startElement( String namespaceURI,
String localName,
String qName,
Attributes attr ) throws SAXException {
contents.reset();
}
public void endElement( String namespaceURI,
String localName,
String qName ) throws SAXException{
try {
if ( localName.equals( "physician_id" ) ) {
prescription.setPhysicianId(Integer.parseInt(contents.toString()));
}
if ( localName.equals( "patient_id" ) ) {
prescription.setPatientId(Integer.parseInt(contents.toString()));
}
if ( localName.equals( "note" ) ) {
prescription.setNote(contents.toString());
}
if ( localName.equals( "drug" ) ) {
prescription.setDrug(contents.toString());
}
} catch ( Exception p)
{ System.out.println(" Here" + p.toString());
}
}
public void characters( char[] ch, int start, int length )
throws SAXException {
contents.write( ch, start, length );
}
public Prescription getPrescription() {
return prescription;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -