protected boolean next()

in SdmxDataParser/src/main/java/org/sdmxsource/sdmx/dataparser/engine/reader/GenericDataReaderEngine.java [120:199]


    protected boolean next(boolean includeObs) {
        String nodeName = null;
        try {
            while (parser.hasNext()) {
                int event = parser.next();
                if (event == XMLStreamConstants.START_ELEMENT) {
                    nodeName = parser.getLocalName();
                    if (nodeName.equalsIgnoreCase("Dataset")) {
                        datasetPosition = DATASET_POSITION.DATASET;
                        attributesOnDatasetNode = new HashMap<String, String>();
                        this.datasetHeaderBean = new DatasetHeaderBeanImpl(parser, headerBean);
                        String dsdId = processDatasetNode();

                        DatasetStructureReferenceBean dsRef = datasetHeaderBean.getDataStructureReference();
                        StructureReferenceBean structureReference = null;
                        String id = null;
                        String serviceURL = null;
                        String structureURL = null;
                        String dimensionAtObservation = null;

                        if (dsRef != null) {
                            id = dsRef.getId();
                            serviceURL = dsRef.getServiceURL();
                            structureURL = dsRef.getStructureURL();
                            dimensionAtObservation = dsRef.getDimensionAtObservation();
                            structureReference = dsRef.getStructureReference();
                        }
                        if (structureReference == null) {
                            if (defaultDsd != null && defaultDsd.getId().equals(dsdId)) {
                                structureReference = defaultDsd.asReference();
                            } else {
                                structureReference = new StructureReferenceBeanImpl(null, dsdId, MaintainableBean.DEFAULT_VERSION, SDMX_STRUCTURE_TYPE.DSD);
                            }
                        }
                        dsRef = new DatasetStructureReferenceBeanImpl(id, structureReference, serviceURL, structureURL, dimensionAtObservation);
                        datasetHeaderBean = datasetHeaderBean.modifyDataStructureReference(dsRef);
                        return true;
                    } else if (nodeName.equals("Series")) {
                        StaxUtil.skipToEndNode(runAheadParser, "SeriesKey");  //Send Run ahead parser to the next key node
                        datasetPosition = DATASET_POSITION.SERIES;
                        return true;
                    } else if (nodeName.equals("Group")) {
                        StaxUtil.skipToEndNode(runAheadParser, "GroupKey");   //Send Run ahead parser to the next key node
                        datasetPosition = DATASET_POSITION.GROUP;
                        groupId = parser.getAttributeValue(null, "type");
                        return true;
                    } else if (nodeName.equals("Obs")) {
                        if (datasetPosition == DATASET_POSITION.SERIES || datasetPosition == DATASET_POSITION.OBSERVATION) {
                            if (includeObs) {
                                datasetPosition = DATASET_POSITION.OBSERVATION;
                                return true;
                            } else {
                                continue;
                            }
                        }
                        datasetPosition = DATASET_POSITION.OBSERAVTION_AS_SERIES;
                        return true;
                    } else if (nodeName.equals("Annotations") || nodeName.equals("Attributes")) {
                        StaxUtil.skipNode(parser);
                    } else if (nodeName.equals("KeyFamilyRef") || nodeName.equals("Time") || nodeName.equals("ObsValue") || nodeName.equals("ObsDimension") || nodeName.equals("SeriesKey") || nodeName.equals("Value") || nodeName.equals("GroupKey")) {
                        //DO NOTHING
                    } else {
                        throw new SdmxSyntaxException("Unexpected Node in XML: " + nodeName);
                    }
                } else if (event == XMLStreamConstants.END_ELEMENT) {
                    nodeName = parser.getLocalName();
                    if (nodeName.equals("Series")) {
                        datasetPosition = null;
                    } else if (nodeName.equals("Group")) {
                        datasetPosition = null;
                    }
                }
            }
        } catch (XMLStreamException ex) {
            close();
            throw new RuntimeException(ex);
        }
        hasNext = false;
        return false;
    }