BrightSide Workbench Full Report + Source Code
org.hibernate.engine.jdbc.ClobProxy_360 Class Reference
Inheritance diagram for org.hibernate.engine.jdbc.ClobProxy_360:
Collaboration diagram for org.hibernate.engine.jdbc.ClobProxy_360:

Public Member Functions

Object invoke (Object proxy, Method method, Object[] args) throws Throwable
 

Static Public Member Functions

static Clob generateProxy (String string)
 
static Clob generateProxy (Reader reader, long length)
 

Protected Member Functions

 ClobProxy_360 (String string)
 
 ClobProxy_360 (Reader reader, long length)
 
long getLength ()
 
InputStream getAsciiStream () throws SQLException
 
Reader getCharacterStream () throws SQLException
 
String getSubString (long start, int length)
 
void resetIfNeeded () throws SQLException
 

Static Protected Member Functions

static ClassLoader getProxyClassLoader ()
 

Detailed Description

Manages aspects of proxying Clobs for non-contextual creation, including proxy creation and handling proxy invocations.

Author
Gavin King
Steve Ebersole
Gail Badner

Definition at line 39 of file ClobProxy_360.java.

Constructor & Destructor Documentation

◆ ClobProxy_360() [1/2]

org.hibernate.engine.jdbc.ClobProxy_360.ClobProxy_360 ( String  string)
protected

Constructor used to build Clob from string data.

Parameters
stringThe byte array
See also
generateProxy(String)

Definition at line 54 of file ClobProxy_360.java.

54  {
55  this.string = string;
56  reader = new StringReader(string);
57  length = string.length();
58  }
Here is the caller graph for this function:

◆ ClobProxy_360() [2/2]

org.hibernate.engine.jdbc.ClobProxy_360.ClobProxy_360 ( Reader  reader,
long  length 
)
protected

Constructor used to build Clob from a reader.

Parameters
readerThe character reader.
lengthThe length of the reader stream.
See also
generateProxy(java.io.Reader, long)

Definition at line 67 of file ClobProxy_360.java.

67  {
68  this.reader = reader;
69  this.length = length;
70  }

Member Function Documentation

◆ generateProxy() [1/2]

static Clob org.hibernate.engine.jdbc.ClobProxy_360.generateProxy ( Reader  reader,
long  length 
)
static

Generates a Clob proxy using a character reader of given length.

Parameters
readerThe character reader
lengthThe length of the character reader
Returns
The generated proxy.

Definition at line 200 of file ClobProxy_360.java.

200  {
201  return ( Clob ) Proxy.newProxyInstance(getProxyClassLoader(),
202  PROXY_INTERFACES,
203  new ClobProxy_360( reader, length )
204  );
205  }
Here is the call graph for this function:

◆ generateProxy() [2/2]

static Clob org.hibernate.engine.jdbc.ClobProxy_360.generateProxy ( String  string)
static

Generates a Clob proxy using the string data.

Parameters
stringThe data to be wrapped as a Clob.
Returns
The generated proxy.

Definition at line 185 of file ClobProxy_360.java.

185  {
186  return ( Clob ) Proxy.newProxyInstance(getProxyClassLoader(),
187  PROXY_INTERFACES,
188  new ClobProxy_360( string )
189  );
190  }
Here is the call graph for this function:

◆ getAsciiStream()

InputStream org.hibernate.engine.jdbc.ClobProxy_360.getAsciiStream ( ) throws SQLException
protected

Definition at line 76 of file ClobProxy_360.java.

