Source Code Cross Referenced for SFieldBlob.java in  » Database-ORM » SimpleORM » simpleorm » core » 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 ORM » SimpleORM » simpleorm.core 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


01:        package simpleorm.core;
02:
03:        import simpleorm.properties.*;
04:        import java.sql.ResultSet;
05:        import java.io.ByteArrayOutputStream;
06:        import java.io.InputStream;
07:
08:        /** Represents a BLOB, Binary large object.  See SFieldBytes for short binary strings.
09:         * Supports returning the entire blob as a byte array, but that is not normal practice.
10:         * ### Untested. */
11:
12:        public class SFieldBlob extends SFieldScalar {
13:            public SFieldBlob(SRecordMeta meta, String columnName, int maxSize,
14:                    SPropertyValue[] pvals) {
15:                super (meta, columnName, pvals);
16:                putProperty(SCon.SBYTE_SIZE, SJSharp.newInteger(maxSize)); // for Create Table only.
17:            }
18:
19:            public SFieldBlob(SRecordMeta meta, String columnName, int maxSize) {
20:                this (meta, columnName, maxSize, new SPropertyValue[0]);
21:            }
22:
23:            public SFieldBlob(SRecordMeta meta, String columnName, int maxSize,
24:                    SPropertyValue pval) {
25:                this (meta, columnName, maxSize, new SPropertyValue[] { pval });
26:            }
27:
28:            public SFieldBlob(SRecordMeta meta, String columnName, int maxSize,
29:                    SPropertyValue pval1, SPropertyValue pval2) {
30:                this (meta, columnName, maxSize, new SPropertyValue[] { pval1,
31:                        pval2 });
32:            }
33:
34:            /** Abstract specializer.  Clone this key field to be a foreign key
35:                to <code>rmeta</code> of the same type.*/
36:            SFieldMeta makeForeignKey(SRecordMeta rmeta, String prefix,
37:                    SPropertyValue[] pvals) {
38:                return new SFieldBlob(rmeta, (prefix == null ? "" : prefix)
39:                        + getString(SCon.SCOLUMN_NAME), SJSharp
40:                        .object2Int(getProperty(SCon.SBYTE_SIZE)), pvals);
41:            }
42:
43:            Object queryFieldValue(ResultSet rs, int sqlIndex) throws Exception {
44:                //  From Marcius.  just getBytes should actually work though, but maybe not in Oracle
45:                //Object res = rs.getBytes(sqlIndex);  
46:                //return res;
47:
48:                // Get the binary content from the result set as a stream 
49:                InputStream is = rs.getBinaryStream(sqlIndex);
50:                // Create a byte array output stream so we can convert the content to a byte[]
51:                ByteArrayOutputStream baos = new ByteArrayOutputStream();
52:                // A small buffer to reduce the number of reads 
53:                byte[] buf = new byte[1024];
54:                // Read bytes from the input stream and place them in the baos
55:                int bytesRead = is.read(buf);
56:                while (bytesRead > 0) {
57:                    baos.write(buf, 0, bytesRead);
58:                    bytesRead = is.read(buf);
59:                }
60:                return baos.toByteArray();
61:            }
62:
63:            Object convertToField(Object raw) {
64:                return raw;
65:            }
66:
67:            /** Specializes SFieldMeta. */
68:            String defaultDataType() {
69:                return "BLOB";
70:            }
71:
72:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.