/** * Generates a single element on the parent by using this path. This * will follow the path to its end, and then use that same element content * as the returned element, after wrapping it with the correct key (id). * * elements along it. */ public Element generateSingle(Element parent, ElementMetadata<?, ?> parentMetadata, ElementMetadata<?, ?> metadata) { Preconditions.checkState(path.selectsElement(), "An attribute path cannot be used to generate elements."); Element element = getFinalElement(path, parent); if (element == null) { return null; } try { ElementKey<?, ?> realKey = mergeKeys( element.getElementKey(), metadata.getKey()); return Element.createElement(realKey, element); } catch (ContentCreationException e) { throw new IllegalArgumentException("Invalid metadata", e); } }
/** * Generates a single element on the parent by using this path. This * will follow the path to its end, and then use that same element content * as the returned element, after wrapping it with the correct key (id). * * elements along it. */ public Element generateSingle(Element parent, ElementMetadata<?, ?> parentMetadata, ElementMetadata<?, ?> metadata) { Preconditions.checkState(path.selectsElement(), "An attribute path cannot be used to generate elements."); Element element = getFinalElement(path, parent); if (element == null) { return null; } try { ElementKey<?, ?> realKey = mergeKeys( element.getElementKey(), metadata.getKey()); return Element.createElement(realKey, element); } catch (ContentCreationException e) { throw new IllegalArgumentException("Invalid metadata", e); } }
/** * Generates a single element on the parent by using this path. This * will follow the path to its end, and then use that same element content * as the returned element, after wrapping it with the correct key (id). * * elements along it. */ public Element generateSingle(Element parent, ElementMetadata<?, ?> parentMetadata, ElementMetadata<?, ?> metadata) { Preconditions.checkState(path.selectsElement(), "An attribute path cannot be used to generate elements."); Element element = getFinalElement(path, parent); if (element == null) { return null; } try { ElementKey<?, ?> realKey = mergeKeys( element.getElementKey(), metadata.getKey()); return Element.createElement(realKey, element); } catch (ContentCreationException e) { throw new IllegalArgumentException("Invalid metadata", e); } }
/** * Generate a text value through the path. If the path ends in an element, * the value will be the text content of the final element. If the path * ends in an attribute, the value will be the value of that attribute. */ public Object generate(Element element, ElementMetadata<?, ?> metadata) { Path bound = path.toAbsolute(metadata); element = getFinalElement(bound, element); if (element == null) { return null; } // Generate the value at the end of the path. if (bound.selectsAttribute()) { return generateAttributeValue(element, bound.getSelectedElement(), bound.getSelectedAttributeKey(), bound.getSelectedAttribute()); } else { return generateTextValue(element, bound.getSelectedElement()); } }
/** * Generate a text value through the path. If the path ends in an element, * the value will be the text content of the final element. If the path * ends in an attribute, the value will be the value of that attribute. */ public Object generate(Element element, ElementMetadata<?, ?> metadata) { Path bound = path.toAbsolute(metadata); element = getFinalElement(bound, element); if (element == null) { return null; } // Generate the value at the end of the path. if (bound.selectsAttribute()) { return generateAttributeValue(element, bound.getSelectedElement(), bound.getSelectedAttributeKey(), bound.getSelectedAttribute()); } else { return generateTextValue(element, bound.getSelectedElement()); } }
/** * Generate a text value through the path. If the path ends in an element, * the value will be the text content of the final element. If the path * ends in an attribute, the value will be the value of that attribute. */ public Object generate(Element element, ElementMetadata<?, ?> metadata) { Path bound = path.toAbsolute(metadata); element = getFinalElement(bound, element); if (element == null) { return null; } // Generate the value at the end of the path. if (bound.selectsAttribute()) { return generateAttributeValue(element, bound.getSelectedElement(), bound.getSelectedAttributeKey(), bound.getSelectedAttribute()); } else { return generateTextValue(element, bound.getSelectedElement()); } }