⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 data.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
// **********************************************************************// <copyright>//  BBN Technologies//  10 Moulton Street//  Cambridge, MA 02138//  (617) 873-8000// //  Copyright (C) BBNT Solutions LLC. All rights reserved.// </copyright>// **********************************************************************// $Source: /cvs/distapps/openmap/src/vpfservlet/WEB-INF/src/com/bbn/openmap/vpfservlet/Data.java,v $// $Revision: 1.4.2.2 $ $Date: 2005/08/11 21:03:08 $ $Author: dietrick $// **********************************************************************package com.bbn.openmap.vpfservlet;import java.io.IOException;import java.util.ArrayList;import java.util.Iterator;import java.util.List;import java.util.ListIterator;import java.util.NoSuchElementException;import java.util.StringTokenizer;import javax.servlet.ServletException;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import com.bbn.openmap.io.FormatException;import com.bbn.openmap.layer.util.html.ListElement;import com.bbn.openmap.layer.util.html.StringElement;import com.bbn.openmap.layer.util.html.TableHeaderElement;import com.bbn.openmap.layer.util.html.TableRowElement;import com.bbn.openmap.layer.util.html.WrapElement;import com.bbn.openmap.layer.vpf.Constants;import com.bbn.openmap.layer.vpf.DcwColumnInfo;import com.bbn.openmap.layer.vpf.DcwRecordFile;/** * A servlet class that will output table data. */public class Data extends VPFHttpServlet {    /** the name of the http parameter with the table name */    public static final String VDTParam = "vdt";    /** the possible values of the rowselect parameter */    public static final String RowSelectParam = "show";    public static final String RowSelectAll = "all";    public static final String RowSelectNone = "none";    public static final String RowSelectTest = "test";    /** other parameters that the servlet takes */    public static final String JoinColumnParam = "colname";    public static final String JoinOtherTableParam = "othertable";    public static final String JoinOtherTableKeyParam = "othertablekey";    public static final String IsTiledParam = "isTiled";    /**     * A do-nothing constructor - init does all the work.     */    public Data() {        super();    }    public void doGet(HttpServletRequest request, HttpServletResponse response)            throws ServletException, IOException {        DcwRecordFile foo = (DcwRecordFile) request.getAttribute(DispatchServlet.RECORD_FILE_OBJ);        if (foo == null) {            response.sendError(HttpServletResponse.SC_BAD_REQUEST);            return;        }        try {            doWork(request, response, foo);        } catch (FormatException fe) {            response.getWriter().println("FormatException dealing with table: "                    + fe);        }    }    /**     * Generates the heading used for each HTML table     */    protected TableRowElement generateHeader(HttpServletRequest req,                                             HttpServletResponse resp,                                             DcwColumnInfo[] dci) {        TableRowElement thr = new TableRowElement();        for (int i = 0; i < dci.length; i++) {            DcwColumnInfo dc = dci[i];            String colName = dc.getColumnName();            if (dc.getValueDescriptionTable() == null) {                thr.addElement(new TableHeaderElement(colName));            } else {                StringBuffer baseurl = new StringBuffer();                baseurl.append(req.getContextPath());                baseurl.append(req.getServletPath());                baseurl.append(req.getPathInfo()).append("?");                String show = req.getParameter(RowSelectParam);                String vdtl = req.getParameter(VDTParam);                if (show != null) {                    baseurl.append(RowSelectParam).append("=");                    baseurl.append(show).append("&");                }                baseurl.append(VDTParam).append("=");                if (vdtl == null) {                    vdtl = "";                }                boolean appendCol = true;                boolean needSep = false;                StringTokenizer st = new StringTokenizer(vdtl, ",");                while (st.hasMoreTokens()) {                    String sname = st.nextToken();                    if (colName.equals(sname)) {                        appendCol = false;                    } else {                        append(baseurl, sname, needSep);                        needSep = true;                    }                }                if (appendCol) {                    append(baseurl, colName, needSep);                }                thr.addElement(THE(colName, baseurl.toString()));            }        }        return thr;    }    public static StringBuffer append(StringBuffer base, String app,                                      boolean needSep) {        return (needSep ? base.append(",") : base).append(app);    }    public static final String ROWLIST_OBJECT = Data.class.getPackage()            .getName()            + ".rowlist";    protected void doWork(HttpServletRequest request,                          HttpServletResponse response, DcwRecordFile drf)            throws FormatException, IOException {        DcwColumnInfo dci[] = drf.getColumnInfo();        int rowlist[] = (int[]) request.getAttribute(ROWLIST_OBJECT);        ListElement rows = new ListElement();        WrapElement table = new WrapElement("table", "BORDER=1 ALIGN=CENTER", rows);        TableRowElement thr = generateHeader(request, response, dci);        rows.addElement(thr);        String row_show = request.getParameter(RowSelectParam);        boolean printall = RowSelectAll.equals(row_show);        boolean parseall = RowSelectTest.equals(row_show);        boolean schemaonly = RowSelectNone.equals(row_show);        String baseurl = request.getContextPath() + request.getServletPath()                + request.getPathInfo();        String all = baseurl + "?" + RowSelectParam + "=" + RowSelectAll;        String none = baseurl + "?" + RowSelectParam + "=" + RowSelectNone;        String some = baseurl;        String test = baseurl + "?" + RowSelectParam + "=" + RowSelectTest;        String qstr = request.getQueryString();        if (rowlist != null) {            qstr = null;        }        if (qstr == null) {            qstr = VDTParam + "=ALL";        }        if (qstr.indexOf(VDTParam + "=") == -1) {            qstr += "&" + VDTParam + "=ALL";        }        String vdtlookup = baseurl + "?" + qstr;        response.getWriter().println("<H2>Table Data</H2>");        String redisplay = "Redisplay " + buildHREF(response, all, "All")                + "\r\n|" + buildHREF(response, none, "None") + "\r\n|"                + buildHREF(response, some, "Some") + "\r\n|"                + buildHREF(response, test, "Test") + "\r\n|"                + buildHREF(response, vdtlookup, "All VDT Columns") + "\r\n";        if (schemaonly) {            response.getWriter().println("Data Omitted: " + redisplay);            return;        }        RowMaker rm;        String basepath = getRootDir(request);        String joincol = request.getParameter(JoinColumnParam);        String jointable = request.getParameter(JoinOtherTableParam);        String jointablekey = request.getParameter(JoinOtherTableKeyParam);        if ((joincol != null) && (jointable != null)) {            String isTiledJoin = request.getParameter(IsTiledParam);            boolean isTiled = Boolean.valueOf(isTiledJoin).booleanValue();            if (Constants.ID.equals(jointablekey)) {                rm = new JoinRowMaker(drf, joincol, jointable, isTiled);            } else {                rm = new ComplexJoinRowMaker(drf, joincol, jointable, jointablekey, isTiled);            }        } else if (drf.getTableName().equals(Constants.charVDTTableName)                || drf.getTableName().equals(Constants.intVDTTableName)) {            rm = new VDTRowMaker(request, response, basepath, drf);        } else if (drf.getTableName().equals("fcs")) {            rm = new FCSRowMaker(request, response, basepath, drf);        } else if (request.getParameter(VDTParam) != null) {            String subsetmarkup = request.getParameter(VDTParam);            String[] ss = null;            if (subsetmarkup != null) {                StringTokenizer st = new StringTokenizer(subsetmarkup, ",", false);                ss = new String[st.countTokens()];                for (int i = 0; i < ss.length; i++) {                    ss[i] = st.nextToken();                    if ("ALL".equals(ss[i])) {                        ss = null; // null array gets all VDT lookups                        break;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -