PlacemarkIO { public static List<Placemark> readPlacemarks(Reader reader, GeoCoding geoCoding, PlacemarkDescriptor placemarkDescriptor) throws IOException { final char[] magicBytes = new char[5]; try (PushbackReader inputReader = new PushbackReader(reader, magicBytes.length)) { inputReader.read(magicBytes); inputReader.unread(magicBytes); if (XmlWriter.XML_HEADER_LINE.startsWith(new String(magicBytes))) { return readPlacemarksFromXMLFile(inputReader, geoCoding, placemarkDescriptor); } else { return readPlacemarksFromFlatFile(inputReader, geoCoding, placemarkDescriptor); } } } private  PlacemarkIO(); static List<Placemark> readPlacemarks(Reader reader, GeoCoding geoCoding,
                                                 PlacemarkDescriptor placemarkDescriptor); static void writePlacemarksWithAdditionalData(Writer writer,
                                                         String roleLabel, String productName,
                                                         List<Placemark> placemarkList, List<Object[]> valueList,
                                                         String[] standardColumnNames, String[] additionalColumnNames); static void writePlacemarksFile(Writer writer, List<Placemark> placemarks); static BeamFileFilter createTextFileFilter(); static BeamFileFilter createPlacemarkFileFilter(); static Placemark createPlacemark(Element element, PlacemarkDescriptor descriptor, GeoCoding geoCoding); static void writeXML(Placemark placemark, XmlWriter writer, int indent); static void writeColor(final String tagName, final int indent, final Color color, final XmlWriter writer); static final String FILE_EXTENSION_FLAT_OLD; static final String FILE_EXTENSION_XML_OLD; static final String FILE_EXTENSION_FLAT_TEXT; static final String FILE_EXTENSION_PLACEMARK; }
@Test public void testReadPlacemarkTextFileWithDateTimeFromConstantInput() throws Exception { final StringWriter stringWriter = new StringWriter(WRITER_INITIAL_SIZE); PrintWriter writer = new PrintWriter(stringWriter); writer.printf("Name Lat Lon DateTime%n"); writer.printf("One 59.885 10.664 2005-04-18T17:53:58%n"); writer.printf("Two 59.883 10.657 2006-08-06T12:54:58%n"); writer.printf("Three 59.88 10.65 2007-09-01T07:55:58%n"); List<Placemark> actualPlacemarks = PlacemarkIO.readPlacemarks(new StringReader(stringWriter.toString()), GEO_CODING, PinDescriptor.getInstance()); assertEquals(3, actualPlacemarks.size()); final Placemark mark1 = actualPlacemarks.get(0); assertEquals("One", mark1.getLabel()); assertDateTime(mark1, 2005, 3, 18, 17, 53, 58); assertEquals(59.885, mark1.getGeoPos().getLat(), 1.0e-3); assertEquals(10.664, mark1.getGeoPos().getLon(), 1.0e-3); final Placemark mark2 = actualPlacemarks.get(1); assertEquals("Two", mark2.getLabel()); assertDateTime(mark2, 2006, 7, 6, 12, 54, 58); assertEquals(59.883, mark2.getGeoPos().getLat(), 1.0e-3); assertEquals(10.657, mark2.getGeoPos().getLon(), 1.0e-3); final Placemark mark3 = actualPlacemarks.get(2); assertEquals("Three", mark3.getLabel()); assertDateTime(mark3, 2007, 8, 1, 7, 55, 58); assertEquals(59.88, mark3.getGeoPos().getLat(), 1.0e-3); assertEquals(10.65, mark3.getGeoPos().getLon(), 1.0e-3); }