for (ProtocolDocumentOperation.Component.KeyValuePair pair : c.getElementStart().getAttributeList()) { attributesMap.put(pair.getKey(), pair.getValue()); for (ProtocolDocumentOperation.Component.KeyValuePair pair : c.getDeleteElementStart().getAttributeList()) { attributesMap.put(pair.getKey(), pair.getValue()); for (ProtocolDocumentOperation.Component.KeyValuePair pair : c.getReplaceAttributes().getOldAttributeList()) { oldAttributesMap.put(pair.getKey(), pair.getValue()); newAttributesMap.put(pair.getKey(), pair.getValue());
@Override public void replaceAttributes(Attributes oldAttributes, Attributes newAttributes) { ProtocolDocumentOperation.Component.ReplaceAttributes.Builder r = ProtocolDocumentOperation.Component.ReplaceAttributes.newBuilder(); if (oldAttributes.isEmpty() && newAttributes.isEmpty()) { r.setEmpty(true); } else { for (String name : oldAttributes.keySet()) { r.addOldAttribute(ProtocolDocumentOperation.Component.KeyValuePair.newBuilder() .setKey(name).setValue(oldAttributes.get(name)).build()); } for (String name : newAttributes.keySet()) { r.addNewAttribute(ProtocolDocumentOperation.Component.KeyValuePair.newBuilder() .setKey(name).setValue(newAttributes.get(name)).build()); } } output.addComponent(newComponentBuilder().setReplaceAttributes(r.build()).build()); }
private ProtocolDocumentOperation.Component.ElementStart makeElementStart( String type, Attributes attributes) { ProtocolDocumentOperation.Component.ElementStart.Builder e = ProtocolDocumentOperation.Component.ElementStart.newBuilder(); e.setType(type); for (String name : attributes.keySet()) { e.addAttribute(ProtocolDocumentOperation.Component.KeyValuePair.newBuilder() .setKey(name).setValue(attributes.get(name)).build()); } return e.build(); }