/** * Get the value of an attribute by id. */ public Object getAttributeValue(QName id) { if (state.attributes == null) { return null; } Attribute attribute = state.attributes.get(id); return (attribute == null) ? null : attribute.getValue(); }
/** * Get the value of an attribute by id. */ public Object getAttributeValue(QName id) { if (state.attributes == null) { return null; } Attribute attribute = state.attributes.get(id); return (attribute == null) ? null : attribute.getValue(); }
/** * Get the value of an attribute by id. */ public Object getAttributeValue(QName id) { if (state.attributes == null) { return null; } Attribute attribute = state.attributes.get(id); return (attribute == null) ? null : attribute.getValue(); }
/** * Remove attribute (if present). * * @param id the qualified name of the attribute. * @return this element */ public Object removeAttributeValue(QName id) { throwExceptionIfLocked(); Attribute removed = (state.attributes == null) ? null : state.attributes.remove(id); return (removed == null) ? null : removed.getValue(); }
/** * Remove attribute (if present). * * @param id the qualified name of the attribute. * @return this element */ public Object removeAttributeValue(QName id) { throwExceptionIfLocked(); Attribute removed = (state.attributes == null) ? null : state.attributes.remove(id); return (removed == null) ? null : removed.getValue(); }
/** * Remove attribute (if present). * * @param id the qualified name of the attribute. * @return this element */ public Object removeAttributeValue(QName id) { throwExceptionIfLocked(); Attribute removed = (state.attributes == null) ? null : state.attributes.remove(id); return (removed == null) ? null : removed.getValue(); }
/** * Returns the attribute value cast to the appropriate type, based on the * given key. * * @param <T> return type * @param key the attribute key to use to cast the attribute value * @return typed attribute value * @throws IllegalArgumentException if the value cannot be converted to the * key type */ public <T> T getAttributeValue(AttributeKey<T> key) { Attribute attribute = (state.attributes == null) ? null : state.attributes.get(key.getId()); Object value = (attribute == null) ? null : attribute.getValue(); if (value == null) { return null; } try { return ObjectConverter.getValue(value, key.getDatatype()); } catch (ParseException e) { throw new IllegalArgumentException("Unable to convert value " + e + " to datatype " + key.getDatatype()); } }
/** * Returns the attribute value cast to the appropriate type, based on the * given key. * * @param <T> return type * @param key the attribute key to use to cast the attribute value * @return typed attribute value * @throws IllegalArgumentException if the value cannot be converted to the * key type */ public <T> T getAttributeValue(AttributeKey<T> key) { Attribute attribute = (state.attributes == null) ? null : state.attributes.get(key.getId()); Object value = (attribute == null) ? null : attribute.getValue(); if (value == null) { return null; } try { return ObjectConverter.getValue(value, key.getDatatype()); } catch (ParseException e) { throw new IllegalArgumentException("Unable to convert value " + e + " to datatype " + key.getDatatype()); } }
/** * Returns the attribute value cast to the appropriate type, based on the * given key. * * @param <T> return type * @param key the attribute key to use to cast the attribute value * @return typed attribute value * @throws IllegalArgumentException if the value cannot be converted to the * key type */ public <T> T getAttributeValue(AttributeKey<T> key) { Attribute attribute = (state.attributes == null) ? null : state.attributes.get(key.getId()); Object value = (attribute == null) ? null : attribute.getValue(); if (value == null) { return null; } try { return ObjectConverter.getValue(value, key.getDatatype()); } catch (ParseException e) { throw new IllegalArgumentException("Unable to convert value " + e + " to datatype " + key.getDatatype()); } }
/** * Get a list of attributes for the given element. */ protected List<XmlWriter.Attribute> getAttributes(Element e, ElementMetadata<?, ?> metadata) { List<XmlWriter.Attribute> attrs = null; Iterator<Attribute> attributeIterator = e.getAttributeIterator(metadata); if (attributeIterator.hasNext()) { ElementKey<?, ?> key = e.getElementKey(); attrs = new ArrayList<XmlWriter.Attribute>(); while (attributeIterator.hasNext()) { Attribute attribute = attributeIterator.next(); AttributeKey<?> attKey = attribute.getAttributeKey(); AttributeMetadata<?> attMeta = (metadata == null) ? null : metadata.bindAttribute(attKey); QName qName = attMeta != null ? attMeta.getName() : attKey.getId(); String alias = (qName.getNs() != null) ? qName.getNs().getAlias() : null; attrs.add(new XmlWriter.Attribute(alias, qName.getLocalName(), attribute.getValue().toString())); } } return attrs; }
/** * Get a list of attributes for the given element. */ protected List<XmlWriter.Attribute> getAttributes(Element e, ElementMetadata<?, ?> metadata) { List<XmlWriter.Attribute> attrs = null; Iterator<Attribute> attributeIterator = e.getAttributeIterator(metadata); if (attributeIterator.hasNext()) { ElementKey<?, ?> key = e.getElementKey(); attrs = new ArrayList<XmlWriter.Attribute>(); while (attributeIterator.hasNext()) { Attribute attribute = attributeIterator.next(); AttributeKey<?> attKey = attribute.getAttributeKey(); AttributeMetadata<?> attMeta = (metadata == null) ? null : metadata.bindAttribute(attKey); QName qName = attMeta != null ? attMeta.getName() : attKey.getId(); String alias = (qName.getNs() != null) ? qName.getNs().getAlias() : null; attrs.add(new XmlWriter.Attribute(alias, qName.getLocalName(), attribute.getValue().toString())); } } return attrs; }
/** * Get a list of attributes for the given element. */ protected List<XmlWriter.Attribute> getAttributes(Element e, ElementMetadata<?, ?> metadata) { List<XmlWriter.Attribute> attrs = null; Iterator<Attribute> attributeIterator = e.getAttributeIterator(metadata); if (attributeIterator.hasNext()) { ElementKey<?, ?> key = e.getElementKey(); attrs = new ArrayList<XmlWriter.Attribute>(); while (attributeIterator.hasNext()) { Attribute attribute = attributeIterator.next(); AttributeKey<?> attKey = attribute.getAttributeKey(); AttributeMetadata<?> attMeta = (metadata == null) ? null : metadata.bindAttribute(attKey); QName qName = attMeta != null ? attMeta.getName() : attKey.getId(); String alias = (qName.getNs() != null) ? qName.getNs().getAlias() : null; attrs.add(new XmlWriter.Attribute(alias, qName.getLocalName(), attribute.getValue().toString())); } } return attrs; }
@Override public String toString() { ToStringHelper helper = Objects.toStringHelper(this); helper.addValue(getElementId() + "@" + Integer.toHexString(hashCode())); Iterator<Attribute> aIter = getAttributeIterator(); while (aIter.hasNext()) { Attribute att = aIter.next(); helper.add(att.getAttributeKey().getId().toString(), att.getValue()); } if (hasTextValue()) { helper.addValue(getTextValue()); } return helper.toString(); } }
@Override public String toString() { ToStringHelper helper = Objects.toStringHelper(this); helper.addValue(getElementId() + "@" + Integer.toHexString(hashCode())); Iterator<Attribute> aIter = getAttributeIterator(); while (aIter.hasNext()) { Attribute att = aIter.next(); helper.add(att.getAttributeKey().getId().toString(), att.getValue()); } if (hasTextValue()) { helper.addValue(getTextValue()); } return helper.toString(); } }
@Override public String toString() { ToStringHelper helper = Objects.toStringHelper(this); helper.addValue(getElementId() + "@" + Integer.toHexString(hashCode())); Iterator<Attribute> aIter = getAttributeIterator(); while (aIter.hasNext()) { Attribute att = aIter.next(); helper.add(att.getAttributeKey().getId().toString(), att.getValue()); } if (hasTextValue()) { helper.addValue(getTextValue()); } return helper.toString(); } }