org.entur.netex.loader.parser.VehicleScheduleFrameParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of netex-parser-java Show documentation
Show all versions of netex-parser-java Show documentation
Library for parsing NeTEx files and looking up entities in an index.
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);
}
}
}