public <T extends Element>T setAttributeValue(QName qname, String value) { internal.setAttributeValue(qname, value); return (T)this; }
public <T extends Element> T setAttributeValue(QName qname, String value) { internal.setAttributeValue(qname, value); return (T)this; }
public <T extends Element> T setAttributeValue(String name, String value) { internal.setAttributeValue(name, value); return (T)this; }
public <T extends Element>T setAttributeValue(String name, String value) { internal.setAttributeValue(name, value); return (T)this; }
public StreamBuilder writeAttribute( String name, String namespace, String prefix, String value) { if (!(current instanceof Element)) throw new IllegalStateException("Not currently an element"); ((Element)current).setAttributeValue(getQName(name, namespace, prefix), value); return this; }
public StreamBuilder writeAttribute(String name, String namespace, String prefix, String value) { if (!(current instanceof Element)) throw new IllegalStateException("Not currently an element"); ((Element)current).setAttributeValue(getQName(name, namespace, prefix), value); return this; }
/** * Set the value of dir attribute */ public static <T extends Element> void setDirection(Direction direction, T element) { if (direction != Direction.UNSPECIFIED) element.setAttributeValue(DIR, direction.toString().toLowerCase()); else if (direction == Direction.UNSPECIFIED) element.setAttributeValue(DIR, ""); else if (direction == null) element.removeAttribute(DIR); }
private static void setPositionAttributes(Element pos, Position position) { if (pos != null) { if (position.getFeatureTypeTag() != null) pos.setAttributeValue("featuretypetag", position.getFeatureTypeTag()); if (position.getRelationshipTag() != null) pos.setAttributeValue("relationshiptag", position.getRelationshipTag()); if (position.getElevation() != null) pos.setAttributeValue("elev", position.getElevation().toString()); if (position.getFloor() != null) pos.setAttributeValue("floor", position.getFloor().toString()); if (position.getRadius() != null) pos.setAttributeValue("radius", position.getRadius().toString()); } }
@Override protected void runTest() throws Throwable { Element element = abdera.getFactory().newElement(new QName("test")); QName qname = new QName("urn:test", "attr", "p"); element.setAttributeValue(qname, "value"); assertThat(element.getAttributes()).containsExactly(qname); element.setAttributeValue(qname, null); assertThat(element.getAttributes()).isEmpty(); } }
public Collection addAccepts(Map<String, String> mediaRanges) { complete(); if (mediaRanges != null) { for (Map.Entry<String, String> entry : mediaRanges.entrySet()) { if (!accepts(entry.getKey())) { try { Element accept = addSimpleExtension(ACCEPT, new MimeType(entry.getKey()).toString()); if (entry.getValue() != null) { accept.setAttributeValue(ALTERNATE, entry.getValue()); } } catch (Exception e) { } } } } return this; } }
@Override protected void runTest() throws Throwable { Element element = abdera.getFactory().newElement(new QName("test")); element.setAttributeValue(qname, "value"); assertThat(element.getAttributeValue(qname)).isEqualTo("value"); List<QName> attrs = element.getAttributes(); assertThat(attrs).hasSize(1); QName actualQName = attrs.get(0); assertThat(actualQName).isEqualTo(qname); assertThat(actualQName.getPrefix()).isEqualTo(qname.getPrefix()); } }
@Override protected void runTest() throws Throwable { Factory factory = abdera.getFactory(); Element element = factory.newElement(new QName("test")); element.setAttributeValue("attr", "value"); Object xpathResult = abdera.getXPath().selectSingleNode("./@attr", element); assertThat(xpathResult).isInstanceOf(Attribute.class); assertThat(((Attribute)xpathResult).getFactory()).isSameAs(factory); } }
public Collection setAccept(Map<String, String> mediaRanges) { complete(); if (mediaRanges != null && mediaRanges.size() > 0) { _removeChildren(ACCEPT, true); _removeChildren(PRE_RFC_ACCEPT, true); if (mediaRanges.size() == 1 && mediaRanges.keySet().iterator().next().equals("")) { addExtension(ACCEPT); } else { for (Map.Entry<String, String> entry : mediaRanges.entrySet()) { if (entry.getKey().equalsIgnoreCase("entry")) { addSimpleExtension(ACCEPT, "application/atom+xml;type=entry"); } else { try { Element accept = addSimpleExtension(ACCEPT, new MimeType(entry.getKey()).toString()); if (entry.getValue() != null) { accept.setAttributeValue(ALTERNATE, entry.getValue()); } } catch (javax.activation.MimeTypeParseException e) { throw new org.apache.abdera.util.MimeTypeParseException(e); } } } } } else { _removeChildren(ACCEPT, true); _removeChildren(PRE_RFC_ACCEPT, true); } return this; }