/** * Parses a single element using this path. This will follow the path until * the second to last element on the path, and then parse into the final * element using the real parent instead of the path's parent. * * elements along it. */ public void parse(Element parent, ElementMetadata<?, ?> parentMetadata, Element element, ElementMetadata<?, ?> metadata) throws ParseException { Preconditions.checkState(path.selectsElement(), "An attribute path cannot be used to parse elements."); parent = createParentElement(path, parent); ElementKey<?, ?> lastKey = path.getSelectedElementKey(); try { Element child = Element.createElement(lastKey, element); parent.addElement(child); } catch (ContentCreationException e) { throw new ParseException(e); } }
/** * Parses a single element using this path. This will follow the path until * the second to last element on the path, and then parse into the final * element using the real parent instead of the path's parent. * * elements along it. */ public void parse(Element parent, ElementMetadata<?, ?> parentMetadata, Element element, ElementMetadata<?, ?> metadata) throws ParseException { Preconditions.checkState(path.selectsElement(), "An attribute path cannot be used to parse elements."); parent = createParentElement(path, parent); ElementKey<?, ?> lastKey = path.getSelectedElementKey(); try { Element child = Element.createElement(lastKey, element); parent.addElement(child); } catch (ContentCreationException e) { throw new ParseException(e); } }
/** * Parses a single element using this path. This will follow the path until * the second to last element on the path, and then parse into the final * element using the real parent instead of the path's parent. * * elements along it. */ public void parse(Element parent, ElementMetadata<?, ?> parentMetadata, Element element, ElementMetadata<?, ?> metadata) throws ParseException { Preconditions.checkState(path.selectsElement(), "An attribute path cannot be used to parse elements."); parent = createParentElement(path, parent); ElementKey<?, ?> lastKey = path.getSelectedElementKey(); try { Element child = Element.createElement(lastKey, element); parent.addElement(child); } catch (ContentCreationException e) { throw new ParseException(e); } }
/** * Travels along the path, creating any elements that don't exist until it * gets to the final key. If the final key is an element, it creates that * element if necessary and returns it. If the final key is an attribute, it * returns the parent of that attribute. */ static Element createFinalElement(Path path, Element rootElement) throws ParseException { Element parent = createParentElement(path, rootElement); if (path.selectsAttribute() || parent == null) { return parent; } ElementKey<?, ?> childKey = path.getSelectedElementKey(); Element child = parent.getElement(childKey); if (child == null) { try { child = Element.createElement(childKey); parent.addElement(child); } catch (ContentCreationException e) { throw new ParseException(e); } } return child; }
/** * Travels along the path, creating any elements that don't exist until it * gets to the final key. If the final key is an element, it creates that * element if necessary and returns it. If the final key is an attribute, it * returns the parent of that attribute. */ static Element createFinalElement(Path path, Element rootElement) throws ParseException { Element parent = createParentElement(path, rootElement); if (path.selectsAttribute() || parent == null) { return parent; } ElementKey<?, ?> childKey = path.getSelectedElementKey(); Element child = parent.getElement(childKey); if (child == null) { try { child = Element.createElement(childKey); parent.addElement(child); } catch (ContentCreationException e) { throw new ParseException(e); } } return child; }
/** * Travels along the path, creating any elements that don't exist until it * gets to the final key. If the final key is an element, it creates that * element if necessary and returns it. If the final key is an attribute, it * returns the parent of that attribute. */ static Element createFinalElement(Path path, Element rootElement) throws ParseException { Element parent = createParentElement(path, rootElement); if (path.selectsAttribute() || parent == null) { return parent; } ElementKey<?, ?> childKey = path.getSelectedElementKey(); Element child = parent.getElement(childKey); if (child == null) { try { child = Element.createElement(childKey); parent.addElement(child); } catch (ContentCreationException e) { throw new ParseException(e); } } return child; }