Package org.postgresql.util

Examples of org.postgresql.util.PGtokenizer


     * @param s Definition of the line segment in PostgreSQL's syntax
     * @exception SQLException on conversion failure
     */
    public void setValue(String s) throws SQLException
    {
        PGtokenizer t = new PGtokenizer(PGtokenizer.removeBox(s), ',');
        if (t.getSize() != 2)
            throw new PSQLException(GT.tr("Conversion to type {0} failed: {1}.", new Object[]{type,s}), PSQLState.DATA_TYPE_MISMATCH);

        point[0] = new PGpoint(t.getToken(0));
        point[1] = new PGpoint(t.getToken(1));
    }
View Full Code Here


    ResultSet rsChildren = childrenArray.getResultSet();
    assertNotNull(rsChildren);
    while (rsChildren.next()) {
      String comp = rsChildren.getString(2);
      PGtokenizer token = new PGtokenizer(PGtokenizer.removePara(comp),',');
      token.remove("\"", "\""); //remove surrounding double quotes
      if (2 < token.getSize()) {
        int childID = Integer.parseInt(token.getToken(0));
        String value = token.getToken(2).replace("\"\"", "\""); //remove double quotes escaping with double quotes
        assertEquals(children[childID-1],value);
      } else
        fail("Needs to have 3 tokens");
    }
    }
View Full Code Here

     * @param s Definition of this point in PostgreSQL's syntax
     * @exception SQLException on conversion failure
     */
    public void setValue(String s) throws SQLException
    {
        PGtokenizer t = new PGtokenizer(PGtokenizer.removePara(s), ',');
        try
        {
            x = Double.parseDouble(t.getToken(0));
            y = Double.parseDouble(t.getToken(1));
        }
        catch (NumberFormatException e)
        {
            throw new PSQLException(GT.tr("Conversion to type {0} failed: {1}.", new Object[]{type,s}), PSQLState.DATA_TYPE_MISMATCH, e);
        }
View Full Code Here

     * @param s Definition of the polygon in PostgreSQL's syntax
     * @exception SQLException on conversion failure
     */
    public void setValue(String s) throws SQLException
    {
        PGtokenizer t = new PGtokenizer(PGtokenizer.removePara(s), ',');
        int npoints = t.getSize();
        points = new PGpoint[npoints];
        for (int p = 0;p < npoints;p++)
            points[p] = new PGpoint(t.getToken(p));
    }
View Full Code Here

     * @param s Definition of the line in PostgreSQL's syntax
     * @exception SQLException on conversion failure
     */
    public void setValue(String s) throws SQLException
    {
        PGtokenizer t = new PGtokenizer(PGtokenizer.removeBox(s), ',');
        if (t.getSize() != 2)
            throw new PSQLException(GT.tr("Conversion to type {0} failed: {1}.", new Object[]{type,s}), PSQLState.DATA_TYPE_MISMATCH);

        point[0] = new PGpoint(t.getToken(0));
        point[1] = new PGpoint(t.getToken(1));
    }
View Full Code Here

        if (value.equals("(EMPTY)")) {
            // Special case for PostGIS 0.X style empty geometry collections
            // (which are not OpenGIS compliant)
            return;
        }
        PGtokenizer t = new PGtokenizer(PGtokenizer.removePara(value), ',');
        int subgeomcount = t.getSize();
        subgeoms = createSubGeomArray(subgeomcount);
        for (int p = 0; p < subgeomcount; p++) {
            subgeoms[p] = createSubGeomInstance(t.getToken(p), haveM);
        }
        dimension = subgeoms[0].dimension;
        // fetch haveMeasure from subpoint because haveM does only work with
        // 2d+M, not with 3d+M geometries
        haveMeasure = subgeoms[0].haveMeasure;
View Full Code Here

        }
        String myPrefix = getPrefix();
        if (value.startsWith(myPrefix)) {
            value = value.substring(myPrefix.length()).trim();
        }
        PGtokenizer t = new PGtokenizer(PGtokenizer.removePara(value), ',');
        llb = new Point(t.getToken(0));
        urt = new Point(t.getToken(1));
        if (srid != Geometry.UNKNOWN_SRID) {
            llb.setSrid(srid);
            urt.setSrid(srid);
        }
    }
View Full Code Here

            haveM = true;
            value = value.substring(6).trim();
        } else if (value.indexOf("POINT") == 0) {
            value = value.substring(5).trim();
        }
        PGtokenizer t = new PGtokenizer(PGtokenizer.removePara(value), ' ');
        try {
            x = Double.valueOf(t.getToken(0)).doubleValue();
            y = Double.valueOf(t.getToken(1)).doubleValue();
            haveM |= t.getSize() == 4;
            if ((t.getSize() == 3 && !haveM) || (t.getSize() == 4)) {
                z = Double.valueOf(t.getToken(2)).doubleValue();
                dimension = 3;
            } else {
                dimension = 2;
            }
            if (haveM) {
                m = Double.valueOf(t.getToken(dimension)).doubleValue();
            }
        } catch (NumberFormatException e) {
            throw new SQLException("Error parsing Point: " + e.toString());
        }
        haveMeasure = haveM;
View Full Code Here

     *            "parent" Polygon, and is passed further to our parent.
     */

    protected LinearRing(String value, boolean haveM) throws SQLException {
        super(LINEARRING);
        PGtokenizer t = new PGtokenizer(PGtokenizer.removePara(value.trim()), ',');
        int npoints = t.getSize();
        Point[] points = new Point[npoints];
        for (int p = 0; p < npoints; p++) {
            points[p] = new Point(t.getToken(p), haveM);
        }
        this.dimension = points[0].dimension;
        // fetch haveMeasure from subpoint because haveM does only work with
        // 2d+M, not with 3d+M geometries
        this.haveMeasure = points[0].haveMeasure;
View Full Code Here

    /** Our apps entry point */
    public static void main(String[] args) throws SQLException, ClassNotFoundException {
        loadDrivers();

        PGtokenizer dburls;
        String dbuser = null;
        String dbpass = null;

        if (args.length == 1 && args[0].equalsIgnoreCase("offline")) {
            System.out.println("Performing only offline tests");
            dburls = new PGtokenizer("", ';');
        } else if (args.length == 3) {
            System.out.println("Performing offline and online tests");
            dburls = new PGtokenizer(args[0], ';');

            dbuser = args[1];
            dbpass = args[2];
        } else {
            System.err.println("Usage: java examples/TestParser dburls user pass");
            System.err.println("   or: java examples/TestParser offline");
            System.err.println();
            System.err.println("dburls has one or more jdbc urls separated by ; in the following format");
            System.err.println("jdbc:postgresql://HOST:PORT/DATABASENAME");
            System.exit(1);
            // Signal the compiler that code flow ends here.
            return;
        }

        Connection[] conns;
        conns = new Connection[dburls.getSize()];
        for (int i = 0; i < dburls.getSize(); i++) {
            System.out.println("Creating JDBC connection to " + dburls.getToken(i));
            conns[i] = connect(dburls.getToken(i), dbuser, dbpass);
        }

        System.out.println("Performing tests...");
        System.out.println("***");

 
View Full Code Here

TOP

Related Classes of org.postgresql.util.PGtokenizer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.