Code example for Attributes

Methods: getValue, toString

0
    @Override 
    public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
        validateStopped(); 
 
        if(qName.equals("piraso")) {
            id = attributes.getValue("id");
            watchedAddr = attributes.getValue("watched-address");
 
            fireEntryReadStartedEvent(new EntryReadEvent(this, id, watchedAddr));
        } else if(qName.equals("entry")) {
            try { 
                currentEntryClassName = attributes.getValue("class-name");
                currentEntryDate = mapper.readValue(attributes.getValue("date"), Date.class);
                currentEntryId = Long.valueOf(attributes.getValue("id"));
            } catch (Exception e) {
                LOG.warn(String.format("Unable to parse entry with attributes '%s'", attributes.toString()));
 
                currentEntryClassName = null;
                currentEntryDate = null; 
                currentEntryId = null;
            }