Example usage for javax.xml.stream XMLStreamReader next

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

Introduction

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

Prototype

public int next() throws XMLStreamException;

Source Link

Document

Get next parsing event - a processor may return all contiguous character data in a single chunk, or it may split it into several chunks.

Usage

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 .c om
        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 static List<ActivitiListener> parseListeners(XMLStreamReader xtr) {
    List<ActivitiListener> listenerList = new ArrayList<ActivitiListener>();
    boolean readyWithListener = false;
    try {//w  w w.j a v a2s.  c  o  m
        ActivitiListener listener = null;
        while (readyWithListener == false && xtr.hasNext()) {
            xtr.next();
            if (xtr.isStartElement() && ("executionListener".equalsIgnoreCase(xtr.getLocalName())
                    || "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;
                            readyWithListener = true;
                        }
                    }
                } else {
                    listener = parseListener(xtr);
                }
                listenerList.add(listener);

            } else if (xtr.isStartElement() && "field".equalsIgnoreCase(xtr.getLocalName())) {
                listener.getFieldExtensions().add(parseFieldExtension(xtr));
            } else if (xtr.isEndElement() && "extensionElements".equalsIgnoreCase(xtr.getLocalName())) {
                readyWithListener = true;
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    return listenerList;
}

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

private ManualTask parseManualTask(XMLStreamReader xtr) {
    ManualTask manualTask = new ManualTask();
    boolean readyWithTask = false;
    try {/*from   w  w w .  j  a  v a 2 s  . c  om*/
        while (readyWithTask == false && xtr.hasNext()) {
            xtr.next();
            if (xtr.isStartElement() && "extensionElements".equalsIgnoreCase(xtr.getLocalName())) {
                manualTask.getExecutionListeners().addAll(parseListeners(xtr));

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

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

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

private CallActivity parseCallActivity(XMLStreamReader xtr) {
    CallActivity callActivity = new CallActivity();
    if (xtr.getAttributeValue(null, "calledElement") != null
            && xtr.getAttributeValue(null, "calledElement").length() > 0) {
        callActivity.setCalledElement(xtr.getAttributeValue(null, "calledElement"));
    }/*w  w  w  .j ava 2 s  .  c om*/
    boolean readyWithTask = false;
    try {
        while (readyWithTask == false && xtr.hasNext()) {
            xtr.next();
            if (xtr.isStartElement() && "extensionElements".equalsIgnoreCase(xtr.getLocalName())) {

                fillExtensionsForCallActivity(xtr, callActivity);

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

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

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

private ReceiveTask parseReceiveTask(XMLStreamReader xtr) {
    ReceiveTask receiveTask = new ReceiveTask();
    boolean readyWithTask = false;
    try {/*from  www.  j  a v a2s. c o m*/
        while (readyWithTask == false && xtr.hasNext()) {
            xtr.next();
            if (xtr.isStartElement() && "extensionElements".equalsIgnoreCase(xtr.getLocalName())) {
                receiveTask.getExecutionListeners().addAll(parseListeners(xtr));

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

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

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

private BusinessRuleTask parseBusinessRuleTask(XMLStreamReader xtr) {
    BusinessRuleTask businessRuleTask = new BusinessRuleTask();
    if (xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "rules") != null) {
        String ruleNames = xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "rules");
        if (ruleNames != null && ruleNames.length() > 0) {
            businessRuleTask.getRuleNames().clear();
            if (ruleNames.contains(",") == false) {
                businessRuleTask.getRuleNames().add(ruleNames);
            } else {
                String[] ruleNameList = ruleNames.split(",");
                for (String rule : ruleNameList) {
                    businessRuleTask.getRuleNames().add(rule);
                }//  ww  w .j  av  a2 s  . co  m
            }
        }
    }
    if (xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "ruleVariablesInput") != null) {
        String inputNames = xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "ruleVariablesInput");
        if (inputNames != null && inputNames.length() > 0) {
            businessRuleTask.getInputVariables().clear();
            if (inputNames.contains(",") == false) {
                businessRuleTask.getInputVariables().add(inputNames);
            } else {
                String[] inputNamesList = inputNames.split(",");
                for (String input : inputNamesList) {
                    businessRuleTask.getInputVariables().add(input);
                }
            }
        }
    }
    if (xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "exclude") != null) {
        businessRuleTask
                .setExclude(Boolean.valueOf(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "exclude")));
    }
    if (xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "resultVariableName") != null) {
        businessRuleTask.setResultVariableName(
                xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "resultVariableName"));
    }

    boolean readyWithTask = false;
    try {
        while (readyWithTask == false && xtr.hasNext()) {
            xtr.next();
            if (xtr.isStartElement() && "extensionElements".equalsIgnoreCase(xtr.getLocalName())) {
                businessRuleTask.getExecutionListeners().addAll(parseListeners(xtr));

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

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

    return businessRuleTask;
}

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

private BoundaryEventModel parseBoundaryEvent(XMLStreamReader xtr) {
    BoundaryEvent boundaryEvent = new BoundaryEvent();
    boundaryEvent.setName(xtr.getAttributeValue(null, "name"));

    if (xtr.getAttributeValue(null, "cancelActivity") != null) {
        String cancelActivity = xtr.getAttributeValue(null, "cancelActivity");
        if ("true".equalsIgnoreCase(cancelActivity)) {
            boundaryEvent.setCancelActivity(true);
        } else {/* w  w w.  j  a v a  2  s . co  m*/
            boundaryEvent.setCancelActivity(false);
        }
    }

    BoundaryEventModel model = new BoundaryEventModel();
    model.boundaryEvent = boundaryEvent;
    model.attachedRef = xtr.getAttributeValue(null, "attachedToRef");
    try {
        while (xtr.hasNext()) {
            xtr.next();
            if (xtr.isStartElement() && "timerEventDefinition".equalsIgnoreCase(xtr.getLocalName())) {
                model.type = BoundaryEventModel.TIMEEVENT;
                boundaryEvent.getEventDefinitions().add(parseTimerEventDefinition(xtr));
                break;

            } else if (xtr.isStartElement() && "errorEventDefinition".equalsIgnoreCase(xtr.getLocalName())) {
                model.type = BoundaryEventModel.ERROREVENT;
                boundaryEvent.getEventDefinitions().add(parseErrorEventDefinition(xtr));
                break;

            } else if (xtr.isStartElement() && "signalEventDefinition".equalsIgnoreCase(xtr.getLocalName())) {
                model.type = BoundaryEventModel.SIGNALEVENT;
                boundaryEvent.getEventDefinitions().add(parseSignalEventDefinition(xtr));
                break;

            } else if (xtr.isEndElement() && "boundaryEvent".equalsIgnoreCase(xtr.getLocalName())) {
                break;
            }
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
    return model;
}

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

private IntermediateCatchEvent parseIntermediateCatchEvent(XMLStreamReader xtr) {
    IntermediateCatchEvent catchEvent = new IntermediateCatchEvent();

    try {/*from   w w  w  .j a  va  2 s .  co m*/
        while (xtr.hasNext()) {
            xtr.next();
            if (xtr.isStartElement() && "timerEventDefinition".equalsIgnoreCase(xtr.getLocalName())) {
                catchEvent.getEventDefinitions().add(parseTimerEventDefinition(xtr));
                break;

            } else if (xtr.isStartElement() && "signalEventDefinition".equalsIgnoreCase(xtr.getLocalName())) {
                catchEvent.getEventDefinitions().add(parseSignalEventDefinition(xtr));
                break;

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

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

private ThrowEvent parseIntermediateThrowEvent(XMLStreamReader xtr) {
    ThrowEvent throwEvent = new ThrowEvent();
    try {/*w w w.ja  v a  2s . c om*/
        while (xtr.hasNext()) {
            xtr.next();
            if (xtr.isStartElement() && "signalEventDefinition".equalsIgnoreCase(xtr.getLocalName())) {
                throwEvent.getEventDefinitions().add(parseSignalEventDefinition(xtr));
                break;

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

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

private TimerEventDefinition parseTimerEventDefinition(XMLStreamReader xtr) {
    TimerEventDefinition eventDefinition = new TimerEventDefinition();
    try {//from w w w  .ja  v  a 2 s . com
        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;
}