All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.entur.netex.loader.parser.VehicleScheduleFrameParser Maven / Gradle / Ivy

There is a newer version: 3.1.29
Show newest version
package org.entur.netex.loader.parser;

import java.util.ArrayList;
import java.util.Collection;

import org.entur.netex.index.api.NetexEntitiesIndex;
import org.rutebanken.netex.model.Block;
import org.rutebanken.netex.model.Block_VersionStructure;
import org.rutebanken.netex.model.BlocksInFrame_RelStructure;
import org.rutebanken.netex.model.DataManagedObjectStructure;
import org.rutebanken.netex.model.VehicleSchedule_VersionFrameStructure;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

class VehicleScheduleFrameParser extends NetexParser {
    private static final Logger LOG = LoggerFactory.getLogger(VehicleScheduleFrameParser.class);

    private final Collection blocks = new ArrayList<>();

    @Override
    void parse(VehicleSchedule_VersionFrameStructure frame) {
        parseBlocks(frame.getBlocks());
    }

    @Override
    void setResultOnIndex(NetexEntitiesIndex netexIndex) {
        netexIndex.getBlockIndex().putAll(blocks);
    }

    private void parseBlock(Block_VersionStructure element) {
        if (element instanceof Block block) {
            blocks.add(block);
        } else {
            informOnElementIntentionallySkipped(LOG, element);
        }
    }

    private void parseBlocks(BlocksInFrame_RelStructure elements) {
        for (DataManagedObjectStructure e : elements.getBlockOrCompoundBlockOrTrainBlock()) {
            parseBlock((Block_VersionStructure) e);
        }
    }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy