-
Notifications
You must be signed in to change notification settings - Fork 1
A wrapper for the iRail API for Java programming languages
iRail/iRailForJ
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This is the official Java wrapper for the iRail API. USAGE ------ 1. Download the .jar at https://github.com/downloads/iRail/iRailForJ/iRailForJ.jar 2. copy iRailForJ jar file in your project Example: construct an IRail instance connecting to the dev API, with language set to dutch. get connections from LIEDEKERKE to BRUSSELS CENTRAL stations. list departure and arrival for each, skipping non-direct connections. formatted a la NMBS. ---cut here--- public class IRailExample { public static final String TEST_URL="http://api.irail.be"; public static void main(String[] argv) throws Exception { IRail iRail =new IRail(TEST_URL,"nl"); Calendar cal =Calendar.getInstance(); List<Connection> connections = iRail.getConnections("LIEDEKERKE","BRUSSEL CENTRAAL"); for(Connection connection : connections) { // skip connections that have transfers, to keep this example simple if(connection.hasVias()) continue; TripNode departure=connection.getDeparture(); TripNode arrival =connection.getArrival(); cal.setTime(departure.getTime()); System.out.printf("DEPARTURE [%2d:%02d %-22s %-3s %2s +%02dH%02d] -> ", cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), departure.getStation().getName(), departure.getVehicle().getType(), departure.getPlatform(), (departure.getDelay()/60)/60, (departure.getDelay()/60)%60); cal.setTime(arrival.getTime()); System.out.printf("ARRIVAL [%2d:%02d %-22s %-3s %2s]\n", cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), arrival.getStation().getName(), arrival.getVehicle().getType(), arrival.getPlatform()); } } } ---cut here--- output example: DEPARTURE [20:47 LIEDEKERKE IC 3 +00H10] -> ARRIVAL [21:11 BRUSSEL CENTRAAL IC 1] DEPARTURE [21:17 LIEDEKERKE IR 3 +00H00] -> ARRIVAL [21:39 BRUSSEL CENTRAAL IR 3] DEPARTURE [21:19 LIEDEKERKE CR 1 +00H00] -> ARRIVAL [21:55 BRUSSEL CENTRAAL CR 2] DEPARTURE [21:47 LIEDEKERKE IC 3 +00H00] -> ARRIVAL [22:16 BRUSSEL CENTRAAL IC 1] DEPARTURE [22:17 LIEDEKERKE IR 3 +00H00] -> ARRIVAL [22:39 BRUSSEL CENTRAAL IR 3] LINKS ------ http://project.iRail.be http://iRail.be LICENSE --------- The Code is released under GPL v3. This means you can take this code, and put it into your project. Your project however should be licensed under a GPL v3 compatible license. Author: Pieter Colpaert <pieter[aŧ]iRail.be> - http://bonsansnom.wordpress.com
About
A wrapper for the iRail API for Java programming languages
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published