@Override public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { if ("message".equals(qName)) { entry = new EntryImpl(); for (int i = 0; i < atts.getLength(); i++) { if ("time".equals(atts.getQName(i))) { try { entry.setTime(EmpathyParser.TIME_FORMAT.parse(atts.getValue(i))); } catch (ParseException ex) { LOG.log(Level.SEVERE, ex.getLocalizedMessage(), ex); } } if ("name".equals(atts.getQName(i))) { entry.setName(atts.getValue(i)); } if ("type".equals(atts.getQName(i))) { entry.setType(atts.getValue(i)); } if ("id".equals(atts.getQName(i))) { entry.setId(atts.getValue(i)); } } } }
@Override public void characters(char[] chars, int start, int length) throws SAXException { if (entry == null) { return; } StringBuilder sb = new StringBuilder(); for (int i = start; i < (start + length); i++) { sb.append(chars[i]); } entry.setMessage(sb.toString()); this.writer.writerEntry(entry, chat); entry = null; }