org.opentripplanner.standalone.config.NetexConfig Maven / Gradle / Ivy
package org.opentripplanner.standalone.config;
import java.util.Collections;
import java.util.Set;
import java.util.regex.Pattern;
public class NetexConfig {
private static final String EMPTY_STRING_PATTERN = "$^";
private static final String IGNORE_FILE_PATTERN = EMPTY_STRING_PATTERN;
private static final String SHARED_FILE_PATTERN = "shared-data\\.xml";
private static final String SHARED_GROUP_FILE_PATTERN = "(\\w{3})-.*-shared\\.xml";
private static final String GROUP_FILE_PATTERN = "(\\w{3})-.*\\.xml";
private static final String NETEX_FEED_ID = "DefaultFeed";
private static final Set FERRY_IDS_NOT_ALLOWED_FOR_BICYCLE = Collections.emptySet();
/**
* This field is used to identify the specific NeTEx feed. It is used instead of the feed_id
* field in GTFS file feed_info.txt.
*/
public final String netexFeedId;
/**
* This field is used to exclude matching files in the module file(zip file entries).
* The ignored files are not loaded.
*
* Default value is '$^'
which matches empty stings (not a valid file name).
* @see #sharedFilePattern
*/
public final Pattern ignoreFilePattern;
/**
* This field is used to match shared files(zip file entries) in the module file.
* Shared files are loaded first. Then the rest of the files are grouped and loaded.
*
* The pattern 'shared-data\.xml'
matches 'shared-data.xml'
*
* File names are matched in the following order - and treated accordingly to the first match:
*
* - {@link #ignoreFilePattern}
* - Shared file pattern (this)
* - {@link #sharedGroupFilePattern}.
* - {@link #groupFilePattern}.
*
*
* Default value is 'shared-data\.xml'
*/
public final Pattern sharedFilePattern;
/**
* This field is used to match shared group files in the module file(zip file entries).
* Typically this is used to group all files from one agency together.
*
* Shared group files are loaded after shared files, but before the matching group
* files. Each group of files are loaded as a unit, followed by next group.
*
* Files are grouped together by the first group pattern in the regular expression.
*
* The pattern '(\w{3})-.*-shared\.xml'
matches 'RUT-shared.xml'
with
* group 'RUT'
.
*
* Default value is '(\w{3})-.*-shared\.xml'
* @see #sharedFilePattern
* @see #groupFilePattern
*/
public final Pattern sharedGroupFilePattern;
/**
* This field is used to match group files in the module file(zip file entries).
* group files are loaded right the after shared group files are loaded.
*
* Files are grouped together by the first group pattern in the regular expression.
*
* The pattern '(\w{3})-.*\.xml'
matches 'RUT-Line-208-Hagalia-Nevlunghavn.xml'
with
* group 'RUT'
.
*
* Default value is '(\w{3})-.*\.xml'
* @see #sharedFilePattern
* @see #sharedGroupFilePattern
*/
public final Pattern groupFilePattern;
/**
* Bicycles are allowed on most ferries however Nordic profile doesn't contain a place where
* bicycle conveyance can be defined.
*
* For this reason we allow bicycles on ferries by default and allow to override the rare
* case where this is not the case.
*/
public final Set ferryIdsNotAllowedForBicycle;
NetexConfig(NodeAdapter config) {
ignoreFilePattern = config.asPattern("ignoreFilePattern", IGNORE_FILE_PATTERN);
sharedFilePattern = config.asPattern("sharedFilePattern", SHARED_FILE_PATTERN);
sharedGroupFilePattern = config.asPattern("sharedGroupFilePattern", SHARED_GROUP_FILE_PATTERN);
groupFilePattern = config.asPattern("groupFilePattern", GROUP_FILE_PATTERN);
netexFeedId = config.asText("netexFeedId", NETEX_FEED_ID);
ferryIdsNotAllowedForBicycle = config.asTextSet(
"ferryIdsNotAllowedForBicycle",
FERRY_IDS_NOT_ALLOWED_FOR_BICYCLE
);
}
}