Source Code Cross Referenced for BasicFIDMapper.java in  » GIS » GeoTools-2.4.1 » org » geotools » data » jdbc » fidmapper » 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 » GIS » GeoTools 2.4.1 » org.geotools.data.jdbc.fidmapper 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *    GeoTools - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2004-2006, GeoTools Project Managment Committee (PMC)
005:         *    
006:         *    This library is free software; you can redistribute it and/or
007:         *    modify it under the terms of the GNU Lesser General Public
008:         *    License as published by the Free Software Foundation;
009:         *    version 2.1 of the License.
010:         *
011:         *    This library is distributed in the hope that it will be useful,
012:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         *    Lesser General Public License for more details.
015:         *
016:         * TODO: 26-may-2005 D. Adler Removed returnFIDColumnsAsAttributes
017:         *                      variable and related accessor method.
018:         * 12-jul-2006 D. Adler GEOT-728 Refactor FIDMapper classes
019:         */
020:        package org.geotools.data.jdbc.fidmapper;
021:
022:        import org.geotools.feature.Feature;
023:        import java.io.IOException;
024:        import java.rmi.server.UID;
025:        import java.sql.Connection;
026:        import java.sql.Statement;
027:        import java.sql.Types;
028:
029:        /**
030:         * Basic FIDMapper implementation that maps the FID of a  Feature to a VARCHAR
031:         * column
032:         *
033:         * @author aaime Andrea Aime
034:         * @author Dani Daniele Franzoni
035:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/jdbc/src/main/java/org/geotools/data/jdbc/fidmapper/BasicFIDMapper.java $
036:         */
037:        public class BasicFIDMapper extends AbstractFIDMapper {
038:            private static final long serialVersionUID = 1L;
039:
040:            /**
041:             * Create a new BasicFIDMapper
042:             *
043:             * @param fieldName 
044:             * @param fieldSize 
045:             */
046:            public BasicFIDMapper(String fieldName, int fieldSize) {
047:                this (fieldName, fieldSize, false);
048:            }
049:
050:            /**
051:             * Create a new BasicFIDMapper
052:             *
053:             * @param tableSchemaName
054:             * @param tableName
055:             * @param fieldName 
056:             * @param fieldSize 
057:             * @param returnFIDColumnsAsAttributes 
058:             */
059:            public BasicFIDMapper(String tableSchemaName, String tableName,
060:                    String fieldName, int fieldSize,
061:                    boolean returnFIDColumnsAsAttributes) {
062:                super (tableSchemaName, tableName);
063:                this .returnFIDColumnsAsAttributes = returnFIDColumnsAsAttributes;
064:                setInfo(fieldName, Types.VARCHAR, fieldSize, 0, false);
065:            }
066:
067:            /**
068:             * Create a new BasicFIDMapper
069:             *
070:
071:             * @param fieldName 
072:             * @param fieldSize 
073:             * @param returnFIDColumnsAsAttributes 
074:             */
075:            public BasicFIDMapper(String fieldName, int fieldSize,
076:                    boolean returnFIDColumnsAsAttributes) {
077:                this (null, null, fieldName, fieldSize,
078:                        returnFIDColumnsAsAttributes);
079:            }
080:
081:            /**
082:             * @see org.geotools.data.jdbc.fidmapper.FIDMapper#getID(java.lang.Object[])
083:             */
084:            public String getID(Object[] attributes) {
085:                if ((attributes != null) && (attributes.length == 1)
086:                        && (attributes[0] != null)) {
087:                    return attributes[0].toString();
088:                } else {
089:                    return null;
090:                }
091:            }
092:
093:            /**
094:             * @see org.geotools.data.jdbc.fidmapper.FIDMapper#getPKAttributes(java.lang.String)
095:             */
096:            public Object[] getPKAttributes(String FID) {
097:                return new Object[] { FID };
098:            }
099:
100:            /**
101:             * @see java.lang.Object#equals(java.lang.Object)
102:             */
103:            public boolean equals(Object object) {
104:                if (!(object instanceof  BasicFIDMapper)) {
105:                    return false;
106:                }
107:
108:                BasicFIDMapper other = (BasicFIDMapper) object;
109:
110:                return other.getColumnName().equals(getColumnName())
111:                        && (other.getColumnSize() == getColumnSize());
112:            }
113:
114:            /**
115:             * This kind of FIDMapper does not generate keys, they must be alreadyT
116:             * present in the primary key.
117:             *
118:             * @see org.geotools.data.fidmapper.FIDMapper#createID(Connection, Feature,
119:             *      Statement)
120:             */
121:            public String createID(Connection conn, Feature feature,
122:                    Statement statement) throws IOException {
123:                //JD: replacing no word characters with underscore
124:                //JD: forcing to start with a latter
125:                // According to GML and XML schema standards, FID is a XML ID
126:                // (http://www.w3.org/TR/xmlschema-2/#ID), whose acceptable values are those that match an
127:                // NCNAME production (http://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-NCName):
128:                // NCName ::= (Letter | '_') (NCNameChar)* /* An XML Name, minus the ":" */
129:                // NCNameChar ::= Letter | Digit | '.' | '-' | '_' | CombiningChar | Extender
130:                // We have to fix the generated UID replacing all non word chars with an _ (it seems
131:                // they area all ":")
132:                //        return "fid-" + new UID().toString().replaceAll( "\\W","_" );
133:                //      optimization, since the UID toString uses only ":" and converts long and integers
134:                // to strings for the rest, so the only non word character is really ":"
135:                return "fid-" + new UID().toString().replace(':', '_');
136:            }
137:
138:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.