idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
41,300
public String getBackStackDescription ( ) { ArrayList < Screen > backStackCopy = new ArrayList <> ( backStack ) ; Collections . reverse ( backStackCopy ) ; String currentScreen = "" ; if ( ! backStackCopy . isEmpty ( ) ) { currentScreen = backStackCopy . remove ( backStackCopy . size ( ) - 1 ) . toString ( ) ; } return...
Returns a human - readable string describing the screens in this Navigator s back stack .
125
17
41,301
@ Override public int read ( final byte [ ] buffer , final int bufPos , final int length ) throws IOException { int i = super . read ( buffer , bufPos , length ) ; if ( ( i == length ) || ( i == - 1 ) ) return i ; int j = super . read ( buffer , bufPos + i , length - i ) ; if ( j == - 1 ) return i ; return j + i ; }
Workaround for an unexpected behavior of BufferedInputStream !
94
12
41,302
private String sendBind ( BindType bindType , String systemId , String password , String systemType , InterfaceVersion interfaceVersion , TypeOfNumber addrTon , NumberingPlanIndicator addrNpi , String addressRange , long timeout ) throws PDUException , ResponseTimeoutException , InvalidResponseException , NegativeRespo...
Sending bind .
215
4
41,303
public OutbindRequest waitForOutbind ( long timeout ) throws IllegalStateException , TimeoutException { SessionState currentSessionState = getSessionState ( ) ; if ( currentSessionState . equals ( SessionState . OPEN ) ) { new SMPPOutboundServerSession . PDUReaderWorker ( ) . start ( ) ; try { return outbindRequestRece...
Wait for outbind request .
169
6
41,304
public String bind ( BindParameter bindParam , long timeout ) throws IOException { try { String smscSystemId = sendBind ( bindParam . getBindType ( ) , bindParam . getSystemId ( ) , bindParam . getPassword ( ) , bindParam . getSystemType ( ) , bindParam . getInterfaceVersion ( ) , bindParam . getAddrTon ( ) , bindParam...
Bind immediately .
413
3
41,305
public static String convertHexStringToString ( String hexString ) { String uHexString = hexString . toLowerCase ( ) ; StringBuilder sBld = new StringBuilder ( ) ; for ( int i = 0 ; i < uHexString . length ( ) ; i = i + 2 ) { char c = ( char ) Integer . parseInt ( uHexString . substring ( i , i + 2 ) , 16 ) ; sBld . ap...
Convert the hex string to string .
117
8
41,306
public static byte [ ] convertHexStringToBytes ( String hexString , int offset , int endIndex ) { byte [ ] data ; String realHexString = hexString . substring ( offset , endIndex ) . toLowerCase ( ) ; if ( ( realHexString . length ( ) % 2 ) == 0 ) data = new byte [ realHexString . length ( ) / 2 ] ; else data = new byt...
Convert the hex string to bytes .
317
8
41,307
private static String intToString ( int value , int digit ) { StringBuilder stringBuilder = new StringBuilder ( digit ) ; stringBuilder . append ( Integer . toString ( value ) ) ; while ( stringBuilder . length ( ) < digit ) { stringBuilder . insert ( 0 , "0" ) ; } return stringBuilder . toString ( ) ; }
Create String representation of integer . Preceding 0 will be add as needed .
75
16
41,308
private static String getDeliveryReceiptValue ( String attrName , String source ) throws IndexOutOfBoundsException { String tmpAttr = attrName + ":" ; int startIndex = source . indexOf ( tmpAttr ) ; if ( startIndex < 0 ) { return null ; } startIndex = startIndex + tmpAttr . length ( ) ; int endIndex = source . indexOf ...
Get the delivery receipt attribute value .
127
7
41,309
private SMPPSession getSession ( ) throws IOException { if ( session == null ) { LOGGER . info ( "Initiate session for the first time to {}:{}" , remoteIpAddress , remotePort ) ; session = newSession ( ) ; } else if ( ! session . getSessionState ( ) . isBound ( ) ) { throw new IOException ( "We have no valid session ye...
Get the session . If the session still null or not in bound state then IO exception will be thrown .
94
21
41,310
private void reconnectAfter ( final long timeInMillis ) { new Thread ( ) { @ Override public void run ( ) { LOGGER . info ( "Schedule reconnect after {} millis" , timeInMillis ) ; try { Thread . sleep ( timeInMillis ) ; } catch ( InterruptedException e ) { } int attempt = 0 ; while ( session == null || session . getSes...
Reconnect session after specified interval .
200
8
41,311
public void accept ( String systemId , InterfaceVersion interfaceVersion ) throws PDUStringException , IllegalStateException , IOException { StringValidator . validateString ( systemId , StringParameter . SYSTEM_ID ) ; lock . lock ( ) ; try { if ( ! done ) { done = true ; try { responseHandler . sendBindResp ( systemId...
Accept the bind request . The provided interface version will be put into the optional parameter sc_interface_version in the bind response message .
128
27
41,312
public void reject ( int errorCode ) throws IllegalStateException , IOException { lock . lock ( ) ; try { if ( done ) { throw new IllegalStateException ( "Response already initiated" ) ; } else { done = true ; try { responseHandler . sendNegativeResponse ( bindType . commandId ( ) , errorCode , originalSequenceNumber )...
Reject the bind request .
98
6
41,313
public void done ( T response ) throws IllegalArgumentException { lock . lock ( ) ; try { if ( response != null ) { this . response = response ; condition . signal ( ) ; } else { throw new IllegalArgumentException ( "response cannot be null" ) ; } } finally { lock . unlock ( ) ; } }
Done with valid response and notify that response already received .
70
11
41,314
public void waitDone ( ) throws ResponseTimeoutException , InvalidResponseException { lock . lock ( ) ; try { if ( ! isDoneResponse ( ) ) { try { condition . await ( timeout , TimeUnit . MILLISECONDS ) ; } catch ( InterruptedException e ) { Thread . currentThread ( ) . interrupt ( ) ; throw new RuntimeException ( "Inte...
Wait until response received or timeout already reached .
141
9
41,315
public byte [ ] serialize ( ) { byte [ ] value = serializeValue ( ) ; ByteBuffer buffer = ByteBuffer . allocate ( value . length + 4 ) ; buffer . putShort ( tag ) ; buffer . putShort ( ( short ) value . length ) ; buffer . put ( value ) ; return buffer . array ( ) ; }
Convert the optional parameter into a byte serialized form conforming to the SMPP specification .
72
20
41,316
@ Override public BindRequest connectAndOutbind ( String host , int port , String systemId , String password ) throws IOException { return connectAndOutbind ( host , port , new OutbindParameter ( systemId , password ) , 60000 ) ; }
Open connection and outbind immediately . The default timeout is 60 seconds .
54
14
41,317
public BindRequest connectAndOutbind ( String host , int port , OutbindParameter outbindParameter , long timeout ) throws IOException { logger . debug ( "Connect and bind to {} port {}" , host , port ) ; if ( getSessionState ( ) != SessionState . CLOSED ) { throw new IOException ( "Session state is not closed" ) ; } co...
Open connection and outbind immediately .
403
7
41,318
private BindRequest waitForBind ( long timeout ) throws IllegalStateException , TimeoutException { SessionState currentSessionState = getSessionState ( ) ; if ( currentSessionState . equals ( SessionState . OPEN ) ) { try { return bindRequestReceiver . waitForRequest ( timeout ) ; } catch ( IllegalStateException e ) { ...
Wait for bind request .
142
5
41,319
public static int bytesToInt ( byte [ ] bytes , int offset ) { // int result = 0x00000000 ; int length ; if ( bytes . length - offset < 4 ) // maximum byte size for int data type // is 4 length = bytes . length - offset ; else length = 4 ; int end = offset + length ; for ( int i = 0 ; i < length ; i ++ ) { result |= ( ...
32 bit .
125
3
41,320
public static short bytesToShort ( byte [ ] bytes , int offset ) { short result = 0x0000 ; int end = offset + 2 ; for ( int i = 0 ; i < 2 ; i ++ ) { result |= ( bytes [ end - i - 1 ] & 0xff ) << ( 8 * i ) ; } return result ; }
16 bit .
73
3
41,321
OutbindRequest waitForRequest ( long timeout ) throws IllegalStateException , TimeoutException { this . lock . lock ( ) ; try { if ( this . alreadyWaitForRequest ) { throw new IllegalStateException ( "waitForRequest(long) method already invoked" ) ; } else if ( this . request == null ) { try { this . requestCondition ....
Wait until the outbind request received for specified timeout .
186
11
41,322
void notifyAcceptOutbind ( Outbind outbind ) throws IllegalStateException { this . lock . lock ( ) ; try { if ( this . request == null ) { this . request = new OutbindRequest ( outbind ) ; this . requestCondition . signal ( ) ; } else { throw new IllegalStateException ( "Already waiting for acceptance outbind" ) ; } } ...
Notify that the outbind was accepted .
90
9
41,323
public void setPduProcessorDegree ( int pduProcessorDegree ) throws IllegalStateException { if ( ! getSessionState ( ) . equals ( SessionState . CLOSED ) ) { throw new IllegalStateException ( "Cannot set PDU processor degree since the PDU dispatcher thread already created" ) ; } this . pduProcessorDegree = pduProcessor...
Set total thread can read PDU and process it in parallel . It s defaulted to 3 .
89
20
41,324
protected void ensureReceivable ( String activityName ) throws IOException { // TODO uudashr: do we have to use another exception for this checking? SessionState currentState = getSessionState ( ) ; if ( ! currentState . isReceivable ( ) ) { throw new IOException ( "Cannot " + activityName + " while session " + session...
Ensure the session is receivable . If the session not receivable then an exception thrown .
89
19
41,325
protected void ensureTransmittable ( String activityName , boolean only ) throws IOException { // TODO uudashr: do we have to use another exception for this checking? SessionState currentState = getSessionState ( ) ; if ( ! currentState . isTransmittable ( ) || ( only && currentState . isReceivable ( ) ) ) { throw new ...
Ensure the session is transmittable . If the session not transmittable then an exception thrown .
107
21
41,326
void notifyAcceptBind ( Bind bindParameter ) throws IllegalStateException { lock . lock ( ) ; try { if ( request == null ) { request = new BindRequest ( bindParameter , responseHandler ) ; requestCondition . signal ( ) ; } else { throw new IllegalStateException ( "Already waiting for acceptance bind" ) ; } } finally { ...
Notify that the bind has accepted .
79
8
41,327
static boolean isCOctetStringValid ( String value , int maxLength ) { if ( value == null ) return true ; if ( value . length ( ) >= maxLength ) return false ; return true ; }
Validate the C - Octet String .
44
9
41,328
static boolean isCOctetStringNullOrNValValid ( String value , int length ) { if ( value == null ) { return true ; } if ( value . length ( ) == 0 ) { return true ; } if ( value . length ( ) == length - 1 ) { return true ; } return false ; }
Validate the C - Octet String
67
8
41,329
static boolean isOctetStringValid ( String value , int maxLength ) { if ( value == null ) return true ; if ( value . length ( ) > maxLength ) return false ; return true ; }
Validate the Octet String
43
6
41,330
public String format ( Calendar calendar , Calendar smscCalendar ) { if ( calendar == null || smscCalendar == null ) { return null ; } long diffTimeInMillis = calendar . getTimeInMillis ( ) - smscCalendar . getTimeInMillis ( ) ; if ( diffTimeInMillis < 0 ) { throw new IllegalArgumentException ( "The requested relative ...
Return the relative time from the calendar datetime against the SMSC datetime .
299
16
41,331
public int append ( byte [ ] b , int offset , int length ) { int oldLength = bytesLength ; bytesLength += length ; int newCapacity = capacityPolicy . ensureCapacity ( bytesLength , bytes . length ) ; if ( newCapacity > bytes . length ) { byte [ ] newB = new byte [ newCapacity ] ; System . arraycopy ( bytes , 0 , newB ,...
Append bytes to specified offset and length .
137
9
41,332
public int appendAll ( OptionalParameter [ ] optionalParameters ) { int length = 0 ; for ( OptionalParameter optionalParamameter : optionalParameters ) { length += append ( optionalParamameter ) ; } return length ; }
Append all optional parameters .
46
6
41,333
public void setSourceArchiveUrls ( List < String > sourceArchiveUrls ) { if ( sourceArchiveUrls == null ) throw new IllegalArgumentException ( ) ; this . sourceArchiveUrls = new ArrayList < String > ( sourceArchiveUrls ) ; }
Sets the list of source archive URLs . The source archives must be ZIP compressed archives containing COPPER workflows as . java files .
62
27
41,334
public void setCompilerOptionsProviders ( List < CompilerOptionsProvider > compilerOptionsProviders ) { if ( compilerOptionsProviders == null ) throw new NullPointerException ( ) ; this . compilerOptionsProviders = new ArrayList < CompilerOptionsProvider > ( compilerOptionsProviders ) ; }
Sets the list of CompilerOptionsProviders . They are called before compiling the workflow files to append compiler options .
64
24
41,335
private void doHousekeeping ( ) { logger . info ( "started" ) ; while ( ! shutdown ) { try { List < EarlyResponse > removedEarlyResponses = new ArrayList <> ( ) ; synchronized ( responseMap ) { Iterator < List < EarlyResponse >> responseMapIterator = responseMap . values ( ) . iterator ( ) ; while ( responseMapIterator...
Jetzt gibt es eine Map von Listen und man muss immer alles komplett Ueberpruefen - ggf . optimieren
307
37
41,336
public void asynchLog ( final AuditTrailEvent e , final AuditTrailCallback cb ) { CommandCallback < BatchInsertIntoAutoTrail . Command > callback = new CommandCallback < BatchInsertIntoAutoTrail . Command > ( ) { @ Override public void commandCompleted ( ) { cb . done ( ) ; } @ Override public void unhandledException (...
returns immediately after queueing the log message
110
9
41,337
public static void closeConnection ( Connection con ) { if ( con != null ) { try { con . close ( ) ; } catch ( SQLException ex ) { logger . debug ( "Could not close JDBC Connection" , ex ) ; } catch ( Throwable ex ) { logger . debug ( "Unexpected exception on closing JDBC Connection" , ex ) ; } } }
Close the given JDBC Connection and ignore any thrown exception . This is useful for typical finally blocks in manual JDBC code .
80
25
41,338
public synchronized void release ( int count ) { used -= count ; if ( used < 0 ) used = 0 ; // no negative number of ticket! if ( logger . isDebugEnabled ( ) ) logger . debug ( "Released " + count + " tickets! (Now " + this . toString ( ) + ")" ) ; notifyAll ( ) ; }
Releases the given number of tickets and notifies potentially waiting threads that new tickets are in the pool .
74
21
41,339
public String obtainAndReturnTicketPoolId ( Workflow < ? > wf ) { TicketPool tp = findPool ( wf . getClass ( ) . getName ( ) ) ; tp . obtain ( ) ; return tp . getId ( ) ; }
For testing ..
58
3
41,340
protected String classnameReplacement ( String classname ) { if ( classname . startsWith ( COPPER_2X_PACKAGE_PREFIX ) ) { String className3x = classname . replace ( COPPER_2X_PACKAGE_PREFIX , COPPER_3_PACKAGE_PREFIX ) ; if ( ( COPPER_3_PACKAGE_PREFIX + COPPER_2X_INTERRUPT_NAME ) . equals ( className3x ) ) { return COPP...
For downward compatibility there is a package name replacement during deserialization of workflow instances and responses . The default implementation ensures downward compatibility to copper &lt ; = 2 . x .
153
35
41,341
public void addCurrentEntity ( Object entity ) { Object identifier = identifier ( entity ) ; Object o = memento . get ( identifier ) ; if ( o == null ) { inserted . add ( entity ) ; } else { potentiallyChanged . put ( identifier , entity ) ; } }
Use this entity as the new
59
6
41,342
public void putResponse ( Response < ? > r ) { synchronized ( responseMap ) { List < Response < ? > > l = responseMap . get ( r . getCorrelationId ( ) ) ; if ( l == null ) { l = new SortedResponseList ( ) ; responseMap . put ( r . getCorrelationId ( ) , l ) ; } l . add ( r ) ; } }
Internal use only - called by the processing engine
86
9
41,343
protected final void resubmit ( ) throws Interrupt { final String cid = engine . createUUID ( ) ; engine . registerCallbacks ( this , WaitMode . ALL , 0 , cid ) ; Acknowledge ack = createCheckpointAcknowledge ( ) ; engine . notify ( new Response < Object > ( cid , null , null ) , ack ) ; registerCheckpointAcknowledge (...
Causes the engine to stop processing of this workflow instance and to enqueue it again . May be used in case of processor pool change or to create a savepoint .
102
34
41,344
@ Override public int countWorkflowInstances ( WorkflowInstanceFilter filter ) throws Exception { final StringBuilder query = new StringBuilder ( ) ; final List < Object > values = new ArrayList <> ( ) ; query . append ( "SELECT COUNT(*) AS COUNT_NUMBER FROM COP_WORKFLOW_INSTANCE" ) ; appendQueryBase ( query , values ,...
Probably it s gonna be slow . We can consider creating counting table for that sake .
216
17
41,345
private String getAuthHash ( WebContext ctx ) { Value authorizationHeaderValue = ctx . getHeaderValue ( HttpHeaderNames . AUTHORIZATION ) ; if ( ! authorizationHeaderValue . isFilled ( ) ) { return ctx . get ( "Signature" ) . asString ( ctx . get ( "X-Amz-Signature" ) . asString ( ) ) ; } String authentication = String...
Extracts the given hash from the given request . Returns null if no hash was given .
193
19
41,346
private void signalObjectError ( WebContext ctx , HttpResponseStatus status , String message ) { if ( ctx . getRequest ( ) . method ( ) == HEAD ) { ctx . respondWith ( ) . status ( status ) ; } else { ctx . respondWith ( ) . error ( status , message ) ; } log . log ( ctx . getRequest ( ) . method ( ) . name ( ) , messa...
Writes an API error to the log
129
8
41,347
private void signalObjectSuccess ( WebContext ctx ) { log . log ( ctx . getRequest ( ) . method ( ) . name ( ) , ctx . getRequestedURI ( ) , APILog . Result . OK , CallContext . getCurrent ( ) . getWatch ( ) ) ; }
Writes an API success entry to the log
65
9
41,348
private void listBuckets ( WebContext ctx ) { HttpMethod method = ctx . getRequest ( ) . method ( ) ; if ( GET == method ) { List < Bucket > buckets = storage . getBuckets ( ) ; Response response = ctx . respondWith ( ) ; response . setHeader ( HTTP_HEADER_NAME_CONTENT_TYPE , CONTENT_TYPE_XML ) ; XMLStructuredOutput ou...
GET a list of all buckets
337
6
41,349
private void readObject ( WebContext ctx , String bucketName , String objectId ) throws IOException { Bucket bucket = storage . getBucket ( bucketName ) ; String id = objectId . replace ( ' ' , ' ' ) ; String uploadId = ctx . get ( "uploadId" ) . asString ( ) ; if ( ! checkObjectRequest ( ctx , bucket , id ) ) { return...
Dispatching method handling all object specific calls which either read or delete the object but do not provide any data .
263
22
41,350
public boolean supports ( final WebContext ctx ) { return AWS_AUTH4_PATTERN . matcher ( ctx . getHeaderValue ( "Authorization" ) . asString ( "" ) ) . matches ( ) || X_AMZ_CREDENTIAL_PATTERN . matcher ( ctx . get ( "X-Amz-Credential" ) . asString ( "" ) ) . matches ( ) ; }
Determines if the given request contains an AWS4 auth token .
95
14
41,351
public String getBasePath ( ) { StringBuilder sb = new StringBuilder ( getBaseDirUnchecked ( ) . getAbsolutePath ( ) ) ; if ( ! getBaseDirUnchecked ( ) . exists ( ) ) { sb . append ( " (non-existent!)" ) ; } else if ( ! getBaseDirUnchecked ( ) . isDirectory ( ) ) { sb . append ( " (no directory!)" ) ; } else { sb . app...
Returns the base directory as string .
149
7
41,352
public List < Bucket > getBuckets ( ) { List < Bucket > result = Lists . newArrayList ( ) ; for ( File file : getBaseDir ( ) . listFiles ( ) ) { if ( file . isDirectory ( ) ) { result . add ( new Bucket ( file ) ) ; } } return result ; }
Enumerates all known buckets .
70
7
41,353
public Bucket getBucket ( String bucket ) { if ( bucket . contains ( ".." ) || bucket . contains ( "/" ) || bucket . contains ( "\\" ) ) { throw Exceptions . createHandled ( ) . withSystemErrorMessage ( "Invalid bucket name: %s. A bucket name must not contain '..' '/' or '\\'" , bucket ) . handle ( ) ; } return new Buc...
Returns a bucket with the given name
104
7
41,354
public void delete ( ) { if ( ! file . delete ( ) ) { Storage . LOG . WARN ( "Failed to delete data file for object %s (%s)." , getName ( ) , file . getAbsolutePath ( ) ) ; } if ( ! getPropertiesFile ( ) . delete ( ) ) { Storage . LOG . WARN ( "Failed to delete properties file for object %s (%s)." , getName ( ) , getPr...
Deletes the object
111
4
41,355
public void storeProperties ( Map < String , String > properties ) throws IOException { Properties props = new Properties ( ) ; properties . forEach ( props :: setProperty ) ; try ( FileOutputStream out = new FileOutputStream ( getPropertiesFile ( ) ) ) { props . store ( out , "" ) ; } }
Stores the given meta infos for the stored object .
69
12
41,356
public boolean delete ( ) { boolean deleted = false ; for ( File child : file . listFiles ( ) ) { deleted = child . delete ( ) || deleted ; } deleted = file . delete ( ) || deleted ; return deleted ; }
Deletes the bucket and all of its contents .
49
10
41,357
public void makePrivate ( ) { if ( getPublicMarkerFile ( ) . exists ( ) ) { if ( getPublicMarkerFile ( ) . delete ( ) ) { publicAccessCache . put ( getName ( ) , false ) ; } else { Storage . LOG . WARN ( "Failed to delete public marker for bucket %s - it remains public!" , getName ( ) ) ; } } }
Marks the bucket as private accessible .
86
8
41,358
public void makePublic ( ) { if ( ! getPublicMarkerFile ( ) . exists ( ) ) { try { new FileOutputStream ( getPublicMarkerFile ( ) ) . close ( ) ; } catch ( IOException e ) { throw Exceptions . handle ( Storage . LOG , e ) ; } } publicAccessCache . put ( getName ( ) , true ) ; }
Marks the bucket as public accessible .
81
8
41,359
public StoredObject getObject ( String id ) { if ( id . contains ( ".." ) || id . contains ( "/" ) || id . contains ( "\\" ) ) { throw Exceptions . createHandled ( ) . withSystemErrorMessage ( "Invalid object name: %s. A object name must not contain '..' '/' or '\\'" , id ) . handle ( ) ; } return new StoredObject ( ne...
Returns the child object with the given id .
103
9
41,360
@ Override public void start ( ) { if ( layout == null ) { initializationFailed = true ; addError ( "Invalid configuration - No layout for appender: " + name ) ; return ; } if ( streamName == null ) { initializationFailed = true ; addError ( "Invalid configuration - streamName cannot be null for appender: " + name ) ; ...
Configures appender instance and makes it ready for use by the consumers . It validates mandatory parameters and confirms if the configured stream is ready for publishing data yet .
418
33
41,361
@ Override public void stop ( ) { threadPoolExecutor . shutdown ( ) ; BlockingQueue < Runnable > taskQueue = threadPoolExecutor . getQueue ( ) ; int bufferSizeBeforeShutdown = threadPoolExecutor . getQueue ( ) . size ( ) ; boolean gracefulShutdown = true ; try { gracefulShutdown = threadPoolExecutor . awaitTermination ...
Closes this appender instance . Before exiting the implementation tries to flush out buffered log events within configured shutdownTimeout seconds . If that doesn t finish within configured shutdownTimeout it would drop all the buffered log events .
236
44
41,362
private Region findRegion ( ) { boolean regionProvided = ! Validator . isBlank ( this . region ) ; if ( ! regionProvided ) { // Determine region from where application is running, or fall back to default region Region currentRegion = Regions . getCurrentRegion ( ) ; if ( currentRegion != null ) { return currentRegion ;...
Determine region . If not specified tries to determine region from where the application is running or fall back to the default .
117
25
41,363
public void setStreamName ( String streamName ) { Validator . validate ( ! Validator . isBlank ( streamName ) , "streamName cannot be blank" ) ; this . streamName = streamName . trim ( ) ; }
Sets streamName for the kinesis stream to which data is to be published .
50
18
41,364
public void setEncoding ( String charset ) { Validator . validate ( ! Validator . isBlank ( charset ) , "encoding cannot be blank" ) ; this . encoding = charset . trim ( ) ; }
Sets encoding for the data to be published . If none specified default is UTF - 8
49
18
41,365
@ SuppressWarnings ( "unchecked" ) public < T > T getProperty ( String key , Class < T > cls ) { if ( properties != null ) { if ( cls != null && cls != Object . class && cls != String . class && ! cls . isInterface ( ) && ! cls . isArray ( ) ) { // engine.getProperty("loaders", ClasspathLoader.class); key = key + "=" +...
Get config instantiated value .
176
6
41,366
public Map < String , Object > createContext ( final Map < String , Object > parent , Map < String , Object > current ) { return new DelegateMap < String , Object > ( parent , current ) { private static final long serialVersionUID = 1L ; @ Override public Object get ( Object key ) { Object value = super . get ( key ) ;...
Create context map .
112
4
41,367
public Template parseTemplate ( String source , Object parameterTypes ) throws ParseException { String name = "/$" + Digest . getMD5 ( source ) ; if ( ! hasResource ( name ) ) { stringLoader . add ( name , source ) ; } try { return getTemplate ( name , parameterTypes ) ; } catch ( IOException e ) { throw new IllegalSta...
Parse string template .
92
5
41,368
public Resource getResource ( String name , Locale locale , String encoding ) throws IOException { name = UrlUtils . cleanName ( name ) ; locale = cleanLocale ( locale ) ; return loadResource ( name , locale , encoding ) ; }
Get resource .
53
3
41,369
public boolean hasResource ( String name , Locale locale ) { name = UrlUtils . cleanName ( name ) ; locale = cleanLocale ( locale ) ; return stringLoader . exists ( name , locale ) || loader . exists ( name , locale ) ; }
Tests whether the resource denoted by this abstract pathname exists .
56
14
41,370
public void init ( ) { if ( logger != null && StringUtils . isNotEmpty ( name ) ) { if ( logger . isWarnEnabled ( ) && ! ConfigUtils . isFilePath ( name ) ) { try { List < String > realPaths = new ArrayList < String > ( ) ; Enumeration < URL > e = Thread . currentThread ( ) . getContextClassLoader ( ) . getResources ( ...
Init the engine .
294
4
41,371
public void inited ( ) { if ( preload ) { try { int count = 0 ; if ( templateSuffix == null ) { templateSuffix = new String [ ] { ".httl" } ; } for ( String suffix : templateSuffix ) { List < String > list = loader . list ( suffix ) ; if ( list == null ) { continue ; } count += list . size ( ) ; for ( String name : lis...
On all inited .
287
5
41,372
public JSONWriter objectBegin ( ) throws IOException { beforeValue ( ) ; writer . write ( JSON . LBRACE ) ; stack . push ( state ) ; state = new State ( OBJECT ) ; return this ; }
object begin .
47
3
41,373
public JSONWriter objectEnd ( ) throws IOException { writer . write ( JSON . RBRACE ) ; state = stack . pop ( ) ; return this ; }
object end .
34
3
41,374
public JSONWriter objectItem ( String name ) throws IOException { beforeObjectItem ( ) ; writer . write ( JSON . QUOTE ) ; writer . write ( escape ( name ) ) ; writer . write ( JSON . QUOTE ) ; writer . write ( JSON . COLON ) ; return this ; }
object item .
63
3
41,375
public JSONWriter arrayBegin ( ) throws IOException { beforeValue ( ) ; writer . write ( JSON . LSQUARE ) ; stack . push ( state ) ; state = new State ( ARRAY ) ; return this ; }
array begin .
47
3
41,376
public JSONWriter arrayEnd ( ) throws IOException { writer . write ( JSON . RSQUARE ) ; state = stack . pop ( ) ; return this ; }
array end return array value .
34
6
41,377
public MultiFormatter add ( Formatter < ? > ... formatters ) { if ( formatter != null ) { MultiFormatter copy = new MultiFormatter ( ) ; copy . formatters . putAll ( this . formatters ) ; copy . setFormatters ( formatters ) ; return copy ; } return this ; }
Add and copy the MultiFormatter .
68
8
41,378
public MultiFormatter remove ( Formatter < ? > ... formatters ) { if ( formatter != null ) { MultiFormatter copy = new MultiFormatter ( ) ; copy . formatters . putAll ( this . formatters ) ; if ( formatters != null && formatters . length > 0 ) { for ( Formatter < ? > formatter : formatters ) { if ( formatter != null ) ...
Remove and copy the MultiFormatter .
139
8
41,379
public static Properties loadProperties ( String path , boolean required ) { Properties properties = new Properties ( ) ; return loadProperties ( properties , path , required ) ; }
Load properties file
35
3
41,380
public static String json ( Object obj , boolean writeClass , Converter < Object , Map < String , Object > > mc ) throws IOException { if ( obj == null ) return NULL ; StringWriter sw = new StringWriter ( ) ; try { json ( obj , sw , writeClass , mc ) ; return sw . getBuffer ( ) . toString ( ) ; } finally { sw . close (...
json string .
87
3
41,381
void tryToDrainBuffers ( ) { if ( evictionLock . tryLock ( ) ) { try { drainStatus . set ( PROCESSING ) ; drainBuffers ( ) ; } finally { drainStatus . compareAndSet ( PROCESSING , IDLE ) ; evictionLock . unlock ( ) ; } } }
Attempts to acquire the eviction lock and apply the pending operations up to the amortized threshold to the page replacement policy .
67
24
41,382
void drainBuffers ( ) { // 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 array in O(n) time by using // counting sort and chaining on a collision. // Moves the tasks into the output a...
Drains the buffers up to the amortized threshold and applies the pending operations .
127
17
41,383
int moveTasksFromBuffers ( Task [ ] tasks ) { int maxTaskIndex = - 1 ; for ( int i = 0 ; i < buffers . length ; i ++ ) { int maxIndex = moveTasksFromBuffer ( tasks , i ) ; maxTaskIndex = Math . max ( maxIndex , maxTaskIndex ) ; } return maxTaskIndex ; }
Moves the tasks from the buffers into the output array .
77
12
41,384
int moveTasksFromBuffer ( Task [ ] tasks , int bufferIndex ) { // While a buffer is being drained it may be concurrently appended to. // The // number of tasks removed are tracked so that the length can be // decremented // by the delta rather than set to zero. Queue < Task > buffer = buffers [ bufferIndex ] ; int remo...
Moves the tasks from the specified buffer into the output array .
314
13
41,385
void addTaskToChain ( Task [ ] tasks , Task task , int index ) { task . setNext ( tasks [ index ] ) ; tasks [ index ] = task ; }
Adds the task as the head of the chain at the index location .
37
14
41,386
void updateDrainedOrder ( Task [ ] tasks , int maxTaskIndex ) { if ( maxTaskIndex >= 0 ) { Task task = tasks [ maxTaskIndex ] ; drainedOrder = task . getOrder ( ) + 1 ; } }
Updates the order to start the next drain from .
50
11
41,387
V put ( K key , V value , boolean onlyIfAbsent ) { checkNotNull ( key ) ; checkNotNull ( value ) ; final int weight = weigher . weightOf ( key , value ) ; final WeightedValue < V > weightedValue = new WeightedValue < V > ( value , weight ) ; final Node node = new Node ( key , weightedValue ) ; for ( ; ; ) { final Node ...
Adds a node to the list and the data store . If an existing node is found then its value is updated if allowed .
285
25
41,388
public static Engine getEngine ( String configPath , Properties configProperties ) { if ( StringUtils . isEmpty ( configPath ) ) { configPath = HTTL_PROPERTIES ; } VolatileReference < Engine > reference = ENGINES . get ( configPath ) ; if ( reference == null ) { reference = new VolatileReference < Engine > ( ) ; // qui...
Get template engine singleton .
217
6
41,389
public String getProperty ( String key , String defaultValue ) { String value = getProperty ( key , String . class ) ; return StringUtils . isEmpty ( value ) ? defaultValue : value ; }
Get config value .
43
4
41,390
public int getProperty ( String key , int defaultValue ) { String value = getProperty ( key , String . class ) ; return StringUtils . isEmpty ( value ) ? defaultValue : Integer . parseInt ( value ) ; }
Get config int value .
49
5
41,391
public boolean getProperty ( String key , boolean defaultValue ) { String value = getProperty ( key , String . class ) ; return StringUtils . isEmpty ( value ) ? defaultValue : Boolean . parseBoolean ( value ) ; }
Get config boolean value .
50
5
41,392
private void processInput ( boolean endOfInput ) throws IOException { // Prepare decoderIn for reading decoderIn . flip ( ) ; CoderResult coderResult ; while ( true ) { coderResult = decoder . decode ( decoderIn , decoderOut , endOfInput ) ; if ( coderResult . isOverflow ( ) ) { flushOutput ( ) ; } else if ( coderResul...
Decode the contents of the input ByteBuffer into a CharBuffer .
160
14
41,393
private void flushOutput ( ) throws IOException { if ( decoderOut . position ( ) > 0 ) { writer . write ( decoderOut . array ( ) , 0 , decoderOut . position ( ) ) ; decoderOut . rewind ( ) ; } }
Flush the output .
57
5
41,394
public static Context getContext ( ) { Context context = LOCAL . get ( ) ; if ( context == null ) { context = new Context ( null , null ) ; LOCAL . set ( context ) ; } return context ; }
Get the current context from thread local .
48
8
41,395
public static Context pushContext ( Map < String , Object > current ) { Context context = new Context ( getContext ( ) , current ) ; LOCAL . set ( context ) ; return context ; }
Push the current context to thread local .
41
8
41,396
public static void popContext ( ) { Context context = LOCAL . get ( ) ; if ( context != null ) { Context parent = context . getParent ( ) ; if ( parent != null ) { LOCAL . set ( parent ) ; } else { LOCAL . remove ( ) ; } } }
Pop the current context from thread local and restore parent context to thread local .
63
15
41,397
private void checkThread ( ) { if ( Thread . currentThread ( ) != thread ) { throw new IllegalStateException ( "Don't cross-thread using the " + Context . class . getName ( ) + " object, it's thread-local only. context thread: " + thread . getName ( ) + ", current thread: " + Thread . currentThread ( ) . getName ( ) ) ...
Check the cross - thread use .
87
7
41,398
private void setCurrent ( Map < String , Object > current ) { if ( current instanceof Context ) { throw new IllegalArgumentException ( "Don't using the " + Context . class . getName ( ) + " object as a parameters, it's implicitly delivery by thread-local. parameter context: " + ( ( Context ) current ) . thread . getNam...
Set the current context
101
4
41,399
public Context setTemplate ( Template template ) { checkThread ( ) ; if ( template != null ) { setEngine ( template . getEngine ( ) ) ; } this . template = template ; return this ; }
Set the current template .
43
5