Package org.goplanit.gtfs.util
Class GtfsUtils
- java.lang.Object
-
- org.goplanit.gtfs.util.GtfsUtils
-
public class GtfsUtils extends Object
General utilities specific to this GTFS API- Author:
- markr
-
-
Constructor Summary
Constructors Constructor Description GtfsUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static FileInputStream
createFileInputStream(File gtfsFileLocation, GtfsFileConditions filePresenceCondition)
Create a file based input stream for given file and issue warnings dependent on the presence conditions imposed if it is not presentstatic InputStream
createInputStream(URL gtfsLocation, GtfsFileScheme fileScheme, GtfsFileConditions filePresenceCondition)
Based on passed in location and the file scheme create an input stream to the appropriate file, log warnings if not present but conditions require otherwise.static InputStream
createInputStream(URL gtfsLocation, GtfsFileScheme fileScheme, GtfsFileConditions filePresenceCondition, boolean logInfo)
Based on passed in location and the file scheme create an input stream to the appropriate file, log warnings if not present but conditions require otherwise.static InputStream
createZipEntryInputStream(URL gtfsLocation, String zipInternalFileName, GtfsFileConditions filePresenceCondition, boolean logInfo)
Create a zip based input stream for given zip internal file location and issue warnings dependent on the presence conditions imposed if it is not presentstatic EnumSet<GtfsKeyType>
getSupportedKeys(GtfsObjectType objectType)
Collect the supported keys via reflection where it is assumed the object type's class has a default constructor.static boolean
isValidGtfsLocation(URL gtfsLocation)
A GTFS location URL is valid when it is either a directory or a zip file from which we can source the various GTFS filesstatic ExtendedLocalTime
parseGtfsTime(String gtfsTime)
PArse a GTFS time HH:MM:SS that is allowed to extend beyond the 24h cycle as an ExtendeLocalTime object
-
-
-
Method Detail
-
isValidGtfsLocation
public static boolean isValidGtfsLocation(URL gtfsLocation)
A GTFS location URL is valid when it is either a directory or a zip file from which we can source the various GTFS files- Parameters:
gtfsLocation
- to verify- Returns:
- true when valid, false otherwise
-
createInputStream
public static InputStream createInputStream(URL gtfsLocation, GtfsFileScheme fileScheme, GtfsFileConditions filePresenceCondition, boolean logInfo)
Based on passed in location and the file scheme create an input stream to the appropriate file, log warnings if not present but conditions require otherwise.- Parameters:
gtfsLocation
- to use (dir or zip)fileScheme
- to use to extract correct file name fromfilePresenceCondition
- indicates if the file should be present or not.logInfo
- when true log extensive information on the type and how to input stream is being created- Returns:
- input stream to GTFS file
-
createInputStream
public static InputStream createInputStream(URL gtfsLocation, GtfsFileScheme fileScheme, GtfsFileConditions filePresenceCondition)
Based on passed in location and the file scheme create an input stream to the appropriate file, log warnings if not present but conditions require otherwise.- Parameters:
gtfsLocation
- to use (dir or zip)fileScheme
- to use to extract correct file name fromfilePresenceCondition
- indicates if the file should be present or not. If- Returns:
- input stream to GTFS file
-
createZipEntryInputStream
public static InputStream createZipEntryInputStream(URL gtfsLocation, String zipInternalFileName, GtfsFileConditions filePresenceCondition, boolean logInfo) throws URISyntaxException
Create a zip based input stream for given zip internal file location and issue warnings dependent on the presence conditions imposed if it is not present- Parameters:
gtfsLocation
- zip file to create input stream forzipInternalFileName
- file internal to zip file to create stream forfilePresenceCondition
- for this filelogInfo
- log extensive info on creating zip entry stream for debugging- Returns:
- created input stream, null if not available
- Throws:
URISyntaxException
- when URL cannot be converted to URI to append internal file name
-
createFileInputStream
public static FileInputStream createFileInputStream(File gtfsFileLocation, GtfsFileConditions filePresenceCondition)
Create a file based input stream for given file and issue warnings dependent on the presence conditions imposed if it is not present- Parameters:
gtfsFileLocation
- to create input stream forfilePresenceCondition
- for this file- Returns:
- created input stream, null if not available
-
getSupportedKeys
public static EnumSet<GtfsKeyType> getSupportedKeys(GtfsObjectType objectType)
Collect the supported keys via reflection where it is assumed the object type's class has a default constructor. If so the supported keys are collected via a temporary instance that is created to access the abstract method providing the type specific supported keys- Parameters:
objectType
- to use- Returns:
- supported keys
-
parseGtfsTime
public static ExtendedLocalTime parseGtfsTime(String gtfsTime)
PArse a GTFS time HH:MM:SS that is allowed to extend beyond the 24h cycle as an ExtendeLocalTime object- Parameters:
gtfsTime
- to parse- Returns:
- extended local time found
-
-