idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
13,900
public String getAnswerPattern ( ) { if ( InputElement_Type . featOkTst && ( ( InputElement_Type ) jcasType ) . casFeat_answerPattern == null ) jcasType . jcas . throwFeatMissing ( "answerPattern" , "edu.cmu.lti.oaqa.framework.types.InputElement" ) ; return jcasType . ll_cas . ll_getStringValue ( addr , ( ( InputElement_Type ) jcasType ) . casFeatCode_answerPattern ) ; }
getter for answerPattern - gets
13,901
public void setAnswerPattern ( String v ) { if ( InputElement_Type . featOkTst && ( ( InputElement_Type ) jcasType ) . casFeat_answerPattern == null ) jcasType . jcas . throwFeatMissing ( "answerPattern" , "edu.cmu.lti.oaqa.framework.types.InputElement" ) ; jcasType . ll_cas . ll_setStringValue ( addr , ( ( InputElement_Type ) jcasType ) . casFeatCode_answerPattern , v ) ; }
setter for answerPattern - sets
13,902
public String getDataset ( ) { if ( InputElement_Type . featOkTst && ( ( InputElement_Type ) jcasType ) . casFeat_dataset == null ) jcasType . jcas . throwFeatMissing ( "dataset" , "edu.cmu.lti.oaqa.framework.types.InputElement" ) ; return jcasType . ll_cas . ll_getStringValue ( addr , ( ( InputElement_Type ) jcasType ) . casFeatCode_dataset ) ; }
getter for dataset - gets
13,903
public void setDataset ( String v ) { if ( InputElement_Type . featOkTst && ( ( InputElement_Type ) jcasType ) . casFeat_dataset == null ) jcasType . jcas . throwFeatMissing ( "dataset" , "edu.cmu.lti.oaqa.framework.types.InputElement" ) ; jcasType . ll_cas . ll_setStringValue ( addr , ( ( InputElement_Type ) jcasType ) . casFeatCode_dataset , v ) ; }
setter for dataset - sets
13,904
public String getQuuid ( ) { if ( InputElement_Type . featOkTst && ( ( InputElement_Type ) jcasType ) . casFeat_quuid == null ) jcasType . jcas . throwFeatMissing ( "quuid" , "edu.cmu.lti.oaqa.framework.types.InputElement" ) ; return jcasType . ll_cas . ll_getStringValue ( addr , ( ( InputElement_Type ) jcasType ) . casFeatCode_quuid ) ; }
getter for quuid - gets
13,905
public void setQuuid ( String v ) { if ( InputElement_Type . featOkTst && ( ( InputElement_Type ) jcasType ) . casFeat_quuid == null ) jcasType . jcas . throwFeatMissing ( "quuid" , "edu.cmu.lti.oaqa.framework.types.InputElement" ) ; jcasType . ll_cas . ll_setStringValue ( addr , ( ( InputElement_Type ) jcasType ) . casFeatCode_quuid , v ) ; }
setter for quuid - sets
13,906
public Bucket < Data > getEmptyBucketWithSameProperties ( ) throws FileLockException , IOException { Bucket < Data > newBucket = new Bucket < Data > ( this . bucketId , gp ) ; return newBucket ; }
returns a new empty Bucket with the same properties of this bucket
13,907
public int freeMemory ( ) { int size = 0 ; for ( int m = 0 ; m < memory . length ; m ++ ) { size += memory [ m ] . length ; memory [ m ] = null ; } memory = null ; return size ; }
This method frees the allocated memory .
13,908
public boolean isDisplayed ( String other ) { return ( getDisplay ( ) == null || getDisplay ( ) . compareTo ( "all" ) == 0 || getDisplay ( ) . indexOf ( other ) != - 1 ) ; }
Determine if this operation is visible in another .
13,909
private void handleInvalidCORS ( final HttpServletRequest request , final HttpServletResponse response , final FilterChain filterChain ) { String origin = request . getHeader ( CorsFilter . REQUEST_HEADER_ORIGIN ) ; String method = request . getMethod ( ) ; String accessControlRequestHeaders = request . getHeader ( REQUEST_HEADER_ACCESS_CONTROL_REQUEST_HEADERS ) ; response . setContentType ( "text/plain" ) ; response . setStatus ( HttpServletResponse . SC_FORBIDDEN ) ; response . resetBuffer ( ) ; if ( log . isDebugEnabled ( ) ) { StringBuilder message = new StringBuilder ( "Invalid CORS request; Origin=" ) ; message . append ( origin ) ; message . append ( ";Method=" ) ; message . append ( method ) ; if ( accessControlRequestHeaders != null ) { message . append ( ";Access-Control-Request-Headers=" ) ; message . append ( accessControlRequestHeaders ) ; } log . debug ( message . toString ( ) ) ; } }
Handles a CORS request that violates specification .
13,910
public UnprotectedStringBuffer getNamespaceURI ( CharSequence namespacePrefix ) { for ( ElementContext ctx : event . context ) { for ( Pair < UnprotectedStringBuffer , UnprotectedStringBuffer > ns : ctx . namespaces ) if ( ns . getValue1 ( ) . equals ( namespacePrefix ) ) return ns . getValue2 ( ) ; } return new UnprotectedStringBuffer ( ) ; }
Get the namespace URI for a prefix or empty string if the prefix is not defined .
13,911
public Attribute getAttributeByFullName ( CharSequence name ) { for ( Attribute attr : event . attributes ) if ( attr . text . equals ( name ) ) return attr ; return null ; }
Shortcut to get the attribute for the given full name .
13,912
public Attribute getAttributeByLocalName ( CharSequence name ) { for ( Attribute attr : event . attributes ) if ( attr . localName . equals ( name ) ) return attr ; return null ; }
Shortcut to get the attibute for the given local name .
13,913
public Attribute getAttributeWithPrefix ( CharSequence prefix , CharSequence name ) { for ( Attribute attr : event . attributes ) if ( attr . localName . equals ( name ) && attr . namespacePrefix . equals ( prefix ) ) return attr ; return null ; }
Shortcut to get the attribute for the given namespace prefix and local name .
13,914
public Attribute getAttributeWithNamespaceURI ( CharSequence uri , CharSequence name ) { for ( Attribute attr : event . attributes ) if ( attr . localName . equals ( name ) && getNamespaceURI ( attr . namespacePrefix ) . equals ( uri ) ) return attr ; return null ; }
Shortcut to get the attribute for the given namespace URI and local name .
13,915
public Attribute removeAttributeByFullName ( CharSequence name ) { for ( Iterator < Attribute > it = event . attributes . iterator ( ) ; it . hasNext ( ) ; ) { Attribute attr = it . next ( ) ; if ( attr . text . equals ( name ) ) { it . remove ( ) ; return attr ; } } return null ; }
Remove and return the attribute for the given full name if it exists .
13,916
public Attribute removeAttributeByLocalName ( CharSequence name ) { for ( Iterator < Attribute > it = event . attributes . iterator ( ) ; it . hasNext ( ) ; ) { Attribute attr = it . next ( ) ; if ( attr . localName . equals ( name ) ) { it . remove ( ) ; return attr ; } } return null ; }
Remove and return the attibute for the given local name if it exists .
13,917
public Attribute removeAttributeWithPrefix ( CharSequence prefix , CharSequence name ) { for ( Iterator < Attribute > it = event . attributes . iterator ( ) ; it . hasNext ( ) ; ) { Attribute attr = it . next ( ) ; if ( attr . localName . equals ( name ) && attr . namespacePrefix . equals ( prefix ) ) { it . remove ( ) ; return attr ; } } return null ; }
Remove and return the attribute for the given namespace prefix and local name if it exists .
13,918
public Attribute removeAttributeWithNamespaceURI ( CharSequence uri , CharSequence name ) { for ( Iterator < Attribute > it = event . attributes . iterator ( ) ; it . hasNext ( ) ; ) { Attribute attr = it . next ( ) ; if ( attr . localName . equals ( name ) && getNamespaceURI ( attr . namespacePrefix ) . equals ( uri ) ) { it . remove ( ) ; return attr ; } } return null ; }
Remove and return the attribute for the given namespace URI and local name if it exists .
13,919
public static boolean isSpaceChar ( char c ) { if ( c == 0x20 ) return true ; if ( c > 0xD ) return false ; if ( c < 0x9 ) return false ; return isSpace [ c - 9 ] ; }
Return true if the given character is considered as a white space .
13,920
@ SuppressWarnings ( "resource" ) public static ISynchronizationPoint < IOException > savePropertiesFile ( Properties properties , IO . Writable output , Charset charset , byte priority , boolean closeIOAtEnd ) { BufferedWritableCharacterStream stream = new BufferedWritableCharacterStream ( output , charset , 4096 ) ; return savePropertiesFile ( properties , stream , priority , closeIOAtEnd ) ; }
Save properties to a Writable IO .
13,921
public static ISynchronizationPoint < IOException > savePropertiesFile ( Properties properties , ICharacterStream . Writable . Buffered output , byte priority , boolean closeStreamAtEnd ) { SavePropertiesFileTask task = new SavePropertiesFileTask ( properties , output , priority , closeStreamAtEnd ) ; task . start ( ) ; return task . getOutput ( ) ; }
Save properties to a writable character stream .
13,922
private Persona establishOwner ( org . hawkular . accounts . api . model . Resource resource , Persona current ) { while ( resource != null && resource . getPersona ( ) == null ) { resource = resource . getParent ( ) ; } if ( resource != null && resource . getPersona ( ) . equals ( current ) ) { current = null ; } return current ; }
Establishes the owner . If the owner of the parent is the same as the current user then create the resource as being owner - less inheriting the owner from the parent .
13,923
private static void cs_augment ( int k , DZcs A , int [ ] jmatch , int jmatch_offset , int [ ] cheap , int cheap_offset , int [ ] w , int w_offset , int [ ] js , int js_offset , int [ ] is , int is_offset , int [ ] ps , int ps_offset ) { int p , i = - 1 , Ap [ ] = A . p , Ai [ ] = A . i , head = 0 , j ; boolean found = false ; js [ js_offset + 0 ] = k ; while ( head >= 0 ) { j = js [ js_offset + head ] ; if ( w [ w_offset + j ] != k ) { w [ w_offset + j ] = k ; for ( p = cheap [ cheap_offset + j ] ; p < Ap [ j + 1 ] && ! found ; p ++ ) { i = Ai [ p ] ; found = ( jmatch [ jmatch_offset + i ] == - 1 ) ; } cheap [ cheap_offset + j ] = p ; if ( found ) { is [ is_offset + head ] = i ; break ; } ps [ ps_offset + head ] = Ap [ j ] ; } for ( p = ps [ ps_offset + head ] ; p < Ap [ j + 1 ] ; p ++ ) { i = Ai [ p ] ; if ( w [ w_offset + jmatch [ jmatch_offset + i ] ] == k ) continue ; ps [ ps_offset + head ] = p + 1 ; is [ is_offset + head ] = i ; js [ js_offset + ( ++ head ) ] = jmatch [ jmatch_offset + i ] ; break ; } if ( p == Ap [ j + 1 ] ) head -- ; } if ( found ) for ( p = head ; p >= 0 ; p -- ) jmatch [ jmatch_offset + is [ is_offset + p ] ] = js [ js_offset + p ] ; }
find an augmenting path starting at column k and extend the match if found
13,924
protected void validate ( File directory , ValidationOptions option ) { if ( ! directory . exists ( ) ) { this . errors . addError ( "directory <{}> does not exist in file system" , directory . getAbsolutePath ( ) ) ; } else if ( ! directory . isDirectory ( ) ) { this . errors . addError ( "directory <{}> is not a directory" , directory . getAbsolutePath ( ) ) ; } else if ( directory . isHidden ( ) ) { this . errors . addError ( "directory <{}> is a hidden directory" , directory . getAbsolutePath ( ) ) ; } else { switch ( option ) { case AS_SOURCE : if ( ! directory . canRead ( ) ) { this . errors . addError ( "directory <{}> is not readable" , directory . getAbsolutePath ( ) ) ; } break ; case AS_SOURCE_AND_TARGET : if ( ! directory . canRead ( ) ) { this . errors . addError ( "directory <{}> is not readable" , directory . getAbsolutePath ( ) ) ; } if ( ! directory . canWrite ( ) ) { this . errors . addError ( "directory <{}> is not writable" , directory . getAbsolutePath ( ) ) ; } break ; case AS_TARGET : if ( ! directory . canWrite ( ) ) { this . errors . addError ( "directory <{}> is not writable" , directory . getAbsolutePath ( ) ) ; } break ; } } }
Does the actual validation
13,925
public void checkCacheMode ( Boolean boolShouldBeCached ) { try { boolean bCurrentlyCached = ( this . getRemoteTableType ( CachedRemoteTable . class ) != null ) ; if ( ( this . getRecord ( ) . getOpenMode ( ) & DBConstants . OPEN_CACHE_RECORDS ) == DBConstants . OPEN_CACHE_RECORDS ) boolShouldBeCached = Boolean . TRUE ; if ( ( this . getRecord ( ) . getOpenMode ( ) & DBConstants . OPEN_DONT_CACHE ) == DBConstants . OPEN_DONT_CACHE ) boolShouldBeCached = Boolean . FALSE ; if ( boolShouldBeCached == null ) return ; if ( ( ! bCurrentlyCached ) && ( boolShouldBeCached . booleanValue ( ) ) ) { Utility . getLogger ( ) . info ( "Cache ON: " + this . getRecord ( ) . getTableNames ( false ) ) ; this . setRemoteTable ( new CachedRemoteTable ( m_tableRemote ) ) ; } else if ( ( bCurrentlyCached ) && ( ! boolShouldBeCached . booleanValue ( ) ) ) { Utility . getLogger ( ) . info ( "Cache OFF: " + this . getRecord ( ) . getTableNames ( false ) ) ; RemoteTable tableRemote = this . getRemoteTableType ( CachedRemoteTable . class ) . getRemoteTableType ( null ) ; ( ( CachedRemoteTable ) m_tableRemote ) . setRemoteTable ( null ) ; ( ( CachedRemoteTable ) m_tableRemote ) . free ( ) ; this . setRemoteTable ( tableRemote ) ; } } catch ( RemoteException ex ) { } }
Make sure the cache is set up correctly for this type of query .
13,926
public int dataToFields ( Rec record ) throws DBException { try { return ( ( BaseBuffer ) m_dataSource ) . bufferToFields ( ( FieldList ) record , DBConstants . DONT_DISPLAY , DBConstants . READ_MOVE ) ; } catch ( Exception ex ) { throw DatabaseException . toDatabaseException ( ex ) ; } }
Move the data source buffer to all the fields . In this implementation move the local copy of the returned datasource to the fields .
13,927
public void fieldsToData ( Rec record ) throws DBException { try { int iFieldTypes = BaseBuffer . PHYSICAL_FIELDS ; if ( ! ( ( Record ) record ) . isAllSelected ( ) ) iFieldTypes = BaseBuffer . DATA_FIELDS ; m_dataSource = new VectorBuffer ( null , iFieldTypes ) ; ( ( BaseBuffer ) m_dataSource ) . fieldsToBuffer ( ( FieldList ) record ) ; } catch ( Exception ex ) { throw DatabaseException . toDatabaseException ( ex ) ; } }
Move all the fields to the output buffer . In this implementation create a new VectorBuffer and move the fielddata to it .
13,928
public void tableUpdated ( ) { super . tableUpdated ( ) ; synchronized ( unsortedRowsCacheLock ) { unsortedRowsCache = null ; } synchronized ( sortedRowsCacheLock ) { sortedRowsCache = null ; } synchronized ( rowCacheLock ) { rowCacheLoaded = false ; rowCache . clear ( ) ; } }
Clears the global caches when the table is updated .
13,929
public void doInitialKey ( ) { FileListener nextListener = ( FileListener ) this . getNextEnabledListener ( ) ; if ( nextListener != null ) { boolean bOldState = nextListener . setEnabledListener ( false ) ; nextListener . doInitialKey ( ) ; nextListener . setEnabledListener ( bOldState ) ; } else if ( this . getOwner ( ) != null ) this . getOwner ( ) . doInitialKey ( ) ; }
Setup the initial key position in this record ... Save it!
13,930
public void writeField ( ObjectOutputStream daOut , Converter converter ) throws IOException { String strFieldName = DBConstants . BLANK ; if ( converter != null ) if ( converter . getField ( ) != null ) strFieldName = converter . getField ( ) . getClass ( ) . getName ( ) ; Object data = null ; if ( converter != null ) data = converter . getData ( ) ; daOut . writeUTF ( strFieldName ) ; daOut . writeObject ( data ) ; }
Encode and write this field s data to the stream .
13,931
public BaseField readField ( ObjectInputStream daIn , BaseField fldCurrent ) throws IOException , ClassNotFoundException { String strFieldName = daIn . readUTF ( ) ; Object objData = daIn . readObject ( ) ; if ( fldCurrent == null ) if ( strFieldName . length ( ) > 0 ) { fldCurrent = ( BaseField ) ClassServiceUtility . getClassService ( ) . makeObjectFromClassName ( strFieldName ) ; if ( fldCurrent != null ) { fldCurrent . init ( null , null , DBConstants . DEFAULT_FIELD_LENGTH , null , null ) ; if ( this . getOwner ( ) != null ) this . getOwner ( ) . addListener ( new RemoveConverterOnCloseHandler ( fldCurrent ) ) ; } } if ( fldCurrent != null ) fldCurrent . setData ( objData ) ; return fldCurrent ; }
Decode and read this field from the stream . Will create a new field init it and set the data if the field is not passed in .
13,932
public static void clean ( String suffix ) { try { CtClass ctClass = POOL . getCtClass ( AbstractFelixCommandsService . class . getName ( ) + suffix ) ; ctClass . defrost ( ) ; ctClass . detach ( ) ; } catch ( NotFoundException e ) { LOG . log ( Level . WARNING , "Unable to clean Console Service. " + e . getMessage ( ) , e ) ; } }
Detach generated class
13,933
public String getSQLType ( boolean bIncludeLength , Map < String , Object > properties ) { String strType = ( String ) properties . get ( DBSQLTypes . SHORT ) ; if ( strType == null ) strType = DBSQLTypes . SMALLINT ; return strType ; }
Get the SQL type of this field . Typically SHORT or SMALLINT .
13,934
public static String urlEncode ( final String text ) throws Exception { ByteArrayOutputStream buffer = new ByteArrayOutputStream ( ) ; for ( int b : toUTF8Bytes ( text ) ) { if ( b < 0 ) { b = 256 + b ; } if ( UNRESERVED_CHARS . get ( b ) ) { buffer . write ( b ) ; } else { buffer . write ( URL_ESCAPE_CHAR ) ; char hex1 = Character . toUpperCase ( Character . forDigit ( ( b >> 4 ) & 0xF , 16 ) ) ; char hex2 = Character . toUpperCase ( Character . forDigit ( b & 0xF , 16 ) ) ; buffer . write ( hex1 ) ; buffer . write ( hex2 ) ; } } return new String ( buffer . toByteArray ( ) ) ; }
Encodes the given text .
13,935
public int submitFilePathOrClasspath ( String filePathOrResourceClasspath ) { return submitStream ( JMOptional . getOptional ( JMFiles . readLines ( filePathOrResourceClasspath ) ) . orElseGet ( ( ) -> JMResources . readLines ( filePathOrResourceClasspath ) ) . stream ( ) ) ; }
Submit file path or classpath int .
13,936
public int getSolverLength ( ) { int length = 4 + 8 + 4 ; if ( this . identifier != null ) { try { length += this . identifier . getBytes ( "UTF-16BE" ) . length ; } catch ( UnsupportedEncodingException e ) { throw new RuntimeException ( "Unable to encode UTF16 strings." , e ) ; } } length += 4 ; if ( this . data != null ) { length += this . data . length ; } return length ; }
Returns the length of this attribute in bytes as encoded according to the Solver - World Model protocol .
13,937
public void basicValidate ( final String section ) throws ConfigException { if ( StringUtils . isEmpty ( host ) || port == null || port <= 0 || port > MAX_PORT ) { throw new ConfigException ( section , "Invalid host and port" ) ; } }
Returns the validation state of the config
13,938
public ErrorLogger getLogger ( final String name ) { if ( name == null || name . equals ( "" ) ) return null ; if ( ! hasLog ( name ) ) { addLog ( name ) ; } return getLog ( name ) ; }
Gets a logger for a specified name . If the logger doesn t exist then it creates one .
13,939
public ErrorLogger getLog ( final String name ) { return hasLog ( name ) ? logs . get ( name ) : null ; }
Gets the error log
13,940
public void addLog ( final String name ) { ErrorLogger log = new ErrorLogger ( name ) ; logs . put ( name , log ) ; log . setVerboseDebug ( debugLevel ) ; }
Adds the error log
13,941
public List < LogMessage > getLogs ( ) { final ArrayList < LogMessage > messages = new ArrayList < LogMessage > ( ) ; for ( final String logName : logs . keySet ( ) ) { messages . addAll ( logs . get ( logName ) . getLogMessages ( ) ) ; } Collections . sort ( messages , new LogMessageComparator ( ) ) ; return messages ; }
Gets a list of all of the logs that are managed .
13,942
public void setPropertiesField ( Field fldProperties ) { if ( fldProperties != null ) { m_fldProperties = ( PropertiesField ) fldProperties ; this . loadFieldProperties ( ) ; this . addListener ( new FileListener ( null ) { public void setOwner ( ListenerOwner owner ) { if ( owner == null ) if ( this . getOwner ( ) != null ) ( ( PropertiesInput ) PropertiesInput . this ) . restoreFieldProperties ( ) ; super . setOwner ( owner ) ; } } ) ; } }
SetPropertiesField Method .
13,943
public void loadFieldProperties ( Field fldProperties ) { if ( fldProperties == null ) return ; boolean [ ] rgbEnabled = this . setEnableListeners ( false ) ; ; try { this . setKeyArea ( PropertiesInput . KEY_KEY ) ; this . close ( ) ; while ( this . hasNext ( ) ) { this . next ( ) ; this . edit ( ) ; this . remove ( ) ; } Map < String , Object > properties = ( ( PropertiesField ) fldProperties ) . getProperties ( ) ; Iterator < String > iterator = properties . keySet ( ) . iterator ( ) ; while ( iterator . hasNext ( ) ) { String strKey = iterator . next ( ) ; String strValue = ( String ) properties . get ( strKey ) ; this . addNew ( ) ; this . getField ( PropertiesInput . KEY ) . setString ( strKey ) ; if ( this . seek ( null ) ) { this . edit ( ) ; this . remove ( ) ; } this . addNew ( ) ; this . getField ( PropertiesInput . KEY ) . setString ( strKey ) ; this . getField ( PropertiesInput . VALUE ) . setString ( strValue ) ; this . add ( ) ; } if ( this . getRecordOwner ( ) instanceof GridScreen ) ( ( GridScreen ) this . getRecordOwner ( ) ) . reSelectRecords ( ) ; } catch ( DBException ex ) { ex . printStackTrace ( ) ; } finally { this . setEnableListeners ( rgbEnabled ) ; } }
LoadFieldProperties Method .
13,944
public void restoreFieldProperties ( PropertiesField fldProperties ) { if ( fldProperties == null ) return ; try { Map < String , Object > properties = fldProperties . getProperties ( ) ; this . close ( ) ; while ( this . hasNext ( ) ) { this . next ( ) ; String strKey = this . getField ( PropertiesInput . KEY ) . getString ( ) ; String strValue = this . getField ( PropertiesInput . VALUE ) . getString ( ) ; if ( strValue != null ) if ( strValue . length ( ) > 0 ) { fldProperties . setProperty ( strKey , strValue ) ; properties . remove ( strKey ) ; } } Iterator < String > iterator = properties . keySet ( ) . iterator ( ) ; while ( iterator . hasNext ( ) ) { String strKey = iterator . next ( ) ; fldProperties . setProperty ( strKey , null ) ; } } catch ( DBException ex ) { ex . printStackTrace ( ) ; } }
RestoreFieldProperties Method .
13,945
private static Predicate < Triple > inDomainRangeFilter ( final String domain ) { return triple -> propertiesWithInDomainRange . contains ( triple . getPredicate ( ) ) && ! triple . getObject ( ) . ntriplesString ( ) . startsWith ( "<" + domain ) ; }
Verify that the range of the property is in the repository domain
13,946
public void initialize ( Map < String , String > params ) throws WPBIOException { try { memcacheClient = new WPBMemCacheClient ( ) ; String address = "" ; if ( params != null && params . get ( CONFIG_MEMCACHE_SERVERS ) != null ) { address = params . get ( CONFIG_MEMCACHE_SERVERS ) ; } memcacheClient . initialize ( address ) ; if ( params . get ( CONFIG_MEMCACHE_CHECK_INTERVAL ) != null ) { try { sleepTime = Integer . valueOf ( params . get ( CONFIG_MEMCACHE_CHECK_INTERVAL ) ) ; } catch ( NumberFormatException e ) { } } WPBMemCacheSyncRunnable syncRunnable = new WPBMemCacheSyncRunnable ( this , memcacheClient , sleepTime ) ; ( new Thread ( syncRunnable ) ) . start ( ) ; } catch ( IOException e ) { throw new WPBIOException ( "cannot create memcache client" , e ) ; } }
default sleep time is 10 seconds
13,947
public void init ( Record record , Record recordToSync , boolean bUpdateOnSelect ) { super . init ( record , null , recordToSync , bUpdateOnSelect , DBConstants . SELECT_TYPE ) ; }
SelectOnUpdateHandler - Constructor .
13,948
public int doErrorReturn ( int iChangeType , int iErrorCode ) { if ( iChangeType == DBConstants . AFTER_UPDATE_TYPE ) if ( this . isModLockMode ( ) ) { if ( this . getOwner ( ) . getTable ( ) . getCurrentTable ( ) == this . getOwner ( ) . getTable ( ) ) { boolean bRunMergeCode = false ; if ( ( this . getOwner ( ) . getMasterSlave ( ) & RecordOwner . MASTER ) != 0 ) if ( ( this . getOwner ( ) . getDatabaseType ( ) & DBConstants . SERVER_REWRITES ) == 0 ) bRunMergeCode = true ; if ( ( this . getOwner ( ) . getMasterSlave ( ) & RecordOwner . SLAVE ) != 0 ) if ( ( this . getOwner ( ) . getDatabaseType ( ) & DBConstants . SERVER_REWRITES ) != 0 ) bRunMergeCode = true ; if ( bRunMergeCode ) return this . refreshMergeAndRewrite ( iErrorCode ) ; } } return super . doErrorReturn ( iChangeType , iErrorCode ) ; }
Called when a error happens on a file operation return the error code or fix the problem .
13,949
public boolean isModLockMode ( ) { Record record = this . getOwner ( ) ; if ( record != null ) if ( ( record . getOpenMode ( ) & DBConstants . OPEN_LAST_MOD_LOCK_TYPE ) == DBConstants . OPEN_LAST_MOD_LOCK_TYPE ) return true ; return false ; }
Am I checking for modification locks?
13,950
public void setTheDate ( ) { boolean [ ] rgbEnabled = m_field . setEnableListeners ( false ) ; Calendar calAfter = m_field . getCalendar ( ) ; Calendar calBefore = m_field . getCalendar ( ) ; m_field . setValue ( DateTimeField . currentTime ( ) , DBConstants . DISPLAY , DBConstants . SCREEN_MOVE ) ; calAfter = m_field . getCalendar ( ) ; if ( calBefore != null ) if ( calAfter . before ( calBefore ) ) calAfter = calBefore ; if ( calAfter != null ) if ( calAfter . equals ( calBefore ) ) { calAfter . add ( Calendar . SECOND , 1 ) ; m_field . setCalendar ( calAfter , DBConstants . DISPLAY , DBConstants . SCREEN_MOVE ) ; } Utility . getLogger ( ) . info ( "Set date: " + m_field . toString ( ) ) ; m_field . setEnableListeners ( rgbEnabled ) ; }
Set the date field to the current time . Also make sure the time is not the same as it is currently .
13,951
public void clearTemporaryKeyField ( ) { Record record = this . getOwner ( ) ; KeyArea keyArea = record . getKeyArea ( 0 ) ; if ( keyArea . getKeyFields ( false , true ) == 2 ) if ( m_fakeKeyField != null ) keyArea . removeKeyField ( m_fakeKeyField ) ; }
Remove the temporary key field .
13,952
public static < E > void swap ( E [ ] array1 , int array1Index , E [ ] array2 , int array2Index ) { if ( array1 [ array1Index ] != array2 [ array2Index ] ) { E hold = array1 [ array1Index ] ; array1 [ array1Index ] = array2 [ array2Index ] ; array2 [ array2Index ] = hold ; } }
Swap the elements of two arrays at the specified positions .
13,953
public static < E > void swap ( E [ ] array1 , E [ ] array2 , int index ) { TrivialSwap . swap ( array1 , index , array2 , index ) ; }
Swap the elements of two arrays at the same position
13,954
public static < E > void swap ( E [ ] array , int index1 , int index2 ) { TrivialSwap . swap ( array , index1 , array , index2 ) ; }
Swap two elements of array at the specified positions
13,955
public static < E > void swap ( List < E > list1 , int list1Index , List < E > list2 , int list2Index ) { if ( list1 . get ( list1Index ) != list2 . get ( list2Index ) ) { E hold = list1 . remove ( list1Index ) ; if ( list1 != list2 || list1Index > list2Index ) { list1 . add ( list1Index , list2 . get ( list2Index ) ) ; } else { list1 . add ( list1Index , list2 . get ( list2Index - 1 ) ) ; } list2 . remove ( list2Index ) ; list2 . add ( list2Index , hold ) ; } }
Swap the elements of two lists at the specified positions . The run time of this method depends on the implementation of the lists since elements are removed and added in the lists .
13,956
public static < E > void swap ( List < E > list1 , List < E > list2 , int index ) { TrivialSwap . swap ( list1 , index , list2 , index ) ; }
Swap all the elements of two lists at the same position . The run time of this method depends on the implementation of the lists since elements are removed and added in the lists .
13,957
public static < E > void swap ( List < E > list , int index1 , int index2 ) { TrivialSwap . swap ( list , index1 , list , index2 ) ; }
Swap two elements of a list at the specified positions . The run time of this method depends on the implementation of the lists since elements are removed and added in the lists .
13,958
public static < E > void swap ( List < E > list1 , List < E > list2 ) { int minLength = Math . min ( list1 . size ( ) , list2 . size ( ) ) ; for ( int i = 0 ; i < minLength ; i ++ ) { TrivialSwap . swap ( list1 , list2 , i ) ; } }
Helper method that swaps all the elements of the arrays . The run time of this method depends on the implementation of the lists since elements are removed and added in the lists . It also depends on the length of the shortest list .
13,959
public static void swap ( int [ ] intArray1 , int array1Index , int [ ] intArray2 , int array2Index ) { if ( intArray1 [ array1Index ] != intArray2 [ array2Index ] ) { int hold = intArray1 [ array1Index ] ; intArray1 [ array1Index ] = intArray2 [ array2Index ] ; intArray2 [ array2Index ] = hold ; } }
Swap the elements of two int arrays at the specified positions .
13,960
public static void swap ( short [ ] shortArray1 , int array1Index , short [ ] shortArray2 , int array2Index ) { if ( shortArray1 [ array1Index ] != shortArray2 [ array2Index ] ) { short hold = shortArray1 [ array1Index ] ; shortArray1 [ array1Index ] = shortArray2 [ array2Index ] ; shortArray2 [ array2Index ] = hold ; } }
Swap the elements of two short arrays at the specified positions .
13,961
public static void swap ( short [ ] shortArray1 , short [ ] shortArray2 , int index ) { TrivialSwap . swap ( shortArray1 , index , shortArray2 , index ) ; }
Swap the elements of two short arrays at the same position
13,962
public static void swap ( float [ ] floatArray1 , int array1Index , float [ ] floatArray2 , int array2Index ) { if ( floatArray1 [ array1Index ] != floatArray2 [ array2Index ] ) { float hold = floatArray1 [ array1Index ] ; floatArray1 [ array1Index ] = floatArray2 [ array2Index ] ; floatArray2 [ array2Index ] = hold ; } }
Swap the elements of two float arrays at the specified positions .
13,963
public static void swap ( float [ ] floatArray1 , float [ ] floatArray2 , int index ) { TrivialSwap . swap ( floatArray1 , index , floatArray2 , index ) ; }
Swap the elements of two float arrays at the same position
13,964
public static void swap ( float [ ] floatArray , int index1 , int index2 ) { TrivialSwap . swap ( floatArray , index1 , floatArray , index2 ) ; }
Swap two elements of a float array at the specified positions
13,965
public static void swap ( double [ ] doubleArray1 , int array1Index , double [ ] doubleArray2 , int array2Index ) { if ( doubleArray1 [ array1Index ] != doubleArray2 [ array2Index ] ) { double hold = doubleArray1 [ array1Index ] ; doubleArray1 [ array1Index ] = doubleArray2 [ array2Index ] ; doubleArray2 [ array2Index ] = hold ; } }
Swap the elements of two double arrays at the specified positions .
13,966
public static void swap ( double [ ] doubleArray1 , double [ ] doubleArray2 , int index ) { TrivialSwap . swap ( doubleArray1 , index , doubleArray2 , index ) ; }
Swap the elements of two double arrays at the same position
13,967
public static void swap ( double [ ] doubleArray , int index1 , int index2 ) { TrivialSwap . swap ( doubleArray , index1 , doubleArray , index2 ) ; }
Swap two elements of a double array at the specified positions
13,968
public static Path getFile ( HttpServletRequest request ) throws IOException { Path result = null ; DiskFileItemFactory factory = new DiskFileItemFactory ( ) ; ServletFileUpload upload = new ServletFileUpload ( factory ) ; try { for ( FileItem item : upload . parseRequest ( request ) ) { if ( ! item . isFormField ( ) ) { result = Files . createTempFile ( "upload" , ".file" ) ; item . write ( result . toFile ( ) ) ; } } } catch ( Exception e ) { throw new IOException ( "Error processing uploaded file" , e ) ; } return result ; }
Handles reading an uploaded file .
13,969
private Header [ ] combineHeaders ( NameValuePair [ ] headers ) { Header [ ] fullHeaders = new Header [ this . headers . size ( ) + headers . length ] ; for ( int i = 0 ; i < this . headers . size ( ) ; i ++ ) { fullHeaders [ i ] = this . headers . get ( i ) ; } for ( int i = 0 ; i < headers . length ; i ++ ) { NameValuePair header = headers [ i ] ; fullHeaders [ i + this . headers . size ( ) ] = new BasicHeader ( header . getName ( ) , header . getValue ( ) ) ; } return fullHeaders ; }
Sets the combined request headers .
13,970
public void map ( I item , T target ) { mapSet . add ( item , target ) ; reverseMap . add ( target , item ) ; }
Maps item to target
13,971
public void map ( Collection < I > items , T target ) { for ( I item : items ) { map ( item , target ) ; } }
Maps collections of items to target
13,972
public void unmap ( Collection < I > items , T target ) { for ( I item : items ) { unmap ( item , target ) ; } }
Remove collection mappings to target
13,973
public void unmap ( T target ) { Set < I > items = reverseMap . get ( target ) ; items . forEach ( ( i ) -> mapSet . removeItem ( i , target ) ) ; reverseMap . remove ( target ) ; }
Remove all mappings to target
13,974
public T match ( Collection < I > items ) { for ( I item : items ) { T match = match ( item ) ; if ( match != null ) { return match ; } } return null ; }
Returns target if one of collection items match . Otherwise returns null . Matched targets mappings are removed .
13,975
public T match ( I item ) { Set < T > set = mapSet . get ( item ) ; if ( set . size ( ) == 1 ) { T match = set . iterator ( ) . next ( ) ; unmap ( match ) ; return match ; } return null ; }
Returns target if item match . Otherwise returns null . Matched targets mappings are removed .
13,976
public < A > void match ( Map < A , ? extends Collection < I > > samples , BiConsumer < T , A > consumer ) { Map < A , Collection < I > > m = new HashMap < > ( samples ) ; boolean cont = true ; while ( cont ) { cont = false ; Iterator < Entry < A , Collection < I > > > iterator = m . entrySet ( ) . iterator ( ) ; while ( iterator . hasNext ( ) ) { Entry < A , Collection < I > > e = iterator . next ( ) ; T match = match ( e . getValue ( ) ) ; if ( match != null ) { consumer . accept ( match , e . getKey ( ) ) ; cont = true ; iterator . remove ( ) ; } } } }
Matches A objects to T targets . Each A is mapped to subset of items . Each match is passed to consumer . Map is traversed as long as there are matches . Each match will remove targets mappings .
13,977
public static String [ ] getResources ( String basePath , String regex ) { RegexResourceCriteria criteria = new RegexResourceCriteria ( regex ) ; String [ ] resourcesNames = classpathResources . getResources ( basePath , criteria ) ; return resourcesNames ; }
Returns the names of the resources in the given directory that match the given regular expression .
13,978
public static Class [ ] getClasses ( String basePackage , Class requiredInterface ) { return getClasses ( basePackage , new Class [ ] { requiredInterface } ) ; }
Returns an array of concrete classes in the given package that implement the specified interface .
13,979
public static Class [ ] getClasses ( String basePackage , Class [ ] requiredInterfaces ) { List classes = new ArrayList ( ) ; ClassCriteria criteria = new ClassCriteria ( requiredInterfaces ) ; String basePath = basePackage . replace ( '.' , File . separatorChar ) ; String [ ] resourcesNames = classpathResources . getResources ( basePath , criteria ) ; for ( int i = 0 ; i < resourcesNames . length ; i ++ ) { String resourceName = resourcesNames [ i ] ; if ( resourceName == null ) { continue ; } String className = getClassName ( resourceName ) ; try { Class c = Class . forName ( className ) ; classes . add ( c ) ; } catch ( ClassNotFoundException e ) { } } return ( Class [ ] ) classes . toArray ( new Class [ classes . size ( ) ] ) ; }
Returns an array of concrete classes in the given package that implement all of the specified interfaces .
13,980
public static String getClassName ( String resourceName ) { String className = resourceName . replace ( File . separatorChar , '.' ) ; if ( className . length ( ) > 7 ) { className = className . substring ( 0 , className . length ( ) - 6 ) ; } return className ; }
Returns the fully qualified class name represented by the given resource .
13,981
public BaseHolder getSessionFromPath ( String strSessionPathID ) { if ( strSessionPathID == null ) return null ; BaseHolder rootHolder = null ; int iStartPosition = 0 ; int iEndPosition = 0 ; while ( iEndPosition < strSessionPathID . length ( ) ) { iEndPosition = strSessionPathID . indexOf ( PATH_SEPARATOR , iStartPosition ) ; if ( iEndPosition == - 1 ) iEndPosition = strSessionPathID . length ( ) ; String strID = strSessionPathID . substring ( iStartPosition , iEndPosition ) ; if ( iStartPosition == 0 ) rootHolder = ( TaskHolder ) m_mapTasks . get ( strID ) ; else rootHolder = rootHolder . get ( strID ) ; if ( rootHolder == null ) return null ; iStartPosition = iEndPosition + 1 ; } return rootHolder ; }
Look up this session in the hierarchy .
13,982
public Map < String , Object > getApplicationProperties ( Map < String , Object > properties ) { if ( properties == null ) return null ; Map < String , Object > propApp = new Hashtable < String , Object > ( ) ; if ( properties . get ( DBParams . LANGUAGE ) != null ) propApp . put ( DBParams . LANGUAGE , properties . get ( DBParams . LANGUAGE ) ) ; if ( properties . get ( DBParams . DOMAIN ) != null ) propApp . put ( DBParams . DOMAIN , properties . get ( DBParams . DOMAIN ) ) ; return propApp ; }
Get application properties from proxy properties .
13,983
public boolean add ( String string ) { if ( filter . accept ( string ) ) { list . add ( string ) ; return true ; } return false ; }
Add a string if it matches this filter pattern .
13,984
public Component getTableCellRendererComponent ( JTable table , Object value , boolean isSelected , boolean hasFocus , int row , int column ) { Component c = tableCellRenderer . getTableCellRendererComponent ( table , value , isSelected , hasFocus , row , column ) ; if ( c instanceof JLabel ) { JLabel l = ( JLabel ) c ; l . setHorizontalTextPosition ( JLabel . LEFT ) ; if ( column == m_iCurrentSortedColumn ) { if ( l . getIcon ( ) == null ) l . setIcon ( getHeaderRendererIcon ( m_bCurrentOrder ) ) ; } else { if ( ( l . getIcon ( ) == ASCENDING_ICON ) || ( l . getIcon ( ) == DESCENDING_ICON ) ) l . setIcon ( null ) ; } } return c ; }
Tweek the column label if this column is sorted .
13,985
public String getContactTypeFromID ( String strContactTypeID ) { if ( Utility . isNumeric ( strContactTypeID ) ) { int iOldKeyArea = this . getDefaultOrder ( ) ; this . setKeyArea ( ContactType . ID_KEY ) ; this . getCounterField ( ) . setString ( strContactTypeID ) ; try { if ( this . seek ( null ) ) strContactTypeID = this . getField ( ContactType . CODE ) . toString ( ) ; } catch ( DBException ex ) { ex . printStackTrace ( ) ; } finally { this . setKeyArea ( iOldKeyArea ) ; } } return strContactTypeID ; }
GetContactTypeFromID Method .
13,986
public Record makeRecordFromRecordName ( String strRecordName , RecordOwner recordOwner ) { int iOldKeyArea = this . getDefaultOrder ( ) ; try { this . addNew ( ) ; this . setKeyArea ( ContactType . CODE_KEY ) ; this . getField ( ContactType . CODE ) . setString ( strRecordName ) ; if ( this . seek ( DBConstants . EQUALS ) ) return this . makeContactRecord ( recordOwner ) ; } catch ( DBException ex ) { this . setKeyArea ( iOldKeyArea ) ; } return null ; }
MakeRecordFromRecordName Method .
13,987
public Record makeContactRecord ( RecordOwner recordOwner ) { String strRecordClass = this . getField ( ContactType . RECORD_CLASS ) . toString ( ) ; return Record . makeRecordFromClassName ( strRecordClass , recordOwner , true , false ) ; }
MakeContactRecord Method .
13,988
public static boolean isDirectTransport ( String strTransportCode ) { if ( ( MessageTransport . DIRECT . equalsIgnoreCase ( strTransportCode ) ) || ( MessageTransport . SERVER . equalsIgnoreCase ( strTransportCode ) ) || ( MessageTransport . CLIENT . equalsIgnoreCase ( strTransportCode ) ) ) return true ; return false ; }
Is this transport code a direct type? .
13,989
public Object createMessageTransport ( String messageTransportType , Task task ) { MessageTransport messageTransport = this . getMessageTransport ( messageTransportType ) ; String className = null ; if ( messageTransport != null ) className = ( ( PropertiesField ) messageTransport . getField ( MessageTransport . PROPERTIES ) ) . getProperty ( "className" ) ; if ( className == null ) { String packageName = BaseMessageTransport . class . getPackage ( ) . getName ( ) ; className = packageName + '.' + messageTransportType . toLowerCase ( ) + '.' + messageTransportType + "MessageTransport" ; } BaseMessageTransport transport = ( BaseMessageTransport ) ClassServiceUtility . getClassService ( ) . makeObjectFromClassName ( className ) ; if ( transport != null ) transport . init ( task , null , null ) ; return transport ; }
Get the message transport for this type
13,990
private < T > T invokeURL ( String toBeInvoked , Class < T > returnType ) throws SameAsServiceException { URL url ; try { url = new URL ( toBeInvoked ) ; } catch ( MalformedURLException e ) { throw new SameAsServiceException ( "An error occurred while building the URL '" + toBeInvoked + "'" ) ; } URLConnection connection = null ; Reader reader = null ; if ( this . cache != null ) { lock . lock ( ) ; } try { connection = url . openConnection ( ) ; long lastModified = connection . getLastModified ( ) ; if ( this . cache != null ) { CacheKey cacheKey = new CacheKey ( toBeInvoked , lastModified ) ; T cached = this . cache . get ( cacheKey , returnType ) ; if ( cached != null ) { return cached ; } } if ( connection instanceof HttpURLConnection ) { ( ( HttpURLConnection ) connection ) . connect ( ) ; } reader = new InputStreamReader ( connection . getInputStream ( ) ) ; Gson gson = this . gsonBuilder . create ( ) ; T response = gson . fromJson ( reader , returnType ) ; if ( this . cache != null ) { CacheKey cacheKey = new CacheKey ( toBeInvoked , lastModified ) ; this . cache . put ( cacheKey , response ) ; } return response ; } catch ( IOException e ) { throw new SameAsServiceException ( format ( "An error occurred while invoking the URL '%s': %s" , toBeInvoked , e . getMessage ( ) ) ) ; } catch ( JsonParseException e ) { throw new SameAsServiceException ( "An error occurred while parsing the JSON response" , e ) ; } finally { if ( this . cache != null ) { lock . unlock ( ) ; } if ( connection != null && connection instanceof HttpURLConnection ) { ( ( HttpURLConnection ) connection ) . disconnect ( ) ; } if ( reader != null ) { try { reader . close ( ) ; } catch ( IOException e ) { } } } }
Invokes a Sameas . org service URL and parses the JSON response .
13,991
public void disconnectControls ( FieldList fieldList ) { if ( fieldList == null ) { for ( int i = 0 ; ; i ++ ) { fieldList = this . getFieldList ( i ) ; if ( fieldList == null ) break ; this . disconnectControls ( fieldList ) ; } } else { for ( int iFieldSeq = 0 ; iFieldSeq < fieldList . getFieldCount ( ) ; iFieldSeq ++ ) { FieldInfo field = fieldList . getField ( iFieldSeq ) ; Component component = null ; int iIndex = 0 ; while ( ( component = ( Component ) field . getComponent ( iIndex ) ) != null ) { if ( ( component . getParent ( ) == null ) || ( this . isAncestorOf ( component ) ) ) { if ( component instanceof Freeable ) ( ( Freeable ) component ) . free ( ) ; field . removeComponent ( component ) ; } else iIndex ++ ; } } } }
Go through all the fields in this record and remove all their components . Free the component if they are freeable .
13,992
public boolean doAction ( String strAction , int iOptions ) { if ( strAction == Constants . SUBMIT ) { this . controlsToFields ( ) ; } else if ( strAction == Constants . RESET ) { this . resetFields ( ) ; } return super . doAction ( strAction , iOptions ) ; }
Process this action . This class calls controltofields on submit and resetfields on reset .
13,993
public C createObject ( String className , Class clazz ) throws ClassNotFoundException { return createObject ( className , clazz , null ) ; }
Creates an instance from a Class .
13,994
public Method createMethod ( C object , String methodName , Class [ ] parameterTypes ) throws NoSuchMethodException { Class clazz = object . getClass ( ) ; try { @ SuppressWarnings ( "unchecked" ) Method method = clazz . getMethod ( methodName , parameterTypes ) ; return method ; } catch ( NoSuchMethodException nsme ) { String info = "The specified class " + clazz . getName ( ) ; info += " does not have a method \"" + methodName + "\" as expected: " ; info += nsme . getMessage ( ) ; throw new NoSuchMethodException ( info ) ; } }
Creates a method for a class .
13,995
public void addFilter ( Filter filter , Object value ) { if ( filter . getParameterClass ( ) . isInstance ( value ) ) { parameters . put ( filter . repr ( ) , value ) ; } else { String msg = "You need to supply the correct parameter for the " + filter + " filter. Expecting a(n) " + filter . getParameterClass ( ) . getSimpleName ( ) ; throw new FilterParameterException ( msg ) ; } }
Adds a parameter to the search operation
13,996
public List < Lot > doSearch ( ExtraLotInfo extras ) { ClientResource resource = new ClientResource ( Route . SEARCH . url ( ) ) ; Route . handleExtraInfo ( resource , extras , auth ) ; Route . addParameters ( resource . getReference ( ) , this . parameters ) ; try { Representation repr = resource . get ( ) ; return new ObjectMapper ( ) . readValue ( repr . getText ( ) , new TypeReference < List < Lot > > ( ) { } ) ; } catch ( IOException ex ) { LEX4JLogger . log ( Level . WARNING , "Could not retrieve search results correctly!" ) ; return null ; } }
Performs the search operation based on filters that are currently active .
13,997
public String skipped ( ) { int start = 0 ; if ( stack . size ( ) > 1 ) { start = stack . get ( stack . size ( ) - 2 ) . end ( ) ; } int end = stack . get ( stack . size ( ) - 1 ) . start ( ) ; return text . subSequence ( start , end ) . toString ( ) ; }
Returns the skipped text after successfull call to find
13,998
public static String paragraph ( int sentenceCount , boolean supplemental , int randomSentencesToAdd ) { String paragraphString = sentences ( sentenceCount + RandomUtils . nextInt ( randomSentencesToAdd ) , supplemental ) ; return paragraphString ; }
random lorem paragraph
13,999
public static List < String > words ( int count , boolean supplemental ) { List < String > words = new ArrayList < String > ( ) ; for ( int i = 0 ; i < count ; i ++ ) { String wordString = word ( ) ; if ( supplemental ) { wordString = wordString + fetchString ( "lorem.supplemental" ) ; } words . add ( wordString ) ; } return words ; }
generate a list of random words