Changeset 9385 in josm
- Timestamp:
- 2016-01-10T13:48:42+01:00 (9 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/OverpassDownloadAction.java
r9242 r9385 50 50 import org.openstreetmap.josm.tools.OverpassTurboQueryWizard; 51 51 import org.openstreetmap.josm.tools.Shortcut; 52 import org.openstreetmap.josm.tools.UncheckedParseException; 52 53 import org.openstreetmap.josm.tools.Utils; 53 54 … … 157 158 try { 158 159 overpassQuery.setText(OverpassTurboQueryWizard.getInstance().constructQuery(overpassWizardText)); 159 } catch ( OverpassTurboQueryWizard.ParseException ex) {160 } catch (UncheckedParseException ex) { 160 161 HelpAwareOptionPane.showOptionDialog( 161 162 Main.parent, -
trunk/src/org/openstreetmap/josm/tools/OverpassTurboQueryWizard.java
r8855 r9385 24 24 private static OverpassTurboQueryWizard instance; 25 25 private final ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript"); 26 27 /**28 * An exception to indicate a failed parse.29 */30 public static class ParseException extends RuntimeException {31 }32 26 33 27 /** … … 60 54 * @param search the {@link org.openstreetmap.josm.actions.search.SearchAction} like query 61 55 * @return an Overpass QL query 62 * @throws ParseException when the parsing fails56 * @throws UncheckedParseException when the parsing fails 63 57 */ 64 public String constructQuery(String search) throws ParseException {58 public String constructQuery(String search) throws UncheckedParseException { 65 59 try { 66 60 final Object result = ((Invocable) engine).invokeFunction("construct_query", search); 67 61 if (result == Boolean.FALSE) { 68 throw new ParseException();62 throw new UncheckedParseException(); 69 63 } 70 64 String query = (String) result; -
trunk/src/org/openstreetmap/josm/tools/date/DateUtils.java
r9383 r9385 18 18 import org.openstreetmap.josm.data.preferences.BooleanProperty; 19 19 import org.openstreetmap.josm.tools.CheckParameterUtil; 20 import org.openstreetmap.josm.tools.UncheckedParseException; 20 21 21 22 /** … … 66 67 * @param str The XML date as string 67 68 * @return The date 68 */ 69 public static synchronized Date fromString(String str) { 69 * @throws UncheckedParseException if the date does not match any of the supported date formats 70 */ 71 public static synchronized Date fromString(String str) throws UncheckedParseException { 70 72 return new Date(tsFromString(str)); 71 73 } … … 75 77 * @param str The XML date as string 76 78 * @return The date in milliseconds since epoch 77 */ 78 public static synchronized long tsFromString(String str) { 79 * @throws UncheckedParseException if the date does not match any of the supported date formats 80 */ 81 public static synchronized long tsFromString(String str) throws UncheckedParseException { 79 82 // "2007-07-25T09:26:24{Z|{+|-}01:00}" 80 83 if (checkLayout(str, "xxxx-xx-xxTxx:xx:xxZ") || … … 130 133 return XML_DATE.newXMLGregorianCalendar(str).toGregorianCalendar().getTimeInMillis(); 131 134 } catch (Exception ex) { 132 return System.currentTimeMillis();135 throw new UncheckedParseException("The date string (" + str + ") could not be parsed."); 133 136 } 134 137 } -
trunk/test/unit/org/openstreetmap/josm/tools/OverpassTurboQueryWizardTest.java
r8876 r9385 46 46 * Test erroneous value. 47 47 */ 48 @Test(expected = OverpassTurboQueryWizard.ParseException.class)48 @Test(expected = UncheckedParseException.class) 49 49 public void testErroneous() { 50 50 OverpassTurboQueryWizard.getInstance().constructQuery("foo"); -
trunk/test/unit/org/openstreetmap/josm/tools/date/DateUtilsTest.java
r9383 r9385 4 4 import static org.junit.Assert.assertEquals; 5 5 6 import java.util.Date; 6 7 import java.util.TimeZone; 7 8 8 9 import org.junit.BeforeClass; 9 10 import org.junit.Test; 11 import org.openstreetmap.josm.tools.UncheckedParseException; 10 12 11 13 /** … … 65 67 assertEquals(-1041337172130L, DateUtils.fromString("1937-01-01T12:00:27.87+00:20").getTime()); 66 68 } 69 70 /** 71 * Verifies that parsing an illegal date throws a {@link UncheckedParseException} 72 */ 73 @Test(expected = UncheckedParseException.class) 74 public void testIllegalDate() { 75 DateUtils.fromString("2014-"); 76 } 67 77 }
Note:
See TracChangeset
for help on using the changeset viewer.