FileDocCategorySizeDatePackage
KmlParser.javaAPI DocAndroid 1.5 API7077Wed May 06 22:41:08 BST 2009com.android.ddmuilib.location

KmlParser

public class KmlParser extends Object
A very basic KML parser to meet the need of the emulator control panel.

It parses basic Placemark information.

Fields Summary
private static final String
NS_KML_2
private static final String
NODE_PLACEMARK
private static final String
NODE_NAME
private static final String
NODE_COORDINATES
private static final Pattern
sLocationPattern
private static SAXParserFactory
sParserFactory
private String
mFileName
private KmlHandler
mHandler
Constructors Summary
public KmlParser(String fileName)
Creates a new GPX parser for a file specified by its full path.

param
fileName The full path of the GPX file to parse.

        mFileName = fileName;
    
Methods Summary
public WayPoint[]getWayPoints()
Returns the parsed {@link WayPoint} objects, or null if none were found (or if the parsing failed.

        if (mHandler != null) {
            return mHandler.getWayPoints();
        }
        
        return null;
    
public booleanparse()
Parses the GPX file.

return
true if success.

        try {
            SAXParser parser = sParserFactory.newSAXParser();

            mHandler = new KmlHandler();

            parser.parse(new InputSource(new FileReader(mFileName)), mHandler);
            
            return mHandler.getSuccess();
        } catch (ParserConfigurationException e) {
        } catch (SAXException e) {
        } catch (IOException e) {
        } finally {
        }

        return false;