Changeset 7864 in josm for trunk/src/org
- Timestamp:
- 2014-12-20T22:43:20+01:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/AddNoteAction.java
r7852 r7864 15 15 import org.openstreetmap.josm.gui.Notification; 16 16 import org.openstreetmap.josm.gui.dialogs.NotesDialog; 17 import org.openstreetmap.josm.tools.CheckParameterUtil; 17 18 import org.openstreetmap.josm.tools.ImageProvider; 18 19 … … 34 35 tr("Add note mode"), 35 36 mapFrame, ImageProvider.getCursor("crosshair", "create_note")); 36 if (data == null) { 37 throw new IllegalArgumentException("Note data must not be null"); 38 } 37 CheckParameterUtil.ensureParameterNotNull(data, "data"); 39 38 noteData = data; 40 39 } -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitiveType.java
r6889 r7864 47 47 if (type.getAPIName().equals(typeName)) return type; 48 48 } 49 throw new IllegalArgumentException(MessageFormat.format("Parameter ''{0}'' is not a valid type name. Got ''{1}''.", "typeName", typeName)); 49 throw new IllegalArgumentException(MessageFormat.format( 50 "Parameter ''{0}'' is not a valid type name. Got ''{1}''.", "typeName", typeName)); 50 51 } 51 52 53 /** 54 * Determines the OSM primitive type of the given object. 55 * @param obj the S object to inspect 56 * @return the OSM primitive type of {@code obj} 57 * @throws IllegalArgumentException if {@code obj} is null or of unknown type 58 */ 52 59 public static OsmPrimitiveType from(IPrimitive obj) { 53 60 if (obj instanceof INode) return NODE; 54 61 if (obj instanceof IWay) return WAY; 55 62 if (obj instanceof IRelation) return RELATION; 56 throw new IllegalArgumentException( );63 throw new IllegalArgumentException("Unknown type: "+obj); 57 64 } 58 65 -
trunk/src/org/openstreetmap/josm/data/osm/RelationMember.java
r6305 r7864 3 3 4 4 import java.util.Arrays; 5 6 import org.openstreetmap.josm.tools.CheckParameterUtil; 5 7 6 8 /** … … 128 130 * @throws IllegalArgumentException thrown if member is <code>null</code> 129 131 */ 130 public RelationMember(String role, OsmPrimitive member) throws IllegalArgumentException{ 132 public RelationMember(String role, OsmPrimitive member) { 133 CheckParameterUtil.ensureParameterNotNull(member, "member"); 131 134 if (role == null) { 132 135 role = ""; 133 136 } 134 if (member == null)135 throw new IllegalArgumentException("Relation member cannot be null");136 137 this.role = role; 137 138 this.member = member; -
trunk/src/org/openstreetmap/josm/gui/ExtendedDialog.java
r7545 r7864 527 527 public ExtendedDialog toggleEnable(String togglePref) { 528 528 if (!modal) { 529 throw new Illegal ArgumentException();529 throw new IllegalStateException(); 530 530 } 531 531 this.toggleable = true; -
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r7843 r7864 266 266 values.add(g.getOptarg()); 267 267 } else 268 throw new IllegalArgumentException( );268 throw new IllegalArgumentException("Invalid option: "+c); 269 269 } 270 270 // positional arguments are a shortcut for the --download ... option -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/ListMergeModel.java
r7017 r7864 372 372 private void copy(ListRole sourceRole, int[] rows, int position) { 373 373 if (position < 0 || position > getMergedEntriesSize()) 374 throw new IllegalArgumentException( );374 throw new IllegalArgumentException("Position must be between 0 and "+getMergedEntriesSize()+" but is "+position); 375 375 List<T> newItems = new ArrayList<>(rows.length); 376 376 List<T> source = entries.get(sourceRole); -
trunk/src/org/openstreetmap/josm/gui/dialogs/DialogsPanel.java
r7005 r7864 10 10 import javax.swing.JSplitPane; 11 11 12 import org.openstreetmap.josm.gui.widgets.MultiSplitPane;13 12 import org.openstreetmap.josm.gui.widgets.MultiSplitLayout.Divider; 14 13 import org.openstreetmap.josm.gui.widgets.MultiSplitLayout.Leaf; 15 14 import org.openstreetmap.josm.gui.widgets.MultiSplitLayout.Node; 16 15 import org.openstreetmap.josm.gui.widgets.MultiSplitLayout.Split; 16 import org.openstreetmap.josm.gui.widgets.MultiSplitPane; 17 import org.openstreetmap.josm.tools.CheckParameterUtil; 17 18 import org.openstreetmap.josm.tools.Destroyable; 18 19 … … 161 162 } 162 163 } else { 163 if (triggeredBy == null) 164 throw new IllegalArgumentException(); 164 CheckParameterUtil.ensureParameterNotNull(triggeredBy, "triggeredBy"); 165 165 166 166 int sumP = 0; // sum of preferred heights of dialogs in default view (without the triggering dialog) -
trunk/src/org/openstreetmap/josm/gui/layer/TMSLayer.java
r7823 r7864 81 81 import org.openstreetmap.josm.io.OsmTransferException; 82 82 import org.openstreetmap.josm.io.UTFInputStreamReader; 83 import org.openstreetmap.josm.tools.CheckParameterUtil; 83 84 import org.openstreetmap.josm.tools.Utils; 84 85 import org.xml.sax.InputSource; … … 111 112 public static final IntegerProperty PROP_TMS_JOBS = new IntegerProperty("tmsloader.maxjobs", 25); 112 113 public static final StringProperty PROP_TILECACHE_DIR; 113 114 114 115 private static final boolean newcache = Main.pref.getBoolean("tms.newcache"); 115 116 … … 401 402 } 402 403 403 public static void checkUrl(String url) throws IllegalArgumentException { 404 if (url == null) { 405 throw new IllegalArgumentException(); 406 } else { 407 Matcher m = Pattern.compile("\\{[^}]*\\}").matcher(url); 408 while (m.find()) { 409 boolean isSupportedPattern = false; 410 for (String pattern : TemplatedTMSTileSource.ALL_PATTERNS) { 411 if (m.group().matches(pattern)) { 412 isSupportedPattern = true; 413 break; 414 } 415 } 416 if (!isSupportedPattern) { 417 throw new IllegalArgumentException(tr("{0} is not a valid TMS argument. Please check this server URL:\n{1}", m.group(), url)); 418 } 404 /** 405 * Checks validity of given URL. 406 * @param url URL to check 407 * @throws IllegalArgumentException if url is null or invalid 408 */ 409 public static void checkUrl(String url) { 410 CheckParameterUtil.ensureParameterNotNull(url, "url"); 411 Matcher m = Pattern.compile("\\{[^}]*\\}").matcher(url); 412 while (m.find()) { 413 boolean isSupportedPattern = false; 414 for (String pattern : TemplatedTMSTileSource.ALL_PATTERNS) { 415 if (m.group().matches(pattern)) { 416 isSupportedPattern = true; 417 break; 418 } 419 } 420 if (!isSupportedPattern) { 421 throw new IllegalArgumentException( 422 tr("{0} is not a valid TMS argument. Please check this server URL:\n{1}", m.group(), url)); 419 423 } 420 424 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/Cascade.java
r7509 r7864 42 42 public <T> T get(String key, T def, Class<T> klass, boolean suppressWarnings) { 43 43 if (def != null && !klass.isInstance(def)) 44 throw new IllegalArgumentException( );44 throw new IllegalArgumentException(def+" is not an instance of "+klass); 45 45 Object o = prop.get(key); 46 46 if (o == null) -
trunk/src/org/openstreetmap/josm/gui/mappaint/NodeElemStyle.java
r7621 r7864 45 45 public Symbol(SymbolShape symbol, int size, Stroke stroke, Color strokeColor, Color fillColor) { 46 46 if (stroke != null && strokeColor == null) 47 throw new IllegalArgumentException( );47 throw new IllegalArgumentException("Stroke given without color"); 48 48 if (stroke == null && fillColor == null) 49 throw new IllegalArgumentException( );49 throw new IllegalArgumentException("Either a stroke or a fill color must be given"); 50 50 this.symbol = symbol; 51 51 this.size = size; -
trunk/src/org/openstreetmap/josm/gui/mappaint/Range.java
r7069 r7864 13 13 public static final Range ZERO_TO_INFINITY = new Range(0.0, Double.POSITIVE_INFINITY); 14 14 15 /** 16 * Constructs a new {@code Range}. 17 * @param lower Lower bound. Must be positive or zero 18 * @param upper Upper bound 19 * @throws IllegalArgumentException if the range is invalid ({@code lower < 0 || lower >= upper}) 20 */ 15 21 public Range(double lower, double upper) { 16 22 if (lower < 0 || lower >= upper) 17 throw new IllegalArgumentException( );23 throw new IllegalArgumentException("Invalid range: "+lower+"-"+upper); 18 24 this.lower = lower; 19 25 this.upper = upper; … … 29 35 public static Range cut(Range a, Range b) { 30 36 if (b.lower >= a.upper || b.upper <= a.lower) 31 throw new IllegalArgumentException( );37 throw new IllegalArgumentException("Ranges do not overlap: "+a+" - "+b); 32 38 return new Range(Math.max(a.lower, b.lower), Math.min(a.upper, b.upper)); 33 39 } … … 49 55 public Range reduceAround(double x, Range other) { 50 56 if (!contains(x)) 51 throw new IllegalArgumentException( );57 throw new IllegalArgumentException(x+" is not inside "+this); 52 58 if (other.contains(x)) 53 throw new IllegalArgumentException( );59 throw new IllegalArgumentException(x+" is inside "+other); 54 60 55 61 if (x < other.lower && other.lower < upper) -
trunk/src/org/openstreetmap/josm/gui/mappaint/StyleCache.java
r7083 r7864 105 105 public StyleList get(double scale) { 106 106 if (scale <= 0) 107 throw new IllegalArgumentException( );107 throw new IllegalArgumentException("scale must be <= 0 but is "+scale); 108 108 for (int i=0; i<data.size(); ++i) { 109 109 if (bd.get(i) < scale && scale <= bd.get(i+1)) { … … 120 120 public Pair<StyleList, Range> getWithRange(double scale) { 121 121 if (scale <= 0) 122 throw new IllegalArgumentException( );122 throw new IllegalArgumentException("scale must be <= 0 but is "+scale); 123 123 for (int i=0; i<data.size(); ++i) { 124 124 if (bd.get(i) < scale && scale <= bd.get(i+1)) { -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java
r7801 r7864 592 592 public static double level2scale(int lvl) { 593 593 if (lvl < 0) 594 throw new IllegalArgumentException( );594 throw new IllegalArgumentException("lvl must be >= 0 but is "+lvl); 595 595 // preliminary formula - map such that mapnik imagery tiles of the same 596 596 // or similar level are displayed at the given scale … … 600 600 public static int scale2level(double scale) { 601 601 if (scale < 0) 602 throw new IllegalArgumentException( );602 throw new IllegalArgumentException("scale must be >= 0 but is "+scale); 603 603 return (int) Math.floor(Math.log(2 * Math.PI * R / 2.56 / scale) / Math.log(2)); 604 604 } -
trunk/src/org/openstreetmap/josm/gui/preferences/projection/AbstractProjectionChoice.java
r7184 r7864 35 35 public AbstractProjectionChoice(String name, String id) { 36 36 this(name, id, null); 37 if (!id.startsWith("core:")) throw new IllegalArgumentException( );37 if (!id.startsWith("core:")) throw new IllegalArgumentException(id+" does not start with core:"); 38 38 this.cacheDir = id.substring(5); 39 39 } -
trunk/src/org/openstreetmap/josm/gui/preferences/projection/CodeProjectionChoice.java
r7668 r7864 215 215 public Collection<String> getPreferences(JPanel panel) { 216 216 if (!(panel instanceof CodeSelectionPanel)) { 217 throw new IllegalArgumentException( );217 throw new IllegalArgumentException("Unsupported panel: "+panel); 218 218 } 219 219 CodeSelectionPanel csPanel = (CodeSelectionPanel) panel; -
trunk/src/org/openstreetmap/josm/gui/preferences/projection/CustomProjectionChoice.java
r7668 r7864 232 232 public Collection<String> getPreferences(JPanel panel) { 233 233 if (!(panel instanceof PreferencePanel)) { 234 throw new IllegalArgumentException( );234 throw new IllegalArgumentException("Unsupported panel: "+panel); 235 235 } 236 236 PreferencePanel prefPanel = (PreferencePanel) panel; -
trunk/src/org/openstreetmap/josm/gui/preferences/projection/ListProjectionChoice.java
r7015 r7864 106 106 public Collection<String> getPreferences(JPanel panel) { 107 107 if (!(panel instanceof CBPanel)) { 108 throw new IllegalArgumentException( );108 throw new IllegalArgumentException("Unsupported panel: "+panel); 109 109 } 110 110 CBPanel p = (CBPanel) panel; -
trunk/src/org/openstreetmap/josm/gui/preferences/projection/UTMProjectionChoice.java
r7668 r7864 106 106 public Collection<String> getPreferences(JPanel panel) { 107 107 if (!(panel instanceof UTMPanel)) { 108 throw new IllegalArgumentException( );108 throw new IllegalArgumentException("Unsupported panel: "+panel); 109 109 } 110 110 UTMPanel p = (UTMPanel) panel; -
trunk/src/org/openstreetmap/josm/gui/tagging/TagEditorModel.java
r7024 r7864 176 176 */ 177 177 public void add(TagModel tag) { 178 if (tag == null) 179 throw new IllegalArgumentException("argument 'tag' must not be null"); 178 CheckParameterUtil.ensureParameterNotNull(tag, "tag"); 180 179 tags.add(tag); 181 180 setDirty(true); … … 184 183 185 184 public void prepend(TagModel tag) { 186 if (tag == null) 187 throw new IllegalArgumentException("argument 'tag' must not be null"); 185 CheckParameterUtil.ensureParameterNotNull(tag, "tag"); 188 186 tags.add(0, tag); 189 187 setDirty(true); -
trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletingComboBox.java
r7863 r7864 223 223 cbEditor.setItem(((AutoCompletionListItem)item).getValue()); 224 224 } else 225 throw new IllegalArgumentException( );225 throw new IllegalArgumentException("Unsupported item: "+item); 226 226 } 227 227 -
trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletionList.java
r7725 r7864 11 11 import javax.swing.JTable; 12 12 import javax.swing.table.AbstractTableModel; 13 14 import org.openstreetmap.josm.tools.CheckParameterUtil; 13 15 14 16 /** … … 58 60 */ 59 61 public void applyFilter(String filter) { 60 if (filter == null) 61 throw new IllegalArgumentException("argument 'filter' must not be null"); 62 CheckParameterUtil.ensureParameterNotNull(filter, "filter"); 62 63 this.filter = filter; 63 64 filter(); … … 102 103 */ 103 104 public void add(AutoCompletionList other) { 104 if (other == null) 105 throw new IllegalArgumentException("argument 'other' must not be null"); 105 CheckParameterUtil.ensureParameterNotNull(other, "other"); 106 106 for (AutoCompletionListItem item : other.list) { 107 107 appendOrUpdatePriority(item); … … 119 119 */ 120 120 public void add(List<AutoCompletionListItem> other) { 121 if (other == null) 122 throw new IllegalArgumentException("argument 'other' must not be null"); 121 CheckParameterUtil.ensureParameterNotNull(other, "other"); 123 122 for (AutoCompletionListItem toadd : other) { 124 123 appendOrUpdatePriority(toadd); … … 148 147 filter(); 149 148 } 150 149 151 150 public void addUserInput(Collection<String> values) { 152 151 if (values == null) return; -
trunk/src/org/openstreetmap/josm/gui/widgets/MultiSplitLayout.java
r7025 r7864 43 43 44 44 import org.openstreetmap.josm.Main; 45 import org.openstreetmap.josm.tools.CheckParameterUtil; 45 46 import org.openstreetmap.josm.tools.Utils; 46 47 … … 828 829 */ 829 830 public List<Divider> dividersThatOverlap(Rectangle r) { 830 if (r == null) 831 throw new IllegalArgumentException("null Rectangle"); 831 CheckParameterUtil.ensureParameterNotNull(r, "r"); 832 832 return dividersThatOverlap(getModel(), r); 833 833 } … … 886 886 */ 887 887 public void setBounds(Rectangle bounds) { 888 if (bounds == null) 889 throw new IllegalArgumentException("null bounds"); 888 CheckParameterUtil.ensureParameterNotNull(bounds, "bounds"); 890 889 this.bounds = new Rectangle(bounds); 891 890 } … … 1077 1076 */ 1078 1077 public Leaf(String name) { 1079 if (name == null) 1080 throw new IllegalArgumentException("name is null"); 1078 CheckParameterUtil.ensureParameterNotNull(name, "name"); 1081 1079 this.name = name; 1082 1080 } … … 1097 1095 */ 1098 1096 public void setName(String name) { 1099 if (name == null) 1100 throw new IllegalArgumentException("name is null"); 1097 CheckParameterUtil.ensureParameterNotNull(name, "name"); 1101 1098 this.name = name; 1102 1099 } -
trunk/src/org/openstreetmap/josm/tools/ExifReader.java
r7592 r7864 175 175 176 176 if (Double.isNaN(deg) && Double.isNaN(min) && Double.isNaN(sec)) 177 throw new IllegalArgumentException( );177 throw new IllegalArgumentException("deg, min and sec are NaN"); 178 178 179 179 value = (Double.isNaN(deg) ? 0 : deg + (Double.isNaN(min) ? 0 : (min / 60)) + (Double.isNaN(sec) ? 0 : (sec / 3600))); -
trunk/src/org/openstreetmap/josm/tools/Geometry.java
r7828 r7864 329 329 CheckParameterUtil.ensureValidCoordinates(p4, "p4"); 330 330 331 if (!p1.isValid()) throw new IllegalArgumentException( );331 if (!p1.isValid()) throw new IllegalArgumentException(p1+" is invalid"); 332 332 333 333 // Basically, the formula from wikipedia is used: -
trunk/src/org/openstreetmap/josm/tools/ImageResource.java
r7731 r7864 81 81 public ImageIcon getImageIcon(Dimension dim) { 82 82 if (dim.width < -1 || dim.width == 0 || dim.height < -1 || dim.height == 0) 83 throw new IllegalArgumentException( );83 throw new IllegalArgumentException(dim+" is invalid"); 84 84 Image img = imgCache.get(dim); 85 85 if (img != null) { … … 123 123 public ImageIcon getImageIconBounded(Dimension maxSize) { 124 124 if (maxSize.width < -1 || maxSize.width == 0 || maxSize.height < -1 || maxSize.height == 0) 125 throw new IllegalArgumentException( );125 throw new IllegalArgumentException(maxSize+" is invalid"); 126 126 float realWidth; 127 127 float realHeight; -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r7835 r7864 189 189 public static int mod(int a, int n) { 190 190 if (n <= 0) 191 throw new IllegalArgumentException( );191 throw new IllegalArgumentException("n must be <= 0 but is "+n); 192 192 int res = a % n; 193 193 if (res < 0) { … … 206 206 */ 207 207 public static String join(String sep, Collection<?> values) { 208 if (sep == null) 209 throw new IllegalArgumentException(); 208 CheckParameterUtil.ensureParameterNotNull(sep, "sep"); 210 209 if (values == null) 211 210 return null;
Note:
See TracChangeset
for help on using the changeset viewer.