Changeset 30864 in osm
- Timestamp:
- 2014-12-19T18:06:07+01:00 (10 years ago)
- Location:
- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/DatabaseLoadException.java
r23190 r30864 19 19 /** 20 20 * Default constructor, which sets the message description. 21 * @param message message to be shown to user 21 * @param message the detail message (which is saved for later retrieval 22 * by the {@link #getMessage()} method). 22 23 */ 23 24 public DatabaseLoadException(String message) { 24 25 super(message); 25 26 } 27 28 /** 29 * Default constructor, which sets the message description and cause. 30 * @param message the detail message (which is saved for later retrieval 31 * by the {@link #getMessage()} method). 32 * @param cause the cause (which is saved for later retrieval by the 33 * {@link #getCause()} method). (A <tt>null</tt> value is 34 * permitted, and indicates that the cause is nonexistent or 35 * unknown.) 36 */ 37 public DatabaseLoadException(String message, Throwable cause) { 38 super(message, cause); 39 } 26 40 } -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/parser/DatabaseParser.java
r30861 r30864 111 111 112 112 try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(getDatabasePath()))) { 113 114 115 116 117 118 119 113 int total = 0, count; 114 byte[] buffer = new byte[1024*512]; 115 while ((count = con.getInputStream().read(buffer)) >= 0) { 116 bos.write(buffer, 0, count); 117 total += count; 118 Main.error("CzechAddress: MVČR database: " + String.valueOf(total/1024) + " kb downloaded."); 119 } 120 120 } 121 121 … … 128 128 129 129 } catch (IOException ioexp) { 130 ioexp.printStackTrace(); 131 throw new DatabaseLoadException("Chyba při načítání databáze"); 130 throw new DatabaseLoadException("Chyba při načítání databáze", ioexp); 132 131 } 133 132 } -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/parser/MvcrParser.java
r30346 r30864 9 9 import java.util.zip.ZipEntry; 10 10 import java.util.zip.ZipInputStream; 11 11 12 import org.openstreetmap.josm.Main; 12 13 import org.openstreetmap.josm.plugins.czechaddress.DatabaseLoadException; … … 38 39 //============================================================================== 39 40 41 @Override 40 42 public void startElement(String uri, String localName, String name, 41 43 Attributes attributes) throws SAXException { … … 176 178 } 177 179 180 @Override 178 181 public void setDocumentLocator(Locator locator) {} 182 @Override 179 183 public void startDocument() throws SAXException {} 184 @Override 180 185 public void endDocument() throws SAXException {} 186 @Override 181 187 public void startPrefixMapping(String prefix, String uri) throws SAXException {} 188 @Override 182 189 public void endPrefixMapping(String prefix) throws SAXException {} 190 @Override 183 191 public void characters(char[] ch, int start, int length) throws SAXException {} 192 @Override 184 193 public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {} 194 @Override 185 195 public void processingInstruction(String target, String data) throws SAXException {} 196 @Override 186 197 public void skippedEntity(String name) throws SAXException {} 187 198 … … 237 248 } 238 249 250 @Override 239 251 protected InputStream getDatabaseStream() throws DatabaseLoadException { 240 252 ZipInputStream zis; 241 253 ZipEntry zipEntry = null; 242 254 try { 243 zis = new ZipInputStream(new FileInputStream(getDatabasePath()));244 245 while ((zipEntry = zis.getNextEntry()) != null)246 if (zipEntry.getName().equals("adresy.xml"))247 break;255 zis = new ZipInputStream(new FileInputStream(getDatabasePath())); 256 257 while ((zipEntry = zis.getNextEntry()) != null) 258 if (zipEntry.getName().equals("adresy.xml")) 259 break; 248 260 249 261 } catch (IOException ioexp) { 250 throw new DatabaseLoadException("Chyba při čtení archivu s databází." );262 throw new DatabaseLoadException("Chyba při čtení archivu s databází.", ioexp); 251 263 } 252 264 253 265 if (zipEntry == null) 254 throw new DatabaseLoadException(266 throw new DatabaseLoadException( 255 267 "ZIP archiv s databází neobsahuje soubor 'adresy.xml'."); 256 268 -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/parser/XMLParser.java
r15585 r30864 2 2 3 3 import java.io.IOException; 4 4 5 import org.openstreetmap.josm.plugins.czechaddress.DatabaseLoadException; 6 import org.openstreetmap.josm.plugins.czechaddress.addressdatabase.Database; 5 7 import org.xml.sax.ContentHandler; 6 8 import org.xml.sax.InputSource; … … 22 24 implements ContentHandler { 23 25 26 @Override 24 27 protected void parseDatabase() throws DatabaseLoadException { 25 28 … … 31 34 32 35 } catch (IOException ioexp) { 33 throw new DatabaseLoadException("Chyba při čtení archivu s databází." );36 throw new DatabaseLoadException("Chyba při čtení archivu s databází.", ioexp); 34 37 } catch (SAXException saxexp) { 35 throw new DatabaseLoadException("Selhaho parsování XML souboru s databází adres." );38 throw new DatabaseLoadException("Selhaho parsování XML souboru s databází adres.", saxexp); 36 39 } 37 40 }
Note:
See TracChangeset
for help on using the changeset viewer.