private boolean elementMatch(Element element1, Element element2) { // TODO(ljvderijk): Elements should define their own equals method for each // different type, improvements to the ElementSerializer can also be made. return element1.getProperties().equals(element2.getProperties()); }
for (Entry<String, String> entry : src.getProperties().entrySet()) {
@Override public XmlStringBuilder toXml(Element element) { XmlStringBuilder res = XmlStringBuilder.createEmpty(); if (element.getProperties().containsKey("category")) { res.append(XmlStringBuilder.createEmpty().wrap( "category", "name", element.getProperty("category"))); if (element.getProperties().containsKey("title")) { res.append(XmlStringBuilder.createEmpty().wrap( "title", "value", element.getProperty("title"))); if (element.getProperties().containsKey("thumbnail")) { res.append(XmlStringBuilder.createEmpty().wrap( "thumbnail", "value", element.getProperty("thumbnail"))); for (Map.Entry<String, String> property : element.getProperties().entrySet()) { if (property.getKey().equals("category") || property.getKey().equals("url") || property.getKey().equals("title") || property.getKey().equals("thumbnail") || if (element.getProperties().containsKey("author")) { attributes.add("author"); attributes.add(element.getProperty("author")); if (element.getProperties().containsKey("ifr")) { attributes.add("ifr"); attributes.add(element.getProperty("ifr"));
@Override public JsonElement serialize(Element src, Type typeOfSrc, JsonSerializationContext context) { if (src.getType() == ElementType.ATTACHMENT) { src = new Element(ElementType.IMAGE, createImageProperties(src.getProperties())); } return super.serialize(src, typeOfSrc, context); }
@Override public XmlStringBuilder toXml(Element element) { XmlStringBuilder res = XmlStringBuilder.createEmpty(); // A cast would be nice here, but unfortunately the element // gets deserialized as an actual Element Line line = new Line(element.getProperties()); List<String> attributes = Lists.newArrayList(); if (!isEmptyOrWhitespace(line.getLineType())) { attributes.add("t"); attributes.add(line.getLineType()); } if (!isEmptyOrWhitespace(line.getIndent())) { attributes.add("i"); attributes.add(line.getIndent()); } if (!isEmptyOrWhitespace(line.getAlignment())) { attributes.add("a"); attributes.add(line.getAlignment()); } if (!isEmptyOrWhitespace(line.getDirection())) { attributes.add("d"); attributes.add(line.getDirection()); } String[] asArray = new String[attributes.size()]; attributes.toArray(asArray); return res.wrap(LineContainers.LINE_TAGNAME, asArray); }
for (Map.Entry<String, String> property : element.getProperties().entrySet()) {
Element result = null; if (FormElement.getFormElementTypes().contains(type)) { result = new FormElement(type, entry.getValue().getProperties()); } else if (type == ElementType.GADGET) { result = new Gadget(entry.getValue().getProperties()); } else if (type == ElementType.IMAGE) { result = new Image(entry.getValue().getProperties()); } else if (type == ElementType.LINE) { result = new Line(entry.getValue().getProperties()); } else { result = new Element(type, entry.getValue().getProperties());
@Override public XmlStringBuilder toXml(Element element) { XmlStringBuilder res = XmlStringBuilder.createEmpty(); if (element.getProperties().containsKey("attachmentId")) { if (element.getProperty(CAPTION_STR) != null) { res.append(XmlStringBuilder.createText(element.getProperty(CAPTION_STR)) .wrap("caption")); } return res.wrap("image", ATTACHMENT_STR, element.getProperty("attachmentId")); } return res; }
public void testElementTypeAndPropertyConstruction() { Map<String, String> properties = new HashMap<String, String>(); properties.put(NAME, VALUE); Element element = new Element(ElementType.GADGET, properties); assertEquals(ElementType.GADGET, element.getType()); assertEquals(1, element.getProperties().size()); assertEquals(VALUE, element.getProperty(NAME)); }
public void testElementTypeConstruction() { Element element = new Element(ElementType.BUTTON); assertEquals(ElementType.BUTTON, element.getType()); assertEquals(0, element.getProperties().size()); }
public void testElementTypeAndPropertyConstruction() { Map<String, String> properties = new HashMap<String, String>(); properties.put(NAME, VALUE); Element element = new Element(ElementType.GADGET, properties); assertEquals(ElementType.GADGET, element.getType()); assertEquals(1, element.getProperties().size()); assertEquals(VALUE, element.getProperty(NAME)); }
public void testElementTypeConstruction() { Element element = new Element(ElementType.BUTTON); assertEquals(ElementType.BUTTON, element.getType()); assertEquals(0, element.getProperties().size()); }