Source Code Cross Referenced for PGpath.java in  » Database-JDBC-Connection-Pool » postgresql » org » postgresql » geometric » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database JDBC Connection Pool » postgresql » org.postgresql.geometric 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*-------------------------------------------------------------------------
002:         *
003:         * Copyright (c) 2003-2005, PostgreSQL Global Development Group
004:         *
005:         * IDENTIFICATION
006:         *   $PostgreSQL: pgjdbc/org/postgresql/geometric/PGpath.java,v 1.14 2007/07/16 15:02:53 jurka Exp $
007:         *
008:         *-------------------------------------------------------------------------
009:         */
010:        package org.postgresql.geometric;
011:
012:        import org.postgresql.util.GT;
013:        import org.postgresql.util.PGobject;
014:        import org.postgresql.util.PGtokenizer;
015:        import org.postgresql.util.PSQLException;
016:        import org.postgresql.util.PSQLState;
017:
018:        import java.io.Serializable;
019:        import java.sql.SQLException;
020:
021:        /**
022:         *     This implements a path (a multiple segmented line, which may be closed)
023:         */
024:        public class PGpath extends PGobject implements  Serializable, Cloneable {
025:            /**
026:             * True if the path is open, false if closed
027:             */
028:            public boolean open;
029:
030:            /**
031:             * The points defining this path
032:             */
033:            public PGpoint points[];
034:
035:            /**
036:             * @param points the PGpoints that define the path
037:             * @param open True if the path is open, false if closed
038:             */
039:            public PGpath(PGpoint[] points, boolean open) {
040:                this ();
041:                this .points = points;
042:                this .open = open;
043:            }
044:
045:            /**
046:             * Required by the driver
047:             */
048:            public PGpath() {
049:                setType("path");
050:            }
051:
052:            /**
053:             * @param s definition of the path in PostgreSQL's syntax.
054:             * @exception SQLException on conversion failure
055:             */
056:            public PGpath(String s) throws SQLException {
057:                this ();
058:                setValue(s);
059:            }
060:
061:            /**
062:             * @param s Definition of the path in PostgreSQL's syntax
063:             * @exception SQLException on conversion failure
064:             */
065:            public void setValue(String s) throws SQLException {
066:                // First test to see if were open
067:                if (s.startsWith("[") && s.endsWith("]")) {
068:                    open = true;
069:                    s = PGtokenizer.removeBox(s);
070:                } else if (s.startsWith("(") && s.endsWith(")")) {
071:                    open = false;
072:                    s = PGtokenizer.removePara(s);
073:                } else
074:                    throw new PSQLException(GT.tr(
075:                            "Cannot tell if path is open or closed: {0}.", s),
076:                            PSQLState.DATA_TYPE_MISMATCH);
077:
078:                PGtokenizer t = new PGtokenizer(s, ',');
079:                int npoints = t.getSize();
080:                points = new PGpoint[npoints];
081:                for (int p = 0; p < npoints; p++)
082:                    points[p] = new PGpoint(t.getToken(p));
083:            }
084:
085:            /**
086:             * @param obj Object to compare with
087:             * @return true if the two paths are identical
088:             */
089:            public boolean equals(Object obj) {
090:                if (obj instanceof  PGpath) {
091:                    PGpath p = (PGpath) obj;
092:
093:                    if (p.points.length != points.length)
094:                        return false;
095:
096:                    if (p.open != open)
097:                        return false;
098:
099:                    for (int i = 0; i < points.length; i++)
100:                        if (!points[i].equals(p.points[i]))
101:                            return false;
102:
103:                    return true;
104:                }
105:                return false;
106:            }
107:
108:            public int hashCode() {
109:                // XXX not very good..
110:                int hash = 0;
111:                for (int i = 0; i < points.length && i < 5; ++i) {
112:                    hash = hash ^ points[i].hashCode();
113:                }
114:                return hash;
115:            }
116:
117:            public Object clone() throws CloneNotSupportedException {
118:                PGpath newPGpath = (PGpath) super .clone();
119:                if (newPGpath.points != null) {
120:                    newPGpath.points = (PGpoint[]) newPGpath.points.clone();
121:                    for (int i = 0; i < newPGpath.points.length; ++i)
122:                        newPGpath.points[i] = (PGpoint) newPGpath.points[i]
123:                                .clone();
124:                }
125:                return newPGpath;
126:            }
127:
128:            /**
129:             * This returns the path in the syntax expected by org.postgresql
130:             */
131:            public String getValue() {
132:                StringBuffer b = new StringBuffer(open ? "[" : "(");
133:
134:                for (int p = 0; p < points.length; p++) {
135:                    if (p > 0)
136:                        b.append(",");
137:                    b.append(points[p].toString());
138:                }
139:                b.append(open ? "]" : ")");
140:
141:                return b.toString();
142:            }
143:
144:            public boolean isOpen() {
145:                return open;
146:            }
147:
148:            public boolean isClosed() {
149:                return !open;
150:            }
151:
152:            public void closePath() {
153:                open = false;
154:            }
155:
156:            public void openPath() {
157:                open = true;
158:            }
159:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.