Search in sources :

Example 1 with XmlWriter

use of com.revolsys.record.io.format.xml.XmlWriter in project com.revolsys.open by revolsys.

the class BaseDoclet method setOptions.

protected void setOptions(final String[][] options) {
    for (final String[] option : options) {
        final String optionName = option[0];
        if (optionName.equals("-d")) {
            this.destDir = option[1];
        } else if (optionName.equals("-doctitle")) {
            this.docTitle = option[1];
        } else if (optionName.equals("-customcssurl")) {
            this.customCssUrls.add(option[1]);
        }
    }
    try {
        final File dir = new File(this.destDir);
        final File indexFile = new File(dir, "index.html");
        final FileWriter out = new FileWriter(indexFile);
        this.writer = new XmlWriter(out, false);
        this.writer.setIndent(false);
        this.writer.setWriteNewLine(false);
        DocletUtil.copyFiles(this.destDir);
    } catch (final IOException e) {
        throw new IllegalArgumentException(e.fillInStackTrace().getMessage(), e);
    }
}
Also used : FileWriter(java.io.FileWriter) IOException(java.io.IOException) File(java.io.File) XmlWriter(com.revolsys.record.io.format.xml.XmlWriter)

Example 2 with XmlWriter

use of com.revolsys.record.io.format.xml.XmlWriter in project com.revolsys.open by revolsys.

the class OgrVrtWriter method write.

public static void write(final File file, final RecordDefinition recordDefinition, final String dataSource) throws IOException {
    try (XmlWriter writer = new XmlWriter(new FileWriter(file))) {
        writer.setIndent(true);
        writer.startDocument("UTF-8", "1.0");
        writer.startTag("OGRVRTDataSource");
        writer.startTag("OGRVRTLayer");
        final String typeName = recordDefinition.getName();
        writer.attribute("name", typeName);
        writer.startTag("SrcDataSource");
        writer.attribute("relativeToVRT", "1");
        writer.text(dataSource);
        writer.endTag("SrcDataSource");
        writer.element(new QName("SrcLayer"), typeName);
        for (final FieldDefinition attribute : recordDefinition.getFields()) {
            final String fieldName = attribute.getName();
            final DataType fieldType = attribute.getDataType();
            final Class<?> typeClass = attribute.getTypeClass();
            if (Geometry.class.isAssignableFrom(typeClass)) {
                final GeometryFactory geometryFactory = recordDefinition.getGeometryFactory();
                writer.element("GeometryType", "wkb" + fieldType);
                if (geometryFactory != null) {
                    writer.element("LayerSRS", "EPSG:" + geometryFactory.getCoordinateSystemId());
                }
                writer.startTag("GeometryField");
                writer.attribute("encoding", "WKT");
                writer.attribute("field", fieldName);
                writer.attribute("name", fieldName);
                writer.attribute("reportSrcColumn", "FALSE");
                writer.element("GeometryType", "wkb" + fieldType);
                if (geometryFactory != null) {
                    writer.element("SRS", "EPSG:" + geometryFactory.getCoordinateSystemId());
                }
                writer.endTag("GeometryField");
            } else {
                writer.startTag("Field");
                writer.attribute("name", fieldName);
                String type = "String";
                if (Arrays.asList(DataTypes.BYTE, DataTypes.SHORT, DataTypes.INT, DataTypes.LONG, DataTypes.BIG_INTEGER).contains(fieldType)) {
                    type = "Integer";
                } else if (Arrays.asList(DataTypes.FLOAT, DataTypes.DOUBLE, DataTypes.DECIMAL).contains(fieldType)) {
                    type = "Real";
                } else if (DataTypes.DATE.equals(type)) {
                    type = "Date";
                } else if (DataTypes.DATE_TIME.equals(type)) {
                    type = "DateTime";
                } else {
                    type = "String";
                }
                writer.attribute("type", type);
                final int length = attribute.getLength();
                if (length > 0) {
                    writer.attribute("width", length);
                }
                final int scale = attribute.getScale();
                if (scale > 0) {
                    writer.attribute("scale", scale);
                }
                writer.attribute("src", fieldName);
                writer.endTag("Field");
            }
        }
        writer.endTag("OGRVRTLayer");
        writer.endTag("OGRVRTDataSource");
        writer.endDocument();
    }
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) QName(javax.xml.namespace.QName) FileWriter(java.io.FileWriter) FieldDefinition(com.revolsys.record.schema.FieldDefinition) DataType(com.revolsys.datatype.DataType) XmlWriter(com.revolsys.record.io.format.xml.XmlWriter)

