Java: Why isn't this method recognized?
<p>I am having a problem where a method from another class is not being recognized as existing by Eclipse, even though all the other methods are. I have no idea why this is happening, and cannot figure it out. I get the error <code>The method getData() is undefined for the type TMXReader.TMXHandler</code> when I try doing this:</p>

<pre><code>package tiled.simple.reader;

import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;

import tiled.simple.core.Map;
import tiled.simple.core.MapLayer;
import tiled.simple.core.TileSet;
import davidiserovich.TMXLoader.TMXHandler;
import davidiserovich.TMXLoader.TileMapData;



TMXHandler handler = new TMXHandler();

handler.getData();
</code></pre>

<p>Here is the TMXHandler class:</p>

<pre><code>package davidiserovich.TMXLoader;

import java.util.HashMap;

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

//import android.sax.StartElementListener;

public class TMXHandler extends DefaultHandler {
    /*
     * This is an SAX2 XML parser that interprets the input TMX file and creates
     * a TileMapData object.
     */

    // NOTE: Map Object loading is not yet implemented

    // Markers for which tag we're in
    private boolean inTileSet, inTile, inLayer, inData, inObjectGroup,
            inProperties;

    // ID of the current tile that we're adding properties to.
    // This is actually an OFFSET from firstGID of the tile in
    // the tileset. Beware.
    private String currentTileID;
    private String currentObjectGroupName;
    TileMapData.TMXObject currentObject;

    TileMapData.TileSet currentTileSet;
    TileMapData.Layer currentLayer;

    HashMap&lt;String, HashMap&lt;String, String&gt;&gt; currentTileSetProperties;
    HashMap&lt;String, String&gt; currentLayerProperties;

    private TileMapData data;

    /*
     * These fields hold the buffer and data to help decode the long stream of
     * gids in the data field
     */
    private char buffer[];
    private int bufferIndex;
    private int currentX;
    private int currentY;
    public int MAX_INT_DECIMAL_LENGTH = 10;

    public TMXHandler() {
        super();
        buffer = new char[MAX_INT_DECIMAL_LENGTH];
        bufferIndex = 0;
        currentX = 0;
        currentY = 0;
    }

    public TileMapData getData() {
        return data;
    }

    @Override
    public void startDocument() throws SAXException {
        data = new TileMapData();
    }

    @Override
    public void endDocument() throws SAXException {

    }

    @Override
    public void startElement(String namespaceURI, String localName,
            String qName, Attributes atts) throws SAXException {
        if (localName.equals("map")) {
            // inMap = true;
            // Check that the orientation is orthogonal
            if (!(atts.getValue("orientation").equals("orthogonal"))) {
                throw new SAXException(
                        "Unsupported orientation. Parse Terminated.");
            }
            data.orientation = atts.getValue("orientation");
            data.height = Integer.parseInt(atts.getValue("height"));
            data.width = Integer.parseInt(atts.getValue("width"));
            data.tilewidth = Integer.parseInt(atts.getValue("tilewidth"));
            data.tileheight = Integer.parseInt(atts.getValue("tileheight"));

            // data.sectionId = atts.getValue("id");
        } else if (localName.equals("tileset")) {
            inTileSet = true;
            currentTileSet = new TileMapData.TileSet();
            currentTileSet.firstGID = Integer.parseInt(atts
                    .getValue("firstgid"));
            currentTileSet.tileWidth = Integer.parseInt(atts
                    .getValue("tilewidth"));
            currentTileSet.tileHeight = Integer.parseInt(atts
                    .getValue("tileheight"));
            currentTileSet.name = atts.getValue("name");
            currentTileSetProperties = new HashMap&lt;String, HashMap&lt;String, String&gt;&gt;();

        } else if (inTileSet &amp;&amp; localName.equals("image")) {
            currentTileSet.ImageFilename = atts.getValue("source");
            currentTileSet.imageWidth = Integer
                    .parseInt(atts.getValue("width"));
            currentTileSet.imageHeight = Integer.parseInt(atts
                    .getValue("height"));

        } else if (inTileSet &amp;&amp; localName.equals("tile")) {
            inTile = true;
            currentTileID = atts.getValue("id");

        } else if (inTile &amp;&amp; localName.equals("properties")) {
            inProperties = true;
            currentTileSetProperties.put(currentTileID,
                    new HashMap&lt;String, String&gt;());

        } else if (inLayer &amp;&amp; localName.equals("properties")) {
            inProperties = true;

        } else if (inTile &amp;&amp; inProperties &amp;&amp; localName.equals("property")) {
            (currentTileSetProperties.get(currentTileID)).put(
                    atts.getValue("name"), atts.getValue("value"));

        } else if (inLayer &amp;&amp; inProperties &amp;&amp; localName.equals("property")) {
            currentLayerProperties.put(atts.getValue("name"),
                    atts.getValue("value"));
        } else if (localName.equals("layer")) {
            inLayer = true;

            currentLayer = new TileMapData.Layer();
            currentLayer.name = atts.getValue("name");
            currentLayer.width = Integer.parseInt(atts.getValue("width"));
            currentLayer.height = Integer.parseInt(atts.getValue("height"));
            if (atts.getValue("opacity") != null)
                currentLayer.opacity = Double.parseDouble(atts
                        .getValue("opacity"));
            currentLayer.tiles = new long[currentLayer.height][currentLayer.width];

            currentLayerProperties = new HashMap&lt;String, String&gt;();

        } else if (localName.equals("data")) {
            /*
             * Data is loaded directly into the int array in characters() We
             * just check if the encoding is supported here.
             */
            inData = true;
            String encoding = atts.getValue("encoding");
            if (!encoding.equals("csv")) {
                throw new SAXException(
                        "Unsupported encoding. Parse Terminated.");
            }

        } else if (localName.equals("objectgroup")) {
            inObjectGroup = true;
            currentObjectGroupName = atts.getValue("name");

        } else if (localName.equals("object")) {
            currentObject = new TileMapData.TMXObject();
            currentObject.name = atts.getValue("name");
            currentObject.type = atts.getValue("type");
            currentObject.x = Integer.parseInt(atts.getValue("x"));
            currentObject.y = Integer.parseInt(atts.getValue("y"));
            currentObject.width = Integer.parseInt(atts.getValue("width"));
            currentObject.height = Integer.parseInt(atts.getValue("height"));
            if (inObjectGroup) {
                currentObject.objectGroup = currentObjectGroupName;
            } else {
                currentObject.objectGroup = null;
            }

        }
    }

