2012-08-03 78 views
0

没有人在我的代码中看到任何奇怪的东西吗? 这是存储解析器实例的解析器工厂类。我在文本文件中保存的信息对象数据库usualy格式
在调试时找不到消息源

/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 debugging "source not found"

回答

0

我试图在我的Eclipse版本上复制问题,但无法执行。我在Eclipse JUNO,OSX Mountain Lion上。

我修改代码中的位进行测试:

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(); 
    } 
}