private void skipChildrenOfNode(InputNode node) throws Exception { while(node.getNext() != null) { // Do nothing } }
public class KeyConverter implements Converter<Key> { private String otherValue; @Override public Key read(InputNode node) throws Exception { String elementValue = node.getNext("element").getValue().trim(); otherValue = node.getNext("other").getValue().trim(); return new Key(elementValue); } @Override public void write(OutputNode arg0, Key arg1) throws Exception { throw new UnsupportedOperationException(); } /** * @return the otherValue */ public String getOtherValue() { return otherValue; }
protected void readElements(InputNode input, T target, XmlReadContext context) throws Exception { InputNode node; while ((node = input.getNext()) != null) { readElement(node, target, context); } }
/** * This <code>validate</code> method will validate the XML element list * from the provided node and validate its children as entry types. * This will validate each entry type as a primitive value. In order * to do this the parent string provided forms the element. * * @param node this is the XML element that is to be validated * @param type this is the array type used to create the array * * @return true if the element matches the XML schema class given */ private boolean validate(InputNode node, Class type) throws Exception{ while(true) { InputNode next = node.getNext(); if(next == null) { return true; } root.validate(next); } }
/** * This <code>populate</code> method wll read the XML element list * from the provided node and deserialize its children as entry types. * This will deserialize each entry type as a primitive value. In * order to do this the parent string provided forms the element. * * @param node this is the XML element that is to be deserialized * @param result this is the collection that is to be populated * * @return this returns the item to attach to the object contact */ private Object populate(InputNode node, Object result) throws Exception { Collection list = (Collection) result; while(true) { InputNode next = node.getNext(); if(next == null) { return list; } list.add(root.read(next)); } }
@Override public <T> T readElement(InputNode input, String element, Class<T> type) { InputNode node; try { node = input.getNext(element); } catch (Exception exception) { throw new XmlPersisterException(format("Failed reading %s element from %s", element, input), exception); } return node != null ? read(node, type) : null; }
/** * This method is used to read the key value from the node. The * value read from the node is resolved using the template filter. * If the key value can not be found according to the annotation * attributes then the node is considered as null and is valid. * * @param node this is the node to read the key value from * @param key this is the name of the element used by the key * * @return this returns the value deserialized from the node */ private boolean validateElement(InputNode node, String key) throws Exception { String name = style.getElement(key); InputNode child = node.getNext(name); if(child == null) { return true; } return root.validate(child); }
/** * This method is used to validate the value from the node. The * value read from the node is resolved using the template filter. * If the value value can not be found according to the annotation * attributes then null is assumed and the node is valid. * * @param node this is the node to read the value object from * @param key this is the name of the node to be validated * * @return this returns true if the primitive key is valid */ private boolean validateElement(InputNode node, String key) throws Exception { String name = style.getAttribute(key); InputNode child = node.getNext(name); if(child == null) { return true; } return root.validate(node); }
/** * This method is used to read the key value from the node. The * value read from the node is resolved using the template filter. * If the key value can not be found according to the annotation * attributes then null is assumed and returned. * * @param node this is the node to read the key value from * @param key this is the name of the element used by the key * * @return this returns the value deserialized from the node */ private Object readElement(InputNode node, String key) throws Exception { String name = style.getElement(key); InputNode child = node.getNext(name); if(child == null) { return null; } return root.read(child); }
/** * This method is used to read the element value from the node. The * value read from the node is resolved using the template filter. * If the value value can not be found according to the annotation * attributes then null is assumed and returned. * * @param node this is the node to read the value object from * @param key this is the name of the value XML element * * @return this returns the value deserialized from the node */ private Object readElement(InputNode node, String key) throws Exception { String name = style.getAttribute(key); InputNode child = node.getNext(name); if(child == null) { return null; } return root.read(child); }
/** * This method is used to read the element value from the node. The * value read from the node is resolved using the template filter. * If the value value can not be found according to the annotation * attributes then null is assumed and returned. * * @param node this is the node to read the value object from * @param key this is the name of the value XML element * * @return this returns the value deserialized from the node */ private Object readElement(InputNode node, String key) throws Exception { String name = style.getAttribute(key); InputNode child = node.getNext(name); if(child == null) { return null; } return root.read(child); }
/** * This method is used to read the key value from the node. The * value read from the node is resolved using the template filter. * If the key value can not be found according to the annotation * attributes then null is assumed and returned. * * @param node this is the node to read the key value from * @param key this is the name of the element used by the key * * @return this returns the value deserialized from the node */ private Object readElement(InputNode node, String key) throws Exception { String name = style.getElement(key); InputNode child = node.getNext(name); if(child == null) { return null; } return root.read(child); }
/** * This method is used to read the key value from the node. The * value read from the node is resolved using the template filter. * If the key value can not be found according to the annotation * attributes then null is assumed and returned. * * @param node this is the node to read the key value from * @param key this is the name of the element used by the key * * @return this returns the value deserialized from the node */ private Object readElement(InputNode node, String key) throws Exception { String name = style.getElement(key); InputNode child = node.getNext(name); if(child == null) { return null; } return root.read(child); }
/** * This method is used to read the key value from the node. The * value read from the node is resolved using the template filter. * If the key value can not be found according to the annotation * attributes then the node is considered as null and is valid. * * @param node this is the node to read the key value from * @param key this is the name of the element used by the key * * @return this returns the value deserialized from the node */ private boolean validateElement(InputNode node, String key) throws Exception { String name = style.getElement(key); InputNode child = node.getNext(name); if(child == null) { return true; } return root.validate(child); }
/** * This method is used to validate the value from the node. The * value read from the node is resolved using the template filter. * If the value value can not be found according to the annotation * attributes then null is assumed and the node is valid. * * @param node this is the node to read the value object from * @param key this is the name of the node to be validated * * @return this returns true if the primitive key is valid */ private boolean validateElement(InputNode node, String key) throws Exception { String name = style.getAttribute(key); InputNode child = node.getNext(name); if(child == null) { return true; } return root.validate(node); }
/** * This method is used to read the element value from the node. The * value read from the node is resolved using the template filter. * If the value value can not be found according to the annotation * attributes then null is assumed and returned. * * @param node this is the node to read the value object from * @param key this is the name of the value XML element * * @return this returns the value deserialized from the node */ private Object readElement(InputNode node, String key) throws Exception { String name = style.getAttribute(key); InputNode child = node.getNext(name); if(child == null) { return null; } return root.read(child); }
@Override public Collect read(InputNode node) throws Exception { List<CollectorStep> collectorSteps = Lists.newArrayList(); InputNode inputNode; while ((inputNode = node.getNext()) != null) { Map<String, String> parameters = getParameters(inputNode); String name = StringUtils.defaultString(parameters.get("name"), inputNode.getName()); CollectorStep collectorStep = new CollectorStep(inputNode.getName(), name, parameters); collectorSteps.add(collectorStep); } ValidationUtils.validateSleep(collectorSteps); return new Collect(collectorSteps); }
@Override public Collect read(InputNode node) throws Exception { List<CollectorStep> collectorSteps = Lists.newArrayList(); InputNode inputNode; while ((inputNode = node.getNext()) != null) { Map<String, String> parameters = getParameters(inputNode); String name = StringUtils.defaultString(parameters.get("name"), inputNode.getName()); CollectorStep collectorStep = new CollectorStep(inputNode.getName(), name, parameters); collectorSteps.add(collectorStep); } ValidationUtils.validateSleep(collectorSteps); return new Collect(collectorSteps); }
@Override public Property read(InputNode node) throws Exception { Property property = new Property(); InputNode childNode = node.getNext(); if (childNode != null) { property.setProperty(ElementConverter.read(childNode)); } return property; }
/** * This method is used to read the value object from the node. The * value read from the node is resolved using the template filter. * If the value data can not be found according to the annotation * attributes then null is assumed and returned. * * @param node this is the node to read the value object from * * @return this returns the value deserialized from the node */ public Object read(InputNode node) throws Exception { InputNode next = node.getNext(); Class expect = type.getType(); if(next == null) { return null; } if(next.isEmpty()) { return null; } return root.read(next, expect); }