idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
12,500 | public Request authorize ( String name , String password ) { String authString = name + ":" + password ; System . out . println ( "auth string: " + authString ) ; byte [ ] authEncBytes = Base64 . encodeBase64 ( authString . getBytes ( ) ) ; String authStringEnc = new String ( authEncBytes ) ; System . out . println ( "Base64 encoded auth string: " + authStringEnc ) ; return this . authorization ( "Basic " + authStringEnc ) ; } | method to set authorization header after computing digest from user and pasword |
12,501 | public Request addInputStream ( String name , File file ) throws FileNotFoundException { this . postStreams . put ( name , new FileInputStream ( file ) ) ; return this ; } | for post only |
12,502 | public Request setContent ( String text , ContentType contentType ) { entity = new StringEntity ( text , contentType ) ; return this ; } | set request content from input text string with given content type |
12,503 | public Request setContent ( InputStream stream , ContentType contentType ) { entity = new InputStreamEntity ( stream , contentType ) ; return this ; } | set request content from input stream with given content type |
12,504 | public String getFirstParam ( String paramName ) { Collection < String > values = this . params . get ( paramName ) ; if ( values == null || values . isEmpty ( ) ) { return null ; } else { return values . iterator ( ) . next ( ) ; } } | gets first value of specific param . |
12,505 | public java . util . Collection < String > getParam ( String paramName ) { return this . params . get ( paramName ) ; } | get specific param value |
12,506 | protected Response getResponse ( HttpEntity entity , RequestBuilder req ) { CloseableHttpClient client = getClient ( ) ; initHeaders ( req ) ; req . setEntity ( entity ) ; CloseableHttpResponse resp = null ; Response response = null ; try { final HttpUriRequest uriRequest = req . build ( ) ; resp = client . execute ( uriRequest ) ; response = new Response ( resp ) ; response . setMethod ( Methods . POST . getMethod ( ) ) ; response . setRequestLine ( uriRequest . getRequestLine ( ) . toString ( ) ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } finally { try { client . close ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return response ; } | get response from preconfigured http entity and request builder |
12,507 | protected Boolean getBoolean ( final String key , final JSONObject jsonObject ) { Boolean value = null ; if ( hasKey ( key , jsonObject ) ) { try { value = jsonObject . getBoolean ( key ) ; } catch ( JSONException e ) { LOGGER . debug ( "Could not get boolean from JSONObject for key: " + key , e ) ; LOGGER . debug ( "Trying to get the truthy value" ) ; value = getNonStandardBoolean ( key , jsonObject ) ; } } return value ; } | Check to make sure the JSONObject has the specified key and if so return the value as a boolean . If no key is found null is returned . |
12,508 | protected Double getDouble ( final String key , final JSONObject jsonObject ) { Double value = null ; if ( hasKey ( key , jsonObject ) ) { try { value = jsonObject . getDouble ( key ) ; } catch ( JSONException e ) { LOGGER . error ( "Could not get Double from JSONObject for key: " + key , e ) ; } } return value ; } | Check to make sure the JSONObject has the specified key and if so return the value as a double . If no key is found null is returned . |
12,509 | protected Integer getInteger ( final String key , final JSONObject jsonObject ) { Integer value = null ; if ( hasKey ( key , jsonObject ) ) { try { value = jsonObject . getInt ( key ) ; } catch ( JSONException e ) { LOGGER . error ( "Could not get Integer from JSONObject for key: " + key , e ) ; } } return value ; } | Check to make sure the JSONObject has the specified key and if so return the value as a integer . If no key is found null is returned . |
12,510 | protected Long getLong ( final String key , final JSONObject jsonObject ) { Long value = null ; if ( hasKey ( key , jsonObject ) ) { try { value = jsonObject . getLong ( key ) ; } catch ( JSONException e ) { LOGGER . error ( "Could not get Long from JSONObject for key: " + key , e ) ; } } return value ; } | Check to make sure the JSONObject has the specified key and if so return the value as a long . If no key is found null is returned . |
12,511 | protected JSONArray getJSONArray ( final String key , final JSONObject jsonObject ) { JSONArray value = new JSONArray ( ) ; if ( hasKey ( key , jsonObject ) ) { try { value = jsonObject . getJSONArray ( key ) ; } catch ( JSONException e ) { LOGGER . error ( "Could not get JSONArray from JSONObject for key: " + key , e ) ; } } return value ; } | Check to make sure the JSONObject has the specified key and if so return the value as a JSONArray . If no key is found an empty JSONArray is returned . |
12,512 | protected JSONObject getJSONObject ( final String key , final JSONObject jsonObject ) { JSONObject json = null ; try { if ( hasKey ( key , jsonObject ) ) { json = jsonObject . getJSONObject ( key ) ; } } catch ( JSONException e ) { LOGGER . error ( "Could not get JSONObject from JSONObject for key: " + key , e ) ; } return json ; } | Check to make sure the JSONObject has the specified key and if so return the value as a JSONObject . If no key is found null is returned . |
12,513 | protected JSONObject getJSONObject ( final JSONArray jsonArray , final int index ) { JSONObject object = new JSONObject ( ) ; try { object = ( JSONObject ) jsonArray . get ( index ) ; } catch ( JSONException e ) { e . printStackTrace ( ) ; } return object ; } | Return a json object from the provided array . Return an empty object if there is any problems fetching the named entity data . |
12,514 | protected JSONObject getJSONObject ( final String jsonString ) { JSONObject json = new JSONObject ( ) ; try { json = new JSONObject ( jsonString ) ; } catch ( NullPointerException e ) { LOGGER . error ( "JSON string cannot be null." , e ) ; } catch ( JSONException e ) { LOGGER . error ( "Could not parse string into JSONObject." , e ) ; } return json ; } | Fetch a JSONObject from the provided string . |
12,515 | protected boolean hasKey ( final String key , final JSONObject jsonObject ) { return jsonObject != null && jsonObject . has ( key ) ; } | Does the JSONObject have a specified key? |
12,516 | public void setConcept ( String concept ) { if ( concept != null ) { concept = concept . trim ( ) ; } this . concept = concept ; } | Set the detected concept tag . |
12,517 | protected PoolWaitFuture < E > createFuture ( final PoolKey < K > key ) { return new PoolWaitFuture < E > ( lock ) { protected E getPoolObject ( long timeout , TimeUnit unit ) throws IOException , InterruptedException , TimeoutException { return getBlockingUntilAvailableOrTimeout ( key , timeout , unit , this ) ; } } ; } | Creates a Future which will wait for the Keyed Object to become available or timeout |
12,518 | protected E createOrAttemptToBorrow ( final PoolKey < K > key ) { E entry = null ; if ( ! pool . containsKey ( key ) ) { entry = create ( key ) . initialize ( key , this ) ; pool . put ( key , entry ) ; borrowed . add ( entry ) ; return entry ; } entry = pool . get ( key ) ; if ( borrowed . add ( entry ) ) { factory . activate ( entry . get ( ) ) ; return entry ; } return entry . isCurrentOwner ( ) ? entry : null ; } | Default Single Key to Single Object implementation . Advanced Pools extending this class can override this behavior . If the key does not exist then an entry should be created and returned . If the key exists and is not borrowed then the entry should be returned . |
12,519 | protected boolean await ( final PoolWaitFuture < E > future , final PoolKey < K > key , Date deadline ) throws InterruptedException { try { waiting . add ( future ) ; return future . await ( deadline ) ; } finally { waiting . remove ( future ) ; } } | Adds the current PoolWaitFuture into the waiting list . The future will wait up until the specified deadline . If the future is woken up before the specified deadline then true is returned otherwise false . The future will always be removed from the wait list regardless of the outcome . |
12,520 | public static < T > Lazy < T > get ( Supplier < ? extends T > supplier ) { return new SuppliedLazy < T > ( supplier ) ; } | Create a lazy supplier that will obtain its value from another supplier . |
12,521 | public static < T > Lazy < T > build ( final Builder < ? extends T > builder ) { return new SuppliedLazy < T > ( new Supplier < T > ( ) { public T get ( ) { return builder . build ( ) ; } } ) ; } | Create a lazy supplier that will obtain its value from a builder . |
12,522 | public static VaadinForHeroku localServer ( final VaadinForHeroku server ) { return server . withHttpPort ( VaadinForHeroku . DEFAULT_PORT ) . withProductionMode ( false ) . openBrowser ( true ) ; } | Configures the given server for local development |
12,523 | public static VaadinForHeroku herokuServer ( final VaadinForHeroku server ) { return server . withMemcachedSessionManager ( MemcachedManagerBuilder . memcacheAddOn ( ) ) . withHttpPort ( Integer . parseInt ( System . getenv ( VaadinForHeroku . PORT ) ) ) . withProductionMode ( true ) . openBrowser ( false ) ; } | Configures the given server for Heroku |
12,524 | public VaadinForHeroku withFilterDefinition ( final FilterDefinitionBuilder ... filterDefs ) { checkVarArgsArguments ( filterDefs ) ; this . filterDefinitions . addAll ( Arrays . asList ( filterDefs ) ) ; return self ( ) ; } | Add filter definitions to the server configuration . |
12,525 | public VaadinForHeroku withApplicationListener ( final String ... listeners ) { checkVarArgsArguments ( listeners ) ; this . applicationListeners . addAll ( Arrays . asList ( listeners ) ) ; return self ( ) ; } | Add an application listener to the configuration of the server . |
12,526 | < CE extends CatalogueEntity > CE invoke ( final DigesterLoader digesterLoader , String uri , Parameter ... parameters ) { uri = checkNotNull ( uri , "Input URI cannot be null" ) ; try { return invoke ( digesterLoader , new URI ( uri ) , parameters ) ; } catch ( URISyntaxException e ) { throw new RuntimeException ( uri + " is not a valid URI" , e ) ; } } | generic internal methods |
12,527 | public int compare ( Alternative ab ) { if ( production != ab . production ) { throw new IllegalArgumentException ( ) ; } if ( resultOfs != - 1 || ab . resultOfs != - 1 ) { return NE ; } if ( argsOfs . size ( ) == 0 && ab . argsOfs . size ( ) == 0 ) { return EQ ; } if ( argsOfs . size ( ) == 0 || ab . argsOfs . size ( ) == 0 ) { return ALT ; } if ( max ( argsOfs ) < min ( ab . argsOfs ) ) { return LT ; } if ( min ( argsOfs ) > max ( ab . argsOfs ) ) { return GT ; } if ( argsOfs . size ( ) != 1 || ab . argsOfs . size ( ) != 1 ) { return NE ; } else { if ( argsOfs . get ( 0 ) != ab . argsOfs . get ( 0 ) ) { throw new IllegalStateException ( ) ; } return EQ ; } } | Compares functions . |
12,528 | public void setIsNegated ( final Integer isNegated ) { if ( isNegated != null ) { if ( isNegated == 1 ) { setIsNegated ( true ) ; } if ( isNegated == 0 ) { setIsNegated ( false ) ; } } } | Set whether this action verb was negated . |
12,529 | public static CGateSession connect ( InetAddress cgate_server , int command_port , int event_port , int status_change_port ) { return new CGateSession ( cgate_server , command_port , event_port , status_change_port ) ; } | Connect to a C - Gate server using the supplied cgate_server and cgate_port . |
12,530 | private static OkHttpClient createOkHttpClient ( Long timeoutSeconds ) { OkHttpClient . Builder builder = new OkHttpClient . Builder ( ) ; if ( timeoutSeconds != null ) { builder . connectTimeout ( timeoutSeconds , TimeUnit . SECONDS ) ; builder . readTimeout ( timeoutSeconds , TimeUnit . SECONDS ) ; builder . writeTimeout ( timeoutSeconds , TimeUnit . SECONDS ) ; } return builder . build ( ) ; } | Create OkHttpClient client for Web3j . |
12,531 | public static Web3j generateClient ( String clientAddress , Long timeoutSeconds ) { if ( isEmpty ( clientAddress ) ) { throw new IllegalArgumentException ( "You have to define client address, use constructor or environment variable 'web3j.clientAddress'" ) ; } Web3jService web3jService ; if ( clientAddress . startsWith ( "http" ) ) { web3jService = new HttpService ( clientAddress , createOkHttpClient ( timeoutSeconds ) , false ) ; } else if ( clientAddress . startsWith ( "wss" ) ) { try { web3jService = new WebSocketService ( clientAddress , true ) ; ( ( WebSocketService ) web3jService ) . connect ( ) ; } catch ( Exception ex ) { throw new RuntimeException ( ex ) ; } } else if ( System . getProperty ( "os.name" ) . toLowerCase ( ) . startsWith ( "win" ) ) { web3jService = new WindowsIpcService ( clientAddress ) ; } else { web3jService = new UnixIpcService ( clientAddress ) ; } return Web3j . build ( web3jService ) ; } | Generate Ethereum client . |
12,532 | private JPanel getMainPanel ( ) { if ( mainPanel == null ) { mainPanel = new JPanel ( ) ; mainPanel . setLayout ( new GridBagLayout ( ) ) ; GridBagConstraints c = new GridBagConstraints ( ) ; c . insets = new Insets ( 5 , 5 , 5 , 5 ) ; c . fill = GridBagConstraints . HORIZONTAL ; c . gridx = 0 ; c . gridy = 0 ; c . weightx = 0.0D ; mainPanel . add ( new JLabel ( "Host" ) , c ) ; c . gridx = 1 ; c . weightx = 1.0D ; mainPanel . add ( getHostField ( ) , c ) ; c . gridx = 0 ; c . gridy = 1 ; c . weightx = 0.0D ; mainPanel . add ( new JLabel ( "User" ) , c ) ; c . gridx = 1 ; c . weightx = 1.0D ; mainPanel . add ( getUserField ( ) , c ) ; c . gridx = 0 ; c . gridy = 2 ; c . weightx = 0.0D ; mainPanel . add ( new JLabel ( "Password" ) , c ) ; c . gridx = 1 ; c . weightx = 1.0D ; mainPanel . add ( getPasswordField ( ) , c ) ; c . gridx = 0 ; c . gridy = 3 ; c . weightx = 1.0D ; c . gridwidth = 2 ; mainPanel . add ( getRememberPasswordCheckBox ( ) , c ) ; c . gridx = 0 ; c . gridy = 4 ; c . weightx = 1.0D ; c . weighty = 1.0D ; c . gridwidth = 2 ; mainPanel . add ( new JPanel ( ) , c ) ; } return mainPanel ; } | This method initializes mainPanel |
12,533 | private JPanel getButtonPanel ( ) { if ( buttonPanel == null ) { buttonPanel = new JPanel ( ) ; buttonPanel . setLayout ( new GridBagLayout ( ) ) ; GridBagConstraints c1 = new GridBagConstraints ( ) ; c1 . anchor = GridBagConstraints . EAST ; c1 . gridx = 0 ; c1 . gridy = 0 ; c1 . weightx = 1.0D ; c1 . insets = new Insets ( 5 , 5 , 5 , 5 ) ; buttonPanel . add ( getOkButton ( ) , c1 ) ; GridBagConstraints c2 = new GridBagConstraints ( ) ; c2 . gridx = 1 ; c2 . gridy = 0 ; c2 . weightx = 0.0D ; c2 . insets = new Insets ( 5 , 5 , 5 , 5 ) ; buttonPanel . add ( getCancelButton ( ) , c2 ) ; } return buttonPanel ; } | This method initializes buttonPanel |
12,534 | private JButton getCancelButton ( ) { if ( cancelButton == null ) { cancelButton = new JButton ( ) ; cancelButton . setText ( "Cancel" ) ; cancelButton . setMnemonic ( 'C' ) ; cancelButton . addActionListener ( new java . awt . event . ActionListener ( ) { public void actionPerformed ( java . awt . event . ActionEvent e ) { cancelled = true ; timedOut = false ; restore ( ) ; setVisible ( false ) ; } } ) ; } return cancelButton ; } | This method initializes cancelButton |
12,535 | private void save ( ) { Preferences pref = Preferences . userNodeForPackage ( ConnectionDialog . class ) ; pref . put ( "host" , getHost ( ) ) ; pref . put ( "user" , getUser ( ) ) ; boolean remember = getRememberPasswordCheckBox ( ) . isSelected ( ) ; if ( remember ) { try { Cipher cipher = Cipher . getInstance ( "AES/CBC/PKCS5Padding" ) ; KeyGenerator keygen = KeyGenerator . getInstance ( "AES" ) ; SecureRandom random = SecureRandom . getInstance ( "SHA1PRNG" ) ; random . setSeed ( new byte [ ] { 0x60 , ( byte ) 0xFD , 0x28 , 0x07 , 0x35 , 0x4A , 0x0D , 0x3B } ) ; byte [ ] iv = new byte [ 16 ] ; random . nextBytes ( iv ) ; IvParameterSpec spec = new IvParameterSpec ( iv ) ; keygen . init ( 128 , random ) ; cipher . init ( Cipher . ENCRYPT_MODE , keygen . generateKey ( ) , spec ) ; byte [ ] clearText = getPassword ( ) . getBytes ( ) ; byte [ ] cipherText = cipher . doFinal ( clearText ) ; pref . putByteArray ( "password" , cipherText ) ; pref . putBoolean ( "remember" , true ) ; } catch ( Exception e ) { logger . error ( "Could not encrypt password" , e ) ; pref . remove ( "password" ) ; pref . putBoolean ( "remember" , false ) ; } } else { pref . remove ( "password" ) ; pref . putBoolean ( "remember" , false ) ; } } | Saves field values to preferences . |
12,536 | private void restore ( ) { Preferences pref = Preferences . userNodeForPackage ( ConnectionDialog . class ) ; getHostField ( ) . setText ( pref . get ( "host" , "localhost" ) ) ; getUserField ( ) . setText ( pref . get ( "user" , "guest" ) ) ; boolean remember = pref . getBoolean ( "remember" , false ) ; boolean passwordSet = false ; getRememberPasswordCheckBox ( ) . setSelected ( remember ) ; if ( remember ) { byte [ ] cipherText = pref . getByteArray ( "password" , null ) ; if ( cipherText != null ) { try { Cipher cipher = Cipher . getInstance ( "AES/CBC/PKCS5Padding" ) ; KeyGenerator keygen = KeyGenerator . getInstance ( "AES" ) ; SecureRandom random = SecureRandom . getInstance ( "SHA1PRNG" ) ; random . setSeed ( new byte [ ] { 0x60 , ( byte ) 0xFD , 0x28 , 0x07 , 0x35 , 0x4A , 0x0D , 0x3B } ) ; byte [ ] iv = new byte [ 16 ] ; random . nextBytes ( iv ) ; IvParameterSpec spec = new IvParameterSpec ( iv ) ; keygen . init ( 128 , random ) ; cipher . init ( Cipher . DECRYPT_MODE , keygen . generateKey ( ) , spec ) ; byte [ ] clearText = cipher . doFinal ( cipherText ) ; String password = new String ( clearText ) ; getPasswordField ( ) . setText ( password ) ; passwordSet = true ; } catch ( Exception e ) { logger . error ( "Could not decrypt password" , e ) ; } } } if ( ! passwordSet ) { getPasswordField ( ) . setText ( "" ) ; } } | Restores persisted field values from preferences . |
12,537 | public CroquetRestBuilder < T > addJpaEntity ( final Class < ? extends Serializable > entity ) { if ( entity . getAnnotation ( Entity . class ) == null ) { throw new IllegalArgumentException ( "Only classes marked with @Entity can be added" ) ; } settings . getDatabaseSettings ( ) . addEntity ( entity ) ; return this ; } | Adds a JPA entity to Croquet . |
12,538 | public CroquetRestBuilder < T > addDbProperty ( final String property , final Object value ) { settings . getDatabaseSettings ( ) . addProperty ( property , value ) ; return this ; } | Adds a property to the database configuration . |
12,539 | public CroquetRestBuilder < T > setSqlDialect ( final Class < ? extends Dialect > dialectClass ) { settings . getDatabaseSettings ( ) . setDialectClass ( dialectClass ) ; return this ; } | Sets the hibernate . dialect class . |
12,540 | static public int shortToBytes ( short s , byte [ ] buffer , int index ) { int length = 2 ; for ( int i = 0 ; i < length ; i ++ ) { buffer [ index + length - i - 1 ] = ( byte ) ( s >> ( i * 8 ) ) ; } return length ; } | This function converts a short into its corresponding byte format and inserts it into the specified buffer at the specified index . |
12,541 | static public short bytesToShort ( byte [ ] buffer , int index ) { int length = 2 ; short integer = 0 ; for ( int i = 0 ; i < length ; i ++ ) { integer |= ( ( buffer [ index + length - i - 1 ] & 0xFF ) << ( i * 8 ) ) ; } return integer ; } | This function converts the bytes in a byte array at the specified index to its corresponding short value . |
12,542 | static public int intToBytes ( int i , byte [ ] buffer , int index ) { int length = buffer . length - index ; if ( length > 4 ) length = 4 ; for ( int j = 0 ; j < length ; j ++ ) { buffer [ index + length - j - 1 ] = ( byte ) ( i >> ( j * 8 ) ) ; } return length ; } | This function converts a integer into its corresponding byte format and inserts it into the specified buffer at the specified index . |
12,543 | static public int bytesToInt ( byte [ ] buffer , int index ) { int length = buffer . length - index ; if ( length > 4 ) length = 4 ; int integer = 0 ; for ( int i = 0 ; i < length ; i ++ ) { integer |= ( ( buffer [ index + length - i - 1 ] & 0xFF ) << ( i * 8 ) ) ; } return integer ; } | This function converts the bytes in a byte array at the specified index to its corresponding integer value . |
12,544 | static public int longToBytes ( long l , byte [ ] buffer , int index ) { int length = buffer . length - index ; if ( length > 8 ) length = 8 ; for ( int i = 0 ; i < length ; i ++ ) { buffer [ index + length - i - 1 ] = ( byte ) ( l >> ( i * 8 ) ) ; } return length ; } | This function converts a long into its corresponding byte format and inserts it into the specified buffer at the specified index . |
12,545 | static public long bytesToLong ( byte [ ] buffer , int index ) { int length = buffer . length - index ; if ( length > 8 ) length = 8 ; long l = 0 ; for ( int i = 0 ; i < length ; i ++ ) { l |= ( ( buffer [ index + length - i - 1 ] & 0xFFL ) << ( i * 8 ) ) ; } return l ; } | This function converts the bytes in a byte array at the specified index to its corresponding long value . |
12,546 | static public int bigIntegerToBytes ( BigInteger integer , byte [ ] buffer , int index ) { int length = 4 + ( integer . bitLength ( ) + 8 ) / 8 ; System . arraycopy ( intToBytes ( length ) , 0 , buffer , index , 4 ) ; index += 4 ; System . arraycopy ( integer . toByteArray ( ) , 0 , buffer , index , length - 4 ) ; return length ; } | This function converts a big integer into its corresponding byte format and inserts it into the specified buffer at the specified index . |
12,547 | static public BigInteger bytesToBigInteger ( byte [ ] buffer , int index ) { int length = bytesToInt ( buffer , index ) ; index += 4 ; byte [ ] bytes = new byte [ length ] ; System . arraycopy ( buffer , index , bytes , 0 , length ) ; return new BigInteger ( bytes ) ; } | This function converts the bytes in a byte array at the specified index to its corresponding big integer value . |
12,548 | static public int doubleToBytes ( double s , byte [ ] buffer , int index ) { long bits = Double . doubleToRawLongBits ( s ) ; int length = longToBytes ( bits , buffer , index ) ; return length ; } | This function converts a double into its corresponding byte format and inserts it into the specified buffer at the specified index . |
12,549 | static public double bytesToDouble ( byte [ ] buffer , int index ) { double real ; long bits = bytesToLong ( buffer , index ) ; real = Double . longBitsToDouble ( bits ) ; return real ; } | This function converts the bytes in a byte array at the specified index to its corresponding double value . |
12,550 | static public int bigDecimalToBytes ( BigDecimal decimal , byte [ ] buffer , int index ) { BigInteger intVal = decimal . unscaledValue ( ) ; int length = 12 + ( intVal . bitLength ( ) + 8 ) / 8 ; int scale = decimal . scale ( ) ; System . arraycopy ( intToBytes ( scale ) , 0 , buffer , index , 4 ) ; index += 4 ; int precision = decimal . precision ( ) ; System . arraycopy ( intToBytes ( precision ) , 0 , buffer , index , 4 ) ; index += 4 ; System . arraycopy ( bigIntegerToBytes ( intVal ) , 0 , buffer , index , length - 8 ) ; return length ; } | This function converts a big decimal into its corresponding byte format and inserts it into the specified buffer at the specified index . |
12,551 | static public BigDecimal bytesToBigDecimal ( byte [ ] buffer , int index ) { int scale = bytesToInt ( buffer , index ) ; index += 4 ; int precision = bytesToInt ( buffer , index ) ; index += 4 ; BigInteger intVal = bytesToBigInteger ( buffer , index ) ; return new BigDecimal ( intVal , scale , new MathContext ( precision ) ) ; } | This function converts the bytes in a byte array at the specified index to its corresponding big decimal value . |
12,552 | static public int stringToBytes ( String string , byte [ ] buffer , int index ) { byte [ ] bytes = string . getBytes ( ) ; int length = bytes . length ; System . arraycopy ( bytes , 0 , buffer , index , length ) ; return length ; } | This function converts a string into its corresponding byte format and inserts it into the specified buffer at the specified index . |
12,553 | static public int compare ( byte [ ] first , byte [ ] second ) { int firstLength = first . length ; int secondLength = second . length ; int shorterLength = Math . min ( firstLength , secondLength ) ; for ( int i = 0 ; i < shorterLength ; i ++ ) { int result = Byte . compare ( first [ i ] , second [ i ] ) ; if ( result != 0 ) return Integer . signum ( result ) ; } if ( firstLength < secondLength ) return - 1 ; if ( firstLength > secondLength ) return 1 ; return 0 ; } | This function compares two byte arrays for canonical ordering . |
12,554 | private void readPreferences ( ) { boolean runOnStartup = pref . getBoolean ( "runOnStartup" , true ) ; getRunOnStartupCheckBox ( ) . setSelected ( runOnStartup ) ; int maxCpus = pref . getInt ( "maxCpus" , 0 ) ; if ( maxCpus <= 0 ) { getLimitCpusCheckBox ( ) . setSelected ( false ) ; getMaxCpusTextField ( ) . setValue ( Runtime . getRuntime ( ) . availableProcessors ( ) ) ; getMaxCpusTextField ( ) . setEnabled ( false ) ; } else { getLimitCpusCheckBox ( ) . setSelected ( true ) ; getMaxCpusTextField ( ) . setValue ( maxCpus ) ; getMaxCpusTextField ( ) . setEnabled ( true ) ; } if ( getRequireACCheckBox ( ) . isEnabled ( ) ) { boolean requireAC = pref . getBoolean ( "requireAC" , false ) ; int minBattLife = pref . getInt ( "minBattLife" , 0 ) ; int minBattLifeWhileChg = pref . getInt ( "minBattLifeWhileChg" , 0 ) ; getRequireACCheckBox ( ) . setSelected ( requireAC ) ; getMinBatteryLifeSlider ( ) . setEnabled ( ! requireAC ) ; getMinBatteryLifeSlider ( ) . setValue ( minBattLife ) ; getMinBatteryLifeWhileChargingSlider ( ) . setValue ( minBattLifeWhileChg ) ; } else { getRequireACCheckBox ( ) . setSelected ( false ) ; getMinBatteryLifeSlider ( ) . setValue ( 0 ) ; getMinBatteryLifeWhileChargingSlider ( ) . setValue ( 0 ) ; getRequireACCheckBox ( ) . setEnabled ( false ) ; getMinBatteryLifeSlider ( ) . setEnabled ( false ) ; getMinBatteryLifeWhileChargingSlider ( ) . setEnabled ( false ) ; } boolean cacheClassDefinitions = pref . getBoolean ( "cacheClassDefinitions" , true ) ; getCacheClassDefinitionsCheckBox ( ) . setSelected ( cacheClassDefinitions ) ; } | Updates the form elements based on preferences . |
12,555 | private void writePreferences ( ) { boolean runOnStartup = getRunOnStartupCheckBox ( ) . isSelected ( ) ; pref . putBoolean ( "runOnStartup" , runOnStartup ) ; if ( getLimitCpusCheckBox ( ) . isSelected ( ) ) { int maxCpus = ( ( Number ) getMaxCpusTextField ( ) . getValue ( ) ) . intValue ( ) ; pref . putInt ( "maxCpus" , maxCpus ) ; } else { pref . putInt ( "maxCpus" , 0 ) ; } boolean requireAC = getRequireACCheckBox ( ) . isSelected ( ) ; int minBattLife = getMinBatteryLifeSlider ( ) . getValue ( ) ; int minBattLifeWhileChg = getMinBatteryLifeWhileChargingSlider ( ) . getValue ( ) ; pref . putBoolean ( "requireAC" , requireAC ) ; pref . putInt ( "minBattLife" , minBattLife ) ; pref . putInt ( "minBattLifeWhileChg" , minBattLifeWhileChg ) ; boolean cacheClassDefinitions = getCacheClassDefinitionsCheckBox ( ) . isSelected ( ) ; pref . putBoolean ( "cacheClassDefinitions" , cacheClassDefinitions ) ; } | Writes the form values to preferences . |
12,556 | private boolean extendedIdentifierEquals ( String eid1 , String eid2 ) { try { return DomHelpers . compare ( DomHelpers . toDocument ( eid1 , null ) , DomHelpers . toDocument ( eid2 , null ) ) ; } catch ( MarshalException e ) { return false ; } } | Compare two extended identifiers |
12,557 | private boolean distinguishedNameEquals ( String dsn1 , String dsn2 ) { return new X500Principal ( dsn1 ) . equals ( new X500Principal ( dsn2 ) ) ; } | Compare two DSN |
12,558 | private static void getAllInterfaces ( Class < ? > cls , Collection < Class < ? > > interfacesFound ) { while ( cls != null ) { Class < ? > [ ] interfaces = cls . getInterfaces ( ) ; for ( int i = 0 ; i < interfaces . length ; i ++ ) { interfacesFound . add ( interfaces [ i ] ) ; getAllInterfaces ( interfaces [ i ] , interfacesFound ) ; } cls = cls . getSuperclass ( ) ; } } | Get the interfaces for the specified class . |
12,559 | public FilterDefinitionBuilder withParameter ( final String name , final String value ) { if ( parameters . containsKey ( name ) ) { return this ; } this . parameters . put ( name , value ) ; return this ; } | Add a parameter with its associated value . One a parameter has been added its value cannot be changed . |
12,560 | public static FA create ( FA fa , int errorSi ) { FA cfa ; int [ ] sorted ; int si ; int idx ; int faSize ; State faState ; State cfaState ; int nextChar ; int width ; Range range ; int nextSi ; faSize = fa . size ( ) ; cfa = new FA ( ) ; for ( si = 0 ; si < faSize ; si ++ ) { faState = fa . get ( si ) ; if ( cfa . add ( faState . getLabel ( ) ) != si ) { throw new RuntimeException ( ) ; } cfaState = cfa . get ( si ) ; if ( fa . getStart ( ) == si ) { cfa . setStart ( si ) ; } if ( fa . isEnd ( si ) ) { cfa . setEnd ( si ) ; } sorted = faState . sortRanges ( ) ; nextChar = 0 ; for ( idx = 0 ; idx < sorted . length ; idx += width ) { width = countConsecutive ( faState , sorted , idx ) ; range = firstToLast ( faState , sorted , idx , width ) ; nextSi = faState . getEnd ( sorted [ idx ] ) ; if ( nextChar < range . getFirst ( ) ) { cfaState . add ( errorSi , new Range ( ( char ) nextChar , ( char ) ( range . getFirst ( ) - 1 ) ) ) ; } cfaState . add ( faState . getEnd ( sorted [ idx ] ) , range ) ; nextChar = range . getLast ( ) + 1 ; } if ( nextChar <= Character . MAX_VALUE ) { cfaState . add ( errorSi , new Range ( ( char ) nextChar , Character . MAX_VALUE ) ) ; } } return cfa ; } | The last state of the automaton returned is the error state . |
12,561 | public void setJobPriority ( UUID jobId , int priority ) throws Exception { config . getJobService ( ) . setJobPriority ( jobId , priority ) ; } | Sets the priority of the specified job . |
12,562 | public JsonNode toJson ( ) { ObjectNode node = new ObjectMapper ( ) . createObjectNode ( ) ; node . put ( "code" , code ) ; if ( format != null ) { node . put ( "format" , format ) ; } return node ; } | Returns this column in JSON representation . |
12,563 | public static Type findComponent ( Class < ? > type ) { int i ; Type cmp ; for ( i = 0 ; i < Type . PRIMITIVES . length ; i ++ ) { cmp = Type . PRIMITIVES [ i ] ; if ( type == cmp . type ) { return cmp ; } } return Type . REFERENCE ; } | returns Type . REFERENCE_TYPE ; |
12,564 | public static Class < ? > wrappedType ( Class < ? > c ) { int i ; if ( c . isPrimitive ( ) ) { for ( i = 0 ; i < Type . PRIMITIVES . length ; i ++ ) { if ( Type . PRIMITIVES [ i ] . type == c ) { return Type . PRIMITIVES [ i ] . wrapper ; } } throw new RuntimeException ( ) ; } else { return c ; } } | additional functionality for primitive Java Classes |
12,565 | public static Class < ? > classFind ( String name ) { try { return Class . forName ( name ) ; } catch ( ClassNotFoundException e ) { return findType ( name ) . type ; } } | Looks up a class by name . In contrast to Class . forName primitive classes are found and not found is indicated by null . |
12,566 | public static Class < ? > commonBase ( Class < ? > a , Class < ? > b ) { Class < ? > result ; Class < ? > ifc ; if ( b == null ) { throw new IllegalArgumentException ( ) ; } else if ( a == null ) { return b ; } else { result = commonSuperClass ( a , b ) ; if ( Object . class . equals ( result ) ) { ifc = commonInterfaces ( a , b ) ; if ( ifc != null ) { result = ifc ; } } return result ; } } | Gets the common base of two classes . Common base is the most special class both argument are assignable to . The common base for different primitive types is null ; the common base for a primitive type and a reference type is null . |
12,567 | public static void write ( ObjectOutput out , Class < ? > cl ) throws IOException { int dim ; if ( cl == null ) { out . writeByte ( - 1 ) ; } else { dim = 0 ; while ( cl . isArray ( ) ) { dim ++ ; cl = cl . getComponentType ( ) ; } if ( dim > Byte . MAX_VALUE ) { throw new RuntimeException ( "to many dimensions" ) ; } out . writeByte ( ( byte ) dim ) ; out . writeUTF ( cl . getName ( ) ) ; } } | Writes a class Object . |
12,568 | public static Class < ? > read ( ObjectInput in ) throws java . io . IOException { byte dim ; Class < ? > cl ; String name ; dim = in . readByte ( ) ; if ( dim == - 1 ) { return null ; } else { name = in . readUTF ( ) ; cl = classFind ( name ) ; if ( cl == null ) { throw new RuntimeException ( "can't load class " + name ) ; } while ( dim -- > 0 ) { cl = net . oneandone . sushi . util . Arrays . getArrayClass ( cl ) ; } return cl ; } } | Reads a class Object . |
12,569 | public static void writeClasses ( ObjectOutput out , Class < ? > [ ] types ) throws java . io . IOException { int i ; if ( types . length > Byte . MAX_VALUE ) { throw new RuntimeException ( "to many dimensions" ) ; } out . writeByte ( ( byte ) types . length ) ; for ( i = 0 ; i < types . length ; i ++ ) { write ( out , types [ i ] ) ; } } | Writes an array of Class objects . |
12,570 | public static Class < ? > [ ] readClasses ( ObjectInput in ) throws java . io . IOException , ClassNotFoundException { int i , len ; Class < ? > [ ] result ; len = in . readByte ( ) ; result = new Class [ len ] ; for ( i = 0 ; i < len ; i ++ ) { result [ i ] = read ( in ) ; } return result ; } | Reads an array of Class objects . |
12,571 | public void emitArrayNew ( Code dest ) { Type typeCode ; typeCode = getTypeCode ( ) ; if ( typeCode . id == T_REFERENCE ) { dest . emit ( ANEWARRAY , this ) ; } else { dest . emit ( NEWARRAY , typeCode . id ) ; } } | create an array with this as component type |
12,572 | public void write ( Output dest ) throws IOException { int i , max ; dest . writeU2 ( Access . toFlags ( accessFlags ) ) ; dest . writeClassRef ( thisClass ) ; if ( superClass != null ) { dest . writeClassRef ( superClass ) ; } else { dest . writeU2 ( 0 ) ; } max = interfaces . size ( ) ; dest . writeU2 ( max ) ; for ( i = 0 ; i < max ; i ++ ) { dest . writeClassRef ( interfaces . get ( i ) ) ; } max = fields . size ( ) ; dest . writeU2 ( max ) ; for ( i = 0 ; i < max ; i ++ ) { fields . get ( i ) . write ( dest ) ; } max = methods . size ( ) ; dest . writeU2 ( max ) ; for ( i = 0 ; i < max ; i ++ ) { methods . get ( i ) . write ( dest ) ; } max = attributes . size ( ) ; dest . writeU2 ( max ) ; for ( i = 0 ; i < max ; i ++ ) { attributes . get ( i ) . write ( dest ) ; } } | Write this class file to the specified output stream . |
12,573 | public boolean with ( PrefixSet op ) { PrefixSet next ; long tmp ; Prefix l ; Prefix r ; next = new PrefixSet ( ) ; l = todo . iterator ( ) ; while ( l . step ( ) ) { r = op . iterator ( ) ; while ( r . step ( ) ) { tmp = Prefix . concat ( l . data , r . data , k ) ; if ( tmp >= firstFullValue ) { done . add ( tmp ) ; } else { next . add ( tmp ) ; } } } todo = next ; return todo . isEmpty ( ) ; } | true when done |
12,574 | public static Identity createExtendedIdentifier ( String namespaceUri , String namespacePrefix , String identifierName , String attributeValue , String administrativeDomain ) { Document doc = mDocumentBuilder . newDocument ( ) ; Element e = doc . createElementNS ( namespaceUri , namespacePrefix + ":" + identifierName ) ; if ( attributeValue != null ) { e . setAttribute ( "name" , attributeValue ) ; } e . setAttribute ( "administrative-domain" , administrativeDomain ) ; doc . appendChild ( e ) ; try { return Identifiers . createExtendedIdentity ( doc ) ; } catch ( MarshalException e1 ) { IfmapJLog . error ( "document that contains the extended identifier can't be handled" ) ; throw new RuntimeException ( e1 ) ; } } | Creates an Extended Identifier . |
12,575 | public static Identity createExtendedIdentifier ( String namespaceUri , String namespacePrefix , String identifierName , String attributeValue ) { return createExtendedIdentifier ( namespaceUri , namespacePrefix , identifierName , attributeValue , "" ) ; } | Creates an Extended Identifier ; uses an empty string for the administrativeDomain attribute . |
12,576 | public Optional < Link > getLinkByRel ( final String rel ) { return Optional . ofNullable ( representation . getLinkByRel ( rel ) ) ; } | Get link . |
12,577 | public List < HalResource > getResourcesByRel ( final String rel ) { final List < ? extends ReadableRepresentation > resources = representation . getResourcesByRel ( rel ) ; return resources . stream ( ) . map ( representation -> new HalResource ( objectMapper , representation ) ) . collect ( Collectors . toList ( ) ) ; } | Get embedded resources by relation |
12,578 | public Optional < String > getValueAsString ( final String name ) { return Optional . ofNullable ( ( String ) representation . getValue ( name , null ) ) ; } | Get property value by name . |
12,579 | public < T > T getResourceAsObject ( final TypeToken < T > type ) { try { return ( T ) objectMapper . readValue ( ( ( ContentRepresentation ) getUnderlyingRepresentation ( ) ) . getContent ( ) , objectMapper . constructType ( type . getType ( ) ) ) ; } catch ( IOException e ) { LOGGER . warn ( "failed to parse resource as object: {}" , e . getMessage ( ) ) ; throw new RuntimeException ( e ) ; } } | Parse root resource as an object . |
12,580 | private void setDistinct ( int leftSi , int rightSi ) { IntArrayList tmp ; int pair ; int i , max ; tmp = distinct [ leftSi ] [ rightSi ] ; if ( tmp != YES ) { distinct [ leftSi ] [ rightSi ] = YES ; if ( tmp != UNKNOWN ) { max = tmp . size ( ) ; for ( i = 0 ; i < max ; i ++ ) { pair = tmp . get ( i ) ; setDistinct ( left ( pair ) , right ( pair ) ) ; } } } } | Mark the pair to be distinct . Recursively marks depending pairs . |
12,581 | public static Selection forClass ( Class cl ) { java . lang . reflect . Constructor [ ] constrs ; int i ; List < Function > lst ; Function fn ; lst = new ArrayList < Function > ( ) ; constrs = cl . getConstructors ( ) ; for ( i = 0 ; i < constrs . length ; i ++ ) { fn = create ( constrs [ i ] ) ; if ( fn != null ) { lst . add ( fn ) ; } } return new Selection ( lst ) ; } | Gets all valid Constructors for the specified Class . |
12,582 | public Object invoke ( Object [ ] vals ) throws InvocationTargetException { try { return constr . newInstance ( vals ) ; } catch ( InvocationTargetException | IllegalArgumentException e ) { throw e ; } catch ( IllegalAccessException e ) { throw new RuntimeException ( "can't access constructor" ) ; } catch ( InstantiationException e ) { throw new RuntimeException ( "can't instantiate" ) ; } } | Invokes the Java constructor . |
12,583 | public static void write ( ObjectOutput out , java . lang . reflect . Constructor constr ) throws IOException { Class cl ; if ( constr == null ) { ClassRef . write ( out , null ) ; } else { cl = constr . getDeclaringClass ( ) ; ClassRef . write ( out , cl ) ; ClassRef . writeClasses ( out , constr . getParameterTypes ( ) ) ; } } | Writes a Java Constructor . |
12,584 | public static java . lang . reflect . Constructor read ( ObjectInput in ) throws ClassNotFoundException , IOException , NoSuchMethodException { Class cl ; Class [ ] types ; cl = ClassRef . read ( in ) ; if ( cl == null ) { return null ; } else { types = ClassRef . readClasses ( in ) ; return cl . getConstructor ( types ) ; } } | Reads a Java Constructor . |
12,585 | public boolean isDatabaseCompatible ( String databaseProductNameRegex , DatabaseVersion minVersion , DatabaseVersion maxVersion ) throws SQLException { readMetaDataIfNeeded ( ) ; if ( ! this . databaseProductName . matches ( databaseProductNameRegex ) ) { return false ; } return new VersionRange ( minVersion , maxVersion ) . isWithinRange ( this . databaseVersion ) ; } | Compares database product name and version information to that reported by the database . |
12,586 | public boolean isDriverCompatible ( String driverName , DriverVersion minVersion , DriverVersion maxVersion ) throws SQLException { readMetaDataIfNeeded ( ) ; if ( ! this . driverName . equals ( driverName ) ) { return false ; } return new VersionRange ( minVersion , maxVersion ) . isWithinRange ( this . driverVersion ) ; } | Compares JDBC driver name and version information to that reported by the driver . |
12,587 | private void checkDuplicates ( ) throws Failure { int i ; Variable v ; String name ; for ( i = 0 ; i < vars . length ; i ++ ) { v = vars [ i ] ; name = v . getName ( ) ; if ( lookup ( name ) != v ) { throw new Failure ( "duplicate variable name: " + name ) ; } } } | Throws Failure if there are multiple variables with the same name . |
12,588 | public static String getUtcTimeAsIso8601 ( Calendar cal ) { try { if ( cal == null ) { return DatatypeFactory . newInstance ( ) . newXMLGregorianCalendar ( new GregorianCalendar ( TimeZone . getTimeZone ( "UTC" ) ) ) . toXMLFormat ( ) . replaceAll ( "\\.[0-9]{3}" , "" ) ; } GregorianCalendar suppliedDateCalendar = new GregorianCalendar ( TimeZone . getTimeZone ( "UTC" ) ) ; suppliedDateCalendar . setTimeInMillis ( cal . getTimeInMillis ( ) ) ; return DatatypeFactory . newInstance ( ) . newXMLGregorianCalendar ( suppliedDateCalendar ) . toXMLFormat ( ) . replaceAll ( "\\.[0-9]{3}" , "" ) ; } catch ( DatatypeConfigurationException e ) { SimpleDateFormat xmlDateUtc = new SimpleDateFormat ( "yyyy-MM-dd'T'HH:mm:ss'Z'" ) ; xmlDateUtc . setTimeZone ( TimeZone . getTimeZone ( "UTC" ) ) ; return xmlDateUtc . format ( Calendar . getInstance ( ) ) ; } } | Formats the given Calendar to an ISO - 8601 compliant string without milliseconds . |
12,589 | public JCGLProfilingFrameType startFrame ( ) { final Frame f = this . frames [ this . frame_index ] ; f . start ( ) ; this . frame_index = ( this . frame_index + 1 ) % this . frames . length ; return f ; } | Start rendering a frame . |
12,590 | public void trimContexts ( ) { for ( int index = 0 ; index < this . frames . length ; ++ index ) { final Frame f = this . frames [ index ] ; f . trimRecursive ( ) ; } this . frame_index = 0 ; } | Trim any cached internal storage . |
12,591 | private void layout ( Output dest ) { Instruction instr ; int instrSize , varSize ; IntArrayList vars ; IntArrayList lens ; int i , j , k , ofs ; int shrink , len ; boolean changes ; instrSize = instructions . size ( ) ; vars = new IntArrayList ( ) ; lens = new IntArrayList ( ) ; ofs = 0 ; for ( i = 0 ; i < instrSize ; i ++ ) { instr = instructions . get ( i ) ; instr . ofs = ofs ; len = instr . getMaxLength ( dest ) ; ofs += len ; if ( instr . type . isVariable ( ) ) { vars . add ( i ) ; lens . add ( len ) ; } } codeSize = ofs ; varSize = vars . size ( ) ; do { changes = false ; shrink = 0 ; for ( i = 0 ; i < varSize ; i ++ ) { j = vars . get ( i ) ; instr = instructions . get ( j ) ; len = instr . getVariableLength ( this ) ; if ( len < lens . get ( i ) ) { changes = true ; shrink += ( lens . get ( i ) - len ) ; lens . set ( i , len ) ; } if ( shrink > 0 ) { for ( k = ( i + 1 == varSize ) ? instrSize - 1 : vars . get ( i + 1 ) ; k > j ; k -- ) { instructions . get ( k ) . ofs -= shrink ; } } } codeSize -= shrink ; } while ( changes ) ; } | compute ofs for all instructions . |
12,592 | public int resolveLabel ( int idx ) { int trueIdx ; if ( idx < 0 ) { trueIdx = labels . get ( - idx ) ; if ( trueIdx < 0 ) { throw new RuntimeException ( "undefined label: " + idx ) ; } return trueIdx ; } else { return idx ; } } | a forward reference is first declared and then defined |
12,593 | public void emitGeneric ( int opcode , Object [ ] args ) { Instruction instr ; InstructionType type ; type = Set . TYPES [ opcode ] ; instr = new Instruction ( - 1 , type , args ) ; instructions . add ( instr ) ; } | pc is increased by 1 . |
12,594 | private int calcStackSize ( ) { int i , max ; int result ; int [ ] startStack ; ExceptionInfo e ; int tmp ; int unreachable ; IntBitSet todo ; List < Jsr > jsrs ; jsrs = Jsr . findJsrs ( this ) ; startStack = new int [ instructions . size ( ) ] ; for ( i = 0 ; i < startStack . length ; i ++ ) { startStack [ i ] = - 1 ; } startStack [ 0 ] = 0 ; todo = new IntBitSet ( ) ; todo . add ( 0 ) ; max = exceptions . size ( ) ; for ( i = 0 ; i < max ; i ++ ) { e = exceptions . get ( i ) ; startStack [ e . handler ] = 1 ; todo . add ( e . handler ) ; } fillStack ( jsrs , todo , startStack ) ; result = 0 ; unreachable = - 1 ; for ( i = 0 ; i < startStack . length ; i ++ ) { tmp = startStack [ i ] ; if ( tmp > result ) { result = tmp ; } if ( ( unreachable == - 1 ) && ( tmp == - 1 ) ) { unreachable = i ; } } if ( unreachable != - 1 ) { LOGGER . warning ( "unreachable code, starting " + unreachable + "\n" ) ; } return result ; } | computed the stack size |
12,595 | public void registerConnection ( Connection connection , ConnectionDefinition connectionDefinition ) { checkNotNull ( connection ) ; checkNotNull ( connectionDefinition ) ; if ( this . connectionDefinitions . putIfAbsent ( connectionDefinition . getName ( ) , connectionDefinition ) != null ) { throw SeedException . createNew ( JmsErrorCode . DUPLICATE_CONNECTION_NAME ) . put ( ERROR_CONNECTION_NAME , connectionDefinition . getName ( ) ) ; } if ( this . connections . putIfAbsent ( connectionDefinition . getName ( ) , connection ) != null ) { throw SeedException . createNew ( JmsErrorCode . DUPLICATE_CONNECTION_NAME ) . put ( ERROR_CONNECTION_NAME , connectionDefinition . getName ( ) ) ; } if ( shouldStartConnections . get ( ) ) { try { connection . start ( ) ; } catch ( JMSException e ) { throw SeedException . wrap ( e , JmsErrorCode . UNABLE_TO_START_JMS_CONNECTION ) . put ( ERROR_CONNECTION_NAME , connectionDefinition . getName ( ) ) ; } } } | Register an existing JMS connection to be managed by the JMS plugin . |
12,596 | public void registerMessageListener ( MessageListenerDefinition messageListenerDefinition ) { checkNotNull ( messageListenerDefinition ) ; ConnectionDefinition connectionDefinition = connectionDefinitions . get ( messageListenerDefinition . getConnectionName ( ) ) ; if ( connectionDefinition . isJeeMode ( ) && messageListenerDefinition . getPoller ( ) == null ) { throw SeedException . createNew ( JmsErrorCode . MESSAGE_POLLER_REQUIRED_IN_JEE_MODE ) . put ( ERROR_CONNECTION_NAME , connectionDefinition . getName ( ) ) . put ( ERROR_MESSAGE_LISTENER_NAME , messageListenerDefinition . getName ( ) ) ; } try { createMessageConsumer ( messageListenerDefinition ) ; } catch ( JMSException e ) { throw SeedException . wrap ( e , JmsErrorCode . UNABLE_TO_CREATE_MESSAGE_CONSUMER ) . put ( ERROR_MESSAGE_LISTENER_NAME , messageListenerDefinition . getName ( ) ) ; } if ( messageListenerDefinitions . putIfAbsent ( messageListenerDefinition . getName ( ) , messageListenerDefinition ) != null ) { throw SeedException . createNew ( JmsErrorCode . DUPLICATE_MESSAGE_LISTENER_NAME ) . put ( ERROR_MESSAGE_LISTENER_NAME , messageListenerDefinition . getName ( ) ) ; } } | Register a message listener definition to be managed by the JMS plugin . |
12,597 | public static List < String > extractParameterNames ( Serializable lambda , int lambdaParametersCount ) { SerializedLambda serializedLambda = serialized ( lambda ) ; Method lambdaMethod = lambdaMethod ( serializedLambda ) ; String [ ] paramNames = paramNameReader . getParamNames ( lambdaMethod ) ; return asList ( Arrays . copyOfRange ( paramNames , paramNames . length - lambdaParametersCount , paramNames . length ) ) ; } | Extracts names of a serializable lambda parameters |
12,598 | protected final void initialize ( ) { if ( development ) { loggingSettings . getLoggers ( ) . put ( "org.hibernate.SQL" , Level . DEBUG ) ; loggingSettings . getLoggers ( ) . put ( "com.metrink.croquet" , Level . DEBUG ) ; } init ( ) ; } | Perform post de - serialization modification of the Settings . |
12,599 | @ SuppressWarnings ( "unchecked" ) protected < T > Class < T > getClassOrDefault ( final String className , final Class < T > defaultResult ) { try { return className == null ? defaultResult : ( Class < T > ) Class . forName ( className ) ; } catch ( final ClassNotFoundException e ) { LOG . error ( "ClassNotFoundException for {} - defaulting to {}" , className , defaultResult ) ; return defaultResult ; } } | Helper method used to obtain a class from a fully qualified class name . If the value is null or an exception is thrown return the default result instead . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.