idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
41,400
public Context setEngine ( Engine engine ) { checkThread ( ) ; if ( engine != null ) { if ( template != null && template . getEngine ( ) != engine ) { throw new IllegalStateException ( "Failed to set the context engine, because is not the same to template engine. template engine: " + template . getEngine ( ) . getName ...
Set the current engine .
177
5
41,401
public Object get ( String key , Object defaultValue ) { Object value = get ( key ) ; return value == null ? defaultValue : value ; }
Get the variable value .
31
5
41,402
public static boolean showRateDialogIfNeeded ( final Context context , int themeId ) { if ( shouldShowRateDialog ( ) ) { showRateDialog ( context , themeId ) ; return true ; } else { return false ; } }
Show the rate dialog if the criteria is satisfied .
50
10
41,403
public static boolean shouldShowRateDialog ( ) { if ( mOptOut ) { return false ; } else { if ( mLaunchTimes >= sConfig . mCriteriaLaunchTimes ) { return true ; } long threshold = TimeUnit . DAYS . toMillis ( sConfig . mCriteriaInstallDays ) ; // msec if ( new Date ( ) . getTime ( ) - mInstallDate . getTime ( ) >= thres...
Check whether the rate dialog should be shown or not . Developers may call this method directly if they want to show their own view instead of dialog provided by this library .
123
33
41,404
public static void showRateDialog ( final Context context ) { AlertDialog . Builder builder = new AlertDialog . Builder ( context ) ; showRateDialog ( context , builder ) ; }
Show the rate dialog
37
4
41,405
public static int getLaunchCount ( final Context context ) { SharedPreferences pref = context . getSharedPreferences ( PREF_NAME , Context . MODE_PRIVATE ) ; return pref . getInt ( KEY_LAUNCH_TIMES , 0 ) ; }
Get count number of the rate dialog launches
59
8
41,406
private static void storeInstallDate ( final Context context , SharedPreferences . Editor editor ) { Date installDate = new Date ( ) ; if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . GINGERBREAD ) { PackageManager packMan = context . getPackageManager ( ) ; try { PackageInfo pkgInfo = packMan . getPackageInfo...
Store install date . Install date is retrieved from package manager if possible .
173
14
41,407
private static void storeAskLaterDate ( final Context context ) { SharedPreferences pref = context . getSharedPreferences ( PREF_NAME , Context . MODE_PRIVATE ) ; Editor editor = pref . edit ( ) ; editor . putLong ( KEY_ASK_LATER_DATE , System . currentTimeMillis ( ) ) ; editor . apply ( ) ; }
Store the date the user asked for being asked again later .
83
12
41,408
public static < T extends Pane > CompletionStage < T > setContent ( final T parent , final Node content ) { return FxAsync . doOnFxThread ( parent , parentNode -> { parentNode . getChildren ( ) . clear ( ) ; parentNode . getChildren ( ) . add ( content ) ; } ) ; }
Sets as the sole content of a pane another Node . This is supposed to work as having a first Pane being the wanted display zone and the second Node the displayed content .
72
36
41,409
public static CompletionStage < Stage > displayExceptionPane ( final String title , final String readable , final Throwable exception ) { final Pane exceptionPane = new ExceptionHandler ( exception ) . asPane ( readable ) ; final CompletionStage < Stage > exceptionStage = Stages . stageOf ( title , exceptionPane ) ; re...
Creates a pop - up and displays it based on a given exception pop - up title and custom error message .
88
23
41,410
public static CompletionStage < Stage > stageOf ( final String title , final Pane rootPane ) { return FxAsync . computeOnFxThread ( Tuple . of ( title , rootPane ) , titleAndPane -> { final Stage stage = new Stage ( StageStyle . DECORATED ) ; stage . setTitle ( title ) ; stage . setScene ( new Scene ( rootPane ) ) ; re...
Creates a Stage .
96
5
41,411
public static CompletionStage < Stage > scheduleDisplaying ( final Stage stage ) { LOG . debug ( "Requested displaying of stage {} with title : \"{}\"" , stage , stage . getTitle ( ) ) ; return FxAsync . doOnFxThread ( stage , Stage :: show ) ; }
Schedules a stage for displaying .
66
8
41,412
public static CompletionStage < Stage > scheduleHiding ( final Stage stage ) { LOG . debug ( "Requested hiding of stage {} with title : \"{}\"" , stage , stage . getTitle ( ) ) ; return FxAsync . doOnFxThread ( stage , Stage :: hide ) ; }
Schedules a stage for hiding
66
7
41,413
public static CompletionStage < Stage > setStylesheet ( final Stage stage , final String stylesheet ) { LOG . info ( "Setting stylesheet {} for stage {}({})" , stylesheet , stage . toString ( ) , stage . getTitle ( ) ) ; return FxAsync . doOnFxThread ( stage , theStage -> { final Scene stageScene = theStage . getScene ...
Boilerplate for setting the stylesheet of a given stage via Java rather than FXML .
123
19
41,414
public static < T > CompletionStage < T > doOnFxThread ( final T element , final Consumer < T > action ) { return CompletableFuture . supplyAsync ( ( ) -> { action . accept ( element ) ; return element ; } , Platform :: runLater ) ; }
Asynchronously executes a consuming operation on the JavaFX thread .
61
13
41,415
public static < T , U > CompletionStage < U > computeOnFxThread ( final T element , final Function < T , U > compute ) { return CompletableFuture . supplyAsync ( ( ) -> compute . apply ( element ) , Platform :: runLater ) ; }
Asynchronously executes a computing operation on the JavaFX thread .
59
13
41,416
public static String capitalise ( String text ) { if ( empty ( text ) ) { return "" ; } return text . substring ( 0 , 1 ) . toUpperCase ( ) + text . substring ( 1 ) ; }
Capitalise the given text
49
5
41,417
public void startAsync ( ) { Thread thread = new Thread ( new Runnable ( ) { @ Override public void run ( ) { try { start ( ) ; } catch ( Exception e ) { LOG . error ( "Failed to connect to kubernetes: " + e , e ) ; } } } , "Jenkins X PipelineClient Thread" ) ; thread . start ( ) ; }
Starts listening in a background thread to avoid blocking the calling thread
85
13
41,418
public void start ( ) { doClose ( ) ; Watcher < PipelineActivity > listener = new Watcher < PipelineActivity > ( ) { @ Override public void eventReceived ( Action action , PipelineActivity pipelineActivity ) { onEventReceived ( action , pipelineActivity ) ; } @ Override public void onClose ( KubernetesClientException e...
Starts listing and watching the pipelines in the namespace and firing events .
214
14
41,419
public static boolean isNewer ( HasMetadata newer , HasMetadata older ) { long n1 = parseResourceVersion ( newer ) ; long n2 = parseResourceVersion ( older ) ; return n1 >= n2 ; }
Returns true if the first parameter is newer than the second
48
11
41,420
public static long parseResourceVersion ( HasMetadata obj ) { ObjectMeta metadata = obj . getMetadata ( ) ; if ( metadata != null ) { String resourceVersion = metadata . getResourceVersion ( ) ; if ( notEmpty ( resourceVersion ) ) { try { return Long . parseLong ( resourceVersion ) ; } catch ( NumberFormatException e )...
Returns the numeric resource version of the resource
84
8
41,421
public static String getPullRequestName ( String prUrl ) { if ( notEmpty ( prUrl ) ) { int idx = prUrl . lastIndexOf ( "/" ) ; if ( idx > 0 ) { return " #" + prUrl . substring ( idx + 1 ) ; } } return "" ; }
Returns the Pull Request name from the given URL prefixed with space or an empty string if there is no URL
69
22
41,422
public static String convertToKubernetesName ( String text , boolean allowDots ) { String lower = text . toLowerCase ( ) ; StringBuilder builder = new StringBuilder ( ) ; boolean started = false ; char lastCh = ' ' ; for ( int i = 0 , last = lower . length ( ) - 1 ; i <= last ; i ++ ) { char ch = lower . charAt ( i ) ;...
Lets convert the string to btw a valid kubernetes resource name
265
16
41,423
protected final SerializerFactory findSerializerFactory ( ) { SerializerFactory factory = _serializerFactory ; if ( factory == null ) { factory = SerializerFactory . createDefault ( ) ; _defaultSerializerFactory = factory ; _serializerFactory = factory ; } return factory ; }
Gets the serializer factory .
60
7
41,424
public Object readObject ( ) throws IOException { _is . startPacket ( ) ; Object obj = _in . readStreamingObject ( ) ; _is . endPacket ( ) ; return obj ; }
Read the next object
45
4
41,425
public void init ( OutputStream os ) { this . os = os ; _refs = null ; if ( _serializerFactory == null ) _serializerFactory = new SerializerFactory ( ) ; }
Initializes the output
43
4
41,426
public void writeRemote ( String type , String url ) throws IOException { os . write ( ' ' ) ; os . write ( ' ' ) ; printLenString ( type ) ; os . write ( ' ' ) ; printLenString ( url ) ; }
Writes a remote object reference to the stream . The type is the type of the remote interface .
54
20
41,427
public boolean removeRef ( Object obj ) throws IOException { if ( _refs != null ) { _refs . remove ( obj ) ; return true ; } else return false ; }
Removes a reference .
39
5
41,428
public boolean readRequest ( MuxInputStream in , MuxOutputStream out ) throws IOException { int channel = isClient ? 3 : 2 ; in . init ( this , channel ) ; out . init ( this , channel ) ; if ( readChannel ( channel ) != null ) { in . setInputStream ( is ) ; in . readToData ( false ) ; return true ; } else return false ...
Reads a server request .
87
6
41,429
OutputStream writeChannel ( int channel ) throws IOException { while ( os != null ) { boolean canWrite = false ; synchronized ( WRITE_LOCK ) { if ( ! isWriteLocked ) { isWriteLocked = true ; canWrite = true ; } else { try { WRITE_LOCK . wait ( 5000 ) ; } catch ( Exception e ) { } } } if ( canWrite ) { os . write ( ' ' ...
Grabs the channel for writing .
116
7
41,430
InputStream readChannel ( int channel ) throws IOException { while ( ! isClosed ) { if ( inputReady [ channel ] ) { inputReady [ channel ] = false ; return is ; } boolean canRead = false ; synchronized ( READ_LOCK ) { if ( ! isReadLocked ) { isReadLocked = true ; canRead = true ; } else { try { READ_LOCK . wait ( 5000 ...
Reads data from a channel .
131
7
41,431
private void readData ( ) throws IOException { while ( ! isClosed ) { int code = is . read ( ) ; switch ( code ) { case ' ' : case ' ' : case ' ' : case ' ' : break ; case ' ' : { int channel = ( is . read ( ) << 8 ) + is . read ( ) ; inputReady [ channel ] = true ; return ; } case ' ' : { int channel = ( is . read ( )...
Reads data until a channel packet C or error E is received .
173
14
41,432
public void close ( ) throws IOException { isClosed = true ; OutputStream os = this . os ; this . os = null ; InputStream is = this . is ; this . is = null ; if ( os != null ) os . close ( ) ; if ( is != null ) is . close ( ) ; }
Close the mux
68
4
41,433
public static ClassNameResolver buildDefault ( ) { String enable = System . getProperty ( Constants . SERIALIZE_BLACKLIST_ENABLE , Constants . DEFAULT_SERIALIZE_BLACKLIST_ENABLE ) ; if ( Boolean . TRUE . toString ( ) . equalsIgnoreCase ( enable ) ) { ClassNameResolver resolver = new ClassNameResolver ( ) ; resolver . a...
Build default ClassNameResolver
111
6
41,434
private boolean schedule ( Task task ) { int index = bufferIndex ( ) ; int buffered = bufferLengths . incrementAndGet ( index ) ; if ( task . isWrite ( ) ) { buffers [ index ] . add ( task ) ; drainStatus . set ( REQUIRED ) ; return false ; } // A buffer may discard a read task if its length exceeds a tolerance level i...
Schedules the task to be applied to the page replacement policy .
147
14
41,435
boolean shouldDrainBuffers ( boolean delayable ) { if ( executor . isShutdown ( ) ) { DrainStatus status = drainStatus . get ( ) ; return ( status != PROCESSING ) && ( ! delayable || ( status == REQUIRED ) ) ; } return false ; }
Determines whether the buffers should be drained .
64
10
41,436
@ GuardedBy ( "evictionLock" ) void drainBuffers ( int maxToDrain ) { // A mostly strict ordering is achieved by observing that each buffer // contains tasks in a weakly sorted order starting from the last drain. // The buffers can be merged into a sorted list in O(n) time by using // counting sort and chaining on a co...
Drains the buffers and applies the pending operations .
183
10
41,437
@ GuardedBy ( "evictionLock" ) void runTasksInChain ( Task task ) { while ( task != null ) { Task current = task ; task = task . getNext ( ) ; current . setNext ( null ) ; current . run ( ) ; } }
Runs the pending operations on the linked chain .
59
10
41,438
protected String readStringImpl ( int length ) throws IOException { StringBuffer sb = new StringBuffer ( ) ; for ( int i = 0 ; i < length ; i ++ ) { int ch = is . read ( ) ; if ( ch < 0x80 ) sb . append ( ( char ) ch ) ; else if ( ( ch & 0xe0 ) == 0xc0 ) { int ch1 = is . read ( ) ; int v = ( ( ch & 0x1f ) << 6 ) + ( ch...
Reads a string from the underlying stream .
246
9
41,439
public void startEnvelope ( String method ) throws IOException { int offset = _offset ; if ( SIZE < offset + 32 ) { flushBuffer ( ) ; offset = _offset ; } _buffer [ _offset ++ ] = ( byte ) ' ' ; writeString ( method ) ; }
Starts an envelope .
62
5
41,440
@ Override public int writeObjectBegin ( String type ) throws IOException { int newRef = _classRefs . size ( ) ; int ref = _classRefs . put ( type , newRef , false ) ; if ( newRef != ref ) { if ( SIZE < _offset + 32 ) flushBuffer ( ) ; if ( ref <= OBJECT_DIRECT_MAX ) { _buffer [ _offset ++ ] = ( byte ) ( BC_OBJECT_DIRE...
Writes the object definition
177
5
41,441
public void writeNull ( ) throws IOException { int offset = _offset ; byte [ ] buffer = _buffer ; if ( SIZE <= offset + 16 ) { flushBuffer ( ) ; offset = _offset ; } buffer [ offset ++ ] = ' ' ; _offset = offset ; }
Writes a null value to the stream . The null will be written with the following syntax
60
18
41,442
@ Override public void writeByteStream ( InputStream is ) throws IOException { while ( true ) { int len = SIZE - _offset - 3 ; if ( len < 16 ) { flushBuffer ( ) ; len = SIZE - _offset - 3 ; } len = is . read ( _buffer , _offset + 3 , len ) ; if ( len <= 0 ) { _buffer [ _offset ++ ] = BC_BINARY_DIRECT ; return ; } _buff...
Writes a full output stream .
165
7
41,443
public void startPacket ( ) throws IOException { if ( _refs != null ) { _refs . clear ( ) ; _refCount = 0 ; } flushBuffer ( ) ; _isPacket = true ; _offset = 4 ; _buffer [ 0 ] = ( byte ) 0x05 ; // 0x05 = binary _buffer [ 1 ] = ( byte ) 0x55 ; _buffer [ 2 ] = ( byte ) 0x55 ; _buffer [ 3 ] = ( byte ) 0x55 ; }
Starts a streaming packet
111
5
41,444
public void reset ( ) { if ( _refs != null ) { _refs . clear ( ) ; _refCount = 0 ; } _classRefs . clear ( ) ; _typeRefs = null ; _offset = 0 ; _isPacket = false ; _isUnshared = false ; }
Resets all counters and references
66
6
41,445
public int read ( ) throws IOException { int ch ; InputStream is = _is ; if ( is == null ) return - 1 ; else { ch = is . read ( ) ; } _state . next ( ch ) ; return ch ; }
Reads a character .
52
5
41,446
public void freeHessian2Input ( Hessian2Input in ) { if ( in == null ) return ; in . free ( ) ; _freeHessian2Input . free ( in ) ; }
Frees a Hessian 2 . 0 deserializer
44
11
41,447
public void freeHessian2Output ( Hessian2Output out ) { if ( out == null ) return ; out . free ( ) ; _freeHessian2Output . free ( out ) ; }
Frees a Hessian 2 . 0 serializer
44
10
41,448
public void init ( InputStream is ) { _is = is ; _method = null ; _isLastChunk = true ; _chunkLength = 0 ; _peek = - 1 ; _refs = null ; _replyFault = null ; if ( _serializerFactory == null ) _serializerFactory = new SerializerFactory ( ) ; }
Initialize the hessian stream with the underlying input stream .
76
13
41,449
public Object readReply ( Class expectedClass ) throws Throwable { int tag = read ( ) ; if ( tag != ' ' ) error ( "expected hessian reply at " + codeName ( tag ) ) ; int major = read ( ) ; int minor = read ( ) ; tag = read ( ) ; if ( tag == ' ' ) throw prepareFault ( ) ; else { _peek = tag ; Object value = readObject (...
Reads a reply as an object . If the reply has a fault throws the exception .
108
18
41,450
private Throwable prepareFault ( ) throws IOException { HashMap fault = readFault ( ) ; Object detail = fault . get ( "detail" ) ; String message = ( String ) fault . get ( "message" ) ; if ( detail instanceof Throwable ) { _replyFault = ( Throwable ) detail ; if ( message != null && _detailMessageField != null ) { try...
Prepares the fault .
160
5
41,451
public String readHeader ( ) throws IOException { int tag = read ( ) ; if ( tag == ' ' ) { _isLastChunk = true ; _chunkLength = ( read ( ) << 8 ) + read ( ) ; _sbuf . setLength ( 0 ) ; int ch ; while ( ( ch = parseChar ( ) ) >= 0 ) _sbuf . append ( ( char ) ch ) ; return _sbuf . toString ( ) ; } _peek = tag ; return nu...
Reads a header returning null if there are no headers .
109
12
41,452
public long readUTCDate ( ) throws IOException { int tag = read ( ) ; if ( tag != ' ' ) throw error ( "expected date at " + codeName ( tag ) ) ; long b64 = read ( ) ; long b56 = read ( ) ; long b48 = read ( ) ; long b40 = read ( ) ; long b32 = read ( ) ; long b24 = read ( ) ; long b16 = read ( ) ; long b8 = read ( ) ; ...
Reads a date .
162
5
41,453
public org . w3c . dom . Node readNode ( ) throws IOException { int tag = read ( ) ; switch ( tag ) { case ' ' : return null ; case ' ' : case ' ' : case ' ' : case ' ' : _isLastChunk = tag == ' ' || tag == ' ' ; _chunkLength = ( read ( ) << 8 ) + read ( ) ; throw error ( "Can't handle string in this context" ) ; defau...
Reads an XML node .
114
6
41,454
private HashMap readFault ( ) throws IOException { HashMap map = new HashMap ( ) ; int code = read ( ) ; for ( ; code > 0 && code != ' ' ; code = read ( ) ) { _peek = code ; Object key = readObject ( ) ; Object value = readObject ( ) ; if ( key != null && value != null ) map . put ( key , value ) ; } if ( code != ' ' )...
Reads a fault .
112
5
41,455
public Object readObject ( Class cl ) throws IOException { if ( cl == null || cl == Object . class ) return readObject ( ) ; int tag = read ( ) ; switch ( tag ) { case ' ' : return null ; case ' ' : { String type = readType ( ) ; // hessian/3386 if ( "" . equals ( type ) ) { Deserializer reader ; reader = _serializerFa...
Reads an object from the input stream with an expected type .
362
13
41,456
public Object readObject ( ) throws IOException { int tag = read ( ) ; switch ( tag ) { case ' ' : return null ; case ' ' : return Boolean . valueOf ( true ) ; case ' ' : return Boolean . valueOf ( false ) ; case ' ' : return Integer . valueOf ( parseInt ( ) ) ; case ' ' : return Long . valueOf ( parseLong ( ) ) ; case...
Reads an arbitrary object from the input stream when the type is unknown .
476
15
41,457
public Object readRemote ( ) throws IOException { String type = readType ( ) ; String url = readString ( ) ; return resolveRemote ( type , url ) ; }
Reads a remote object .
36
6
41,458
public Object resolveRemote ( String type , String url ) throws IOException { HessianRemoteResolver resolver = getRemoteResolver ( ) ; if ( resolver != null ) return resolver . lookup ( type , url ) ; else return new HessianRemote ( type , url ) ; }
Resolves a remote object .
61
6
41,459
public String readType ( ) throws IOException { int code = read ( ) ; if ( code != ' ' ) { _peek = code ; return "" ; } _isLastChunk = true ; _chunkLength = ( read ( ) << 8 ) + read ( ) ; _sbuf . setLength ( 0 ) ; int ch ; while ( ( ch = parseChar ( ) ) >= 0 ) _sbuf . append ( ( char ) ch ) ; return _sbuf . toString ( ...
Parses a type from the stream .
109
9
41,460
private int parseInt ( ) throws IOException { int b32 = read ( ) ; int b24 = read ( ) ; int b16 = read ( ) ; int b8 = read ( ) ; return ( b32 << 24 ) + ( b24 << 16 ) + ( b16 << 8 ) + b8 ; }
Parses a 32 - bit integer value from the stream .
68
13
41,461
private long parseLong ( ) throws IOException { long b64 = read ( ) ; long b56 = read ( ) ; long b48 = read ( ) ; long b40 = read ( ) ; long b32 = read ( ) ; long b24 = read ( ) ; long b16 = read ( ) ; long b8 = read ( ) ; return ( ( b64 << 56 ) + ( b56 << 48 ) + ( b48 << 40 ) + ( b40 << 32 ) + ( b32 << 24 ) + ( b24 <<...
Parses a 64 - bit long value from the stream .
130
13
41,462
private double parseDouble ( ) throws IOException { long b64 = read ( ) ; long b56 = read ( ) ; long b48 = read ( ) ; long b40 = read ( ) ; long b32 = read ( ) ; long b24 = read ( ) ; long b16 = read ( ) ; long b8 = read ( ) ; long bits = ( ( b64 << 56 ) + ( b56 << 48 ) + ( b48 << 40 ) + ( b40 << 32 ) + ( b32 << 24 ) +...
Parses a 64 - bit double value from the stream .
144
13
41,463
private int parseChar ( ) throws IOException { while ( _chunkLength <= 0 ) { if ( _isLastChunk ) return - 1 ; int code = read ( ) ; switch ( code ) { case ' ' : case ' ' : _isLastChunk = false ; _chunkLength = ( read ( ) << 8 ) + read ( ) ; break ; case ' ' : case ' ' : _isLastChunk = true ; _chunkLength = ( read ( ) <...
Reads a character from the underlying stream .
143
9
41,464
private int parseUTF8Char ( ) throws IOException { int ch = read ( ) ; if ( ch < 0x80 ) return ch ; else if ( ( ch & 0xe0 ) == 0xc0 ) { int ch1 = read ( ) ; int v = ( ( ch & 0x1f ) << 6 ) + ( ch1 & 0x3f ) ; return v ; } else if ( ( ch & 0xf0 ) == 0xe0 ) { int ch1 = read ( ) ; int ch2 = read ( ) ; int v = ( ( ch & 0x0f ...
Parses a single UTF8 character .
182
9
41,465
private int parseByte ( ) throws IOException { while ( _chunkLength <= 0 ) { if ( _isLastChunk ) { return - 1 ; } int code = read ( ) ; switch ( code ) { case ' ' : _isLastChunk = false ; _chunkLength = ( read ( ) << 8 ) + read ( ) ; break ; case ' ' : _isLastChunk = true ; _chunkLength = ( read ( ) << 8 ) + read ( ) ;...
Reads a byte from the underlying stream .
135
9
41,466
public InputStream readInputStream ( ) throws IOException { int tag = read ( ) ; switch ( tag ) { case ' ' : return null ; case ' ' : case ' ' : _isLastChunk = tag == ' ' ; _chunkLength = ( read ( ) << 8 ) + read ( ) ; break ; default : throw expect ( "inputStream" , tag ) ; } return new InputStream ( ) { boolean _isCl...
Reads bytes based on an input stream .
248
9
41,467
int read ( byte [ ] buffer , int offset , int length ) throws IOException { int readLength = 0 ; while ( length > 0 ) { while ( _chunkLength <= 0 ) { if ( _isLastChunk ) return readLength == 0 ? - 1 : readLength ; int code = read ( ) ; switch ( code ) { case ' ' : _isLastChunk = false ; _chunkLength = ( read ( ) << 8 )...
Reads bytes from the underlying stream .
217
8
41,468
protected OutputStream getOutputStream ( ) throws IOException { if ( os == null && server != null ) os = server . writeChannel ( channel ) ; return os ; }
Gets the raw output stream . Clients will normally not call this .
36
15
41,469
public void write ( int ch ) throws IOException { OutputStream os = getOutputStream ( ) ; os . write ( ' ' ) ; os . write ( 0 ) ; os . write ( 1 ) ; os . write ( ch ) ; }
Writes a data byte to the output stream .
51
10
41,470
public void write ( byte [ ] buffer , int offset , int length ) throws IOException { OutputStream os = getOutputStream ( ) ; for ( ; length > 0x8000 ; length -= 0x8000 ) { os . write ( ' ' ) ; os . write ( 0x80 ) ; os . write ( 0x00 ) ; os . write ( buffer , offset , 0x8000 ) ; offset += 0x8000 ; } os . write ( ' ' ) ;...
Writes data to the output stream .
127
8
41,471
public void close ( ) throws IOException { if ( server != null ) { OutputStream os = getOutputStream ( ) ; this . os = null ; MuxServer server = this . server ; this . server = null ; server . close ( channel ) ; } }
Complete writing to the stream closing the channel .
56
9
41,472
protected void writeUTF ( int code , String string ) throws IOException { OutputStream os = getOutputStream ( ) ; os . write ( code ) ; int charLength = string . length ( ) ; int length = 0 ; for ( int i = 0 ; i < charLength ; i ++ ) { char ch = string . charAt ( i ) ; if ( ch < 0x80 ) length ++ ; else if ( ch < 0x800 ...
Writes a UTF - 8 string .
273
8
41,473
public boolean readToOutputStream ( OutputStream os ) throws IOException { InputStream is = readInputStream ( ) ; if ( is == null ) return false ; if ( _buffer == null ) _buffer = new byte [ 256 ] ; try { int len ; while ( ( len = is . read ( _buffer , 0 , _buffer . length ) ) > 0 ) { os . write ( _buffer , 0 , len ) ;...
Reads data to an output stream .
106
8
41,474
@ Override public Object writeReplace ( Object obj ) { Calendar cal = ( Calendar ) obj ; return new CalendarHandle ( cal . getClass ( ) , cal . getTimeInMillis ( ) ) ; }
java . util . Calendar serializes to com . caucho . hessian . io . CalendarHandle
45
22
41,475
public static String mangleName ( Method method , boolean isFull ) { StringBuffer sb = new StringBuffer ( ) ; sb . append ( method . getName ( ) ) ; Class [ ] params = method . getParameterTypes ( ) ; for ( int i = 0 ; i < params . length ; i ++ ) { sb . append ( ' ' ) ; sb . append ( mangleClass ( params [ i ] , isFul...
Creates a unique mangled method name based on the method name and the method parameters .
108
18
41,476
public static String mangleClass ( Class cl , boolean isFull ) { String name = cl . getName ( ) ; if ( name . equals ( "boolean" ) || name . equals ( "java.lang.Boolean" ) ) return "boolean" ; else if ( name . equals ( "int" ) || name . equals ( "java.lang.Integer" ) || name . equals ( "short" ) || name . equals ( "jav...
Mangles a classname .
495
6
41,477
@ Override public void addHeader ( String key , String value ) { _conn . setRequestProperty ( key , value ) ; }
Adds a HTTP header .
28
5
41,478
public void sendRequest ( ) throws IOException { if ( _conn instanceof HttpURLConnection ) { HttpURLConnection httpConn = ( HttpURLConnection ) _conn ; _statusCode = 500 ; try { _statusCode = httpConn . getResponseCode ( ) ; } catch ( Exception e ) { } parseResponseHeaders ( httpConn ) ; InputStream is = null ; if ( _s...
Sends the request
343
4
41,479
@ Override public void destroy ( ) { close ( ) ; URLConnection conn = _conn ; _conn = null ; if ( conn instanceof HttpURLConnection ) ( ( HttpURLConnection ) conn ) . disconnect ( ) ; }
Disconnect the connection
50
4
41,480
protected InputStream getInputStream ( ) throws IOException { if ( is == null && server != null ) is = server . readChannel ( channel ) ; return is ; }
Gets the raw input stream . Clients will normally not call this .
36
15
41,481
private void skipToEnd ( ) throws IOException { InputStream is = getInputStream ( ) ; if ( is == null ) return ; if ( chunkLength > 0 ) is . skip ( chunkLength ) ; for ( int tag = is . read ( ) ; tag >= 0 ; tag = is . read ( ) ) { switch ( tag ) { case ' ' : server . freeReadLock ( ) ; this . is = is = server . readCha...
Skips data until the end of the channel .
202
10
41,482
void readToData ( boolean returnOnYield ) throws IOException { InputStream is = getInputStream ( ) ; if ( is == null ) return ; for ( int tag = is . read ( ) ; tag >= 0 ; tag = is . read ( ) ) { switch ( tag ) { case ' ' : server . freeReadLock ( ) ; if ( returnOnYield ) return ; server . readChannel ( channel ) ; brea...
Reads tags until getting data .
172
7
41,483
protected void readTag ( int tag ) throws IOException { int length = ( is . read ( ) << 8 ) + is . read ( ) ; is . skip ( length ) ; }
Subclasses will extend this to read values .
39
9
41,484
protected String readUTF ( ) throws IOException { int len = ( is . read ( ) << 8 ) + is . read ( ) ; StringBuffer sb = new StringBuffer ( ) ; while ( len > 0 ) { int d1 = is . read ( ) ; if ( d1 < 0 ) return sb . toString ( ) ; else if ( d1 < 0x80 ) { len -- ; sb . append ( ( char ) d1 ) ; } else if ( ( d1 & 0xe0 ) == ...
Reads a UTF - 8 string .
253
8
41,485
public Object getObjectInstance ( Object obj , Name name , Context nameCtx , Hashtable < ? , ? > environment ) throws Exception { Reference ref = ( Reference ) obj ; String api = null ; String url = null ; for ( int i = 0 ; i < ref . size ( ) ; i ++ ) { RefAddr addr = ref . get ( i ) ; String type = addr . getType ( ) ...
JNDI object factory so the proxy can be used as a resource .
260
15
41,486
private String base64 ( String value ) { StringBuffer cb = new StringBuffer ( ) ; int i = 0 ; for ( i = 0 ; i + 2 < value . length ( ) ; i += 3 ) { long chunk = ( int ) value . charAt ( i ) ; chunk = ( chunk << 8 ) + ( int ) value . charAt ( i + 1 ) ; chunk = ( chunk << 8 ) + ( int ) value . charAt ( i + 2 ) ; cb . app...
Creates the Base64 value .
341
7
41,487
@ Override public void writeObject ( Object obj , AbstractHessianOutput out ) throws IOException { if ( out . addRef ( obj ) ) { return ; } int ref = out . writeObjectBegin ( getClassName ( obj ) ) ; if ( ref < - 1 ) { out . writeString ( "value" ) ; InputStream is = null ; try { is = getInputStream ( obj ) ; } catch (...
Writes the object to the output stream .
293
9
41,488
protected Object readObjectImpl ( Class cl ) throws IOException { try { Object obj = cl . newInstance ( ) ; if ( _refs == null ) _refs = new ArrayList ( ) ; _refs . add ( obj ) ; HashMap fieldMap = getFieldMap ( cl ) ; int code = read ( ) ; for ( ; code >= 0 && code != ' ' ; code = read ( ) ) { unread ( ) ; Object key ...
Reads an object from the input stream . cl is known not to be a Map .
267
18
41,489
public void setSendCollectionType ( boolean isSendType ) { if ( _collectionSerializer == null ) _collectionSerializer = new CollectionSerializer ( ) ; _collectionSerializer . setSendJavaType ( isSendType ) ; if ( _mapSerializer == null ) _mapSerializer = new MapSerializer ( ) ; _mapSerializer . setSendJavaType ( isSend...
Set true if the collection serializer should send the java type .
86
13
41,490
public Object readList ( AbstractHessianInput in , int length , String type ) throws HessianProtocolException , IOException { Deserializer deserializer = getDeserializer ( type ) ; if ( deserializer != null ) return deserializer . readList ( in , length ) ; else return new CollectionDeserializer ( ArrayList . class ) ....
Reads the object as a list .
87
8
41,491
@ Override public Object readMap ( AbstractHessianInput in ) throws IOException { Object value = null ; while ( ! in . isEnd ( ) ) { String key = in . readString ( ) ; if ( key . equals ( "value" ) ) value = readStreamValue ( in ) ; else in . readObject ( ) ; } in . readMapEnd ( ) ; return value ; }
Reads the Hessian 1 . 0 style map .
86
11
41,492
public void service ( ServletRequest request , ServletResponse response ) throws IOException , ServletException { HttpServletRequest req = ( HttpServletRequest ) request ; HttpServletResponse res = ( HttpServletResponse ) response ; if ( ! req . getMethod ( ) . equals ( "POST" ) ) { res . setStatus ( 500 ) ; // , "Hess...
Execute a request . The path - info of the request selects the bean . Once the bean s selected it will be applied .
321
26
41,493
public void writeObjectImpl ( Object obj ) throws IOException { Class cl = obj . getClass ( ) ; try { Method method = cl . getMethod ( "writeReplace" , new Class [ 0 ] ) ; Object repl = method . invoke ( obj , new Object [ 0 ] ) ; writeObject ( repl ) ; return ; } catch ( Exception e ) { } try { writeMapBegin ( cl . ge...
Applications which override this can do custom serialization .
258
10
41,494
public boolean checkDuplicate ( T obj ) { int top = _top . get ( ) ; for ( int i = top - 1 ; i >= 0 ; i -- ) { if ( _freeStack . get ( i ) == obj ) return true ; } return false ; }
Debugging to see if the object has already been freed .
59
12
41,495
public Serializer getSerializer ( String className ) { Serializer serializer = _serializerClassMap . get ( className ) ; if ( serializer == AbstractSerializer . NULL ) return null ; else return serializer ; }
Returns the serializer for a given class .
49
9
41,496
public Deserializer getDeserializer ( String className ) { Deserializer deserializer = _deserializerClassMap . get ( className ) ; if ( deserializer == AbstractDeserializer . NULL ) return null ; else return deserializer ; }
Returns the deserializer for a given class .
57
10
41,497
public Deserializer getCustomDeserializer ( Class cl ) { Deserializer deserializer = _customDeserializerMap . get ( cl . getName ( ) ) ; if ( deserializer == AbstractDeserializer . NULL ) return null ; else if ( deserializer != null ) return deserializer ; try { Class serClass = Class . forName ( cl . getName ( ) + "He...
Returns a custom deserializer the class
219
8
41,498
private void init ( ) { if ( _parent != null ) { _serializerFiles . addAll ( _parent . _serializerFiles ) ; _deserializerFiles . addAll ( _parent . _deserializerFiles ) ; _serializerClassMap . putAll ( _parent . _serializerClassMap ) ; _deserializerClassMap . putAll ( _parent . _deserializerClassMap ) ; } if ( _parent ...
Initialize the factory
500
4
41,499
protected HessianConnection sendRequest ( String methodName , Object [ ] args ) throws IOException { HessianConnection conn = null ; conn = _factory . getConnectionFactory ( ) . open ( _url ) ; boolean isValid = false ; try { addRequestHeaders ( conn ) ; OutputStream os = null ; try { os = conn . getOutputStream ( ) ; ...
Sends the HTTP request to the Hessian connection .
238
11