I finally finished my XML parsing code, and now looking at it, it scares me. This code is for a simple Android-based, text adventure game.
I have all my data about encounters, locations, and characters stored in XML files in the 'res' folder.
I coded this XML parser to go through the XML files and store data into a class called Encounter. I can then access the data inside Encounter anywhere in my code.
So I guess I got the OOP part down. But the actual parsing just looks so messy.
Is there a better way to go about parsing XML data?
Here is my code:
public class XmlParser extends Activity {
private String xmlValue;
private int encounterID;
Encounter encounter;
public XmlParser()
throws XmlPullParserException, IOException
{
XmlPullParser xpp = getResources().getXml(R.xml.encounters);
int eventType = xpp.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
String elName = xpp.getName();
if(eventType == XmlPullParser.START_TAG) { //creature
eventType = xpp.next();
//top level nodes
if(xpp.getName().equalsIgnoreCase("identity")){
eventType = xpp.next();
if(elName.equalsIgnoreCase("name")) {
encounter.name = xpp.getText();
} else if(elName.equalsIgnoreCase("race")) {
encounter.race = xpp.getText();
} else if(elName.equalsIgnoreCase("gender")) {
encounter.gender = xpp.getText();
} else if(elName.equalsIgnoreCase("alignment")) {
encounter.alignment = xpp.getText();
} else if(elName.equalsIgnoreCase("age")) {
try {
encounter.age = Integer.parseInt(xpp.getText());
} catch (NumberFormatException e) {
//ok
}
}
} else if (xpp.getName().equalsIgnoreCase("appearance")) {
eventType = xpp.next();
if(elName.equalsIgnoreCase("condition")){
encounter.condition = xpp.getText();
} else if(elName.equalsIgnoreCase("skinColor")) {
encounter.skinColor = xpp.getText();
} else if(elName.equalsIgnoreCase("hairColor")) {
encounter.hairColor = xpp.getText();
} else if(elName.equalsIgnoreCase("size")) {
encounter.size = xpp.getText();
} else if(elName.equalsIgnoreCase("height")) {
encounter.height = xpp.getText();
} else if(elName.equalsIgnoreCase("weight")) {
encounter.weight = xpp.getText();
}
} else if (xpp.getName().equalsIgnoreCase("stats")) {
eventType = xpp.next();
if(elName.equalsIgnoreCase("hitPoints")) {
try {
encounter.HP = Integer.parseInt(xpp.getText());
} catch (NumberFormatException e) {
//ok
}
} else if(elName.equalsIgnoreCase("armorClass")) {
try {
encounter.AC = Integer.parseInt(xpp.getText());
} catch (NumberFormatException e) {
//ok
}
} else if(elName.equalsIgnoreCase("actionPoints")) {
try {
encounter.AP = Integer.parseInt(xpp.getText());
} catch (NumberFormatException e) {
//ok
}
} else if(elName.equalsIgnoreCase("magicPoint")) {
try {
encounter.AP = Integer.parseInt(xpp.getText());
} catch (NumberFormatException e) {
//ok
}
} else if(elName.equalsIgnoreCase("strength")) {
try {
encounter.strength = Integer.parseInt(xpp.getText());
} catch (NumberFormatException e) {
//ok
}
} else if(elName.equalsIgnoreCase("dexterity")) {
try {
encounter.dexterity = Integer.parseInt(xpp.getText());
} catch (NumberFormatException e) {
//ok
}
} else if(elName.equalsIgnoreCase("intelligence")) {
try {
encounter.intelligence = Integer.parseInt(xpp.getText());
} catch (NumberFormatException e) {
//ok
}
}
} else if (xpp.getName().equalsIgnoreCase("inventory")) {
eventType = xpp.next();
if(elName.equalsIgnoreCase("weapon")) {
encounter.weapon = xpp.getText();
} else if(elName.equalsIgnoreCase("armor")) {
encounter.armor = xpp.getText();
} else if(elName.equalsIgnoreCase("magicItem")) {
encounter.magicItem = xpp.getText();
}
} else if (xpp.getName().equalsIgnoreCase("magic")) {
eventType = xpp.next();
if(elName.equalsIgnoreCase("attackSpell")) {
encounter.attackSpell = xpp.getText();
} else if(elName.equalsIgnoreCase("defenseSpell")) {
encounter.defenseSpell = xpp.getText();
}
} else if (xpp.getName().equalsIgnoreCase("treasureItems")) {
eventType = xpp.next();
if(elName.equalsIgnoreCase("item1")) {
encounter.item1 = xpp.getText();
} else if(elName.equalsIgnoreCase("item2")) {
encounter.item2 = xpp.getText();
}
}
} else if(eventType == XmlPullParser.END_TAG) {
//System.out.println("End tag "+xpp.getName());
}
eventType = xpp.next();
}
//System.out.println("End document");
}
In case anyone is interested, here is my XML file for encounters:
<?xml version="1.0" encoding="UTF-8"?>
<encounters>
<creature id="1" type="monster">
<identity>
<name></name>
<race></race>
<gender></gender>
<age></age>
<alignment></alignment>
</identity>
<appearance>
<condition></condition>
<skinColor></skinColor>
<hairColor></hairColor>
<size></size>
<height></height>
<weight></weight>
</appearance>
<stats>
<hitPoints></hitPoints>
<armorClass></armorClass>
<actionPoints></actionPoints>
<magicPoints></magicPoints>
<strength></strength>
<dexterity></dexterity>
<intelligence></intelligence>
</stats>
<inventory>
<weapon></weapon>
<armor></armor>
<magicItem></magicItem>
</inventory>
<magic>
<attackSpell></attackSpell>
<defenseSpell></defenseSpell>
</magic>
<treasureItems>
<item1></item1>
<item2></item2>
</treasureItems>
</creature>
When dealing with XML that has a direct object mapping, as in your case, I usually tend to use a marshalling technology. The most standard nowadays is JAXB. However it add quite a bit overhead (aprox 9 megs) to your application, which is not negligible in a mobile application. In this case a more lightweight marshalling API such as simple, can have a niche.
You can check out VTD-XML, the lightweight library works
excellent with android (the larger does too, but it is much larger in filesize).
There is also the SAX-parser that comes with android.
Other than that, when I use the XmlPullParser, I usually have a map with the tagnames as keys and integers, then I can just get the value from the map and then use a simple switch, which clears up the code a bit:
//Before parsing, or if used frequently the map can be put outside the method and reused:
final HashMap<String, Integer> tags = new HashMap<String, Integer>(9, 1);
tags.put("encounters", 0);
tags.put("identity", 1);
tags.put("name", 2);
//And so on...
//in your parse-loop:
int tag = tags.get(xpp.getName());
switch(tag){
case 0: //Handle encounter tag...
break;
case 1: //Handle identity tag...
break;
case 2: //Handle name tag...
break;
//For all tags.
}
Related
Let's imagine that we have to call one method from different classes by definition coming at run time. For example we receive JSON like this:
{"calculator": "MyClass1", "parameter1": 1.0, "parameter2": 2.0, ... }
MyClass1 and more classes either extend some base class or implement some interface (just to be able to enumerate them at run time). We have to create object, pass the parameters to the object and call calculate() method.
I can think of two ways to do this:
switch(calculatorString) { case "MyClass1": calculator = new MyClass1(); ...
using Java Reflection
The first way is really stupid because the code must be updated each time new calculator class is added to the project. The second way is slightly better, but the IDE is unable to catch any type errors we make while creating the objects and invoking the method.
Are there other ways to do this (possibly better)?
You could maybe use the Java Service Provider Interface:
See for example here:
https://docs.oracle.com/javase/tutorial/sound/SPI-intro.html
https://www.baeldung.com/java-spi
It allows for different implementations/services that you implement (you still need class names in the services files) but don't have to use reflection directly.
You define the service providers in the META-INF
META-INF/services/com.baeldung.rate.spi.ExchangeRateProvider
Your services can register themselves and if you allow them to use the input json, you will be very flexible.
Reflection is the best way to create object at runtime, but its all depend on usecase.
You can also use factory design pattern for object Creation.
Using ReflectionAPI
try {
cls = Class.forName(className);
instance = cls.newInstance();
instance = BeanUtils.populateBean(properties, cls);
} catch (Exception e) {
e.printStackTrace();
}
BeanUtil Class
public static Object populateBean(Map<String, Object> propertyMap, Class<?> clazz) throws Exception {
PropertyUtilsBean bean = new PropertyUtilsBean();
Object obj = null;
try {
obj = clazz.newInstance();
for(Map.Entry<String, Object> entrySet: propertyMap.entrySet()) {
PropertyDescriptor descriptor = null;
try {
descriptor =
bean.getPropertyDescriptor(obj, entrySet.getKey());
if (descriptor == null) {
continue;
}
Method writeMethod = bean.getWriteMethod(descriptor);
writeMethod.invoke(obj, convert(descriptor.getPropertyType(), entrySet.getValue(), DATE_PATTERN));
} catch (IncompatibleConversion e) {
throw e;
} catch (Exception e) {
throw new Exception("Unable to parse");
}
}
}catch(Exception e) {
throw e;
}
return obj;
}
Convert Class
private static Object convert(Class<?> clzz, Object value, String datePattern) throws Exception {
if (clzz.isAssignableFrom(BigInteger.class)) {
if (value == null) {
return value;
}
if (value instanceof BigInteger) {
return value;
}
try {
return new BigInteger(value.toString());
} catch (Exception e) {
throw new IncompatibleConversion(e);
}
} else if (clzz.isAssignableFrom(BigDecimal.class)) {
if (value == null) {
return value;
}
if (value instanceof BigDecimal) {
return parseBigDecimal(value.toString(), DECIMAL_PRECISION);
}
try {
return parseBigDecimal(value.toString(), DECIMAL_PRECISION);
} catch (Exception e) {
throw new IncompatibleConversion(e);
}
} else if (clzz.isAssignableFrom(Integer.class)) {
if (value == null) {
return value;
}
if (value instanceof Integer) {
return value;
}
try {
return new Integer(value.toString());
} catch (Exception e) {
throw new IncompatibleConversion(e);
}
} else if (clzz.isAssignableFrom(Long.class)) {
if (value == null) {
return value;
}
if (value instanceof Long) {
return value;
}
try {
return new Long(value.toString());
} catch (Exception e) {
throw new IncompatibleConversion(e);
}
} else if (clzz.isAssignableFrom(String.class)) {
if (value == null) {
return value;
}
if (value instanceof String) {
return value;
}
try {
return value.toString();
} catch (Exception e) {
throw new IncompatibleConversion(e);
}
} else if (clzz.isAssignableFrom(Date.class)) {
if (value == null) {
return value;
}
if (value instanceof Date) {
return value;
}
if (datePattern == null) {
throw new Exception("date pattern cannot be null");
}
try {
SimpleDateFormat sdf = new SimpleDateFormat(datePattern);
return sdf.parse(value.toString());
} catch (Exception e) {
throw new IncompatibleConversion(e);
}
} else if (clzz.isAssignableFrom(Byte.class)) {
if (value == null) {
return value;
}
if (value instanceof Byte) {
return (value);
} else if (value instanceof Number) {
return new Byte(((Number) value).byteValue());
}
try {
return (new Byte(value.toString()));
} catch (Exception e) {
throw new IncompatibleConversion(e);
}
} else if (clzz.isAssignableFrom(Float.class)) {
if (value == null) {
return value;
}
if (value instanceof Float) {
return (value);
}
try {
return new Float(value.toString());
} catch (Exception e) {
throw new IncompatibleConversion(e);
}
} else if (clzz.isAssignableFrom(Double.class)) {
if (value == null) {
return value;
}
if (value instanceof Double) {
return (value);
}
try {
return new Double(value.toString());
} catch (Exception e) {
throw new IncompatibleConversion(e);
}
}
throw new Exception("Incompactible Conversion");
}
how can I search a data using binary search? When if statement begins, the program goes to IOException block. It seems that it doesn't try to read the file.
public void busquedaDicotomica1(String clave)
{
String lectura1=null, lectura2=null ;
long posicion;
long tamaño;
long midValue;
boolean valido = true;
try
{
rafObj = new RandomAccessFile("indice1.ind","r");
tamaño = rafObj.length();
midValue = tamaño/2;
rafObj.seek(midValue);
if(clave.equalsIgnoreCase(rafObj.readUTF()))
{
System.out.println("ok");
}
else
{
System.out.println("no");
}
}
catch(EOFException eoe)
{}
catch(FileNotFoundException nfe)
{
VentanaPrincipal.setErrorText(dialogo);
}
catch(IOException ioe)
{
VentanaPrincipal.setErrorText(ioe.getMessage());
}
}
}
I'm a Java (Android) beginner (coming from Python) and I'm trying to catch an exception using Try-Catch as follows:
try {
u.save();
} catch (Exception e) {
Log.wtf("DO THIS", " WHEN SAVE() FAILS");
}
To my surprise I don't see my Log message but I still get the following error:
09-25 10:53:32.147: E/SQLiteDatabase(7991):
android.database.sqlite.SQLiteConstraintException: error code 19:
constraint failed
Why doesn't it catch the Exception? Am I doing something wrong here? All tips are welcome!
The save() method looks as follows:
public final void save() {
final SQLiteDatabase db = Cache.openDatabase();
final ContentValues values = new ContentValues();
for (Field field : mTableInfo.getFields()) {
final String fieldName = mTableInfo.getColumnName(field);
Class<?> fieldType = field.getType();
field.setAccessible(true);
try {
Object value = field.get(this);
if (value != null) {
final TypeSerializer typeSerializer = Cache.getParserForType(fieldType);
if (typeSerializer != null) {
// serialize data
value = typeSerializer.serialize(value);
// set new object type
if (value != null) {
fieldType = value.getClass();
// check that the serializer returned what it promised
if (!fieldType.equals(typeSerializer.getSerializedType())) {
Log.w(String.format("TypeSerializer returned wrong type: expected a %s but got a %s",
typeSerializer.getSerializedType(), fieldType));
}
}
}
}
// TODO: Find a smarter way to do this? This if block is necessary because we
// can't know the type until runtime.
if (value == null) {
values.putNull(fieldName);
}
else if (fieldType.equals(Byte.class) || fieldType.equals(byte.class)) {
values.put(fieldName, (Byte) value);
}
else if (fieldType.equals(Short.class) || fieldType.equals(short.class)) {
values.put(fieldName, (Short) value);
}
else if (fieldType.equals(Integer.class) || fieldType.equals(int.class)) {
values.put(fieldName, (Integer) value);
}
else if (fieldType.equals(Long.class) || fieldType.equals(long.class)) {
values.put(fieldName, (Long) value);
}
else if (fieldType.equals(Float.class) || fieldType.equals(float.class)) {
values.put(fieldName, (Float) value);
}
else if (fieldType.equals(Double.class) || fieldType.equals(double.class)) {
values.put(fieldName, (Double) value);
}
else if (fieldType.equals(Boolean.class) || fieldType.equals(boolean.class)) {
values.put(fieldName, (Boolean) value);
}
else if (fieldType.equals(Character.class) || fieldType.equals(char.class)) {
values.put(fieldName, value.toString());
}
else if (fieldType.equals(String.class)) {
values.put(fieldName, value.toString());
}
else if (fieldType.equals(Byte[].class) || fieldType.equals(byte[].class)) {
values.put(fieldName, (byte[]) value);
}
else if (ReflectionUtils.isModel(fieldType)) {
values.put(fieldName, ((Model) value).getId());
}
else if (ReflectionUtils.isSubclassOf(fieldType, Enum.class)) {
values.put(fieldName, ((Enum<?>) value).name());
}
}
catch (IllegalArgumentException e) {
Log.e(e.getClass().getName(), e);
}
catch (IllegalAccessException e) {
Log.e(e.getClass().getName(), e);
}
}
if (mId == null) {
mId = db.insert(mTableInfo.getTableName(), null, values);
}
else {
db.update(mTableInfo.getTableName(), values, "Id=" + mId, null);
}
Cache.getContext().getContentResolver()
.notifyChange(ContentProvider.createUri(mTableInfo.getType(), mId), null);
}
There are two classes to catch the problems.
Error
Exception
Both are sub-class of Throwable class. When there is situation we do not know, that particular code block will throw Exception or Error? You can use Throwable. Throwable will catch both Errors & Exceptions.
Do this way
try {
u.save();
} catch (Throwable e) {
e.printStackTrace();
}
Constraint failed usually indicates that you did something like pass a null value into a column that you declare as not null when you create your table.
do this way
try {
// do some thing which you want in try block
} catch (JSONException e) {
e.printStackTrace();
Log.e("Catch block", Log.getStackTraceString(e));
}
Try
try {
u.save();
} catch (SQLException sqle) {
Log.wtf("DO THIS", " WHEN SAVE() FAILS");
}catch (Exception e) {
Log.wtf("DO THIS", " WHEN SAVE() FAILS");
}
Log is expecting certain variable-names like verbose(v), debug(d) or info(i).
Your "wtf" doesnt belong there. Check this answer for more info -->
https://stackoverflow.com/a/10006054/2074990
or this:
http://developer.android.com/tools/debugging/debugging-log.html
I was doing a project in JAVA Swing Netbeans IDE 7.1. I created one jFrame with some button and Dropdowns on it. On selecting a choice from the dropdown,another frame object is created and setVisible is set to true. But instead of showing one window, it is showing up 2 windows. There are other similar calls, but none have this issue, someone please help me. Thanks.
Code:
private void itemListItemStateChanged(java.awt.event.ItemEvent evt) {
String item = null;
String filename = null;
item = (String) itemList.getSelectedItem();
if(item=="P"){
filename="p";
description.setText("Description: P");
}
else if(item=="A"){
filename="a";
description.setText("Description: A");
}
else if(item=="R"){
filename="r";
description.setText("Description: R");
}
else if(item=="S"){
filename="s";
description.setText("Description: S");
}
else if(item=="X"){
displayText.setText("");
x xl = new x();
xl.setVisible(true);
}
else if(item=="Xx"){
filename="xx";
description.setText("Description: xx");
}
else {
System.out.println("invalid selection.");
}
if (item=="X"){
return;
}
else {
displayText.setText("");
BufferedReader b = null;
try {
b= new BufferedReader(new FileReader ("/home/sfred/"+filename+".mile"));
} catch (FileNotFoundException ex) {
ex.printStackTrace();
}
try {
line = b.readLine();
} catch (IOException ex) {
ex.printStackTrace();
}
while (line != null){
displayText.append(line + "\n");
try {
line=b.readLine();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
See The Use of Multiple JFrames, Good/Bad Practice? rather use :
1) JDialog
2) CardLayout which will allow you to flip between multiple components on a single JFrame.
You cannot compare String using ==operator must use equals(String s) or else it wont evaluate correctly
if(item.equals("X")) {
}
Rather use switch statement (Java 7+) when comparing String:
switch(item) {
case "P":
//do something
break;
case "X":
//do something
break;
default:
//if no match with above was found..
break;
}
Currently I have a ready design for blackberry application.
Now, I need to call the web service in my app, and that web service will give me some xml response.
So, I need to parse that response from xml to some POJO.
So, for parsing the xml response should I go with the basic DOM praser, or should I use any other J2ME specific prasing concept ?
If anybody have any sample tutorial link for the same then it would be very much useful to me.
Thanks in advance....
It depends on what your web service serves.
If it is REST-based, you're likely responsible to parse the XML yourself, with a library. I've only ever used kXml 2, a J2ME library that can be used on BlackBerry devices. To use it, it's best to link to the source (otherwise, you have to preverify the jar and export it and that never seems to work for me). It's a forward-only pull parser, similar to XmlReader in .NET, if you're familiar with that.
If your web service is WS*-based (i.e. it uses SOAP), you can use a stub generator to generate a client class that you can use. BlackBerry supports JSR 172, the web services API for J2ME. The WTK has a stub generator that works well. Just point the generator to your web service's wsdl file. A web search should clarify how to use it.
Add your xml file data in to strXML
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
InputStream inputStream = new ByteArrayInputStream(strXML.getBytes("UTF-8"));
Document document = builder.parse( inputStream );
Element rootElement = document.getDocumentElement();
rootElement.normalize();
blnViewReport=false;
listNodes(rootElement); // use this function to parse the xml
inputStream.close();
void listNodes(Node node)
{
Node tNode;
String strData;
String nodeName = node.getNodeName();
if( nodeName.equals("Tagname"))
{
tNode=node.getFirstChild();
if(tNode.getNodeType() == Node.TEXT_NODE)
{
// here you get the specified tag value
}
}
else if(nodeName.equals(“Tag name 2”))
.....
.....
NodeList list = node.getChildNodes();
if(list.getLength() > 0)
{
for(int i = 0 ; i<list.getLength() ; i++)
{
listNodes(list.item(i));
}
}
}
I believe that you have recieved the request object.
I will give the code I used to parse the request object from XML.
_value is the object
System.out.println("value="+_value);
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser parser = null; // create a parser
try {
parser = factory.newSAXParser();
}
catch (ParserConfigurationException e1)
{
System.out.println("ParserConfigurationException"+e1.getMessage());
}
catch (SAXException e1)
{
System.out.println("SAXException"+e1.getMessage());
}
// instantiate our handler
PharmacyDataXMLHandler pharmacydataXMLHandler= new PharmacyDataXMLHandler();
ByteArrayInputStream objBAInputStream = new java.io.ByteArrayInputStream(_value.getBytes());
InputSource inputSource = new InputSource(objBAInputStream);
// perform the synchronous parse
try {
parser.parse(inputSource, pharmacydataXMLHandler);
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
_pharmacydataList = pharmacydataXMLHandler.getpharmacydataList();
}
public class PharmacyDataXMLHandler extends DefaultHandler
{
private Vector _pharmacyDataList = new Vector();
PharmacyData _pharmacydata;
StringBuffer _sb = null;
public void warning(SAXParseException e) {
System.err.println("warning: " + e.getMessage());
}
public void error(SAXParseException e) {
System.err.println("error: " + e.getMessage());
}
public void fatalError(SAXParseException e) {
System.err.println("fatalError: " + e.getMessage());
}
public void startElement(String uri, String localName, String name,
Attributes attributes) throws SAXException {
try{
_sb = new StringBuffer("");
if(localName.equals("Table"))
{
_pharmacydata= new PharmacyData();
}
}catch (Exception e) {
System.out.println(""+e.getMessage());
}
}
public void endElement(String namespaceURI, String localName, String qName) throws SAXException
{
try{
if(localName.equals("ID"))
{
// System.out.println("Id :"+sb.toString());
this._pharmacydata.setId(_sb.toString());
}
else if(localName.equals("Name"))
{
//System.out.println("name :"+sb.toString());
this._pharmacydata.setName(_sb.toString());
}
else if(localName.equals("PharmacyID"))
{
// System.out.println("pharmacyId :"+sb.toString());
this._pharmacydata.setPharmacyId(_sb.toString());
}
else if(localName.equals("Password"))
{
// System.out.println("password :"+sb.toString());
this._pharmacydata.setPassword(_sb.toString());
}
else if(localName.equals("Phone"))
{
// System.out.println("phone:"+sb.toString());
this._pharmacydata.setPhone(_sb.toString());
}
else if(localName.equals("Transmit"))
{
//System.out.println("transmit"+sb.toString());
this._pharmacydata.setTransmit(_sb.toString());
}
else if(localName.equals("TimeZone"))
{
// System.out.println("timeZone"+sb.toString());
this._pharmacydata.setTimeZone(_sb.toString());
}
else if(localName.equals("FaxModem"))
{
// System.out.println("faxModem"+sb.toString());
this._pharmacydata.setFaxModem(_sb.toString());
}
else if(localName.equals("VoicePhone"))
{
// System.out.println("voicePhone"+sb.toString());
this._pharmacydata.setVoicePhone(_sb.toString());
}
else if(localName.equals("ZipCode"))
{
// System.out.println("zipCode"+sb.toString());
this._pharmacydata.setZipCode(_sb.toString());
}
else if(localName.equals("Address"))
{
// System.out.println("address"+sb.toString());
this._pharmacydata.setAddress(_sb.toString());
}
else if(localName.equals("City"))
{
// System.out.println("city"+sb.toString());
this._pharmacydata.setCity(_sb.toString());
}
else if(localName.equals("State"))
{
// System.out.println("state"+sb.toString());
this._pharmacydata.setState(_sb.toString());
}
else if(localName.equals("WebInterface"))
{
// System.out.println("webInterface"+sb.toString());
this._pharmacydata.setWebInterface(_sb.toString());
}
else if(localName.equals("NABPnumber"))
{
// System.out.println("nabPnumber"+sb.toString());
this._pharmacydata.setNabPnumber(_sb.toString());
}
else if(localName.equals("ServiceType"))
{
// System.out.println("serviceType:"+sb.toString());
this._pharmacydata.setServiceType(_sb.toString());
}
else if(localName.equals("Mobile"))
{
// System.out.println("mobile:"+sb.toString());
this._pharmacydata.setMobile(_sb.toString());
}
else if(localName.equals("Table"))
{
// System.out.println("end table:"+sb.toString());
_pharmacyDataList.addElement(_pharmacydata);
}
}catch (Exception e) {
System.out.println(""+e.getMessage());
}
}
public void characters(char ch[], int start, int length) {
String theString = new String(ch, start, length);
_sb.append(theString);
}
/**
* #return the PharmacyDataList
*/
public Vector getpharmacydataList()
{
return _pharmacyDataList;
}
}