1 package org.apache.torque.engine.database.model;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 /***
23 * <p>
24 * Supports the Derby / DB2 / SQL92 standard for defining Binary data fields
25 * with either CHAR(#) FOR BIT DATA or VARCHAR(#) FOR BIT DATA. This can be
26 * used in Platform implimentors initialize() methods, by using lines like:
27 * </p>
28 * <code>
29 * setSchemaDomainMapping(new SizedForBitDataDomain(
30 * SchemaType.BINARY, "CHAR", "1"));
31 * setSchemaDomainMapping(new SizedForBitDataDomain(
32 * SchemaType.VARBINARY, "VARCHAR"));
33 * </code>
34 * <p>
35 * This will cause the Column.getSqlString() method to produce items similar to:
36 * </p>
37 * <code>
38 * CHAR(#) FOR BIT DATA
39 * VARCHAR(#)FOR BIT DATA
40 * </code>
41 * <p>
42 * Where: # is the size= schema attribute or a default size specified in the
43 * constructor.
44 * </p>
45 * <p>
46 * Note that this is dependent on the platform implimentation correctly defining
47 * BINARY and VARBINARY as having a size attribute in the "hasSize()" method.
48 * </p>
49 *
50 * @see org.apache.torque.engine.platform.Platform
51 * @see org.apache.torque.engine.database.model.Column#getSqlString()
52 * @author <a href="Monroe@DukeCE.com">Greg Monroe</a>
53 */
54 public class SizedForBitDataDomain extends Domain
55 {
56
57 /***
58 * @see org.apache.torque.engine.database.model.Domain#Domain()
59 */
60 public SizedForBitDataDomain()
61 {
62 super();
63 }
64
65 /***
66 * @see org.apache.torque.engine.database.model.Domain#Domain(String)
67 */
68 public SizedForBitDataDomain(String name)
69 {
70 super(name);
71 }
72
73 /***
74 * @see org.apache.torque.engine.database.model.Domain#Domain(SchemaType)
75 */
76 public SizedForBitDataDomain(SchemaType type)
77 {
78 super(type);
79 }
80
81 /***
82 * @see org.apache.torque.engine.database.model.Domain#
83 * Domain(SchemaType, String)
84 */
85 public SizedForBitDataDomain(SchemaType type, String sqlType)
86 {
87 super(type, sqlType);
88 }
89
90 /***
91 * @see org.apache.torque.engine.database.model.Domain#
92 * Domain(SchemaType, String, String, String)
93 */
94 public SizedForBitDataDomain(SchemaType type, String sqlType, String size,
95 String scale)
96 {
97 super(type, sqlType, size, scale);
98 }
99
100 /***
101 * @see org.apache.torque.engine.database.model.Domain#
102 * Domain(SchemaType, String, String)
103 */
104 public SizedForBitDataDomain(SchemaType type, String sqlType, String size)
105 {
106 super(type, sqlType, size);
107 }
108
109 /***
110 * @see org.apache.torque.engine.database.model.Domain#
111 * Domain(Domain)
112 */
113 public SizedForBitDataDomain(Domain domain)
114 {
115 super(domain);
116 }
117
118 /***
119 * Returns the size postfix for the base SQL Column type.
120 *
121 * @return "(size) FOR BIT DATA" or just " FOR BIT DATA" if size
122 * is null.
123 * @see org.apache.torque.engine.database.model.Domain#getSize()
124 */
125 public String printSize()
126 {
127 String result = "";
128 if ( getSize() != null )
129 {
130 result = "(" + getSize() + ")";
131 }
132 result = result + " FOR BIT DATA";
133 return result;
134 }
135 }