Changeset 30568 in osm for applications/editors
- Timestamp:
- 2014-08-06T19:33:57+02:00 (10 years ago)
- Location:
- applications/editors/josm/plugins/opendata
- Files:
-
- 13 added
- 49 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/opendata/includes/org/j7zip/SevenZip/Archive/Common/BindInfo.java
r29679 r30568 5 5 6 6 public class BindInfo { 7 public RecordVector<CoderStreamsInfo> Coders = new RecordVector< CoderStreamsInfo>();8 public RecordVector<BindPair> BindPairs = new RecordVector< BindPair>();7 public RecordVector<CoderStreamsInfo> Coders = new RecordVector<>(); 8 public RecordVector<BindPair> BindPairs = new RecordVector<>(); 9 9 public IntVector InStreams = new IntVector(); 10 10 public IntVector OutStreams = new IntVector(); -
applications/editors/josm/plugins/opendata/includes/org/j7zip/SevenZip/Archive/Common/CoderMixer2ST.java
r29681 r30568 20 20 21 21 BindInfo _bindInfo = new BindInfo(); 22 ObjectVector<STCoderInfo> _coders = new ObjectVector< STCoderInfo>();22 ObjectVector<STCoderInfo> _coders = new ObjectVector<>(); 23 23 24 24 public CoderMixer2ST() { … … 202 202 CoderInfo mainCoder = _coders.get(_mainCoderIndex); 203 203 204 ObjectVector< java.io.InputStream > seqInStreams = new ObjectVector< java.io.InputStream>(); // CObjectVector< CMyComPtr<ISequentialInStream> >205 ObjectVector< java.io.OutputStream > seqOutStreams = new ObjectVector< java.io.OutputStream>(); // CObjectVector< CMyComPtr<ISequentialOutStream> >204 ObjectVector< java.io.InputStream > seqInStreams = new ObjectVector< >(); // CObjectVector< CMyComPtr<ISequentialInStream> > 205 ObjectVector< java.io.OutputStream > seqOutStreams = new ObjectVector< >(); // CObjectVector< CMyComPtr<ISequentialOutStream> > 206 206 int startInIndex = _bindInfo.GetCoderInStreamIndex(_mainCoderIndex); 207 207 int startOutIndex = _bindInfo.GetCoderOutStreamIndex(_mainCoderIndex); … … 220 220 seqOutStreams.add(seqOutStream); 221 221 } 222 RecordVector< java.io.InputStream > seqInStreamsSpec = new RecordVector< java.io.InputStream>();223 RecordVector< java.io.OutputStream > seqOutStreamsSpec = new RecordVector< java.io.OutputStream>();222 RecordVector< java.io.InputStream > seqInStreamsSpec = new RecordVector< >(); 223 RecordVector< java.io.OutputStream > seqOutStreamsSpec = new RecordVector< >(); 224 224 for (i = 0; i < mainCoder.NumInStreams; i++) 225 225 seqInStreamsSpec.add(seqInStreams.get(i)); -
applications/editors/josm/plugins/opendata/includes/org/j7zip/SevenZip/Archive/Common/FilterCoder.java
r29681 r30568 4 4 import java.io.IOException; 5 5 6 import org.j7zip.SevenZip.HRESULT;7 6 import org.j7zip.SevenZip.ICompressCoder; 8 7 import org.j7zip.SevenZip.ICompressSetOutStream; -
applications/editors/josm/plugins/opendata/includes/org/j7zip/SevenZip/Archive/SevenZip/ArchiveDatabase.java
r29679 r30568 10 10 public BoolVector PackCRCsDefined = new BoolVector(); 11 11 public IntVector PackCRCs = new IntVector(); 12 public ObjectVector<Folder> Folders = new ObjectVector< Folder>();12 public ObjectVector<Folder> Folders = new ObjectVector<>(); 13 13 public IntVector NumUnPackStreamsVector = new IntVector(); 14 public ObjectVector<FileItem> Files = new ObjectVector< FileItem>();14 public ObjectVector<FileItem> Files = new ObjectVector<>(); 15 15 16 16 void Clear() { -
applications/editors/josm/plugins/opendata/includes/org/j7zip/SevenZip/Archive/SevenZip/BindInfoEx.java
r29679 r30568 7 7 class BindInfoEx extends BindInfo { 8 8 9 RecordVector<MethodID> CoderMethodIDs = new RecordVector< MethodID>();9 RecordVector<MethodID> CoderMethodIDs = new RecordVector<>(); 10 10 11 11 public void Clear() { -
applications/editors/josm/plugins/opendata/includes/org/j7zip/SevenZip/Archive/SevenZip/CoderInfo.java
r29679 r30568 7 7 int NumInStreams; 8 8 int NumOutStreams; 9 public ObjectVector<AltCoderInfo> AltCoders = new org.j7zip.Common.ObjectVector< AltCoderInfo>();9 public ObjectVector<AltCoderInfo> AltCoders = new org.j7zip.Common.ObjectVector<>(); 10 10 11 11 boolean IsSimpleCoder() { return (NumInStreams == 1) && (NumOutStreams == 1); } -
applications/editors/josm/plugins/opendata/includes/org/j7zip/SevenZip/Archive/SevenZip/Decoder.java
r29681 r30568 45 45 46 46 _mixerCoder = null; 47 _decoders = new ObjectVector< Object>();47 _decoders = new ObjectVector<>(); 48 48 49 49 // #ifndef EXCLUDE_COM -- LoadMethodMap(); … … 117 117 118 118 119 ObjectVector<java.io.InputStream> inStreams = new ObjectVector< java.io.InputStream>(); // CObjectVector< CMyComPtr<ISequentialInStream> >119 ObjectVector<java.io.InputStream> inStreams = new ObjectVector<>(); // CObjectVector< CMyComPtr<ISequentialInStream> > 120 120 121 121 LockedInStream lockedInStream = new LockedInStream(); … … 357 357 if (numCoders == 0) 358 358 return 0; 359 RecordVector<java.io.InputStream> inStreamPointers = new RecordVector< java.io.InputStream>(); // CRecordVector<ISequentialInStream *>359 RecordVector<java.io.InputStream> inStreamPointers = new RecordVector<>(); // CRecordVector<ISequentialInStream *> 360 360 inStreamPointers.Reserve(inStreams.size()); 361 361 for (i = 0; i < inStreams.size(); i++) 362 362 inStreamPointers.add(inStreams.get(i)); 363 363 364 RecordVector<java.io.OutputStream> outStreamPointer = new RecordVector< java.io.OutputStream>();364 RecordVector<java.io.OutputStream> outStreamPointer = new RecordVector<>(); 365 365 outStreamPointer.add(outStream); 366 366 return _mixerCoder.Code( -
applications/editors/josm/plugins/opendata/includes/org/j7zip/SevenZip/Archive/SevenZip/Folder.java
r29679 r30568 11 11 12 12 class Folder { 13 public RecordVector<CoderInfo> Coders = new RecordVector< CoderInfo>();14 RecordVector<BindPair> BindPairs = new RecordVector< BindPair>();13 public RecordVector<CoderInfo> Coders = new RecordVector<>(); 14 RecordVector<BindPair> BindPairs = new RecordVector<>(); 15 15 IntVector PackStreams = new IntVector(); 16 16 LongVector UnPackSizes = new LongVector(); -
applications/editors/josm/plugins/opendata/includes/org/j7zip/SevenZip/Archive/SevenZip/Handler.java
r29681 r30568 84 84 return HRESULT.S_OK; 85 85 86 ObjectVector<ExtractFolderInfo> extractFolderInfoVector = new ObjectVector< ExtractFolderInfo>();86 ObjectVector<ExtractFolderInfo> extractFolderInfoVector = new ObjectVector<>(); 87 87 for(int ii = 0; ii < numItems; ii++) { 88 88 int ref2Index = allFilesMode ? ii : indices[ii]; -
applications/editors/josm/plugins/opendata/includes/org/j7zip/SevenZip/Archive/SevenZip/InArchive.java
r29681 r30568 32 32 33 33 public InArchive() { 34 _inByteVector = new ObjectVector< InByte2>();34 _inByteVector = new ObjectVector<>(); 35 35 _inByteBack = new InByte2(); 36 36 } … … 710 710 IntVector packCRCs = new IntVector(); // CRecordVector<UInt32> packCRCs; 711 711 712 ObjectVector<Folder> folders = new ObjectVector< Folder>();712 ObjectVector<Folder> folders = new ObjectVector<>(); 713 713 714 714 IntVector numUnPackStreamsInFolders = new IntVector(); … … 823 823 streamSwitch.Set(this, buffer2); 824 824 825 ObjectVector<ByteBuffer> dataVector = new ObjectVector< ByteBuffer>(); // CObjectVector<CByteBuffer> dataVector;825 ObjectVector<ByteBuffer> dataVector = new ObjectVector<>(); // CObjectVector<CByteBuffer> dataVector; 826 826 827 827 for (;;) { … … 863 863 } 864 864 865 ObjectVector<ByteBuffer> dataVector = new ObjectVector< ByteBuffer>();865 ObjectVector<ByteBuffer> dataVector = new ObjectVector<>(); 866 866 867 867 if (type == NID.kAdditionalStreamsInfo) { -
applications/editors/josm/plugins/opendata/includes/org/jopendocument/dom/ChildCreator.java
r28000 r30568 37 37 throw new NullPointerException("null content"); 38 38 this.content = content; 39 this.elemsOrder = new ArrayList< Element>(children);39 this.elemsOrder = new ArrayList<>(children); 40 40 } 41 41 -
applications/editors/josm/plugins/opendata/includes/org/jopendocument/dom/ImmutableDocStyledNode.java
r28000 r30568 25 25 26 26 private static final Set<Document> getDocuments(final ODPackage pkg) { 27 final Set<Document> res = new HashSet< Document>();27 final Set<Document> res = new HashSet<>(); 28 28 for (final String entry : pkg.getEntries()) { 29 29 final ODPackageEntry e = pkg.getEntry(entry); -
applications/editors/josm/plugins/opendata/includes/org/jopendocument/dom/ODMeta.java
r28000 r30568 42 42 private static final Map<XMLVersion, List<Element>> ELEMS_ORDER; 43 43 static { 44 ELEMS_ORDER = new HashMap< XMLVersion, List<Element>>(2);44 ELEMS_ORDER = new HashMap<>(2); 45 45 ELEMS_ORDER.put(XMLVersion.getOOo(), createChildren(XMLVersion.getOOo())); 46 46 ELEMS_ORDER.put(XMLVersion.getOD(), createChildren(XMLVersion.getOD())); … … 50 50 final Namespace meta = ins.getMETA(); 51 51 final Namespace dc = ins.getNS("dc"); 52 final List<Element> res = new ArrayList< Element>(8);52 final List<Element> res = new ArrayList<>(8); 53 53 res.add(new Element("generator", meta)); 54 54 res.add(new Element("title", dc)); -
applications/editors/josm/plugins/opendata/includes/org/jopendocument/dom/ODPackage.java
r28000 r30568 37 37 private static final Set<String> subdocNames; 38 38 static { 39 subdocNames = new HashSet< String>();39 subdocNames = new HashSet<>(); 40 40 // section 2.1 of OpenDocument-v1.1-os.odt 41 41 subdocNames.add("content.xml"); … … 49 49 50 50 public ODPackage() { 51 this.files = new HashMap< String, ODPackageEntry>();51 this.files = new HashMap<>(); 52 52 this.file = null; 53 53 } -
applications/editors/josm/plugins/opendata/includes/org/jopendocument/dom/ODSingleXMLDocument.java
r28000 r30568 28 28 final static Set<String> DONT_PREFIX; 29 29 static { 30 DONT_PREFIX = new HashSet< String>();30 DONT_PREFIX = new HashSet<>(); 31 31 // don't touch to user fields and variables 32 32 // we want them to be the same across the document … … 57 57 ODSingleXMLDocument(ODSingleXMLDocument doc, ODPackage p) { 58 58 super(doc); 59 this.stylesNames = new HashSet< String>(doc.stylesNames);60 this.listStylesNames = new HashSet< String>(doc.listStylesNames);59 this.stylesNames = new HashSet<>(doc.stylesNames); 60 this.listStylesNames = new HashSet<>(doc.listStylesNames); 61 61 this.pkg = p; 62 62 this.meta = ODMeta.create(this); -
applications/editors/josm/plugins/opendata/includes/org/jopendocument/dom/ODXMLDocument.java
r28000 r30568 41 41 private static final Map<XMLVersion, List<Element>> ELEMS_ORDER; 42 42 static { 43 ELEMS_ORDER = new HashMap< XMLVersion, List<Element>>(2);43 ELEMS_ORDER = new HashMap<>(2); 44 44 ELEMS_ORDER.put(XMLVersion.getOOo(), createChildren(XMLVersion.getOOo())); 45 45 ELEMS_ORDER.put(XMLVersion.getOD(), createChildren(XMLVersion.getOD())); … … 48 48 private static final List<Element> createChildren(XMLVersion ins) { 49 49 final Namespace ns = ins.getOFFICE(); 50 final List<Element> res = new ArrayList< Element>(8);50 final List<Element> res = new ArrayList<>(8); 51 51 res.add(new Element("meta", ns)); 52 52 res.add(new Element("settings", ns)); … … 63 63 static private final Map<String, String> namePrefixes; 64 64 static { 65 namePrefixes = new HashMap< String, String>();65 namePrefixes = new HashMap<>(); 66 66 namePrefixes.put("table:table", "table"); 67 67 namePrefixes.put("text:a", "office"); -
applications/editors/josm/plugins/opendata/includes/org/jopendocument/dom/StyleDesc.java
r28000 r30568 68 68 this.family = family; 69 69 this.baseName = baseName; 70 this.refElements = new CollectionMap< String, String>();70 this.refElements = new CollectionMap<>(); 71 71 // 4 since they are not common 72 this.multiRefElements = new CollectionMap< String, String>(4);72 this.multiRefElements = new CollectionMap<>(4); 73 73 } 74 74 -
applications/editors/josm/plugins/opendata/includes/org/jopendocument/dom/StyleStyle.java
r28000 r30568 37 37 private static boolean descsLoaded = false; 38 38 static { 39 family2Desc = new HashMap< XMLVersion, Map<String, StyleDesc<?>>>();40 class2Desc = new HashMap< XMLVersion, Map<Class<? extends StyleStyle>, StyleDesc<?>>>();39 family2Desc = new HashMap<>(); 40 class2Desc = new HashMap<>(); 41 41 for (final XMLVersion v : XMLVersion.values()) { 42 42 family2Desc.put(v, new HashMap<String, StyleDesc<?>>()); -
applications/editors/josm/plugins/opendata/includes/org/jopendocument/dom/XMLVersion.java
r28000 r30568 81 81 82 82 private XMLVersion(String name, Namespace manifest) { 83 this.nss = new HashMap< String, Namespace>(16);83 this.nss = new HashMap<>(16); 84 84 } 85 85 -
applications/editors/josm/plugins/opendata/includes/org/jopendocument/dom/spreadsheet/Cell.java
r28000 r30568 136 136 */ 137 137 public String getTextValue(final boolean ooMode) { 138 final List<String> ps = new ArrayList< String>();138 final List<String> ps = new ArrayList<>(); 139 139 for (final Object o : this.getElement().getChildren()) { 140 140 final Element child = (Element) o; -
applications/editors/josm/plugins/opendata/includes/org/jopendocument/dom/spreadsheet/Row.java
r28000 r30568 44 44 this.parent = parent; 45 45 this.index = index; 46 this.cells = new ArrayList< Cell<D>>();46 this.cells = new ArrayList<>(); 47 47 for (final Element cellElem : this.getCellElements()) { 48 48 addCellElem(cellElem); … … 59 59 60 60 private void addCellElem(final Element cellElem) { 61 final Cell<D> cell = new Cell< D>(this, cellElem);61 final Cell<D> cell = new Cell<>(this, cellElem); 62 62 this.cells.add(cell); 63 63 -
applications/editors/josm/plugins/opendata/includes/org/jopendocument/dom/spreadsheet/SpreadSheet.java
r28000 r30568 49 49 50 50 // map Sheet by XML elements so has not to depend on ordering or name 51 this.sheets = new HashMap< Element, Sheet>();51 this.sheets = new HashMap<>(); 52 52 } 53 53 -
applications/editors/josm/plugins/opendata/includes/org/jopendocument/dom/spreadsheet/Table.java
r28000 r30568 44 44 super(parent, local, TableStyle.class); 45 45 46 this.rows = new ArrayList< Row<D>>();47 this.cols = new ArrayList< Column<D>>();46 this.rows = new ArrayList<>(); 47 this.cols = new ArrayList<>(); 48 48 49 49 this.readColumns(); … … 71 71 72 72 private final void addCol(Element clone) { 73 this.cols.add(new Column< D>(this, clone));73 this.cols.add(new Column<>(this, clone)); 74 74 } 75 75 76 76 private Tuple2<List<Element>, Integer> flatten(boolean col) { 77 final List<Element> res = new ArrayList< Element>();77 final List<Element> res = new ArrayList<>(); 78 78 final Element header = this.getElement().getChild("table-header-" + getName(col) + "s", getTABLE()); 79 79 if (header != null) … … 128 128 129 129 private synchronized void addRow(Element child) { 130 this.rows.add(new Row< D>(this, child, this.rows.size()));130 this.rows.add(new Row<>(this, child, this.rows.size())); 131 131 } 132 132 -
applications/editors/josm/plugins/opendata/includes/org/jopendocument/io/SaxContentUnmarshaller.java
r29298 r30568 40 40 41 41 public SaxContentUnmarshaller() { 42 this.stack = new Stack< Object>();42 this.stack = new Stack<>(); 43 43 } 44 44 -
applications/editors/josm/plugins/opendata/includes/org/jopendocument/model/office/OfficeBody.java
r28000 r30568 24 24 public class OfficeBody { 25 25 26 private final List<OfficeSpreadsheet> officeSpreadsheets = new Vector< OfficeSpreadsheet>();26 private final List<OfficeSpreadsheet> officeSpreadsheets = new Vector<>(); 27 27 28 28 public void addOfficeSpreadsheet(final OfficeSpreadsheet spread) { -
applications/editors/josm/plugins/opendata/includes/org/jopendocument/model/office/OfficeSpreadsheet.java
r28000 r30568 22 22 23 23 public class OfficeSpreadsheet { 24 List<TableTable> tables = new Vector< TableTable>();24 List<TableTable> tables = new Vector<>(); 25 25 26 26 public void addTable(final TableTable table) { -
applications/editors/josm/plugins/opendata/includes/org/jopendocument/model/table/TableTable.java
r28000 r30568 25 25 26 26 // Une colonne ou ligne repeated est dupliquée dans la liste 27 ArrayList<TableTableColumn> columns = new ArrayList< TableTableColumn>();27 ArrayList<TableTableColumn> columns = new ArrayList<>(); 28 28 29 29 private int printStartCol = 0; … … 35 35 private int printStopRow = 0; 36 36 37 ArrayList<TableTableRow> rows = new ArrayList< TableTableRow>();37 ArrayList<TableTableRow> rows = new ArrayList<>(); 38 38 39 39 public void addColumn(final TableTableColumn col) { -
applications/editors/josm/plugins/opendata/includes/org/jopendocument/model/table/TableTableRow.java
r29298 r30568 27 27 ArrayList<TableTableCell> allCells; 28 28 29 Vector<TableTableCell> cells = new Vector< TableTableCell>();29 Vector<TableTableCell> cells = new Vector<>(); 30 30 31 31 int id = 0; … … 47 47 */ 48 48 void computeAllCells() { 49 this.allCells = new ArrayList< TableTableCell>();49 this.allCells = new ArrayList<>(); 50 50 for (int index = 0; index < this.cells.size(); index++) { 51 51 final TableTableCell c = this.cells.get(index); -
applications/editors/josm/plugins/opendata/includes/org/jopendocument/model/text/TextP.java
r28000 r30568 24 24 public class TextP { 25 25 26 private final List<TextSpan> textSpans = new Vector< TextSpan>();26 private final List<TextSpan> textSpans = new Vector<>(); 27 27 28 28 public void addTextSpan(final TextSpan p) { -
applications/editors/josm/plugins/opendata/includes/org/jopendocument/util/FileUtils.java
r28000 r30568 31 31 private static final Map<String, String> ext2mime; 32 32 static { 33 ext2mime = new HashMap< String, String>();33 ext2mime = new HashMap<>(); 34 34 ext2mime.put(".xml", "text/xml"); 35 35 ext2mime.put(".jpg", "image/jpeg"); -
applications/editors/josm/plugins/opendata/includes/org/jopendocument/util/StringUtils.java
r28000 r30568 47 47 super(); 48 48 this.esc = esc; 49 this.substitution = new LinkedHashMap< Character, Character>();50 this.inv = new HashMap< Character, Character>();49 this.substitution = new LinkedHashMap<>(); 50 this.inv = new HashMap<>(); 51 51 this.add(esc, name); 52 52 } -
applications/editors/josm/plugins/opendata/includes/org/jopendocument/util/Tuple2.java
r28000 r30568 31 31 // just to make the code shorter 32 32 public static final <A, B> Tuple2<A, B> create(A a, B b) { 33 return new Tuple2< A, B>(a, b);33 return new Tuple2<>(a, b); 34 34 } 35 35 -
applications/editors/josm/plugins/opendata/includes/org/jopendocument/util/cc/Transformer.java
r28000 r30568 21 21 22 22 public static final <N> ITransformer<N, N> nopTransformer() { 23 return new ITransformerWrapper< N, N>(TransformerUtils.nopTransformer());23 return new ITransformerWrapper<>(TransformerUtils.nopTransformer()); 24 24 } 25 25 -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/NeptuneReader.java
r30532 r30568 39 39 import neptune.TridentObjectType; 40 40 41 import org.openstreetmap.josm.Main; 41 42 import org.openstreetmap.josm.data.coor.LatLon; 42 43 import org.openstreetmap.josm.data.osm.DataSet; … … 103 104 Validator validator = schema.newValidator(); 104 105 validator.validate(xmlFile); 105 System.out.println(xmlFile.getSystemId() + " is valid");106 Main.info(xmlFile.getSystemId() + " is valid"); 106 107 return true; 107 108 } catch (SAXException e) { 108 System.out.println(xmlFile.getSystemId() + " is NOT valid");109 System.out.println("Reason: " + e.getLocalizedMessage());109 Main.error(xmlFile.getSystemId() + " is NOT valid"); 110 Main.error("Reason: " + e.getLocalizedMessage()); 110 111 } catch (IOException e) { 111 System.out.println(xmlFile.getSystemId() + " is NOT valid");112 System.out.println("Reason: " + e.getLocalizedMessage());112 Main.error(xmlFile.getSystemId() + " is NOT valid"); 113 Main.error("Reason: " + e.getLocalizedMessage()); 113 114 } finally { 114 115 try { … … 119 120 } 120 121 } catch (FileNotFoundException e) { 121 System.err.println(e.getMessage());122 Main.error(e.getMessage()); 122 123 } 123 124 … … 317 318 } else { 318 319 // TODO 319 System.out.println("TODO: handle StopPoint "+childId);320 Main.info("TODO: handle StopPoint "+childId); 320 321 } 321 322 322 323 } else { 323 System.err.println("Unsupported child: "+childId);324 Main.warn("Unsupported child: "+childId); 324 325 } 325 326 } 326 327 } else if (sa.getStopAreaExtension().getAreaType().equals(ChouetteAreaType.BOARDING_POSITION)) { 327 // System.out.println("skipping StopArea with type "+sa.getStopAreaExtension().getAreaType()+": "+sa.getObjectId());328 //Main.info("skipping StopArea with type "+sa.getStopAreaExtension().getAreaType()+": "+sa.getObjectId()); 328 329 } else { 329 System.err.println("Unsupported StopArea type: "+sa.getStopAreaExtension().getAreaType());330 Main.warn("Unsupported StopArea type: "+sa.getStopAreaExtension().getAreaType()); 330 331 } 331 332 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/OsmDownloader.java
r30563 r30568 15 15 try { 16 16 String oapiServer = Main.pref.get(OdConstants.PREF_OAPI, OdConstants.DEFAULT_OAPI); 17 System.out.println(oapiReq);17 Main.info(oapiReq); 18 18 String oapiReqEnc = URLEncoder.encode(oapiReq, OdConstants.UTF8); 19 19 Main.main.menu.openLocation.openUrl(false, oapiServer+"data="+oapiReqEnc); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/archive/ArchiveReader.java
r30563 r30568 7 7 import java.io.IOException; 8 8 import java.util.ArrayList; 9 import java.util.Collection; 10 import java.util.Collections; 11 import java.util.HashMap; 9 12 import java.util.List; 13 import java.util.Map; 10 14 11 15 import javax.xml.bind.JAXBException; … … 56 60 57 61 protected abstract String getTaskMessage(); 58 59 public DataSet parseDoc(final ProgressMonitor progressMonitor) throws IOException, XMLStreamException, FactoryConfigurationError, JAXBException { 60 61 final File temp = OdUtils.createTempDir(); 62 63 protected Collection<File> getDocsToParse(final File temp, final ProgressMonitor progressMonitor) throws FileNotFoundException, IOException { 62 64 final List<File> candidates = new ArrayList<>(); 63 65 66 if (progressMonitor != null) { 67 progressMonitor.beginTask(getTaskMessage()); 68 } 69 extractArchive(temp, candidates); 70 71 if (promptUser && candidates.size() > 1) { 72 DialogPrompter<CandidateChooser> prompt = new DialogPrompter<CandidateChooser>() { 73 @Override 74 protected CandidateChooser buildDialog() { 75 return new CandidateChooser(progressMonitor.getWindowParent(), candidates); 76 } 77 }; 78 if (prompt.promptInEdt().getValue() == 1) { 79 return Collections.singleton(prompt.getDialog().getSelectedFile()); 80 } 81 } else if (!candidates.isEmpty()) { 82 return candidates; 83 } 84 return Collections.emptyList(); 85 } 86 87 public Map<File, DataSet> parseDocs(final ProgressMonitor progressMonitor) throws IOException, XMLStreamException, FactoryConfigurationError, JAXBException { 88 Map<File, DataSet> result = new HashMap<>(); 89 File temp = OdUtils.createTempDir(); 64 90 try { 91 file = null; 92 for (File f : getDocsToParse(temp, progressMonitor)) { 93 DataSet from = getDataForFile(f, progressMonitor); 94 if (from != null) { 95 result.put(f, from); 96 } 97 } 98 } finally { 99 OdUtils.deleteDir(temp); 65 100 if (progressMonitor != null) { 66 progressMonitor. beginTask(getTaskMessage());101 progressMonitor.finishTask(); 67 102 } 68 extractArchive(temp, candidates); 69 70 file = null; 71 72 if (promptUser && candidates.size() > 1) { 73 DialogPrompter<CandidateChooser> prompt = new DialogPrompter<CandidateChooser>() { 74 @Override 75 protected CandidateChooser buildDialog() { 76 return new CandidateChooser(progressMonitor.getWindowParent(), candidates); 77 } 78 }; 79 if (prompt.promptInEdt().getValue() == 1) { 80 file = prompt.getDialog().getSelectedFile(); 81 } 82 } else if (!candidates.isEmpty()) { 83 file = candidates.get(0); 103 } 104 return result; 105 } 106 107 public DataSet parseDoc(final ProgressMonitor progressMonitor) throws IOException, XMLStreamException, FactoryConfigurationError, JAXBException { 108 File temp = OdUtils.createTempDir(); 109 110 try { 111 file = null; 112 Collection<File> files = getDocsToParse(temp, progressMonitor); 113 if (!files.isEmpty()) { 114 file = files.iterator().next(); 84 115 } 85 116 86 DataSet from = getDataForFile( progressMonitor);117 DataSet from = getDataForFile(file, progressMonitor); 87 118 if (from != null) { 88 119 ds = from; … … 100 131 } 101 132 102 protected DataSet getDataForFile( final ProgressMonitor progressMonitor)133 protected DataSet getDataForFile(File f, final ProgressMonitor progressMonitor) 103 134 throws FileNotFoundException, IOException, XMLStreamException, FactoryConfigurationError, JAXBException { 104 if (f ile== null) {135 if (f == null) { 105 136 return null; 106 } else if (!f ile.exists()) {107 Main.warn("File does not exist: "+f ile.getPath());137 } else if (!f.exists()) { 138 Main.warn("File does not exist: "+f.getPath()); 108 139 return null; 109 140 } else { 141 Main.info("Parsing file "+f.getName()); 110 142 DataSet from = null; 111 FileInputStream in = new FileInputStream(f ile);143 FileInputStream in = new FileInputStream(f); 112 144 ProgressMonitor instance = null; 113 145 if (progressMonitor != null) { 114 146 instance = progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false); 115 147 } 116 if (f ile.getName().toLowerCase().endsWith(OdConstants.CSV_EXT)) {148 if (f.getName().toLowerCase().endsWith(OdConstants.CSV_EXT)) { 117 149 from = CsvReader.parseDataSet(in, handler, instance); 118 } else if (f ile.getName().toLowerCase().endsWith(OdConstants.KML_EXT)) {150 } else if (f.getName().toLowerCase().endsWith(OdConstants.KML_EXT)) { 119 151 from = KmlReader.parseDataSet(in, instance); 120 } else if (f ile.getName().toLowerCase().endsWith(OdConstants.KMZ_EXT)) {152 } else if (f.getName().toLowerCase().endsWith(OdConstants.KMZ_EXT)) { 121 153 from = KmzReader.parseDataSet(in, instance); 122 } else if (f ile.getName().toLowerCase().endsWith(OdConstants.XLS_EXT)) {154 } else if (f.getName().toLowerCase().endsWith(OdConstants.XLS_EXT)) { 123 155 from = XlsReader.parseDataSet(in, handler, instance); 124 } else if (f ile.getName().toLowerCase().endsWith(OdConstants.ODS_EXT)) {156 } else if (f.getName().toLowerCase().endsWith(OdConstants.ODS_EXT)) { 125 157 from = OdsReader.parseDataSet(in, handler, instance); 126 } else if (f ile.getName().toLowerCase().endsWith(OdConstants.SHP_EXT)) {127 from = ShpReader.parseDataSet(in, f ile, handler, instance);128 } else if (f ile.getName().toLowerCase().endsWith(OdConstants.MIF_EXT)) {129 from = MifReader.parseDataSet(in, f ile, handler, instance);130 } else if (f ile.getName().toLowerCase().endsWith(OdConstants.TAB_EXT)) {131 from = TabReader.parseDataSet(in, f ile, handler, instance);132 } else if (f ile.getName().toLowerCase().endsWith(OdConstants.GML_EXT)) {158 } else if (f.getName().toLowerCase().endsWith(OdConstants.SHP_EXT)) { 159 from = ShpReader.parseDataSet(in, f, handler, instance); 160 } else if (f.getName().toLowerCase().endsWith(OdConstants.MIF_EXT)) { 161 from = MifReader.parseDataSet(in, f, handler, instance); 162 } else if (f.getName().toLowerCase().endsWith(OdConstants.TAB_EXT)) { 163 from = TabReader.parseDataSet(in, f, handler, instance); 164 } else if (f.getName().toLowerCase().endsWith(OdConstants.GML_EXT)) { 133 165 from = GmlReader.parseDataSet(in, handler, instance); 134 } else if (f ile.getName().toLowerCase().endsWith(OdConstants.XML_EXT)) {135 if (OdPlugin.getInstance().xmlImporter.acceptFile(f ile)) {166 } else if (f.getName().toLowerCase().endsWith(OdConstants.XML_EXT)) { 167 if (OdPlugin.getInstance().xmlImporter.acceptFile(f)) { 136 168 from = NeptuneReader.parseDataSet(in, handler, instance); 137 169 } else { 138 System.err.println("Unsupported XML file: "+f ile.getName());170 System.err.println("Unsupported XML file: "+f.getName()); 139 171 } 140 172 141 173 } else { 142 System.err.println("Unsupported file extension: "+f ile.getName());174 System.err.println("Unsupported file extension: "+f.getName()); 143 175 } 144 176 return from; … … 151 183 if (entryName.toLowerCase().endsWith("."+ext)) { 152 184 candidates.add(file); 153 System.out.println(entryName);154 185 break; 155 186 } … … 159 190 || OdPlugin.getInstance().xmlImporter.acceptFile(file))) { 160 191 candidates.add(file); 161 System.out.println(entryName);162 192 } 163 193 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/archive/SevenZipReader.java
r30436 r30568 11 11 import java.io.OutputStream; 12 12 import java.util.List; 13 import java.util.Map; 13 14 14 15 import javax.xml.bind.JAXBException; … … 57 58 } 58 59 59 @Override protected String getTaskMessage() { 60 public static Map<File, DataSet> parseDataSets(InputStream in, AbstractDataSetHandler handler, ProgressMonitor instance, boolean promptUser) 61 throws IOException, XMLStreamException, FactoryConfigurationError, JAXBException { 62 return new SevenZipReader(in, handler, promptUser).parseDocs(instance); 63 } 64 65 @Override 66 protected String getTaskMessage() { 60 67 return tr("Reading 7Zip file..."); 61 68 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/archive/ZipReader.java
r30340 r30568 10 10 import java.io.InputStream; 11 11 import java.util.List; 12 import java.util.Map; 12 13 import java.util.zip.ZipEntry; 13 14 import java.util.zip.ZipInputStream; … … 36 37 return new ZipReader(in, handler, promptUser).parseDoc(instance); 37 38 } 39 40 public static Map<File, DataSet> parseDataSets(InputStream in, AbstractDataSetHandler handler, ProgressMonitor instance, boolean promptUser) 41 throws IOException, XMLStreamException, FactoryConfigurationError, JAXBException { 42 return new ZipReader(in, handler, promptUser).parseDocs(instance); 43 } 38 44 39 45 protected void extractArchive(final File temp, final List<File> candidates) throws IOException, FileNotFoundException { … … 75 81 } 76 82 77 @Override protected String getTaskMessage() { 83 @Override 84 protected String getTaskMessage() { 78 85 return tr("Reading Zip file..."); 79 86 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/DefaultShpHandler.java
r30563 r30568 51 51 boolean res = Math.abs(a - b) <= Main.pref.getDouble(OdConstants.PREF_CRS_COMPARISON_TOLERANCE, OdConstants.DEFAULT_CRS_COMPARISON_TOLERANCE); 52 52 if (Main.pref.getBoolean(OdConstants.PREF_CRS_COMPARISON_DEBUG, false)) { 53 System.out.println("Comparing "+a+" and "+b+" -> "+res);53 Main.debug("Comparing "+a+" and "+b+" -> "+res); 54 54 } 55 55 return res; -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/GeographicReader.java
r30563 r30568 5 5 6 6 import java.awt.Component; 7 import java.awt.GraphicsEnvironment; 7 8 import java.awt.Image; 8 9 import java.util.ArrayList; 10 import java.util.Arrays; 9 11 import java.util.HashMap; 10 12 import java.util.List; … … 200 202 201 203 private static final void compareDebug(CoordinateReferenceSystem crs1, CoordinateReferenceSystem crs2) { 202 System.out.println("-- COMPARING "+crs1.getName()+" WITH "+crs2.getName()+" --");204 Main.debug("-- COMPARING "+crs1.getName()+" WITH "+crs2.getName()+" --"); 203 205 compareDebug("class", crs1.getClass(), crs2.getClass()); 204 206 CoordinateSystem cs1 = crs1.getCoordinateSystem(); … … 229 231 } 230 232 } 231 System.out.println("-- COMPARING FINISHED --");233 Main.debug("-- COMPARING FINISHED --"); 232 234 } 233 235 … … 245 247 246 248 private static final boolean compareDebug(String text, boolean result, Object o1, Object o2) { 247 System.out.println(text + ": " + result + "("+o1+", "+o2+")");249 Main.debug(text + ": " + result + "("+o1+", "+o2+")"); 248 250 return result; 249 251 } … … 253 255 transform = CRS.findMathTransform(crs, wgs84); 254 256 } catch (OperationNotFoundException e) { 255 System.out.println(crs.getName()+": "+e.getMessage()); // Bursa wolf parameters required.257 Main.info(crs.getName()+": "+e.getMessage()); // Bursa wolf parameters required. 256 258 257 259 if (findSimiliarCrs) { … … 267 269 Main.pref.getDouble(OdConstants.PREF_CRS_COMPARISON_TOLERANCE, OdConstants.DEFAULT_CRS_COMPARISON_TOLERANCE)); 268 270 if (((AbstractCRS)candidate).equals((AbstractIdentifiedObject)crs, false)) { 269 System.out.println("Found a potential CRS: "+candidate.getName());271 Main.info("Found a potential CRS: "+candidate.getName()); 270 272 candidates.add(candidate); 271 273 } else if (Main.pref.getBoolean(OdConstants.PREF_CRS_COMPARISON_DEBUG, false)) { … … 281 283 282 284 if (candidates.size() > 1) { 283 System.err.println("Found several potential CRS.");//TODO: ask user which one to use 285 Main.warn("Found several potential CRS: "+Arrays.toString(candidates.toArray())); 286 // TODO: ask user which one to use 284 287 } 285 288 … … 300 303 transform = handler.findMathTransform(crs, wgs84, false); 301 304 } catch (OperationNotFoundException ex) { 302 System.out.println(crs.getName()+": "+ex.getMessage()); // Bursa wolf parameters required.305 Main.warn(crs.getName()+": "+ex.getMessage()); // Bursa wolf parameters required. 303 306 } 304 307 } else { … … 310 313 } 311 314 } catch (OperationNotFoundException ex) { 312 System.out.println(crs.getName()+": "+ex.getMessage()); // Bursa wolf parameters required.315 Main.warn(crs.getName()+": "+ex.getMessage()); // Bursa wolf parameters required. 313 316 } 314 317 } 315 318 } 316 319 if (transform == null) { 317 // ask user before trying lenient method 318 if ( warnLenientMethod(parent, crs)) {320 // ask user before trying lenient method, unless in headless mode (unit tests) 321 if (!GraphicsEnvironment.isHeadless() && warnLenientMethod(parent, crs)) { 319 322 // User canceled 320 323 throw new UserCancelException(); 321 324 } 322 System.out.println("Searching for a lenient math transform.");325 Main.info("Searching for a lenient math transform."); 323 326 transform = CRS.findMathTransform(crs, wgs84, true); 324 327 } -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/GmlReader.java
r30563 r30568 107 107 108 108 private void findCRS(String srs) throws NoSuchAuthorityCodeException, FactoryException { 109 System.out.println("Finding CRS for "+srs);109 Main.info("Finding CRS for "+srs); 110 110 if (gmlHandler != null) { 111 111 crs = gmlHandler.getCrsFor(srs); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/ShpReader.java
r30567 r30568 158 158 } else { 159 159 // Debug unknown geometry 160 System.out.println("\ttype: "+geometry.getType());161 System.out.println("\tbounds: "+geometry.getBounds());162 System.out.println("\tdescriptor: "+desc);163 System.out.println("\tname: "+geometry.getName());164 System.out.println("\tvalue: "+geometry.getValue());165 System.out.println("\tid: "+geometry.getIdentifier());166 System.out.println("-------------------------------------------------------------");160 Main.debug("\ttype: "+geometry.getType()); 161 Main.debug("\tbounds: "+geometry.getBounds()); 162 Main.debug("\tdescriptor: "+desc); 163 Main.debug("\tname: "+geometry.getName()); 164 Main.debug("\tvalue: "+geometry.getValue()); 165 Main.debug("\tid: "+geometry.getIdentifier()); 166 Main.debug("-------------------------------------------------------------"); 167 167 } 168 168 -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/tabular/CsvReader.java
r30563 r30568 8 8 import java.nio.charset.Charset; 9 9 10 import org.openstreetmap.josm.Main; 10 11 import org.openstreetmap.josm.data.osm.DataSet; 11 12 import org.openstreetmap.josm.gui.progress.ProgressMonitor; … … 43 44 if (csvHandler == null || csvHandler.getSeparator() == null || ";".equals(csvHandler.getSeparator())) { 44 45 // If default sep has been used, try comma 45 System.out.println(e.getMessage());46 Main.warn(e.getMessage()); 46 47 csvReader.sep = ","; 47 48 return csvReader.doParse(csvReader.splitLine(), instance); … … 54 55 @Override 55 56 protected void initResources(InputStream in, ProgressMonitor progressMonitor) throws IOException { 56 System.out.println("Parsing CSV file using charset "+charset+" and separator '"+sep+"'");57 Main.info("Parsing CSV file using charset "+charset+" and separator '"+sep+"'"); 57 58 58 59 reader = new BufferedReader(new InputStreamReader(in, charset)); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/tabular/OdsDocument.java
r30563 r30568 11 11 import org.jopendocument.io.SaxContentUnmarshaller; 12 12 import org.jopendocument.model.OpenDocument; 13 import org.openstreetmap.josm.Main; 13 14 import org.xml.sax.InputSource; 14 15 import org.xml.sax.XMLReader; … … 44 45 if (entry.getName().equals("content.xml")) { 45 46 rdr.setContentHandler(contentHandler); 46 System.out.println("Parsing content.xml");47 Main.info("Parsing content.xml"); 47 48 rdr.parse(getEntryInputSource(zis)); 48 49 contentParsed = true; -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/tabular/OdsReader.java
r30532 r30568 13 13 import org.jopendocument.model.table.TableTableRow; 14 14 import org.jopendocument.model.text.TextP; 15 import org.openstreetmap.josm.Main; 15 16 import org.openstreetmap.josm.data.osm.DataSet; 16 17 import org.openstreetmap.josm.gui.progress.ProgressMonitor; … … 38 39 protected void initResources(InputStream in, ProgressMonitor progressMonitor) throws IOException { 39 40 try { 40 System.out.println("Parsing ODS file");41 Main.info("Parsing ODS file"); 41 42 doc = new OdsDocument(in); 42 43 List<OfficeSpreadsheet> spreadsheets = doc.getBody().getOfficeSpreadsheets(); … … 62 63 63 64 if (rowIndex % 5000 == 0) { 64 System.out.println("Lines read: "+rowIndex);65 Main.info("Lines read: "+rowIndex); 65 66 } 66 67 -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/tabular/SpreadSheetReader.java
r30563 r30568 100 100 101 101 public DataSet doParse(String[] header, ProgressMonitor progressMonitor) throws IOException { 102 System.out.println("Header: "+Arrays.toString(header));102 Main.info("Header: "+Arrays.toString(header)); 103 103 104 104 Map<ProjectionPatterns, List<CoordinateColumns>> projColumns = new HashMap<>(); … … 175 175 } 176 176 177 System.out.println("Loading data using projections "+message);177 Main.info("Loading data using projections "+message); 178 178 179 179 final DataSet ds = new DataSet(); -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/tabular/XlsReader.java
r30532 r30568 14 14 import org.apache.poi.ss.usermodel.Sheet; 15 15 import org.apache.poi.ss.usermodel.Workbook; 16 import org.openstreetmap.josm.Main; 16 17 import org.openstreetmap.josm.data.osm.DataSet; 17 18 import org.openstreetmap.josm.gui.progress.ProgressMonitor; … … 35 36 @Override 36 37 protected void initResources(InputStream in, ProgressMonitor progressMonitor) throws IOException { 37 System.out.println("Parsing XLS file");38 Main.info("Parsing XLS file"); 38 39 try { 39 40 wb = new HSSFWorkbook(new POIFSFileSystem(in)); -
applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/NonRegFunctionalTests.java
r30563 r30568 6 6 import static org.junit.Assert.assertTrue; 7 7 8 import java.io.IOException; 9 import java.nio.file.DirectoryIteratorException; 10 import java.nio.file.DirectoryStream; 11 import java.nio.file.Files; 12 import java.nio.file.Path; 13 import java.nio.file.Paths; 14 import java.util.ArrayList; 8 15 import java.util.Collection; 9 16 17 import org.openstreetmap.josm.TestUtils; 10 18 import org.openstreetmap.josm.data.osm.DataSet; 11 19 import org.openstreetmap.josm.data.osm.Node; … … 40 48 assertTrue(found); 41 49 } 50 51 /** 52 * Lists all datasets files matching given extension. 53 * @param ext file extension to search for 54 * @returns List of all datasets files matching given extension 55 * @throws IOException in case of I/O error 56 */ 57 public static Collection<Path> listDataFiles(String ext) throws IOException { 58 Collection<Path> result = new ArrayList<>(); 59 addTree(Paths.get(TestUtils.getTestDataRoot()+"datasets"), result, ext.toLowerCase()); 60 return result; 61 } 62 63 static void addTree(Path directory, Collection<Path> all, String ext) throws IOException { 64 try (DirectoryStream<Path> ds = Files.newDirectoryStream(directory)) { 65 for (Path child : ds) { 66 if (Files.isDirectory(child)) { 67 addTree(child, all, ext); 68 } else if (child.toString().toLowerCase().endsWith(ext)) { 69 all.add(child); 70 } 71 } 72 } catch (DirectoryIteratorException ex) { 73 // I/O error encounted during the iteration, the cause is an IOException 74 throw ex.getCause(); 75 } 76 } 42 77 } -
applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/geographic/MifReaderTest.java
r30550 r30568 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.opendata.core.io.geographic; 3 4 import static org.junit.Assert.assertFalse;5 3 6 4 import java.io.File; … … 13 11 import org.openstreetmap.josm.JOSMFixture; 14 12 import org.openstreetmap.josm.TestUtils; 15 import org.openstreetmap.josm. data.osm.DataSet;13 import org.openstreetmap.josm.plugins.opendata.core.io.NonRegFunctionalTests; 16 14 17 15 /** … … 36 34 File file = new File(TestUtils.getRegressionDataFile(9592, "bg.mif")); 37 35 try (InputStream is = new FileInputStream(file)) { 38 DataSet ds = MifReader.parseDataSet(is, file, null, null); 39 assertFalse(ds.allPrimitives().isEmpty()); 36 NonRegFunctionalTests.testGeneric(MifReader.parseDataSet(is, file, null, null)); 40 37 } 41 38 }
Note:
See TracChangeset
for help on using the changeset viewer.