private String formatAttribute(final Tag tag) { StringBuilder sb = new StringBuilder(); sb.append(tag.getName().getLocalPart()); sb.append(" "); for (Map.Entry<QName, String> attr : tag.getAttributes().entrySet()) { sb.append(attr.getKey()); sb.append("=\""); sb.append(attr.getValue()); sb.append("\" "); } return sb.toString().trim(); }
private String formatAttribute(final Tag tag) { StringBuilder sb = new StringBuilder(); sb.append(tag.getName().getLocalPart()); sb.append(" "); for (Map.Entry<QName, String> attr : tag.getAttributes().entrySet()) { sb.append(attr.getKey()); sb.append("=\""); sb.append(attr.getValue()); sb.append("\" "); } return sb.toString().trim(); }
public int hashCode() { return getName().hashCode() + getAttributes().hashCode(); }
public int hashCode() { return getName().hashCode() + getAttributes().hashCode(); }
public boolean equals(Object object) { if (object == null) { return false; } if (!(object instanceof Tag)) { return false; } if (object == this) { return true; } Tag tag = (Tag) object; if (!getName().equals(tag.getName())) { return false; } for (QName attr : getAttributes().keySet()) { if (getIgnoreAttr().contains(attr.getLocalPart()) || getIgnoreAttr().contains(getName().getLocalPart() + "@" + attr.getLocalPart())) { continue; } if (!tag.getAttributes().containsKey(attr)) { return false; } if (!tag.getAttributes().get(attr).equals(getAttributes().get(attr))) { return false; } } return true; } }
public boolean equals(Object object) { if (object == null) { return false; } if (!(object instanceof Tag)) { return false; } if (object == this) { return true; } Tag tag = (Tag) object; if (!getName().equals(tag.getName())) { return false; } for (QName attr : getAttributes().keySet()) { if (getIgnoreAttr().contains(attr.getLocalPart()) || getIgnoreAttr().contains(getName().getLocalPart() + "@" + attr.getLocalPart())) { continue; } if (!tag.getAttributes().containsKey(attr)) { return false; } if (!tag.getAttributes().get(attr).equals(getAttributes().get(attr))) { return false; } } return true; } }
private String formatTag(Tag tag, int indent) { StringBuilder sb = new StringBuilder(); sb.append(createIndent(indent)); sb.append(indent); sb.append("<"); sb.append(formatAttribute(tag)); sb.append(">"); if (tag.getParent() != null) { sb.append(" (" + tag.getParent().getName().getLocalPart() + ")"); } if (text != null) { sb.append(text); } sb.append("\n"); if (tag.getTags().size() > 0) { indent++; for (Tag subTag : tag.getTags()) { sb.append(formatTag(subTag, indent)); } } return sb.toString(); }
private String formatTag(Tag tag, int indent) { StringBuilder sb = new StringBuilder(); sb.append(createIndent(indent)); sb.append(indent); sb.append("<"); sb.append(formatAttribute(tag)); sb.append(">"); if (tag.getParent() != null) { sb.append(" (" + tag.getParent().getName().getLocalPart() + ")"); } if (text != null) { sb.append(text); } sb.append("\n"); if (tag.getTags().size() > 0) { indent++; for (Tag subTag : tag.getTags()) { sb.append(formatTag(subTag, indent)); } } return sb.toString(); }
protected void assertTagEquals(Tag expected, Tag source, final List<String> ignoreAttr, final List<String> ignoreTag) { if (!expected.getName().equals(source.getName())) { throw new ComparisonFailure("Tags not equal: ", expected.getName().toString(), source.getName().toString()); assertAttributesEquals(expected.getName(), expected.getAttributes(), source.getAttributes(), ignoreAttr); assertAttributesEquals(expected.getName(), source.getAttributes(), expected.getAttributes(), ignoreAttr); if (ignoreTag.contains(expectedTag.getName().getLocalPart()) && expectedTag.getTags().isEmpty()) { continue;
protected void assertTagEquals(Tag expected, Tag source, final List<String> ignoreAttr, final List<String> ignoreTag) { if (!expected.getName().equals(source.getName())) { throw new ComparisonFailure("Tags not equal: ", expected.getName().toString(), source.getName().toString()); assertAttributesEquals(expected.getName(), expected.getAttributes(), source.getAttributes(), ignoreAttr); assertAttributesEquals(expected.getName(), source.getAttributes(), expected.getAttributes(), ignoreAttr); if (ignoreTag.contains(expectedTag.getName().getLocalPart()) && expectedTag.getTags().isEmpty()) { continue;