Source Code Cross Referenced for ColumnFactory.java in  » Database-Client » prefuse » prefuse » data » column » 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 Client » prefuse » prefuse.data.column 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package prefuse.data.column;
002:
003:        import java.util.Date;
004:
005:        import prefuse.data.DataTypeException;
006:        import prefuse.data.Table;
007:        import prefuse.data.expression.Expression;
008:
009:        /**
010:         * Factory class for generating appropriate column instances. Used by
011:         * Tables to generate their columns.
012:         * 
013:         * @author <a href="http://jheer.org">jeffrey heer</a>
014:         */
015:        public class ColumnFactory {
016:
017:            /**
018:             * Get a new column of the given type.
019:             * @param type the column data type
020:             * @return the new column
021:             */
022:            public static final Column getColumn(Class type) {
023:                return getColumn(type, 0, 0, null);
024:            }
025:
026:            /**
027:             * Get a new column of the given type.
028:             * @param type the column data type
029:             * @param nrows the number of rows to include in the column
030:             * @return the new column
031:             */
032:            public static final Column getColumn(Class type, int nrows) {
033:                return getColumn(type, nrows, nrows, null);
034:            }
035:
036:            /**
037:             * Get a new column of the given type.
038:             * @param type the column data type
039:             * @param nrows the number of rows to include in the column
040:             * @param defaultValue the default value for the column
041:             * @return the new column
042:             */
043:            public static final Column getColumn(Class type, int nrows,
044:                    Object defaultValue) {
045:                return getColumn(type, nrows, nrows, defaultValue);
046:            }
047:
048:            /**
049:             * Get a new column of the given type.
050:             * @param type the column data type
051:             * @param nrows the number of rows to include in the column
052:             * @param nnz the number of expected non-zero entries (NOTE: currently
053:             * this value is not being used)
054:             * @param defaultValue the default value for the column
055:             * @return the new column
056:             */
057:            public static final Column getColumn(Class type, int nrows,
058:                    int nnz, Object defaultValue) {
059:                if (type == byte.class) {
060:                    if (defaultValue == null) {
061:                        return new ByteColumn(nrows);
062:                    } else {
063:                        byte def = ((Number) defaultValue).byteValue();
064:                        return new ByteColumn(nrows, nrows, def);
065:                    }
066:                }
067:                if (type == int.class) {
068:                    if (defaultValue == null) {
069:                        return new IntColumn(nrows);
070:                    } else {
071:                        int def = ((Number) defaultValue).intValue();
072:                        return new IntColumn(nrows, nrows, def);
073:                    }
074:                } else if (type == long.class) {
075:                    if (defaultValue == null) {
076:                        return new LongColumn(nrows);
077:                    } else {
078:                        long def = ((Number) defaultValue).longValue();
079:                        return new LongColumn(nrows, nrows, def);
080:                    }
081:                } else if (type == float.class) {
082:                    if (defaultValue == null) {
083:                        return new FloatColumn(nrows);
084:                    } else {
085:                        float def = ((Number) defaultValue).floatValue();
086:                        return new FloatColumn(nrows, nrows, def);
087:                    }
088:                } else if (type == double.class) {
089:                    if (defaultValue == null) {
090:                        return new DoubleColumn(nrows);
091:                    } else {
092:                        double def = ((Number) defaultValue).doubleValue();
093:                        return new DoubleColumn(nrows, nrows, def);
094:                    }
095:                } else if (type == boolean.class) {
096:                    if (defaultValue == null) {
097:                        return new BooleanColumn(nrows);
098:                    } else {
099:                        boolean def = ((Boolean) defaultValue).booleanValue();
100:                        return new BooleanColumn(nrows, nrows, def);
101:                    }
102:                } else if (Date.class.isAssignableFrom(type)) {
103:                    if (defaultValue == null) {
104:                        return new DateColumn(type, nrows);
105:                    } else {
106:                        Date d = ((Date) defaultValue);
107:                        return new DateColumn(type, nrows, nrows, d.getTime());
108:                    }
109:                } else if (type == byte.class || type == short.class
110:                        || type == char.class || type == void.class) {
111:                    throw new DataTypeException(type);
112:                } else {
113:                    return new ObjectColumn(type, nrows, nrows, defaultValue);
114:                }
115:            }
116:
117:            /**
118:             * Get a new column based on the given expression.
119:             * @param t the table the column should be added to
120:             * @param expr the expression that should provide the column values
121:             * @return the new column
122:             */
123:            public static final Column getColumn(Table t, Expression expr) {
124:                return new ExpressionColumn(t, expr);
125:            }
126:
127:            /**
128:             * Get a new column of a constant value.
129:             * @param type the column data type
130:             * @param dflt the default constant value for the column
131:             * @return the new column
132:             */
133:            public static final Column getConstantColumn(Class type, Object dflt) {
134:                return new ConstantColumn(type, dflt);
135:            }
136:
137:        } // end of class ColumnFactory
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.