    @Override
    public void endElement(String namespaceURI, String localName, String qName)
            throws SAXException {

        if (localName.equals("map")) {
            // inMap = false;

        } else if (localName.equals("tileset")) {
            inTileSet = false;
            currentTileSet.properties = currentTileSetProperties;
            currentTileSetProperties = null;
            data.tilesets.add(currentTileSet);
            currentTileSet = null; // Clear it just in case

        } else if (localName.equals("tile")) {
            inTile = false;
            currentTileID = "-1"; // -1 won't be produced when searching for
                                    // properties. Just a safeguard for
                                    // improperly formatted files.

        } else if (localName.equals("properties")) {
            inProperties = false;

        } else if (localName.equals("layer")) {
            inLayer = false;
            currentLayer.properties = currentLayerProperties;
            data.layers.add(currentLayer);
            currentLayer = null; // Clear it just in case
        } else if (localName.equals("data")) {
            inData = false;
            // In case we missed the last entry (no non-numeral chars before tag
            // end)
            if (bufferIndex &gt; 0) {
                currentLayer.tiles[currentY][currentX] = Long
                        .parseLong(new String(buffer, 0, bufferIndex));
            }
            // Clear buffer
            bufferIndex = 0;
            currentX = 0;
            currentY = 0;

        } else if (localName.equals("objectgroup")) {
            inObjectGroup = false;

        } else if (localName.equals("object")) {
            data.objects.add(currentObject);
        }
    }

    @Override
    public void characters(char ch[], int start, int length) {
        /*
         * Java has no unsigned types, so we have to use a long instead of an
         * int so we can "simulate" an unsigned int. Disgusting. Anyway, we're
         * going to add the numbers from the character stream to a buffer until
         * we hit a comma, at which point we empty the buffer and convert it to
         * a long, and dump it into the array. These are raw, so the horizontal
         * and vertical flip bits may be set - to get the actual GID number,
         * we'll use TileMapData's getGIDAt(x, y), which will mask it properly.
         */
        if (inData) {
            for (int i = 0; i &lt; length; i++) {
                if (ch[start + i] &lt;= '9' &amp;&amp; ch[start + i] &gt;= '0') {
                    buffer[bufferIndex] = ch[start + i];
                    // Log.d("Wrote to index", String.valueOf(bufferIndex));
                    bufferIndex++;

                } else {
                    // When we hit a comma or any non-number character, empty
                    // the buffer and enter the relevant
                    // GID into the data field
                    // int what = Integer.parseInt(new String(buffer, 0,
                    // bufferIndex));
                    // Log.d("Number", new String(buffer, 0, bufferIndex));
                    String nextNumber = new String(buffer, 0, bufferIndex);
                    if ((nextNumber != null) &amp;&amp; ((nextNumber.trim()) != "")
                            &amp;&amp; (bufferIndex != 0)) {
                        // Log.d("Checking", nextNumber + " yes");
                        currentLayer.tiles[currentY][currentX] = Long
                                .parseLong(nextNumber);
                        bufferIndex = 0;

                        // Move to the next tile
                        if (currentX &lt; (currentLayer.width - 1)) {
                            currentX++;

                        } else if (currentY &lt; (currentLayer.height - 1)) {
                            currentX = 0;
                            currentY++;
                        }
                    }
                }
            }
        }
    }
}
</code></pre>

<p>Auto-complete shows all the other methods as usable, but for some reason getData "doesn't exist"...</p>

<p>I'm sure this is apparent for experienced Java programmers, but I have no idea why this is happening... so if anyone could tell me why, I'd be grateful. Thanks!</p>
