use of org.onebusaway.gtfs_transformer.impl.StringModificationStrategy in project onebusaway-gtfs-modules by OneBusAway.
the class TransformFactory method handleUpdateOperation.
private void handleUpdateOperation(String line, JSONObject json) throws JSONException, TransformSpecificationException {
EntitiesTransformStrategy strategy = getStrategy(EntitiesTransformStrategy.class);
TypedEntityMatch match = getMatch(line, json);
if (json.has("factory")) {
String factoryType = json.getString("factory");
try {
Class<?> clazz = Class.forName(factoryType);
Object factoryObj = clazz.newInstance();
if (!(factoryObj instanceof EntityTransformStrategy)) {
throw new TransformSpecificationException("factory object is not an instance of EntityTransformStrategy: " + clazz.getName(), line);
}
strategy.addModification(match, (EntityTransformStrategy) factoryObj);
} catch (Throwable ex) {
throw new TransformSpecificationException("error creating factory ModificationStrategy instance", ex, line);
}
return;
}
if (json.has(ARG_UPDATE)) {
JSONObject update = json.getJSONObject(ARG_UPDATE);
EntityTransformStrategy mod = getUpdateEntityTransformStrategy(line, match, update);
strategy.addModification(match, mod);
}
if (json.has("strings")) {
JSONObject strings = json.getJSONObject("strings");
Map<String, Pair<String>> replacements = getEntityPropertiesAndStringReplacementsFromJsonObject(match.getType(), strings);
StringModificationStrategy mod = new StringModificationStrategy(replacements);
strategy.addModification(match, mod);
}
}
Aggregations