/** * Remove a single child element from this element. This method returns true * if the element was found and removed, or false if it was not. It uses * identity and not equality to find a match. * * @param element the child element to remove. * @return true if the child element was removed from this element. */ public boolean removeElement(Element element) { return removeElement(element.getElementKey(), element); }
/** * Remove a single child element from this element. This method returns true * if the element was found and removed, or false if it was not. It uses * identity and not equality to find a match. * * @param element the child element to remove. * @return true if the child element was removed from this element. */ public boolean removeElement(Element element) { return removeElement(element.getElementKey(), element); }
/** * Remove a single child element from this element. This method returns true * if the element was found and removed, or false if it was not. It uses * identity and not equality to find a match. * * @param element the child element to remove. * @return true if the child element was removed from this element. */ public boolean removeElement(Element element) { return removeElement(element.getElementKey(), element); }
/** * Sets a child element to the given value. Uses the element key of the * element as the key. This is equivalent to calling * {@code setElement(element.getElementKey(), element);}. * * @throws NullPointerException if element is null. */ public Element setElement(Element element) { Preconditions.checkNotNull(element); setElement(element.getElementKey(), element); return this; }
/** * Sets a child element to the given value. Uses the element key of the * element as the key. This is equivalent to calling * {@code setElement(element.getElementKey(), element);}. * * @throws NullPointerException if element is null. */ public Element setElement(Element element) { Preconditions.checkNotNull(element); setElement(element.getElementKey(), element); return this; }
/** * Sets a child element to the given value. Uses the element key of the * element as the key. This is equivalent to calling * {@code setElement(element.getElementKey(), element);}. * * @throws NullPointerException if element is null. */ public Element setElement(Element element) { Preconditions.checkNotNull(element); setElement(element.getElementKey(), element); return this; }
/** * Add a child element, using the key of the child element as the key into * this element's children. * * @param element child element * @return this element for chaining * @throws NullPointerException if element is null. */ public Element addElement(Element element) { Preconditions.checkNotNull(element); addElement(element.getElementKey(), element); return this; }
/** * Add a child element, using the key of the child element as the key into * this element's children. * * @param element child element * @return this element for chaining * @throws NullPointerException if element is null. */ public Element addElement(Element element) { Preconditions.checkNotNull(element); addElement(element.getElementKey(), element); return this; }
/** * Add a child element, using the key of the child element as the key into * this element's children. * * @param element child element * @return this element for chaining * @throws NullPointerException if element is null. */ public Element addElement(Element element) { Preconditions.checkNotNull(element); addElement(element.getElementKey(), element); return this; }
/** * Visit all of the children of this element, calling the element visitor * with the child element and child metadata for each child. */ private void visitChildren(ElementVisitor ev, ElementMetadata<?, ?> meta) throws ElementVisitor.StoppedException { // Visit children Iterator<Element> childIterator = getElementIterator(meta); while (childIterator.hasNext()) { Element child = childIterator.next(); ElementMetadata<?, ?> childMeta = (meta == null) ? null : meta.bindElement(child.getElementKey()); child.visit(ev, this, childMeta); } }
/** * Visit all of the children of this element, calling the element visitor * with the child element and child metadata for each child. */ private void visitChildren(ElementVisitor ev, ElementMetadata<?, ?> meta) throws ElementVisitor.StoppedException { // Visit children Iterator<Element> childIterator = getElementIterator(meta); while (childIterator.hasNext()) { Element child = childIterator.next(); ElementMetadata<?, ?> childMeta = (meta == null) ? null : meta.bindElement(child.getElementKey()); child.visit(ev, this, childMeta); } }
/** * Visit all of the children of this element, calling the element visitor * with the child element and child metadata for each child. */ private void visitChildren(ElementVisitor ev, ElementMetadata<?, ?> meta) throws ElementVisitor.StoppedException { // Visit children Iterator<Element> childIterator = getElementIterator(meta); while (childIterator.hasNext()) { Element child = childIterator.next(); ElementMetadata<?, ?> childMeta = (meta == null) ? null : meta.bindElement(child.getElementKey()); child.visit(ev, this, childMeta); } }
public void generate(Element element, ElementMetadata<?, ?> metadata) throws IOException { if (metadata != null && !metadata.getKey().equals(element.getElementKey())) { throw new IllegalStateException( "Element key (" + element.getElementKey() + ") does not match metadata key (" + metadata.getKey() + ")"); } try { element.visit(this, metadata); } catch (StoppedException se) { Throwable cause = se.getCause(); if (cause instanceof IOException) { throw (IOException) cause; } throw se; // unexpected } }
private void init(Object source) { if (source instanceof Element) { Element element = (Element) source; ElementKey<?, ?> key = element.getElementKey(); elementMetadata = getSchema().bind(key, getMetadataContext()); } else { elementMetadata = null; } }
public ClientOutputProperties(GDataRequest req, Object source) { super(req); if (source instanceof Element) { Element element = (Element) source; ElementKey<?, ?> key = element.getElementKey(); elementMetadata = getSchema().bind(key, getMetadataContext()); } else { elementMetadata = null; } }
@Override public void processEndElement() throws ParseException { if (value != null) { value = value.trim(); if (!value.equals("")) { ElementKey<?, ?> elementKey = element.getElementKey(); element.setTextValue( ObjectConverter.getValue(value, elementKey.getDatatype())); } } if (parentElement != null) { parentElement.addElement(element); } } }
@Override public void processEndElement() throws ParseException { if (value != null) { value = value.trim(); if (!value.equals("")) { ElementKey<?, ?> elementKey = element.getElementKey(); element.setTextValue( ObjectConverter.getValue(value, elementKey.getDatatype())); } } if (parentElement != null) { parentElement.addElement(element); } } }
@Override public void processEndElement() throws ParseException { if (value != null) { value = value.trim(); if (!value.equals("")) { ElementKey<?, ?> elementKey = element.getElementKey(); element.setTextValue( ObjectConverter.getValue(value, elementKey.getDatatype())); } } if (parentElement != null) { parentElement.addElement(element); } } }
private void init(Object source) { if (source instanceof Element) { Element element = (Element) source; ElementKey<?, ?> key = element.getElementKey(); elementMetadata = getSchema().bind(key, getMetadataContext()); } else { elementMetadata = null; } }
/** * Add a child element with the given ID. This will add the given element to * the end of the collection of elements with the same ID. If you want to * replace any existing elements use {@link #setElement(QName, Element)} * instead. * * @param id the qualified name to use for the child * @param element child element * @return this element for chaining * @throws NullPointerException if element is null. */ public Element addElement(QName id, Element element) { Preconditions.checkNotNull(element); addElement(ElementKey.of(id, element.getElementKey().getDatatype(), element.getClass()), element); return this; }