Java Code Examples for org.simpleframework.xml.stream.InputNode#getPrefix()

The following examples show how to use org.simpleframework.xml.stream.InputNode#getPrefix() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EntityWithAnyElementConverter.java    From sardine-android with Apache License 2.0 6 votes vote down vote up
@Override
public T read(InputNode node) throws Exception {
    Map<String, Field> entityFields = getEntityFields();
    T entity = entityClass.newInstance();
    List<org.w3c.dom.Element> anyElements = entity.getAny();
    InputNode childNode;
    while((childNode = node.getNext()) != null) {
        if (entityFields.containsKey(childNode.getName())) {
            Field field = entityFields.get(childNode.getName());
            getSetterForField(field).invoke(entity, serializer.read(field.getType(), childNode));
        } else if (childNode.getPrefix() != null && !childNode.getPrefix().isEmpty()) {
            org.w3c.dom.Element element = ElementConverter.read(childNode);
            anyElements.add(element);
        } else {
            // Probably a WebDAV field we don't support yet
            skipChildrenOfNode(childNode);
        }
    }
    return entity;
}
 
Example 2
Source File: EntityWithAnyElementConverter.java    From simpletask-android with GNU General Public License v3.0 6 votes vote down vote up
@Override
public T read(InputNode node) throws Exception {
    Map<String, Field> entityFields = getEntityFields();
    T entity = entityClass.newInstance();
    List<org.w3c.dom.Element> anyElements = entity.getAny();
    InputNode childNode;
    while((childNode = node.getNext()) != null) {
        if (entityFields.containsKey(childNode.getName())) {
            Field field = entityFields.get(childNode.getName());
            getSetterForField(field).invoke(entity, serializer.read(field.getType(), childNode));
        } else if (childNode.getPrefix() != null && !childNode.getPrefix().isEmpty()) {
            org.w3c.dom.Element element = ElementConverter.read(childNode);
            anyElements.add(element);
        } else {
            // Probably a WebDAV field we don't support yet
            skipChildrenOfNode(childNode);
        }
    }
    return entity;
}
 
Example 3
Source File: ElementConverter.java    From sardine-android with Apache License 2.0 4 votes vote down vote up
public static Element read(InputNode node) throws Exception {
    QName qname = new QName(node.getReference(), node.getName(), node.getPrefix());
    org.w3c.dom.Element element = SardineUtil.createElement(qname);
    element.setTextContent(node.getValue());
    return element;
}
 
Example 4
Source File: ElementConverter.java    From simpletask-android with GNU General Public License v3.0 4 votes vote down vote up
public static Element read(InputNode node) throws Exception {
    QName qname = new QName(node.getReference(), node.getName(), node.getPrefix());
    org.w3c.dom.Element element = SardineUtil.createElement(qname);
    element.setTextContent(node.getValue());
    return element;
}