public void printLine(int indent, String tagName, String text) { final String[] tags = createTags(indent, tagName); printLine(tags, text); }
public void printLine(int indent, String tagName, String[][] attributes, String text) { final String[] tags = createTags(indent, tagName, attributes); printLine(tags, text); }
public static void writeColor(final String tagName, final int indent, final Color color, final XmlWriter writer) { final String[] colorTags = XmlWriter.createTags(indent, tagName); writer.println(colorTags[0]); DimapProductHelpers.printColorTag(indent + 1, color, writer); writer.println(colorTags[1]); } }
public void testPrintLineText_parentheses() { StringWriter stringWriter = new StringWriter(); XmlWriter xmlWriter = new XmlWriter(stringWriter, false); xmlWriter.printLine(XmlWriter.createTags(1, "tag"), "test < test > test"); String current = stringWriter.toString(); String expected = " <tag>test < test > test</tag>"; stringWriter = new StringWriter(); new PrintWriter(stringWriter).println(); expected = expected + stringWriter.toString(); assertEquals(expected, current); }
public void testPrintLineEmptyText() { StringWriter stringWriter = new StringWriter(); XmlWriter xmlWriter = new XmlWriter(stringWriter, false); xmlWriter.printLine(XmlWriter.createTags(1, "tag"), ""); String current = stringWriter.toString(); String expected = " <tag />"; stringWriter = new StringWriter(); new PrintWriter(stringWriter).println(); expected = expected + stringWriter.toString(); assertEquals(expected, current); }
public void testPrintLineText_ampersand() { StringWriter stringWriter = new StringWriter(); XmlWriter xmlWriter = new XmlWriter(stringWriter, false); xmlWriter.printLine(XmlWriter.createTags(1, "tag"), "ampersand & ampersand"); String current = stringWriter.toString(); String expected = " <tag>ampersand & ampersand</tag>"; stringWriter = new StringWriter(); new PrintWriter(stringWriter).println(); expected = expected + stringWriter.toString(); assertEquals(expected, current); }
public void testPrintLineWidthText() { StringWriter stringWriter = new StringWriter(); XmlWriter xmlWriter = new XmlWriter(stringWriter, false); xmlWriter.printLine(XmlWriter.createTags(1, "tag"), "name"); String current = stringWriter.toString(); String expected = " <tag>name</tag>"; stringWriter = new StringWriter(); new PrintWriter(stringWriter).println(); expected = expected + stringWriter.toString(); assertEquals(expected, current); }
public void testPrintLineNullText() { StringWriter stringWriter = new StringWriter(); XmlWriter xmlWriter = new XmlWriter(stringWriter, false); xmlWriter.printLine(XmlWriter.createTags(1, "tag"), null); String current = stringWriter.toString(); String expected = " <tag />"; stringWriter = new StringWriter(); new PrintWriter(stringWriter).println(); expected = expected + stringWriter.toString(); assertEquals(expected, current); }
public static void writePlacemarksFile(Writer writer, List<Placemark> placemarks) throws IOException { XmlWriter xmlWriter = new XmlWriter(writer, true); final String[] tags = XmlWriter.createTags(0, "Placemarks"); xmlWriter.println(tags[0]); for (Placemark placemark : placemarks) { if (placemark != null) { writeXML(placemark, xmlWriter, 1); } } xmlWriter.println(tags[1]); xmlWriter.close(); }
public void testCreateTags() { String[] tags = XmlWriter.createTags(0, "name"); assertEquals(2, tags.length); assertEquals("<name>", tags[0]); assertEquals("</name>", tags[1]); }
public void testCreateTagsWithAtribs() { String[] tags = XmlWriter.createTags(2, "name", new String[][]{{"a", "b"}, {"c", "d"}}); assertEquals(2, tags.length); assertEquals(" <name a=\"b\" c=\"d\">", tags[0]); assertEquals(" </name>", tags[1]); }
public void testCreateTagsWithAtribs_ampersand_and_parentheses() { String[] tags = XmlWriter.createTags(2, "name", new String[][]{{"a", "a & b"}, {"c", "d < e > f"}}); assertEquals(2, tags.length); assertEquals(" <name a=\"a & b\" c=\"d < e > f\">", tags[0]); assertEquals(" </name>", tags[1]); } }
public void writeXML(XmlWriter writer, int indent) { Guardian.assertNotNull("writer", writer); Guardian.assertGreaterThan("indent", indent, -1); String[][] attributes = new String[1][]; attributes[0] = new String[]{DimapProductConstants.ATTRIB_NAME, getName()}; String[] bdTags = XmlWriter.createTags(indent, DimapProductConstants.TAG_BITMASK_DEFINITION, attributes); writer.println(bdTags[0]); String description = getDescription(); if (description == null) { description = ""; } attributes[0] = new String[]{DimapProductConstants.ATTRIB_VALUE, description}; writer.printLine(indent + 1, DimapProductConstants.TAG_BITMASK_DESCRIPTION, attributes, null); String expr = getExpr(); if (expr == null) { expr = ""; } attributes[0] = new String[]{DimapProductConstants.ATTRIB_VALUE, expr}; writer.printLine(indent + 1, DimapProductConstants.TAG_BITMASK_EXPRESSION, attributes, null); DimapProductHelpers.printColorTag(indent + 1, getColor(), writer); attributes[0] = new String[]{DimapProductConstants.ATTRIB_VALUE, String.valueOf(getTransparency())}; writer.printLine(indent + 1, DimapProductConstants.TAG_BITMASK_TRANSPARENCY, attributes, null); writer.println(bdTags[1]); }
public static void writeXML(Placemark placemark, XmlWriter writer, int indent) { Guardian.assertNotNull("writer", writer); Guardian.assertGreaterThan("indent", indent, -1); final String[][] attributes = {new String[]{DimapProductConstants.ATTRIB_NAME, placemark.getName()}}; final String[] pinTags = XmlWriter.createTags(indent, DimapProductConstants.TAG_PLACEMARK, attributes); writer.println(pinTags[0]); indent++; writer.printLine(indent, DimapProductConstants.TAG_PLACEMARK_LABEL, placemark.getLabel()); writer.printLine(indent, DimapProductConstants.TAG_PLACEMARK_DESCRIPTION, placemark.getDescription()); final GeoPos geoPos = placemark.getGeoPos(); if (geoPos != null) { writer.printLine(indent, DimapProductConstants.TAG_PLACEMARK_LATITUDE, geoPos.lat); writer.printLine(indent, DimapProductConstants.TAG_PLACEMARK_LONGITUDE, geoPos.lon); } final PixelPos pixelPos = placemark.getPixelPos(); if (pixelPos != null && pixelPos.isValid()) { writer.printLine(indent, DimapProductConstants.TAG_PLACEMARK_PIXEL_X, pixelPos.x); writer.printLine(indent, DimapProductConstants.TAG_PLACEMARK_PIXEL_Y, pixelPos.y); } final String styleCss = placemark.getStyleCss(); if (styleCss != null && !styleCss.isEmpty()) { writer.printLine(indent, DimapProductConstants.TAG_PLACEMARK_STYLE_CSS, styleCss); } writer.println(pinTags[1]); }