org.opentripplanner.api.common.Message Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of otp Show documentation
Show all versions of otp Show documentation
The OpenTripPlanner multimodal journey planning system
package org.opentripplanner.api.common;
import org.opentripplanner.util.Properties;
import java.util.Locale;
/**
* The purpose of Messages is to read supply Message.properties to underlying calling code...
* The ENUM's enumerated values should be named to reflect the property names inside of Message.properties
*/
public enum Message {
// id field is loosely based on HTTP error codes http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
PLAN_OK(200),
SYSTEM_ERROR(500),
GRAPH_UNAVAILABLE(503),
OUTSIDE_BOUNDS(400),
PATH_NOT_FOUND(404),
NO_TRANSIT_TIMES(406),
REQUEST_TIMEOUT(408),
BOGUS_PARAMETER(413),
GEOCODE_FROM_NOT_FOUND(440),
GEOCODE_TO_NOT_FOUND(450),
GEOCODE_FROM_TO_NOT_FOUND(460),
TOO_CLOSE(409),
LOCATION_NOT_ACCESSIBLE(470),
GEOCODE_FROM_AMBIGUOUS(340),
GEOCODE_TO_AMBIGUOUS(350),
GEOCODE_FROM_TO_AMBIGUOUS(360),
UNDERSPECIFIED_TRIANGLE(370),
TRIANGLE_NOT_AFFINE(371),
TRIANGLE_OPTIMIZE_TYPE_NOT_SET(372),
TRIANGLE_VALUES_NOT_SET(373),
;
private Properties config = getConfig();
private final int m_id;
/** enum constructors are private -- see values above */
private Message(int id) {
m_id = id;
}
public int getId() {
return m_id;
}
/** simple checker / getter of the config */
public Properties getConfig() {
if(config == null)
config = new Properties(Message.class);
return config;
}
public String get(String def, Locale l) {
try {
getConfig();
return config.get(name(), l);
}
catch(Exception e) {
Properties.LOG.warn("No entry in Message.properties file could be found for string " + name());
}
return def;
}
public String get(Locale l) {
return get("", l);
}
public String get() {
return get("", Locale.getDefault());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy