public void startElement( String uri, String localName, String qName, org.xml.sax.Attributes atts) throws SAXException { if (DICTIONARY_ELEMENT.equals(localName)) { mAttributes = new Attributes(); for (int i = 0; i < atts.getLength(); i++) { mAttributes.setValue(atts.getLocalName(i), atts.getValue(i)); } /* get the attribute here ... */ if (mAttributes.getValue(ATTRIBUTE_CASE_SENSITIVE) != null) { mIsCaseSensitiveDictionary = Boolean.valueOf(mAttributes.getValue(ATTRIBUTE_CASE_SENSITIVE)); } mAttributes = null; } else if (ENTRY_ELEMENT.equals(localName)) { mAttributes = new Attributes(); for (int i = 0; i < atts.getLength(); i++) { mAttributes.setValue(atts.getLocalName(i), atts.getValue(i)); } } else if (TOKEN_ELEMENT.equals(localName)) { mIsInsideTokenElement = true; } }
/** * Creates the Profile object after processing is complete and switches mIsInsideNgramElement * flag. */ public void endElement(String uri, String localName, String qName) throws SAXException { if (TOKEN_ELEMENT.equals(localName)) { mTokenList.add(token.toString().trim()); token.setLength(0); mIsInsideTokenElement = false; } else if (ENTRY_ELEMENT.equals(localName)) { String[] tokens = mTokenList.toArray(new String[mTokenList.size()]); Entry entry = new Entry(new StringList(tokens), mAttributes); try { mInserter.insert(entry); } catch (InvalidFormatException e) { throw new SAXException("Invalid dictionary format!", e); } mTokenList.clear(); mAttributes = null; } }