0

有人在我的代码中看到什么奇怪的东西吗?这是存储解析器实例的解析器工厂类。我在文本文件中保存了数据库中通常格式的信息对象

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

etc.

我有解析这个文本文件的类,解析器可以解析不同的行。例如,如果行开始 /table/ 我将选择调用 getParser("table") 的表解析器。当我想解析视图时,我遇到了一些问题。我试图通过在 Eclipse 中调试来找到它,但它说我找不到源并在调试中的操作列表中显示类未找到异常..但程序中没有异常..

当我按 F5 跳转到 ParserFactory 的构造函数时会发生这种情况。
有这个类的代码:

/**
 * 
 */
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;
    }
}

编辑: 我有类似的问题(类似的输出 - 意味着找不到源)。 Eclipse 调试“找不到源”

4

1 回答 1

0

我尝试在我的 Eclipse 版本上复制该问题,但无法复制。我在 Eclipse JUNO,OSX 山狮。

我修改了你的代码来测试它:

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();
    }
}
于 2012-08-03T22:14:04.480 回答