0

does anyone see anything strange in my code? This is parser factory class which store instances of parsers. I have in text file saved informations objects in database usualy in format

/table/something/something
nameoftablecolumn/info/info/...

etc.

I have class for parsing this text file, the parsers can parse different lines. For example if the line starts /table/ i'll choose table parser calling getParser("table"). When I want to parse the views, I have some problem. I tried to find it by debuging in Eclipse, but It says me that source is not found and shows class not found exception in list of actions in debuging .. but no exception in program ..

This happens when I jump by F5 to the constructor of ParserFactory.
There is code of this class:

/**
 * 
 */
package appInspector.input.parser;

import java.util.HashMap;


import appInspector.input.parser.database.SourceParser;
import appInspector.input.parser.database.TableParser;
import appInspector.input.parser.database.ViewParser;
import appInspector.input.parser.filesystem.DirectoryParser;
import appInspector.input.parser.filesystem.FileParser;

/**
 *     
 */
public class ParserFactory {


    private HashMap<String, IParser> parsers = new HashMap<String, IParser>();

    private ParserFactory() {
        //filesystem
        parsers.put("directory", new DirectoryParser());
        parsers.put("file", new FileParser());
        //table
        parsers.put("table", new TableParser());
        //view
        parsers.put("view", new ViewParser());
        //source
        parsers.put("source", new SourceParser());
    }

    public static ParserFactory newInstance(){
        return new ParserFactory();
    }

    public IParser getParser(String key) {
        IParser parser = parsers.get(key);
        if(parser == null ){
            System.out.println("Nepodporovaný objekt");

        }
        return parser;
    }
}

EDIT: I have similar problem like there (similar output - mean the source not found). Eclipse debugging "source not found"

Community
  • 1
  • 1
user1097772
  • 3,499
  • 15
  • 59
  • 95

1 Answers1

0

I tried replicating the issue on my version of Eclipse but was not able to. I am on Eclipse JUNO, OSX Mountain Lion.

I modified your code a bit to test it :

package com.aj.spring;

import java.util.HashMap;

/**
 *  *  
 */
public class ParserFactory {

    private HashMap<String, IParser> parsers = new HashMap<String, IParser>();

    private ParserFactory() {
        parsers.put("directory", new FileParser());
        parsers.put("file", new FileParser());
        parsers.put("table", new FileParser());
        parsers.put("view", new FileParser());
        parsers.put("source", new FileParser());
    }

    public static ParserFactory newInstance() {
        return new ParserFactory();
    }

    public IParser getParser(String key) {
        IParser parser = parsers.get(key);
        if (parser == null) {
            System.out.println("Nepodporovan objekt");

        }
        return parser;
    }

    public static void main(String[] args) {
        ParserFactory.newInstance();
    }
}
Ashutosh Jindal
  • 18,501
  • 4
  • 62
  • 91