Example 3 with XmlWriter

use of com.revolsys.record.io.format.xml.XmlWriter in project com.revolsys.open by revolsys.

the class MenuViewController method bootstrapNavbar.

private void bootstrapNavbar(final HttpServletRequest request, final HttpServletResponse response, final Navbar navBar) throws IOException {
    if (navBar != null) {
        try (final OutputStream out = response.getOutputStream();
            XmlWriter writer = new XmlWriter(out, false)) {
            writer.setIndent(false);
            final JexlHttpServletRequestContext jexlContext = new JexlHttpServletRequestContext(request);
            final List<Menu> menus = new ArrayList<>();
            for (final Menu menuItem : navBar.getMenus()) {
                if (menuItem.isVisible()) {
                    menus.add(menuItem);
                }
            }
            final String title = navBar.getTitle();
            if (Property.hasValue(title) || !menus.isEmpty()) {
                BootstrapUtil.navbarStart(writer, navBar, jexlContext);
                bootstrapMenu(writer, menus, 1, jexlContext);
                BootstrapUtil.navbarEnd(writer);
            }
            writer.flush();
        }
    }
}
Also used : OutputStream(java.io.OutputStream) ArrayList(java.util.ArrayList) Menu(com.revolsys.ui.model.Menu) XmlWriter(com.revolsys.record.io.format.xml.XmlWriter) JexlHttpServletRequestContext(com.revolsys.ui.web.config.JexlHttpServletRequestContext)

Example 4 with XmlWriter

use of com.revolsys.record.io.format.xml.XmlWriter in project com.revolsys.open by revolsys.

the class AbstractKeySerializer method toString.

@Override
public String toString(final Object object) {
    final StringWriter out = new StringWriter();
    final XmlWriter xmlOut = new XmlWriter(out);
    serialize(xmlOut, object);
    xmlOut.flush();
    xmlOut.close();
    return out.toString();
}
Also used : StringWriter(java.io.StringWriter) XmlWriter(com.revolsys.record.io.format.xml.XmlWriter)

Example 5 with XmlWriter

use of com.revolsys.record.io.format.xml.XmlWriter in project com.revolsys.open by revolsys.

the class PageInfoHttpMessageConverter method writeWadl.

private void writeWadl(final OutputStream out, final String url, final PageInfo pageInfo) {
    final XmlWriter writer = new XmlWriter(out);
    writer.startDocument("UTF-8", "1.0");
    writer.startTag(APPLICATION);
    writer.startTag(RESOURCES);
    writeWadlResource(writer, url, pageInfo, true);
    writer.endTag(RESOURCES);
    writer.endTag(APPLICATION);
    writer.endDocument();
    writer.close();
}
Also used : XmlWriter(com.revolsys.record.io.format.xml.XmlWriter)

Aggregations

XmlWriter (com.revolsys.record.io.format.xml.XmlWriter)8 FileWriter (java.io.FileWriter)2 DataType (com.revolsys.datatype.DataType)1 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)1 FieldDefinition (com.revolsys.record.schema.FieldDefinition)1 Element (com.revolsys.ui.html.view.Element)1 DocInfo (com.revolsys.ui.model.DocInfo)1 Menu (com.revolsys.ui.model.Menu)1 PageInfo (com.revolsys.ui.model.PageInfo)1 JexlHttpServletRequestContext (com.revolsys.ui.web.config.JexlHttpServletRequestContext)1 File (java.io.File)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 StringWriter (java.io.StringWriter)1 Writer (java.io.Writer)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1