### Question:
AbstractFlagEncoder implements FlagEncoder { public static double parseSpeed(String str) { if (Helper.isEmpty(str)) return -1; if ("none".equals(str)) return MaxSpeed.UNLIMITED_SIGN_SPEED; if (str.endsWith(":rural") || str.endsWith(":trunk")) return 80; if (str.endsWith(":urban")) return 50; if (str.equals("walk") || str.endsWith(":living_street")) return 6; try { int val; int mpInteger = str.indexOf("mp"); if (mpInteger > 0) { str = str.substring(0, mpInteger).trim(); val = Integer.parseInt(str); return val * DistanceCalcEarth.KM_MILE; } int knotInteger = str.indexOf("knots"); if (knotInteger > 0) { str = str.substring(0, knotInteger).trim(); val = Integer.parseInt(str); return val * 1.852; } int kmInteger = str.indexOf("km"); if (kmInteger > 0) { str = str.substring(0, kmInteger).trim(); } else { kmInteger = str.indexOf("kph"); if (kmInteger > 0) { str = str.substring(0, kmInteger).trim(); } } return Integer.parseInt(str); } catch (Exception ex) { return -1; } } AbstractFlagEncoder(PMap properties);  AbstractFlagEncoder(String propertiesStr); protected  AbstractFlagEncoder(int speedBits, double speedFactor, int maxTurnCosts); @Override boolean isRegistered(); void setBlockByDefault(boolean blockByDefault); boolean isBlockFords(); void setBlockFords(boolean blockFords); ConditionalTagInspector getConditionalTagInspector(); int defineNodeBits(int index, int shift); void createEncodedValues(List<EncodedValue> registerNewEncodedValue, String prefix, int index); abstract IntsRef handleWayTags(IntsRef edgeFlags, ReaderWay way, EncodingManager.Access access); int getMaxTurnCosts(); abstract EncodingManager.Access getAccess(ReaderWay way); long handleNodeTags(ReaderNode node); @Override double getMaxSpeed(); @Override int hashCode(); @Override boolean equals(Object obj); static double parseSpeed(String str); void applyWayTags(ReaderWay way, EdgeIteratorState edge); final DecimalEncodedValue getAverageSpeedEnc(); final BooleanEncodedValue getAccessEnc(); @Override T getEncodedValue(String key, Class<T> encodedValueType); @Override BooleanEncodedValue getBooleanEncodedValue(String key); @Override IntEncodedValue getIntEncodedValue(String key); @Override DecimalEncodedValue getDecimalEncodedValue(String key); @Override EnumEncodedValue<T> getEnumEncodedValue(String key, Class<T> enumType); void setEncodedValueLookup(EncodedValueLookup encodedValueLookup); @Override boolean supportsTurnCosts(); @Override boolean supports(Class<?> feature); @Override boolean hasEncodedValue(String key);  }### Answer:
@Test public void testAcceptsCar() { CarFlagEncoder encoder = new CarFlagEncoder(5, 5, 0); assertEquals(40, encoder.parseSpeed("40 km/h"), 1e-3); assertEquals(40, encoder.parseSpeed("40km/h"), 1e-3); assertEquals(40, encoder.parseSpeed("40kmh"), 1e-3); assertEquals(64.374, encoder.parseSpeed("40mph"), 1e-3); assertEquals(48.28, encoder.parseSpeed("30 mph"), 1e-3); assertEquals(-1, encoder.parseSpeed(null), 1e-3); assertEquals(18.52, encoder.parseSpeed("10 knots"), 1e-3); assertEquals(19, encoder.parseSpeed("19 kph"), 1e-3); assertEquals(19, encoder.parseSpeed("19kph"), 1e-3); assertEquals(50, encoder.parseSpeed("RO:urban"), 1e-3); assertEquals(80, encoder.parseSpeed("RU:rural"), 1e-3); assertEquals(6, encoder.parseSpeed("walk"), 1e-3); }