/[classpath]/classpath/java/sql/DataTruncation.java
ViewVC logotype

Diff of /classpath/java/sql/DataTruncation.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by mark, Tue Jan 22 22:27:01 2002 UTC revision 1.6 by ericb, Sun Feb 24 04:25:17 2002 UTC
# Line 1  Line 1 
1  /* DataTruncation.java -- Warning when data has been truncated.  /* DataTruncation.java -- warning when data has been truncated
2     Copyright (C) 1999, 2000 Free Software Foundation, Inc.     Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
3    
4  This file is part of GNU Classpath.  This file is part of GNU Classpath.
5    
# Line 7  GNU Classpath is free software; you can Line 7  GNU Classpath is free software; you can
7  it under the terms of the GNU General Public License as published by  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2, or (at your option)  the Free Software Foundation; either version 2, or (at your option)
9  any later version.  any later version.
10    
11  GNU Classpath is distributed in the hope that it will be useful, but  GNU Classpath is distributed in the hope that it will be useful, but
12  WITHOUT ANY WARRANTY; without even the implied warranty of  WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Line 39  exception statement from your version. * Line 39  exception statement from your version. *
39  package java.sql;  package java.sql;
40    
41  /**  /**
42    * This exception is thrown when a piece of data is unexpectedly   * This exception is thrown when a piece of data is unexpectedly
43    * truncated in JDBC.   * truncated in JDBC. This has an SQLstate of <code>01004</code>.
44    *   *
45    * @author Aaron M. Renn (arenn@urbanophile.com)   * @author Aaron M. Renn (arenn@urbanophile.com)
46    */   * @status updated to 1.4
 public class DataTruncation extends SQLWarning  
 {  
   
 /*************************************************************************/  
   
 /*  
  * Instance Variables  
  */  
   
 /**  
   * The original size of the data.  
   * @serialized  
   */  
 private int dataSize;  
   
 /**  
   * The index of the parameter or column whose value was truncated.  
   * @serialized  
   */  
 private int index;  
   
 /**  
   * Indicates whether or not a parameter value was truncated.  
   * @serialized  
   */  
 private boolean parameter;  
   
 /**  
   * Indicates whether or not a data column value was truncated.  
   * @serialized  
   */  
 private boolean read;  
   
 /**  
   * This is the size of the data after truncation.  
   * @serialized  
   */  
 private int transferSize;  
   
 /*************************************************************************/  
   
 /**  
   * Static Variables  
   */  
   
 /**  
   * This is the serialization UID for this class  
   */  
 private static final long serialVersionUID = 6464298989504059473L;  
   
 /*************************************************************************/  
   
 /*  
  * Constructors  
47   */   */
48    public class DataTruncation extends SQLWarning
 /**  
   * This method initializes a new instance of <code>DataTruncation</code>  
   * with the specified values.  The descriptive error message for this  
   * exception will be "Data truncation", the SQL state will be "01004"  
   * and the vendor specific error code will be set to 0.  
   *  
   * @param index The index of the parameter or column that was truncated.  
   * @param parameter <code>true</code> if a parameter was truncated,  
   * <code>false</code> otherwise.  
   * @param read <code>true</code> if a data column was truncated,  
   * <code>false</code> otherwise.  
   * @param dataSize The original size of the data.  
   * @param transferSize The size of the data after truncation.  
   */  
 public  
 DataTruncation(int index, boolean parameter, boolean read, int dataSize,  
                int transferSize)  
 {  
   super("Data truncation", "01004");  
   
   this.index = index;  
   this.parameter = parameter;  
   this.read = read;  
   this.dataSize = dataSize;  
   this.transferSize = transferSize;  
 }  
   
 /*************************************************************************/  
   
 /*  
  * Instance Methods  
  */  
   
 /**  
   * This method returns the index of the column or parameter that was  
   * truncated.  
   *  
   * @return The index of the column or parameter that was truncated.  
   */  
 public int  
 getIndex()  
 {  
   return(index);  
 }  
   
 /*************************************************************************/  
   
 /**  
   * This method determines whether or not it was a parameter that was  
   * truncated.  
   *  
   * @return <code>true</code> if a parameter was truncated, <code>false</code>  
   * otherwise.  
   */  
 public boolean  
 getParameter()  
 {  
   return(parameter);  
 }  
   
 /*************************************************************************/  
   
 /**  
   * This method determines whether or not it was a column that was  
   * truncated.  
   *  
   * @return <code>true</code> if a column was truncated, <code>false</code>  
   * otherwise.  
   */  
 public boolean  
 getRead()  
 {  
   return(read);  
 }  
   
 /*************************************************************************/  
   
 /**  
   * This method returns the original size of the parameter or column that  
   * was truncated.  
   *  
   * @return The original size of the parameter or column that was truncated.  
   */  
 public int  
 getDataSize()  
 {  
   return(dataSize);  
 }  
   
 /*************************************************************************/  
   
 /**  
   * This method returns the size of the parameter or column after it was  
   * truncated.  
   *  
   * @return The size of the parameter or column after it was truncated.  
   */  
 public int  
 getTransferSize()  
49  {  {
50    return(transferSize);    /**
51  }     * Compatible with JDK 1.1+.
52       */
53      private static final long serialVersionUID = 6464298989504059473L;
54    
55      /**
56       * The original size of the data.
57       *
58       * @serial the original data size
59       */
60      private final int dataSize;
61    
62      /**
63       * The index of the parameter or column whose value was truncated.
64       *
65       * @serial the index that was truncated
66       */
67      private final int index;
68    
69      /**
70       * Indicates whether or not a parameter value was truncated.
71       *
72       * @serial true if a parameter was truncated
73       */
74      private final boolean parameter;
75    
76      /**
77       * Indicates whether or not a data column value was truncated.
78       *
79       * @serial true if a data column was read before truncation
80       */
81      private final boolean read;
82    
83      /**
84       * This is the size of the data after truncation.
85       *
86       * @serial the size actually transferred
87       */
88      private final int transferSize;
89    
90      /**
91       * Create a new instance with the specified values.  The descriptive error
92       * message for this exception will be "Data truncation", the SQL state
93       * will be "01004", and the vendor specific error code will be set to 0.
94       *
95       * @param index the index of the parameter or column that was truncated
96       * @param parameter <code>true</code> if a parameter was truncated
97       * @param read <code>true</code> if a data column was truncated
98       * @param dataSize the original size of the data
99       * @param transferSize the size of the data after truncation
100       */
101      public DataTruncation(int index, boolean parameter, boolean read,
102                            int dataSize, int transferSize)
103      {
104        super("Data truncation", "01004");
105        this.index = index;
106        this.parameter = parameter;
107        this.read = read;
108        this.dataSize = dataSize;
109        this.transferSize = transferSize;
110      }
111    
112      /**
113       * Get the index of the column or parameter that was truncated.
114       *
115       * @return the index of the column or parameter that was truncated
116       */
117      public int getIndex()
118      {
119        return index;
120      }
121    
122      /**
123       * Return true if it was a parameter that was truncated.
124       *
125       * @return <code>true</code> if a parameter was truncated
126       */
127      public boolean getParameter()
128      {
129        return parameter;
130      }
131    
132      /**
133       * Return true if it was a column that was truncated.
134       *
135       * @return <code>true</code> if a column was truncated
136       */
137      public boolean getRead()
138      {
139        return read;
140      }
141    
142      /**
143       * This method returns the original size of the parameter or column that
144       * was truncated.
145       *
146       * @return the original size
147       */
148      public int getDataSize()
149      {
150        return dataSize;
151      }
152    
153      /**
154       * This method returns the size of the parameter or column after it was
155       * truncated.
156       *
157       * @return the truncated size
158       */
159      public int getTransferSize()
160      {
161        return transferSize;
162      }
163  } // class DataTruncation  } // class DataTruncation
   

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26