76  {
77  resetIfNeeded();
78  return new ReaderInputStream( reader );
79  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCharacterStream()

Reader org.hibernate.engine.jdbc.ClobProxy_360.getCharacterStream ( ) throws SQLException
protected

Definition at line 81 of file ClobProxy_360.java.

81  {
82  resetIfNeeded();
83  return reader;
84  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getLength()

long org.hibernate.engine.jdbc.ClobProxy_360.getLength ( )
protected

Definition at line 72 of file ClobProxy_360.java.

72  {
73  return length;
74  }
Here is the caller graph for this function:

◆ getProxyClassLoader()

static ClassLoader org.hibernate.engine.jdbc.ClobProxy_360.getProxyClassLoader ( )
staticprotected

Determines the appropriate class loader to which the generated proxy should be scoped.

Returns
The class loader appropriate for proxy construction.

Definition at line 213 of file ClobProxy_360.java.

213  {
214  ClassLoader cl = Thread.currentThread().getContextClassLoader();
215  if ( cl == null ) {
216  cl = ClobImplementer.class.getClassLoader();
217  }
218  return cl;
219  }
Here is the caller graph for this function:

◆ getSubString()

String org.hibernate.engine.jdbc.ClobProxy_360.getSubString ( long  start,
int  length 
)
protected

Definition at line 86 of file ClobProxy_360.java.

86  {
87  if ( string == null ) {
88  throw new UnsupportedOperationException( "Clob was not created from string; cannot substring" );
89  }
90  // semi-naive implementation
91  int endIndex = Math.min( ((int)start)+length, string.length() );
92  return string.substring( (int)start, endIndex );
93  }
Here is the caller graph for this function:

◆ invoke()

Object org.hibernate.engine.jdbc.ClobProxy_360.invoke ( Object  proxy,
Method  method,
Object[]  args 
) throws Throwable
Exceptions
UnsupportedOperationExceptionif any methods other than Clob#length(), Clob#getAsciiStream(), or Clob#getCharacterStream() are invoked.

Definition at line 103 of file ClobProxy_360.java.

103  {
104  final String methodName = method.getName();
105  final int argCount = method.getParameterTypes().length;
106 
107  if ( "length".equals( methodName ) && argCount == 0 ) {
108  return Long.valueOf( getLength() );
109  }
110  if ( "getAsciiStream".equals( methodName ) && argCount == 0 ) {
111  return getAsciiStream();
112  }
113  if ( "getCharacterStream".equals( methodName ) ) {
114  if ( argCount == 0 ) {
115  return getCharacterStream();
116  }
117  else if ( argCount == 2 ) {
118  long start = (Long) args[0];
119  if ( start < 1 ) {
120  throw new SQLException( "Start position 1-based; must be 1 or more." );
121  }
122  if ( start > getLength() ) {
123  throw new SQLException( "Start position [" + start + "] cannot exceed overall CLOB length [" + getLength() + "]" );
124  }
125  int length = (Integer) args[1];
126  if ( length < 0 ) {
127  // java docs specifically say for getCharacterStream(long,int) that the start+length must not exceed the
128  // total length, however that is at odds with the getSubString(long,int) behavior.
129  throw new SQLException( "Length must be great-than-or-equal to zero." );
130  }
131  return DataHelper.subStream( getCharacterStream(), start-1, length );
132  }
133  }
134  if ( "getSubString".equals( methodName ) && argCount == 2 ) {
135  long start = (Long) args[0];
136  if ( start < 1 ) {
137  throw new SQLException( "Start position 1-based; must be 1 or more." );
138  }
139  // from start to start -1 on buggy 3.6.0
140  if ( start - 1 > getLength() ) {
141  throw new SQLException( "Start position [" + start + "] cannot exceed overall CLOB length [" + getLength() + "]" );
142  }
143  int length = (Integer) args[1];
144  if ( length < 0 ) {
145  throw new SQLException( "Length must be great-than-or-equal to zero." );
146  }
147  return getSubString( start-1, length );
148  }
149  if ( "free".equals( methodName ) && argCount == 0 ) {
150  reader.close();
151  return null;
152  }
153  if ( "toString".equals( methodName ) && argCount == 0 ) {
154  return this.toString();
155  }
156  if ( "equals".equals( methodName ) && argCount == 1 ) {
157  return Boolean.valueOf( proxy == args[0] );
158  }
159  if ( "hashCode".equals( methodName ) && argCount == 0 ) {
160  return new Integer( this.hashCode() );
161  }
162 
163  throw new UnsupportedOperationException( "Clob may not be manipulated from creating session" );
164  }
String getSubString(long start, int length)
Here is the call graph for this function:

◆ resetIfNeeded()

void org.hibernate.engine.jdbc.ClobProxy_360.resetIfNeeded ( ) throws SQLException
protected

Definition at line 166 of file ClobProxy_360.java.

166  {
167  try {
168  if ( needsReset ) {
169  reader.reset();
170  }
171  }
172  catch ( IOException ioe ) {
173  throw new SQLException( "could not reset reader" );
174  }
175  needsReset = true;
176  }
Here is the caller graph for this function:

The documentation for this class was generated from the following file: