Example usage for javax.xml.stream XMLStreamReader getElementText

List of usage examples for javax.xml.stream XMLStreamReader getElementText

Introduction

In this page you can find the example usage for javax.xml.stream XMLStreamReader getElementText.

Prototype

public String getElementText() throws XMLStreamException;

Source Link

Document

Reads the content of a text-only element, an exception is thrown if this is not a text-only element.

Usage

From source file:org.activiti.designer.eclipse.bpmn.BpmnParser.java

private static String parseSequenceFlowCondition(XMLStreamReader xtr, SequenceFlowModel sequenceFlow) {
    String condition = null;/*from   www.  j a va  2 s.  c  o  m*/
    if (xtr.getAttributeValue(null, "name") != null && xtr.getAttributeValue(null, "name").contains("${")) {
        condition = xtr.getAttributeValue(null, "name");
    }
    boolean readyWithSequenceFlow = false;
    try {
        while (readyWithSequenceFlow == false && xtr.hasNext()) {
            xtr.next();
            if (xtr.isStartElement() && "conditionExpression".equalsIgnoreCase(xtr.getLocalName())) {
                condition = xtr.getElementText();

            } else if (xtr.isStartElement() && "extensionElements".equalsIgnoreCase(xtr.getLocalName())) {
                sequenceFlow.listenerList.addAll(parseListeners(xtr));

            } else if (xtr.isEndElement() && "sequenceFlow".equalsIgnoreCase(xtr.getLocalName())) {
                readyWithSequenceFlow = true;
            }
        }
    } catch (Exception e) {
    }
    return condition;
}

From source file:org.activiti.designer.eclipse.bpmn.BpmnParser.java

private UserTask parseUserTask(XMLStreamReader xtr) {
    UserTask userTask = null;// w ww.  j a va 2 s.c  om
    if (xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "formKey") != null) {
        String[] formTypes = PreferencesUtil.getStringArray(Preferences.ALFRESCO_FORMTYPES_USERTASK);
        for (String form : formTypes) {
            if (form.equals(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "formKey"))) {
                userTask = new AlfrescoUserTask();
            }
        }
    }
    if (userTask == null) {
        userTask = new UserTask();
    }

    if (StringUtils.isNotEmpty(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "dueDate"))) {
        userTask.setDueDate(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "dueDate"));
    }

    if (StringUtils.isNotEmpty(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "assignee"))) {
        String assignee = xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "assignee");
        userTask.setAssignee(assignee);

    }

    if (StringUtils.isNotEmpty(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "candidateUsers"))) {
        String expression = xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "candidateUsers");
        String[] expressionList = null;
        if (expression.contains(";")) {
            expressionList = expression.split(";");
        } else {
            expressionList = new String[] { expression };
        }
        for (String user : expressionList) {
            userTask.getCandidateUsers().add(user);
        }

    }

    if (StringUtils.isNotEmpty(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "candidateGroups"))) {
        String expression = xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "candidateGroups");
        String[] expressionList = null;
        if (expression.contains(";")) {
            expressionList = expression.split(";");
        } else {
            expressionList = new String[] { expression };
        }
        for (String group : expressionList) {
            userTask.getCandidateGroups().add(group);
        }
    }

    if (StringUtils.isNotEmpty(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "formKey"))) {
        userTask.setFormKey(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "formKey"));
    }

    if (StringUtils.isNotEmpty(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "priority"))) {
        Integer priorityValue = null;
        try {
            priorityValue = Integer.valueOf(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "priority"));
        } catch (Exception e) {
        }
        userTask.setPriority(priorityValue);
    }

    boolean readyWithUserTask = false;
    try {
        String assignmentType = null;
        ActivitiListener listener = null;
        while (readyWithUserTask == false && xtr.hasNext()) {
            xtr.next();
            if (xtr.isStartElement() && "humanPerformer".equalsIgnoreCase(xtr.getLocalName())) {
                assignmentType = "humanPerformer";

            } else if (xtr.isStartElement() && "potentialOwner".equalsIgnoreCase(xtr.getLocalName())) {
                assignmentType = "potentialOwner";

            } else if (xtr.isStartElement() && "formalExpression".equalsIgnoreCase(xtr.getLocalName())) {
                if ("potentialOwner".equals(assignmentType)) {
                    List<String> assignmentList = new ArrayList<String>();
                    String assignmentText = xtr.getElementText();
                    if (assignmentText.contains(",")) {
                        String[] assignmentArray = assignmentText.split(",");
                        assignmentList = Arrays.asList(assignmentArray);
                    } else {
                        assignmentList.add(assignmentText);
                    }
                    for (String assignmentValue : assignmentList) {
                        if (assignmentValue == null)
                            continue;
                        assignmentValue = assignmentValue.trim();
                        if (assignmentValue.length() == 0)
                            continue;

                        if (assignmentValue.trim().startsWith("user(")) {
                            userTask.getCandidateUsers().add(assignmentValue);

                        } else {
                            userTask.getCandidateGroups().add(assignmentValue);
                        }
                    }

                } else {
                    userTask.setAssignee(xtr.getElementText());
                }

            } else if (xtr.isStartElement() && ("taskListener".equalsIgnoreCase(xtr.getLocalName()))) {

                if (xtr.getAttributeValue(null, "class") != null
                        && "org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener"
                                .equals(xtr.getAttributeValue(null, "class"))
                        || "org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener"
                                .equals(xtr.getAttributeValue(null, "class"))) {

                    listener = new ActivitiListener();
                    listener.setEvent(xtr.getAttributeValue(null, "event"));
                    listener.setImplementationType(ALFRESCO_TYPE);
                    boolean readyWithAlfrescoType = false;
                    while (readyWithAlfrescoType == false && xtr.hasNext()) {
                        xtr.next();
                        if (xtr.isStartElement() && "field".equalsIgnoreCase(xtr.getLocalName())) {
                            String script = getFieldExtensionValue(xtr);
                            if (script != null && script.length() > 0) {
                                listener.setImplementation(script);
                            }
                            readyWithAlfrescoType = true;
                        } else if (xtr.isEndElement()
                                && "extensionElements".equalsIgnoreCase(xtr.getLocalName())) {
                            readyWithAlfrescoType = true;
                            readyWithUserTask = true;
                        }
                    }
                } else {
                    listener = parseListener(xtr);
                }
                userTask.getTaskListeners().add(listener);

            } else if (xtr.isStartElement() && "field".equalsIgnoreCase(xtr.getLocalName())) {
                listener.getFieldExtensions().add(parseFieldExtension(xtr));

            } else if (xtr.isStartElement() && "formProperty".equalsIgnoreCase(xtr.getLocalName())) {
                FormProperty property = new FormProperty();
                userTask.getFormProperties().add(property);
                parseFormProperty(property, xtr);

            } else if (xtr.isStartElement() && "documentation".equalsIgnoreCase(xtr.getLocalName())) {

                String docText = xtr.getElementText();
                if (StringUtils.isEmpty(docText) == false) {
                    userTask.setDocumentation(docText);
                }

            } else if (xtr.isStartElement()
                    && "multiInstanceLoopCharacteristics".equalsIgnoreCase(xtr.getLocalName())) {
                userTask.setLoopCharacteristics(parseMultiInstanceDef(xtr));

            } else if (xtr.isEndElement() && "userTask".equalsIgnoreCase(xtr.getLocalName())) {
                readyWithUserTask = true;
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return userTask;
}

From source file:org.activiti.designer.eclipse.bpmn.BpmnParser.java

private ScriptTask parseScriptTask(XMLStreamReader xtr) {
    ScriptTask scriptTask = new ScriptTask();
    scriptTask.setScriptFormat(xtr.getAttributeValue(null, "scriptFormat"));
    boolean readyWithScriptTask = false;
    try {//from  w  w  w.j  a v  a  2 s .  co m
        while (readyWithScriptTask == false && xtr.hasNext()) {
            xtr.next();
            if (xtr.isStartElement() && "script".equalsIgnoreCase(xtr.getLocalName())) {
                scriptTask.setScript(xtr.getElementText());

            } else if (xtr.isStartElement() && "extensionElements".equalsIgnoreCase(xtr.getLocalName())) {
                scriptTask.getExecutionListeners().addAll(parseListeners(xtr));

            } else if (xtr.isStartElement()
                    && "multiInstanceLoopCharacteristics".equalsIgnoreCase(xtr.getLocalName())) {
                scriptTask.setLoopCharacteristics(parseMultiInstanceDef(xtr));

            } else if (xtr.isEndElement() && "scriptTask".equalsIgnoreCase(xtr.getLocalName())) {
                readyWithScriptTask = true;
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return scriptTask;
}

From source file:org.activiti.designer.eclipse.bpmn.BpmnParser.java

private ServiceTask parseServiceTask(XMLStreamReader xtr) {
    ServiceTask serviceTask = new ServiceTask();
    if (xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "class") != null) {
        serviceTask.setImplementationType(CLASS_TYPE);
        serviceTask.setImplementation(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "class"));

    } else if (xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "expression") != null) {
        serviceTask.setImplementationType(EXPRESSION_TYPE);
        serviceTask.setImplementation(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "expression"));
    } else if (xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "delegateExpression") != null) {
        serviceTask.setImplementationType(DELEGATE_EXPRESSION_TYPE);
        serviceTask/*w w w .j  a  v  a2  s  .co  m*/
                .setImplementation(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "delegateExpression"));
    }

    if (xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "resultVariableName") != null) {
        serviceTask.setResultVariableName(
                xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "resultVariableName"));
    }

    boolean readyWithServiceTask = false;
    try {
        while (readyWithServiceTask == false && xtr.hasNext()) {
            xtr.next();
            if (xtr.isStartElement() && "extensionElements".equalsIgnoreCase(xtr.getLocalName())) {
                fillExtensionsForServiceTask(xtr, serviceTask);

            } else if (xtr.isStartElement()
                    && "multiInstanceLoopCharacteristics".equalsIgnoreCase(xtr.getLocalName())) {
                serviceTask.setLoopCharacteristics(parseMultiInstanceDef(xtr));

            } else if (xtr.isStartElement() && "documentation".equalsIgnoreCase(xtr.getLocalName())) {

                String docText = xtr.getElementText();
                if (StringUtils.isEmpty(docText) == false) {
                    serviceTask.setDocumentation(docText);
                }

            } else if (xtr.isEndElement() && "serviceTask".equalsIgnoreCase(xtr.getLocalName())) {
                readyWithServiceTask = true;
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return serviceTask;
}

From source file:org.activiti.designer.eclipse.bpmn.BpmnParser.java

private static String getFieldExtensionValue(XMLStreamReader xtr) {
    if (xtr.getAttributeValue(null, "stringValue") != null) {
        return xtr.getAttributeValue(null, "stringValue");

    } else if (xtr.getAttributeValue(null, "expression") != null) {
        return xtr.getAttributeValue(null, "expression");

    } else {//from w w  w.j  a va 2 s.  co  m
        boolean readyWithFieldExtension = false;
        try {
            while (readyWithFieldExtension == false && xtr.hasNext()) {
                xtr.next();
                if (xtr.isStartElement() && "string".equalsIgnoreCase(xtr.getLocalName())) {
                    return xtr.getElementText().trim();

                } else if (xtr.isStartElement() && "expression".equalsIgnoreCase(xtr.getLocalName())) {
                    return xtr.getElementText().trim();

                } else if (xtr.isEndElement() && "field".equalsIgnoreCase(xtr.getLocalName())) {
                    return null;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return null;
}

From source file:org.activiti.designer.eclipse.bpmn.BpmnParser.java

private TimerEventDefinition parseTimerEventDefinition(XMLStreamReader xtr) {
    TimerEventDefinition eventDefinition = new TimerEventDefinition();
    try {//from www  .  ja v  a2  s . c  o  m
        while (xtr.hasNext()) {
            xtr.next();
            if (xtr.isStartElement() && "timeDuration".equalsIgnoreCase(xtr.getLocalName())) {
                eventDefinition.setTimeDuration(xtr.getElementText());
                break;

            } else if (xtr.isStartElement() && "timeDate".equalsIgnoreCase(xtr.getLocalName())) {
                eventDefinition.setTimeDate(xtr.getElementText());
                break;

            } else if (xtr.isStartElement() && "timeCycle".equalsIgnoreCase(xtr.getLocalName())) {
                eventDefinition.setTimeCycle(xtr.getElementText());
                break;

            } else if (xtr.isEndElement() && "timerEventDefinition".equalsIgnoreCase(xtr.getLocalName())) {
                break;
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return eventDefinition;
}

From source file:org.activiti.dmn.xml.converter.DmnXMLConverter.java

public DmnDefinition convertToDmnModel(XMLStreamReader xtr) {
    DmnDefinition model = new DmnDefinition();
    DmnElement parentElement = null;//ww w  .  ja  v  a2 s.  c o  m

    try {
        while (xtr.hasNext()) {
            try {
                xtr.next();
            } catch (Exception e) {
                LOGGER.debug("Error reading XML document", e);
                throw new DmnXMLException("Error reading XML", e);
            }

            if (xtr.isStartElement() == false) {
                continue;
            }

            if (ELEMENT_DEFINITIONS.equals(xtr.getLocalName())) {
                model.setId(xtr.getAttributeValue(null, ATTRIBUTE_ID));
                model.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME));
                model.setNamespace(MODEL_NAMESPACE);
                parentElement = model;
            } else if (ELEMENT_DECISION.equals(xtr.getLocalName())) {
                Decision decision = new Decision();
                model.addDrgElement(decision);
                decision.setId(xtr.getAttributeValue(null, ATTRIBUTE_ID));
                decision.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME));
                parentElement = decision;
            } else if (ELEMENT_DECISION_TABLE.equals(xtr.getLocalName())) {
                DecisionTable currentDecisionTable = new DecisionTable();
                currentDecisionTable.setId(xtr.getAttributeValue(null, ATTRIBUTE_ID));

                if (xtr.getAttributeValue(null, ATTRIBUTE_HIT_POLICY) != null) {
                    currentDecisionTable
                            .setHitPolicy(HitPolicy.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_HIT_POLICY)));
                } else {
                    currentDecisionTable.setHitPolicy(HitPolicy.FIRST);
                }

                model.getDrgElements().get(model.getDrgElements().size() - 1)
                        .setDecisionTable(currentDecisionTable);
                model.setCurrentDecisionTable(currentDecisionTable);
                parentElement = currentDecisionTable;
            } else if (ELEMENT_OUTPUT_CLAUSE.equals(xtr.getLocalName())) {
                OutputClause outputClause = new OutputClause();
                model.getCurrentDecisionTable().addOutput(outputClause);
                outputClause.setId(xtr.getAttributeValue(null, ATTRIBUTE_ID));
                outputClause.setLabel(xtr.getAttributeValue(null, ATTRIBUTE_LABEL));
                outputClause.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME));
                outputClause.setTypeRef(xtr.getAttributeValue(null, ATTRIBUTE_TYPE_REF));
                parentElement = outputClause;
            } else if (ELEMENT_DESCRIPTION.equals(xtr.getLocalName())) {
                parentElement.setDescription(xtr.getElementText());
            } else if (ELEMENT_EXTENSIONS.equals(xtr.getLocalName())) {
                while (xtr.hasNext()) {
                    xtr.next();
                    if (xtr.isStartElement()) {
                        DmnExtensionElement extensionElement = DmnXMLUtil.parseExtensionElement(xtr);
                        parentElement.addExtensionElement(extensionElement);
                    } else if (xtr.isEndElement()) {
                        if (ELEMENT_EXTENSIONS.equals(xtr.getLocalName())) {
                            break;
                        }
                    }
                }

            } else if (convertersToDmnMap.containsKey(xtr.getLocalName())) {
                BaseDmnXMLConverter converter = convertersToDmnMap.get(xtr.getLocalName());
                converter.convertToDmnModel(xtr, model);
            }
        }

        processDmnElements(model.getCurrentDecisionTable());

    } catch (DmnXMLException e) {
        throw e;

    } catch (Exception e) {
        LOGGER.error("Error processing DMN document", e);
        throw new DmnXMLException("Error processing DMN document", e);
    }
    return model;
}

From source file:org.apache.axis2.databinding.utils.ConverterUtil.java

public static Object getAnyTypeObject(XMLStreamReader xmlStreamReader, Class extensionMapperClass)
        throws XMLStreamException {
    Object returnObject = null;/*from w  w w.  j  a v  a 2 s  . co  m*/

    // make sure reader is at the first element.
    while (!xmlStreamReader.isStartElement()) {
        xmlStreamReader.next();
    }
    // first check whether this element is null or not
    String nillableValue = xmlStreamReader.getAttributeValue(Constants.XSI_NAMESPACE, "nil");
    if ("true".equals(nillableValue) || "1".equals(nillableValue)) {
        returnObject = null;
        xmlStreamReader.next();
    } else {
        String attributeType = xmlStreamReader.getAttributeValue(Constants.XSI_NAMESPACE, "type");
        if (attributeType != null) {
            String attributeTypePrefix = "";
            if (attributeType.indexOf(":") > -1) {
                attributeTypePrefix = attributeType.substring(0, attributeType.indexOf(":"));
                attributeType = attributeType.substring(attributeType.indexOf(":") + 1);
            }
            NamespaceContext namespaceContext = xmlStreamReader.getNamespaceContext();
            String attributeNameSpace = namespaceContext.getNamespaceURI(attributeTypePrefix);

            if (Constants.XSD_NAMESPACE.equals(attributeNameSpace)) {
                if ("base64Binary".equals(attributeType)) {
                    returnObject = XMLStreamReaderUtils.getDataHandlerFromElement(xmlStreamReader);
                } else {
                    String attribValue = xmlStreamReader.getElementText();
                    if (attribValue != null) {
                        if (attributeType.equals("string")) {
                            returnObject = attribValue;
                        } else if (attributeType.equals("int")) {
                            returnObject = new Integer(attribValue);
                        } else if (attributeType.equals("QName")) {
                            String namespacePrefix = null;
                            String localPart = null;
                            if (attribValue.indexOf(":") > -1) {
                                namespacePrefix = attribValue.substring(0, attribValue.indexOf(":"));
                                localPart = attribValue.substring(attribValue.indexOf(":") + 1);
                                returnObject = new QName(namespaceContext.getNamespaceURI(namespacePrefix),
                                        localPart);
                            }
                        } else if ("boolean".equals(attributeType)) {
                            returnObject = new Boolean(attribValue);
                        } else if ("anyURI".equals(attributeType)) {
                            try {
                                returnObject = new URI(attribValue);
                            } catch (URI.MalformedURIException e) {
                                throw new XMLStreamException("Invalid URI");
                            }
                        } else if ("date".equals(attributeType)) {
                            returnObject = ConverterUtil.convertToDate(attribValue);
                        } else if ("dateTime".equals(attributeType)) {
                            returnObject = ConverterUtil.convertToDateTime(attribValue);
                        } else if ("time".equals(attributeType)) {
                            returnObject = ConverterUtil.convertToTime(attribValue);
                        } else if ("byte".equals(attributeType)) {
                            returnObject = new Byte(attribValue);
                        } else if ("short".equals(attributeType)) {
                            returnObject = new Short(attribValue);
                        } else if ("float".equals(attributeType)) {
                            returnObject = new Float(attribValue);
                        } else if ("long".equals(attributeType)) {
                            returnObject = new Long(attribValue);
                        } else if ("double".equals(attributeType)) {
                            returnObject = new Double(attribValue);
                        } else if ("decimal".equals(attributeType)) {
                            returnObject = new BigDecimal(attribValue);
                        } else if ("unsignedLong".equals(attributeType)) {
                            returnObject = new UnsignedLong(attribValue);
                        } else if ("unsignedInt".equals(attributeType)) {
                            returnObject = new UnsignedInt(attribValue);
                        } else if ("unsignedShort".equals(attributeType)) {
                            returnObject = new UnsignedShort(attribValue);
                        } else if ("unsignedByte".equals(attributeType)) {
                            returnObject = new UnsignedByte(attribValue);
                        } else if ("positiveInteger".equals(attributeType)) {
                            returnObject = new PositiveInteger(attribValue);
                        } else if ("negativeInteger".equals(attributeType)) {
                            returnObject = new NegativeInteger(attribValue);
                        } else if ("nonNegativeInteger".equals(attributeType)) {
                            returnObject = new NonNegativeInteger(attribValue);
                        } else if ("nonPositiveInteger".equals(attributeType)) {
                            returnObject = new NonPositiveInteger(attribValue);
                        } else {
                            throw new ADBException("Unknown type ==> " + attributeType);
                        }
                    } else {
                        throw new ADBException("Attribute value is null");
                    }
                }
            } else {
                try {
                    Method getObjectMethod = extensionMapperClass.getMethod("getTypeObject",
                            new Class[] { String.class, String.class, XMLStreamReader.class });
                    returnObject = getObjectMethod.invoke(null,
                            new Object[] { attributeNameSpace, attributeType, xmlStreamReader });
                } catch (NoSuchMethodException e) {
                    throw new ADBException(
                            "Can not find the getTypeObject method in the " + "extension mapper class ", e);
                } catch (IllegalAccessException e) {
                    throw new ADBException(
                            "Can not access the getTypeObject method in the " + "extension mapper class ", e);
                } catch (InvocationTargetException e) {
                    throw new ADBException(
                            "Can not invoke the getTypeObject method in the " + "extension mapper class ", e);
                }

            }

        } else {
            throw new ADBException("Any type element type has not been given");
        }
    }
    return returnObject;
}

From source file:org.apache.ddlutils.io.DataReader.java

/**
 * Reads the next column-name or column-value sub element.
 *  /* ww  w  .ja va2 s . c  om*/
 * @param xmlReader The reader
 * @param data      Where to store the values
 */
private void readColumnDataSubElement(XMLStreamReader xmlReader, Map data)
        throws XMLStreamException, DdlUtilsXMLException {
    QName elemQName = xmlReader.getName();
    boolean usesBase64 = false;

    for (int idx = 0; idx < xmlReader.getAttributeCount(); idx++) {
        QName attrQName = xmlReader.getAttributeName(idx);
        String value = xmlReader.getAttributeValue(idx);

        if (DatabaseIO.BASE64_ATTR_NAME.equals(attrQName.getLocalPart())) {
            if ("true".equalsIgnoreCase(value)) {
                usesBase64 = true;
            }
            break;
        }
    }

    String value = xmlReader.getElementText();

    if (value != null) {
        value = value.toString().trim();

        if (usesBase64) {
            value = new String(Base64.decodeBase64(value.getBytes()));
        }
    }

    String name = elemQName.getLocalPart();

    if ("column-name".equals(name)) {
        data.put("column-name", value);
    } else if ("column-value".equals(name)) {
        data.put("column-value", value);
    }
    consumeRestOfElement(xmlReader);
}

From source file:org.apache.ddlutils.io.DataReaderKeys.java

private void readColumnSubElement(XMLStreamReader xmlReader, DynaBean bean, Table table)
        throws XMLStreamException, DdlUtilsXMLException {
    QName elemQName = xmlReader.getName();
    boolean usesBase64 = false;

    for (int idx = 0; idx < xmlReader.getAttributeCount(); idx++) {
        QName attrQName = xmlReader.getAttributeName(idx);

        if (DatabaseIO.BASE64_ATTR_NAME.equals(attrQName.getLocalPart())
                && "true".equalsIgnoreCase(xmlReader.getAttributeValue(idx))) {
            usesBase64 = true;//from  w w  w .ja  va  2s  . c  o  m
            break;
        }
    }

    Column column = table.findColumn(elemQName.getLocalPart(), isCaseSensitive());

    if (column == null) {
        _log.warn("Data XML contains an element " + elemQName + " at location " + xmlReader.getLocation()
                + " but there is no column defined in table " + table.getName()
                + " with this name. This element will be ignored.");
    } else {
        String value = xmlReader.getElementText();

        if (value != null) {
            value = value.trim();

            if (usesBase64) {
                value = new String(Base64.decodeBase64(value.getBytes()));
            }
            setColumnValue(bean, table, column, value);
        }
    }
    consumeRestOfElement(xmlReader);
}