@Override public ImmutableMap<String, String> getAttributes() { final ImmutableMap.Builder<String, String> result = ImmutableMap.builder(); final NamedNodeMap attribs = element.getAttributes(); for (int i = 0; i < attribs.getLength(); i++) { final Attr attrib = (Attr) attribs.item(i); result.put(attrib.getName(), attrib.getValue()); } return result.build(); }
@Override @SuppressWarnings( { "cast", "unchecked" } ) protected Map<String, String> getAttributesAsMap( Element element ) { NamedNodeMap nodes = element.getAttributes(); int length = nodes.getLength(); if ( length == 0 ) { return (Map<String, String>) Collections.EMPTY_MAP; } Map<String, String> attributes = new HashMap<String, String>( length ); for ( int loop = 0; loop < length; loop++ ) { Node node = nodes.item( loop ); attributes.put( node.getNodeName(), node.getNodeValue() ); } return attributes; } }