Search in sources :

Example 1 with DictionaryXMLHandler

use of com.zhan_dui.dictionary.handlers.DictionaryXMLHandler in project little-bear-dictionary by daimajia.

the class QueryProcessor method parseConfigureXML.

private DictionaryParseInfomation parseConfigureXML(String childDir, String xmlPath) throws ParserConfigurationException, SAXException, IOException {
    DictionaryParseInfomation dictionaryParseInfomation;
    if (mCacheXMLInformation.containsKey(xmlPath)) {
        dictionaryParseInfomation = mCacheXMLInformation.get(xmlPath);
    } else {
        SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
        SAXParser saxParser = saxParserFactory.newSAXParser();
        DictionaryXMLHandler dictionaryXMLHandler = new DictionaryXMLHandler();
        String xmlFilePath = Constants.getSaveDirectory() + File.separator + childDir + File.separator + xmlPath;
        saxParser.parse(new File(xmlFilePath), dictionaryXMLHandler);
        dictionaryParseInfomation = dictionaryXMLHandler.getResults();
        mCacheXMLInformation.put(xmlPath, dictionaryParseInfomation);
    }
    return dictionaryParseInfomation;
}
Also used : SAXParser(javax.xml.parsers.SAXParser) DictionaryXMLHandler(com.zhan_dui.dictionary.handlers.DictionaryXMLHandler) SpannableString(android.text.SpannableString) File(java.io.File) SAXParserFactory(javax.xml.parsers.SAXParserFactory)

Aggregations

SpannableString (android.text.SpannableString)1 DictionaryXMLHandler (com.zhan_dui.dictionary.handlers.DictionaryXMLHandler)1 File (java.io.File)1 SAXParser (javax.xml.parsers.SAXParser)1 SAXParserFactory (javax.xml.parsers.SAXParserFactory)1