Changeset 6906 in josm
- Timestamp:
- 2014-03-10T02:33:20+01:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 1 deleted
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/coor/Coordinate.java
r6380 r6906 113 113 } 114 114 115 @Override 116 public int hashCode() { 115 protected final int computeHashCode(int init) { 117 116 final int prime = 31; 118 int result = 1;117 int result = init; 119 118 long temp; 120 119 temp = java.lang.Double.doubleToLongBits(x); … … 123 122 result = prime * result + (int) (temp ^ (temp >>> 32)); 124 123 return result; 124 } 125 126 @Override 127 public int hashCode() { 128 return computeHashCode(1); 125 129 } 126 130 -
trunk/src/org/openstreetmap/josm/data/coor/LatLon.java
r6883 r6906 410 410 @Override 411 411 public int hashCode() { 412 final int prime = 31; 413 int result = super.hashCode(); 414 long temp; 415 temp = java.lang.Double.doubleToLongBits(x); 416 result = prime * result + (int) (temp ^ (temp >>> 32)); 417 temp = java.lang.Double.doubleToLongBits(y); 418 result = prime * result + (int) (temp ^ (temp >>> 32)); 419 return result; 412 return computeHashCode(super.hashCode()); 420 413 } 421 414 -
trunk/src/org/openstreetmap/josm/gui/oauth/TestAccessTokenTask.java
r6643 r6906 25 25 import org.openstreetmap.josm.gui.help.HelpUtil; 26 26 import org.openstreetmap.josm.io.OsmApiException; 27 import org.openstreetmap.josm.io.OsmDataParsingException;28 27 import org.openstreetmap.josm.io.OsmServerUserInfoReader; 29 28 import org.openstreetmap.josm.io.OsmTransferException; … … 31 30 import org.openstreetmap.josm.tools.CheckParameterUtil; 32 31 import org.openstreetmap.josm.tools.Utils; 32 import org.openstreetmap.josm.tools.XmlParsingException; 33 33 import org.w3c.dom.Document; 34 34 import org.xml.sax.SAXException; … … 98 98 } 99 99 100 protected UserInfo getUserDetails() throws OsmOAuthAuthorizationException, OsmDataParsingException,OsmTransferException {100 protected UserInfo getUserDetails() throws OsmOAuthAuthorizationException, XmlParsingException, OsmTransferException { 101 101 boolean authenticatorEnabled = true; 102 102 try { … … 124 124 return OsmServerUserInfoReader.buildFromXML(d); 125 125 } catch(SAXException e) { 126 throw new OsmDataParsingException(e);126 throw new XmlParsingException(e); 127 127 } catch(ParserConfigurationException e){ 128 throw new OsmDataParsingException(e);128 throw new XmlParsingException(e); 129 129 } catch(MalformedURLException e) { 130 130 throw new OsmTransferException(e); -
trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferencesModel.java
r6733 r6906 71 71 availablePlugins.addAll(available); 72 72 } 73 availablePluginsModified(); 74 } 75 76 protected final void availablePluginsModified() { 73 77 sort(); 74 78 filterDisplayedPlugins(filterExpression); … … 86 90 } 87 91 88 protected 92 protected void updateAvailablePlugin(PluginInformation other) { 89 93 if (other == null) return; 90 94 PluginInformation pi = getPluginInformation(other.name); … … 106 110 updateAvailablePlugin(other); 107 111 } 108 sort(); 109 filterDisplayedPlugins(filterExpression); 110 Set<String> activePlugins = new HashSet<String>(); 111 activePlugins.addAll(Main.pref.getCollection("plugins", activePlugins)); 112 for (PluginInformation pi: availablePlugins) { 113 if (selectedPluginsMap.get(pi) == null) { 114 if (activePlugins.contains(pi.name)) { 115 selectedPluginsMap.put(pi, true); 116 } 117 } 118 } 119 clearChanged(); 120 notifyObservers(); 112 availablePluginsModified(); 121 113 } 122 114 -
trunk/src/org/openstreetmap/josm/io/DiffResultProcessor.java
r6889 r6906 24 24 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 25 25 import org.openstreetmap.josm.tools.CheckParameterUtil; 26 import org.openstreetmap.josm.tools.XmlParsingException; 26 27 import org.xml.sax.Attributes; 27 28 import org.xml.sax.InputSource; … … 71 72 * @param diffUploadResponse the response. Must not be null. 72 73 * @param progressMonitor a progress monitor. Defaults to {@link NullProgressMonitor#INSTANCE} if null 73 * @throws IllegalArgumentException thrownif diffUploadRequest is null74 * @throws OsmDataParsingException thrown if the diffUploadRequest can't be parsed successfully74 * @throws IllegalArgumentException if diffUploadRequest is null 75 * @throws XmlParsingException if the diffUploadRequest can't be parsed successfully 75 76 * 76 77 */ 77 public void parse(String diffUploadResponse, ProgressMonitor progressMonitor) throws OsmDataParsingException {78 public void parse(String diffUploadResponse, ProgressMonitor progressMonitor) throws XmlParsingException { 78 79 if (progressMonitor == null) { 79 80 progressMonitor = NullProgressMonitor.INSTANCE; … … 85 86 SAXParserFactory.newInstance().newSAXParser().parse(inputSource, new Parser()); 86 87 } catch(IOException e) { 87 throw new OsmDataParsingException(e);88 throw new XmlParsingException(e); 88 89 } catch(ParserConfigurationException e) { 89 throw new OsmDataParsingException(e);90 } catch( OsmDataParsingException e) {90 throw new XmlParsingException(e); 91 } catch(XmlParsingException e) { 91 92 throw e; 92 93 } catch(SAXException e) { 93 throw new OsmDataParsingException(e);94 throw new XmlParsingException(e); 94 95 } finally { 95 96 progressMonitor.finishTask(); … … 147 148 } 148 149 149 protected void throwException(String msg) throws OsmDataParsingException{150 throw new OsmDataParsingException(msg).rememberLocation(locator);150 protected void throwException(String msg) throws XmlParsingException { 151 throw new XmlParsingException(msg).rememberLocation(locator); 151 152 } 152 153 … … 173 174 } 174 175 } catch (NumberFormatException e) { 175 throw new OsmDataParsingException(e).rememberLocation(locator);176 throw new XmlParsingException(e).rememberLocation(locator); 176 177 } 177 178 } -
trunk/src/org/openstreetmap/josm/io/OsmApi.java
r6889 r6906 39 39 import org.openstreetmap.josm.tools.CheckParameterUtil; 40 40 import org.openstreetmap.josm.tools.Utils; 41 import org.openstreetmap.josm.tools.XmlParsingException; 41 42 import org.xml.sax.Attributes; 42 43 import org.xml.sax.InputSource; … … 535 536 } catch(OsmTransferException e) { 536 537 throw e; 537 } catch( OsmDataParsingException e) {538 } catch(XmlParsingException e) { 538 539 throw new OsmTransferException(e); 539 540 } finally { -
trunk/src/org/openstreetmap/josm/io/OsmChangesetContentParser.java
r6552 r6906 19 19 import org.openstreetmap.josm.tools.CheckParameterUtil; 20 20 import org.openstreetmap.josm.tools.Utils; 21 import org.openstreetmap.josm.tools.XmlParsingException; 21 22 import org.xml.sax.Attributes; 22 23 import org.xml.sax.InputSource; … … 38 39 private ChangesetDataSet.ChangesetModificationType currentModificationType; 39 40 40 protected void throwException(String message) throws OsmDataParsingException {41 throw new OsmDataParsingException(message).rememberLocation(locator);41 protected void throwException(String message) throws XmlParsingException { 42 throw new XmlParsingException(message).rememberLocation(locator); 42 43 } 43 44 44 protected void throwException(Exception e) throws OsmDataParsingException {45 throw new OsmDataParsingException(e).rememberLocation(locator);45 protected void throwException(Exception e) throws XmlParsingException { 46 throw new XmlParsingException(e).rememberLocation(locator); 46 47 } 47 48 … … 128 129 * @param progressMonitor the progress monitor. Set to {@link NullProgressMonitor#INSTANCE} if null 129 130 * @return the parsed data 130 * @throws OsmDataParsingException thrown if something went wrong. Check for chained131 * @throws XmlParsingException if something went wrong. Check for chained 131 132 * exceptions. 132 133 */ 133 public ChangesetDataSet parse(ProgressMonitor progressMonitor) throws OsmDataParsingException {134 public ChangesetDataSet parse(ProgressMonitor progressMonitor) throws XmlParsingException { 134 135 if (progressMonitor == null) { 135 136 progressMonitor = NullProgressMonitor.INSTANCE; … … 139 140 progressMonitor.indeterminateSubTask(tr("Parsing changeset content ...")); 140 141 SAXParserFactory.newInstance().newSAXParser().parse(source, new Parser()); 141 } catch( OsmDataParsingException e){142 } catch(XmlParsingException e) { 142 143 throw e; 143 144 } catch (ParserConfigurationException e) { 144 throw new OsmDataParsingException(e);145 throw new XmlParsingException(e); 145 146 } catch(SAXException e) { 146 throw new OsmDataParsingException(e);147 throw new XmlParsingException(e); 147 148 } catch(IOException e) { 148 throw new OsmDataParsingException(e);149 throw new XmlParsingException(e); 149 150 } finally { 150 151 progressMonitor.finishTask(); … … 157 158 * 158 159 * @return the parsed data 159 * @throws OsmDataParsingException thrown if something went wrong. Check for chained160 * @throws XmlParsingException if something went wrong. Check for chained 160 161 * exceptions. 161 162 */ 162 public ChangesetDataSet parse() throws OsmDataParsingException {163 public ChangesetDataSet parse() throws XmlParsingException { 163 164 return parse(null); 164 165 } -
trunk/src/org/openstreetmap/josm/io/OsmChangesetParser.java
r6787 r6906 19 19 import org.openstreetmap.josm.tools.DateUtils; 20 20 import org.openstreetmap.josm.tools.Utils; 21 import org.openstreetmap.josm.tools.XmlParsingException; 21 22 import org.xml.sax.Attributes; 22 23 import org.xml.sax.InputSource; … … 46 47 } 47 48 49 /** 50 * Returns the parsed changesets. 51 * @return the parsed changesets 52 */ 48 53 public List<Changeset> getChangesets() { 49 54 return changesets; … … 58 63 } 59 64 60 protected void throwException(String msg) throws OsmDataParsingException{ 61 throw new OsmDataParsingException(msg).rememberLocation(locator); 62 } 63 /** 64 * The current changeset 65 */ 65 protected void throwException(String msg) throws XmlParsingException { 66 throw new XmlParsingException(msg).rememberLocation(locator); 67 } 68 69 /** The current changeset */ 66 70 private Changeset current = null; 67 71 68 protected void parseChangesetAttributes(Changeset cs, Attributes atts) throws OsmDataParsingException {72 protected void parseChangesetAttributes(Changeset cs, Attributes atts) throws XmlParsingException { 69 73 // -- id 70 74 String value = atts.getValue("id"); … … 186 190 } 187 191 188 protected User createUser(String uid, String name) throws OsmDataParsingException {192 protected User createUser(String uid, String name) throws XmlParsingException { 189 193 if (uid == null) { 190 194 if (name == null) -
trunk/src/org/openstreetmap/josm/io/OsmServerChangesetReader.java
r6830 r6906 18 18 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 19 19 import org.openstreetmap.josm.tools.CheckParameterUtil; 20 import org.openstreetmap.josm.tools.XmlParsingException; 20 21 21 22 /** … … 182 183 OsmChangesetContentParser parser = new OsmChangesetContentParser(in); 183 184 return parser.parse(monitor.createSubTaskMonitor(1, true)); 184 } catch( OsmDataParsingException e) {185 } catch(XmlParsingException e) { 185 186 throw new OsmTransferException(e); 186 187 } finally { -
trunk/src/org/openstreetmap/josm/io/OsmServerUserInfoReader.java
r6889 r6906 19 19 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 20 20 import org.openstreetmap.josm.tools.DateUtils; 21 import org.openstreetmap.josm.tools.XmlParsingException; 21 22 import org.w3c.dom.Document; 22 23 import org.w3c.dom.Node; … … 33 34 * @param document The XML contents 34 35 * @return The user info 35 * @throws OsmDataParsingException if parsing goes wrong36 * @throws XmlParsingException if parsing goes wrong 36 37 */ 37 public static UserInfo buildFromXML(Document document) throws OsmDataParsingException {38 public static UserInfo buildFromXML(Document document) throws XmlParsingException { 38 39 try { 39 40 XPathFactory factory = XPathFactory.newInstance(); … … 42 43 Node xmlNode = (Node)xpath.compile("/osm/user[1]").evaluate(document, XPathConstants.NODE); 43 44 if ( xmlNode== null) 44 throw new OsmDataParsingException(tr("XML tag <user> is missing."));45 throw new XmlParsingException(tr("XML tag <user> is missing.")); 45 46 46 47 // -- id 47 48 String v = getAttribute(xmlNode, "id"); 48 49 if (v == null) 49 throw new OsmDataParsingException(tr("Missing attribute ''{0}'' on XML tag ''{1}''.", "id", "user"));50 throw new XmlParsingException(tr("Missing attribute ''{0}'' on XML tag ''{1}''.", "id", "user")); 50 51 try { 51 52 userInfo.setId(Integer.parseInt(v)); 52 53 } catch(NumberFormatException e) { 53 throw new OsmDataParsingException(tr("Illegal value for attribute ''{0}'' on XML tag ''{1}''. Got {2}.", "id", "user", v));54 throw new XmlParsingException(tr("Illegal value for attribute ''{0}'' on XML tag ''{1}''. Got {2}.", "id", "user", v)); 54 55 } 55 56 // -- display name … … 71 72 v = getAttribute(xmlNode, "lat"); 72 73 if (v == null) 73 throw new OsmDataParsingException(tr("Missing attribute ''{0}'' on XML tag ''{1}''.", "lat", "home"));74 throw new XmlParsingException(tr("Missing attribute ''{0}'' on XML tag ''{1}''.", "lat", "home")); 74 75 double lat; 75 76 try { 76 77 lat = Double.parseDouble(v); 77 78 } catch(NumberFormatException e) { 78 throw new OsmDataParsingException(tr("Illegal value for attribute ''{0}'' on XML tag ''{1}''. Got {2}.", "lat", "home", v));79 throw new XmlParsingException(tr("Illegal value for attribute ''{0}'' on XML tag ''{1}''. Got {2}.", "lat", "home", v)); 79 80 } 80 81 81 82 v = getAttribute(xmlNode, "lon"); 82 83 if (v == null) 83 throw new OsmDataParsingException(tr("Missing attribute ''{0}'' on XML tag ''{1}''.", "lon", "home"));84 throw new XmlParsingException(tr("Missing attribute ''{0}'' on XML tag ''{1}''.", "lon", "home")); 84 85 double lon; 85 86 try { 86 87 lon = Double.parseDouble(v); 87 88 } catch(NumberFormatException e) { 88 throw new OsmDataParsingException(tr("Illegal value for attribute ''{0}'' on XML tag ''{1}''. Got {2}.", "lon", "home", v));89 throw new XmlParsingException(tr("Illegal value for attribute ''{0}'' on XML tag ''{1}''. Got {2}.", "lon", "home", v)); 89 90 } 90 91 91 92 v = getAttribute(xmlNode, "zoom"); 92 93 if (v == null) 93 throw new OsmDataParsingException(tr("Missing attribute ''{0}'' on XML tag ''{1}''.", "zoom", "home"));94 throw new XmlParsingException(tr("Missing attribute ''{0}'' on XML tag ''{1}''.", "zoom", "home")); 94 95 int zoom; 95 96 try { 96 97 zoom = Integer.parseInt(v); 97 98 } catch(NumberFormatException e) { 98 throw new OsmDataParsingException(tr("Illegal value for attribute ''{0}'' on XML tag ''{1}''. Got {2}.", "zoom", "home", v));99 throw new XmlParsingException(tr("Illegal value for attribute ''{0}'' on XML tag ''{1}''. Got {2}.", "zoom", "home", v)); 99 100 } 100 101 userInfo.setHome(new LatLon(lat,lon)); … … 117 118 v = getAttribute(xmlNode, "unread"); 118 119 if (v == null) 119 throw new OsmDataParsingException(tr("Missing attribute ''{0}'' on XML tag ''{1}''.", "unread", "received"));120 throw new XmlParsingException(tr("Missing attribute ''{0}'' on XML tag ''{1}''.", "unread", "received")); 120 121 try { 121 122 userInfo.setUnreadMessages(Integer.parseInt(v)); 122 123 } catch(NumberFormatException e) { 123 throw new OsmDataParsingException(tr("Illegal value for attribute ''{0}'' on XML tag ''{1}''. Got {2}.", "unread", "received", v), e);124 throw new XmlParsingException(tr("Illegal value for attribute ''{0}'' on XML tag ''{1}''. Got {2}.", "unread", "received", v), e); 124 125 } 125 126 } … … 127 128 return userInfo; 128 129 } catch(XPathException e) { 129 throw new OsmDataParsingException(e);130 throw new XmlParsingException(e); 130 131 } 131 132 } -
trunk/src/org/openstreetmap/josm/plugins/ReadLocalPluginInformationTask.java
r6643 r6906 40 40 private boolean canceled; 41 41 42 /** 43 * Constructs a new {@code ReadLocalPluginInformationTask}. 44 */ 42 45 public ReadLocalPluginInformationTask() { 43 46 super(tr("Reading local plugin information.."), false); … … 72 75 } 73 76 74 pr otected void scanSiteCacheFiles(ProgressMonitor monitor,File pluginsDirectory) {75 File[] siteCacheFiles =pluginsDirectory.listFiles(77 private File[] listFiles(File pluginsDirectory, final String regex) { 78 return pluginsDirectory.listFiles( 76 79 new FilenameFilter() { 77 80 @Override 78 81 public boolean accept(File dir, String name) { 79 return name.matches( "^([0-9]+-)?site.*\\.txt$");82 return name.matches(regex); 80 83 } 81 84 } 82 85 ); 86 } 87 88 protected void scanSiteCacheFiles(ProgressMonitor monitor, File pluginsDirectory) { 89 File[] siteCacheFiles = listFiles(pluginsDirectory, "^([0-9]+-)?site.*\\.txt$"); 83 90 if (siteCacheFiles == null || siteCacheFiles.length == 0) 84 91 return; … … 97 104 } 98 105 } 99 100 106 protected void scanIconCacheFiles(ProgressMonitor monitor, File pluginsDirectory) { 101 File[] siteCacheFiles = pluginsDirectory.listFiles( 102 new FilenameFilter() { 103 @Override 104 public boolean accept(File dir, String name) { 105 return name.matches("^([0-9]+-)?site.*plugin-icons\\.zip$"); 106 } 107 } 108 ); 107 File[] siteCacheFiles = listFiles(pluginsDirectory, "^([0-9]+-)?site.*plugin-icons\\.zip$"); 109 108 if (siteCacheFiles == null || siteCacheFiles.length == 0) 110 109 return; -
trunk/src/org/openstreetmap/josm/tools/XmlObjectParser.java
r6643 r6906 43 43 */ 44 44 public class XmlObjectParser implements Iterable<Object> { 45 public static class PresetParsingException extends SAXException {46 private int columnNumber;47 private int lineNumber;48 49 /**50 * Constructs a new {@code PresetParsingException}.51 */52 public PresetParsingException() {53 super();54 }55 56 public PresetParsingException(Exception e) {57 super(e);58 }59 60 public PresetParsingException(String message, Exception e) {61 super(message, e);62 }63 64 public PresetParsingException(String message) {65 super(message);66 }67 68 public PresetParsingException rememberLocation(Locator locator) {69 if (locator == null) return this;70 this.columnNumber = locator.getColumnNumber();71 this.lineNumber = locator.getLineNumber();72 return this;73 }74 75 @Override76 public String getMessage() {77 String msg = super.getMessage();78 if (lineNumber == 0 && columnNumber == 0)79 return msg;80 if (msg == null) {81 msg = getClass().getName();82 }83 msg = msg + " " + tr("(at line {0}, column {1})", lineNumber, columnNumber);84 return msg;85 }86 87 public int getColumnNumber() {88 return columnNumber;89 }90 91 public int getLineNumber() {92 return lineNumber;93 }94 }95 96 45 public static final String lang = LanguageInfo.getLanguageCodeXML(); 97 46 … … 127 76 } 128 77 129 protected void throwException(Exception e) throws PresetParsingException{ 130 throw new PresetParsingException(e).rememberLocation(locator); 131 } 132 133 @Override public void startElement(String ns, String lname, String qname, Attributes a) throws SAXException { 78 protected void throwException(Exception e) throws XmlParsingException { 79 throw new XmlParsingException(e).rememberLocation(locator); 80 } 81 82 @Override 83 public void startElement(String ns, String lname, String qname, Attributes a) throws SAXException { 134 84 if (mapping.containsKey(qname)) { 135 85 Class<?> klass = mapping.get(qname).klass; … … 150 100 } 151 101 } 152 @Override public void endElement(String ns, String lname, String qname) throws SAXException { 102 103 @Override 104 public void endElement(String ns, String lname, String qname) throws SAXException { 153 105 if (mapping.containsKey(qname) && !mapping.get(qname).onStart) { 154 106 report(); … … 158 110 } 159 111 } 160 @Override public void characters(char[] ch, int start, int length) { 112 113 @Override 114 public void characters(char[] ch, int start, int length) { 161 115 characters.append(ch, start, length); 162 116 } … … 281 235 private Iterator<Object> queueIterator = null; 282 236 237 /** 238 * Constructs a new {@code XmlObjectParser}. 239 */ 283 240 public XmlObjectParser() { 284 241 parser = new Parser();
Note:
See TracChangeset
for help on using the changeset viewer.