idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
8,200 | void download ( ) { final String path = location . getAbsolutePath ( ) ; logger . info ( "About to download Galaxy from " + downloader . toString ( ) + " to " + path ) ; this . downloader . downloadTo ( location , cache ) ; logger . info ( "Finished downloading Galaxy to " + path ) ; } | Performs the download of Galaxy . |
8,201 | public final int getRelativeX ( ) { NativeEvent e = getNativeEvent ( ) ; Element target = getTarget ( ) ; return e . getClientX ( ) - target . getAbsoluteLeft ( ) + target . getScrollLeft ( ) + target . getOwnerDocument ( ) . getScrollLeft ( ) ; } | Get relative x position on the page . |
8,202 | public final int getRelativeY ( ) { NativeEvent e = getNativeEvent ( ) ; Element target = getTarget ( ) ; return e . getClientY ( ) - target . getAbsoluteTop ( ) + target . getScrollTop ( ) + target . getOwnerDocument ( ) . getScrollTop ( ) ; } | Get relative y position on the page . |
8,203 | public static Function < Object , Collection < ? > > COLLECTION ( final Class < ? extends Collection > collectionType ) { return as ( new CollectionConverterImpl < > ( collectionType , null ) ) ; } | Converts an object to a collection |
8,204 | public static < T > Function < Object , Collection < T > > COLLECTION ( final Class < ? extends Collection > collectionType , final Class < T > componentType ) { return new CollectionConverterImpl < > ( collectionType , componentType ) ; } | Converts an object to a collection and converts the components as well . |
8,205 | private void setClassFields ( String name , String superClassName , String [ ] interfaces , int asmAccessMask , File location ) { this . className = translateInternalClassName ( name ) ; this . locationFound = location ; if ( ( superClassName != null ) && ( ! superClassName . equals ( "java/lang/Object" ) ) ) { this . superClassName = translateInternalClassName ( superClassName ) ; } if ( interfaces != null ) { this . implementedInterfaces = new String [ interfaces . length ] ; for ( int i = 0 ; i < interfaces . length ; i ++ ) { this . implementedInterfaces [ i ] = translateInternalClassName ( interfaces [ i ] ) ; } } modifier = convertAccessMaskToModifierMask ( asmAccessMask ) ; } | Set the fields in this object . |
8,206 | private int convertAccessMaskToModifierMask ( int asmAccessMask ) { int modifier = 0 ; if ( ( asmAccessMask & Opcodes . ACC_FINAL ) != 0 ) modifier |= Modifier . FINAL ; if ( ( asmAccessMask & Opcodes . ACC_NATIVE ) != 0 ) modifier |= Modifier . NATIVE ; if ( ( asmAccessMask & Opcodes . ACC_INTERFACE ) != 0 ) modifier |= Modifier . INTERFACE ; if ( ( asmAccessMask & Opcodes . ACC_ABSTRACT ) != 0 ) modifier |= Modifier . ABSTRACT ; if ( ( asmAccessMask & Opcodes . ACC_PRIVATE ) != 0 ) modifier |= Modifier . PRIVATE ; if ( ( asmAccessMask & Opcodes . ACC_PROTECTED ) != 0 ) modifier |= Modifier . PROTECTED ; if ( ( asmAccessMask & Opcodes . ACC_PUBLIC ) != 0 ) modifier |= Modifier . PUBLIC ; if ( ( asmAccessMask & Opcodes . ACC_STATIC ) != 0 ) modifier |= Modifier . STATIC ; if ( ( asmAccessMask & Opcodes . ACC_STRICT ) != 0 ) modifier |= Modifier . STRICT ; if ( ( asmAccessMask & Opcodes . ACC_SYNCHRONIZED ) != 0 ) modifier |= Modifier . SYNCHRONIZED ; if ( ( asmAccessMask & Opcodes . ACC_TRANSIENT ) != 0 ) modifier |= Modifier . TRANSIENT ; if ( ( asmAccessMask & Opcodes . ACC_VOLATILE ) != 0 ) modifier |= Modifier . VOLATILE ; return modifier ; } | Convert an ASM access mask to a reflection Modifier mask . |
8,207 | public Message call ( ) throws InterruptedException { AbstractExpectation . LOGGER . info ( "Thread blocked waiting for message to pass condition {}." , this . getBlockingCondition ( ) ) ; try { this . latch . await ( ) ; this . manager . unsetExpectation ( this ) ; AbstractExpectation . LOGGER . info ( "Condition passed." ) ; if ( this . actionFuture != null ) { this . waitUntilActionComplete ( ) ; } AbstractExpectation . LOGGER . info ( "Expectation processing passed." ) ; return this . stash ; } finally { this . manager . unsetExpectation ( this ) ; this . actionFuture = null ; AbstractExpectation . LOGGER . info ( "Thread unblocked." ) ; } } | Will start the wait for the condition to become true . |
8,208 | public final String logOnServer ( LogRecord lr ) { String strongName = getPermutationStrongName ( ) ; logger . error ( lr . getMessage ( ) ) ; return null ; } | Logs a Log Record which has been serialized using GWT RPC on the server . |
8,209 | public void setSymbolMapsDirectory ( String symbolMapsDir ) { if ( deobfuscator == null ) { deobfuscator = new StackTraceDeobfuscator ( symbolMapsDir ) ; } else { deobfuscator . setSymbolMapsDirectory ( symbolMapsDir ) ; } } | By default this service does not do any deobfuscation . In order to do server side deobfuscation you must copy the symbolMaps files to a directory visible to the server and set the directory using this method . |
8,210 | public static String [ ] removePathTemplate ( List < MappedEndpoint > mappedEndpoints ) { return mappedEndpoints . stream ( ) . filter ( me -> ! me . type . equals ( MappedEndpoint . Type . STATIC ) ) . map ( me -> { int idx = me . url . indexOf ( "/{" ) ; return idx >= 0 ? me . url . substring ( 0 , idx ) : me . url ; } ) . distinct ( ) . toArray ( String [ ] :: new ) ; } | best effort to resolve url that may be unique |
8,211 | private static Double3D normalizeDouble3D ( Double3D vector ) { double invertedlen = 1.0D / Math . sqrt ( vector . x * vector . x + vector . y * vector . y + vector . z * vector . z ) ; if ( ( invertedlen == ( 1.0D / 0.0D ) ) || ( invertedlen == ( - 1.0D / 0.0D ) ) || ( invertedlen == 0.0D ) || ( invertedlen != invertedlen ) ) throw new ArithmeticException ( "Vector length is " + Math . sqrt ( vector . x * vector . x + vector . y * vector . y + vector . z * vector . z ) + ", cannot normalize" ) ; return new Double3D ( vector . x * invertedlen , vector . y * invertedlen , vector . z * invertedlen ) ; } | Normalize a Double3D object |
8,212 | public static int findFreePort ( ) { ServerSocket socket = null ; try { socket = new ServerSocket ( 0 ) ; socket . setReuseAddress ( true ) ; int port = socket . getLocalPort ( ) ; try { socket . close ( ) ; } catch ( IOException e ) { } return port ; } catch ( IOException e ) { } finally { if ( socket != null ) { try { socket . close ( ) ; } catch ( IOException e ) { } } } throw new IllegalStateException ( "Could not find a free TCP/IP port to start Galaxy on" ) ; } | Returns a free port number on localhost . |
8,213 | public static boolean indexClassFile ( final Indexer indexer , final List < File > knownFiles , final File classFile ) { if ( knownFiles . contains ( classFile ) ) { return false ; } knownFiles . add ( classFile ) ; try ( final InputStream in = classFile . toURI ( ) . toURL ( ) . openStream ( ) ) { indexer . index ( in ) ; } catch ( final IOException ex ) { throw new RuntimeException ( "Error indexing file: " + classFile , ex ) ; } return true ; } | Indexes a single file except it was already analyzed . |
8,214 | public static void indexDir ( final Indexer indexer , final List < File > knownFiles , final File dir ) { final List < File > classes = Utils4J . pathsFiles ( dir . getPath ( ) , Utils4J :: classFile ) ; for ( final File file : classes ) { indexClassFile ( indexer , knownFiles , file ) ; } } | Indexes all classes in a directory or it s sub directories . |
8,215 | public static boolean indexJar ( final Indexer indexer , final List < File > knownFiles , final File jarFile ) { if ( knownFiles . contains ( jarFile ) ) { return false ; } knownFiles . add ( jarFile ) ; try ( final JarFile jar = new JarFile ( jarFile ) ) { final Enumeration < JarEntry > entries = jar . entries ( ) ; while ( entries . hasMoreElements ( ) ) { final JarEntry entry = entries . nextElement ( ) ; if ( entry . getName ( ) . endsWith ( ".class" ) ) { try ( final InputStream stream = jar . getInputStream ( entry ) ) { indexer . index ( stream ) ; } catch ( final IOException ex ) { throw new RuntimeException ( "Error indexing " + entry . getName ( ) + " in " + jarFile , ex ) ; } } } } catch ( final IOException ex ) { throw new RuntimeException ( "Error indexing " + jarFile , ex ) ; } return true ; } | Indexes a single JAR except it was already analyzed . |
8,216 | public static long totalImageDiff ( BufferedImage img1 , BufferedImage img2 ) { int width = img1 . getWidth ( ) ; int height = img1 . getHeight ( ) ; if ( ( width != img2 . getWidth ( ) ) || ( height != img2 . getHeight ( ) ) ) { throw new IllegalArgumentException ( "Image dimensions do not match" ) ; } long diff = 0 ; for ( int x = 0 ; x < width ; x ++ ) { for ( int y = 0 ; y < height ; y ++ ) { int rgb1 = img1 . getRGB ( x , y ) ; int rgb2 = img2 . getRGB ( x , y ) ; int a1 = ColorUtils . getAlpha ( rgb1 ) ; int r1 = ColorUtils . getRed ( rgb1 ) ; int g1 = ColorUtils . getGreen ( rgb1 ) ; int b1 = ColorUtils . getBlue ( rgb1 ) ; int a2 = ColorUtils . getAlpha ( rgb2 ) ; int r2 = ColorUtils . getRed ( rgb2 ) ; int g2 = ColorUtils . getGreen ( rgb2 ) ; int b2 = ColorUtils . getBlue ( rgb2 ) ; diff += Math . abs ( a1 - a2 ) ; diff += Math . abs ( r1 - r2 ) ; diff += Math . abs ( g1 - g2 ) ; diff += Math . abs ( b1 - b2 ) ; } } return diff ; } | The total difference between two images calculated as the sum of the difference in RGB values of each pixel the images MUST be the same dimensions . |
8,217 | public < T > T to ( Class < T > targetType ) { if ( targetType == String . class ) { return ( T ) value ; } try { final String methodName ; final Class type ; if ( targetType . isPrimitive ( ) ) { final String typeName = targetType . getSimpleName ( ) ; methodName = "parse" + typeName . substring ( 0 , 1 ) . toUpperCase ( ) + typeName . substring ( 1 ) ; type = PRIMITIVE_TO_OBJECT_TYPE_MAP . get ( targetType ) ; } else { methodName = "valueOf" ; type = targetType ; } return ( T ) type . getMethod ( methodName , String . class ) . invoke ( null , value ) ; } catch ( NoSuchMethodException | InvocationTargetException | IllegalAccessException e ) { throw new RuntimeException ( "Could not convert value '" + value + "' to type " + targetType . getName ( ) , e ) ; } } | Converts the underlying string value to a primitive value . |
8,218 | public static void addNewAgent ( ShanksSimulation sim , ShanksAgent agent ) throws ShanksException { sim . registerShanksAgent ( agent ) ; if ( sim . schedule . getTime ( ) < 0 ) { sim . schedule . scheduleRepeating ( Schedule . EPOCH , 2 , agent , 1 ) ; } else { sim . schedule . scheduleRepeating ( sim . schedule . getTime ( ) , 2 , agent , 1 ) ; } sim . logger . info ( "Added a new agent to the simulation: " + agent . getID ( ) ) ; } | Adds an agent to the simulation |
8,219 | public static void removeAgent ( ShanksSimulation sim , String agentID ) throws ShanksException { sim . logger . info ( "Stoppable not fount. Attempting direct stop..." ) ; sim . unregisterShanksAgent ( agentID ) ; sim . logger . info ( "Agent " + agentID + " stopped." ) ; } | Removes an agent with the given name from the simulation |
8,220 | public synchronized void clear ( ) { peers . clear ( ) ; for ( Future < ? > timeout : timeouts . values ( ) ) { timeout . cancel ( true ) ; } timeouts . clear ( ) ; } | Clear all known peers |
8,221 | private void notifyConnected ( Peer peer ) { for ( Listener listener : new HashSet < > ( listeners ) ) { listener . onConnected ( peer ) ; } } | Notifies all registered listeners of the connected peer |
8,222 | private void notifyActive ( Peer peer ) { for ( Listener listener : new HashSet < > ( listeners ) ) { listener . onActive ( peer ) ; } } | Notifies all registered listeners of the active peer |
8,223 | private void notifyInactive ( Peer peer ) { for ( Listener listener : new HashSet < > ( listeners ) ) { listener . onInactive ( peer ) ; } } | Notifies all registered listeners of the inactive peer |
8,224 | private void notifyDisconnected ( Peer peer ) { for ( Listener listener : new HashSet < > ( listeners ) ) { listener . onDisconnected ( peer ) ; } } | Notifies all registered listeners of the disconnected peer |
8,225 | protected final boolean complies ( final String value , final String constValue , final String separators ) { if ( value == null ) { return false ; } else { final StringTokenizer tok = new StringTokenizer ( value , separators ) ; while ( tok . hasMoreTokens ( ) ) { final String t = tok . nextToken ( ) ; if ( t . equals ( constValue ) ) { return true ; } } return false ; } } | Helper method for subclasses to do the comparation . |
8,226 | public final SgArgument getLastArgument ( ) { final int size = arguments . size ( ) ; if ( size == 0 ) { return null ; } return arguments . get ( size - 1 ) ; } | Returns the last argument of the list . |
8,227 | public final void addArgument ( final SgArgument arg ) { if ( arg == null ) { throw new IllegalArgumentException ( "The argument 'arg' cannot be null!" ) ; } if ( arg . getOwner ( ) != this ) { throw new IllegalArgumentException ( "The owner of 'arg' is different from 'this'!" ) ; } if ( ! arguments . contains ( arg ) ) { arguments . add ( arg ) ; } } | Adds an argument to the list . Does nothing if the argument is already in the list of arguments . You will never need to use this method in your code! An argument is added automatically to the owning behavior when it s constructed! |
8,228 | public final void addException ( final SgClass clasz ) { if ( clasz == null ) { throw new IllegalArgumentException ( "The argument 'clasz' cannot be null!" ) ; } if ( ! exceptions . contains ( clasz ) ) { exceptions . add ( clasz ) ; } } | Adds an exception to the list . Does nothing if the class is already in the list of exceptions . |
8,229 | public boolean run ( ) { ExecutorService executors = Executors . newFixedThreadPool ( producers . size ( ) + consumers . size ( ) ) ; runningProducers . set ( producers . size ( ) ) ; for ( Producer < V > producer : producers ) { producer . setOwner ( this ) ; executors . submit ( new ProducerThread ( producer ) ) ; } for ( java . util . function . Consumer < ? super V > consumer : consumers ) { executors . submit ( new ConsumerThread ( consumer ) ) ; } while ( runningProducers . get ( ) > 0 || ! queue . isEmpty ( ) ) { Threads . sleep ( 10 ) ; } executors . shutdown ( ) ; try { executors . awaitTermination ( Integer . MAX_VALUE , TimeUnit . SECONDS ) ; } catch ( InterruptedException e ) { logWarn ( e ) ; return false ; } return true ; } | Starts execution of the broker . |
8,230 | public void execute ( final T runnable ) { synchronized ( queue ) { if ( runnable != null && ! disabled ) { queue . addLast ( runnable ) ; queue . notify ( ) ; System . out . println ( "WorkQueue has added runable - WorkQueue size is " + queue . size ( ) ) ; } } } | Add a Runnable object to the pool to be executed once a thread is available |
8,231 | public static void runAndWait ( final Runnable r ) { try { if ( r != null ) { final Thread thread = new Thread ( r ) ; thread . start ( ) ; thread . join ( ) ; } } catch ( final Exception ex ) { LOG . debug ( "Thread has been interrupted and cannot be joined" , ex ) ; } } | Provides the boilerplate code for running and waiting on a Runnable . |
8,232 | protected String getNewLockValue ( long timeoutInMillis ) { long time = System . currentTimeMillis ( ) + timeoutInMillis + 1l ; String lockValue = ApplicationContext . NODE_ID + ":" + time ; return lockValue ; } | Return the new value for the lock for given timeout . |
8,233 | public File locatePom ( final File folder ) { if ( folder != null && folder . exists ( ) && folder . isDirectory ( ) ) { String moduleVersion = folder . getParentFile ( ) . getName ( ) ; File [ ] list = folder . listFiles ( ) ; File [ ] four = new File [ CeylonUtil . NUM_CEYLON_JAVA_DEP_TYPES ] ; for ( File file : list ) { if ( file . isFile ( ) ) { if ( "module.xml" . equals ( file . getName ( ) ) ) { four [ 0 ] = file ; } else if ( file . getName ( ) . endsWith ( "-" + moduleVersion + ".module" ) ) { four [ 1 ] = file ; } else if ( "module.properties" . equals ( file . getName ( ) ) ) { four [ 2 ] = file ; } else if ( file . getName ( ) . endsWith ( "-" + moduleVersion + ".car" ) ) { four [ 3 ] = file ; } } } for ( File file : four ) { if ( file != null ) { return file ; } } } return new File ( folder , "pom.xml" ) ; } | Implementing Maven API to locate the project model . |
8,234 | public T findOneByAttribute ( String attribute , Object value ) { CriteriaBuilder cb = getEntityManager ( ) . getCriteriaBuilder ( ) ; CriteriaQuery < T > query = cb . createQuery ( getEntityClass ( ) ) ; Root < T > from = query . from ( getEntityClass ( ) ) ; query . where ( cb . equal ( from . get ( attribute ) , value ) ) ; try { return getEntityManager ( ) . createQuery ( query ) . getSingleResult ( ) ; } catch ( NoResultException e ) { return null ; } } | Finds an entity by a given attribute . Returns null if none was found . |
8,235 | protected void execute ( EntityManagerCommand command ) { try { getEntityManagerCommandExecutor ( ) . execute ( command ) ; } catch ( javax . persistence . PersistenceException e ) { throw new PersistenceException ( e ) ; } } | Executes the given command using an EntityManagerCommandExecutor . |
8,236 | public void removeTimeChart ( String chartID ) throws ShanksException { Scenario3DPortrayal scenarioPortrayal = ( Scenario3DPortrayal ) this . getSimulation ( ) . getScenarioPortrayal ( ) ; scenarioPortrayal . removeTimeChart ( chartID ) ; } | Remove a chart to the simulation |
8,237 | public void addScatterPlot ( String scatterID , String xAxisLabel , String yAxisLabel ) throws ShanksException { Scenario3DPortrayal scenarioPortrayal = ( Scenario3DPortrayal ) this . getSimulation ( ) . getScenarioPortrayal ( ) ; scenarioPortrayal . addScatterPlot ( scatterID , xAxisLabel , yAxisLabel ) ; } | Add a Scatter Plot to the simulation |
8,238 | public static < T extends Comparable < ? super T > > Integer getSortOrder ( final T first , final T second ) { if ( first == null && second == null ) return null ; if ( first == null && second != null ) return - 1 ; if ( first != null && second == null ) return 1 ; return first . compareTo ( second ) ; } | Provides an easy way to compare two possibly null comparable objects |
8,239 | public static < T > boolean isEqual ( final T first , final T second ) { if ( first == second ) return true ; if ( first == null && second != null ) return false ; return first . equals ( second ) ; } | Provides an easy way to see if two possibly null objects are equal |
8,240 | public static String [ ] trimStringArray ( final String [ ] input ) { final ArrayList < String > output = new ArrayList < String > ( ) ; for ( int i = 0 ; i < input . length ; i ++ ) { String s = input [ i ] . trim ( ) ; if ( ! s . equals ( "" ) ) output . add ( s ) ; } return output . toArray ( new String [ 0 ] ) ; } | Trims an array of Strings to remove the whitespace . If the string is empty then its removed from the array . |
8,241 | public ConcatVector newWeightsVector ( boolean presize ) { ConcatVector vector = new ConcatVector ( featureToIndex . size ( ) ) ; if ( presize ) { for ( ObjectCursor < String > s : sparseFeatureIndex . keys ( ) ) { int size = sparseFeatureIndex . get ( s . value ) . size ( ) ; vector . setDenseComponent ( ensureFeature ( s . value ) , new double [ size ] ) ; } } setAlwaysOneFeature ( vector , 1 ) ; return vector ; } | This constructs a fresh vector that is sized correctly to accommodate all the known sparse values for vectors that are possibly sparse . |
8,242 | public int ensureFeature ( String featureName ) { int feature = featureToIndex . getOrDefault ( featureName , - 1 ) ; if ( feature == - 1 ) { synchronized ( featureToIndex ) { feature = featureToIndex . getOrDefault ( featureName , - 1 ) ; if ( feature == - 1 ) { feature = featureToIndex . size ( ) ; featureToIndex . put ( featureName , feature ) ; } } } return feature ; } | An optimization this lets clients inform the ConcatVectorNamespace of how many features to expect so that we can avoid resizing ConcatVectors . |
8,243 | public int ensureSparseFeature ( String featureName , String index ) { ensureFeature ( featureName ) ; ObjectIntMap < String > sparseIndex = sparseFeatureIndex . get ( featureName ) ; IntObjectMap < String > reverseSparseIndex = reverseSparseFeatureIndex . get ( featureName ) ; if ( sparseIndex == null || reverseSparseIndex == null ) { synchronized ( sparseFeatureIndex ) { sparseIndex = sparseFeatureIndex . get ( featureName ) ; reverseSparseIndex = reverseSparseFeatureIndex . get ( featureName ) ; if ( sparseIndex == null || reverseSparseIndex == null ) { sparseIndex = new ObjectIntHashMap < > ( ) ; reverseSparseIndex = new IntObjectHashMap < > ( ) ; sparseFeatureIndex . put ( featureName , sparseIndex ) ; reverseSparseFeatureIndex . put ( featureName , reverseSparseIndex ) ; } } } Integer rtn = sparseIndex . getOrDefault ( index , - 1 ) ; if ( rtn == - 1 ) { synchronized ( sparseIndex ) { rtn = sparseIndex . getOrDefault ( index , - 1 ) ; if ( rtn == - 1 ) { rtn = sparseIndex . size ( ) ; reverseSparseIndex . put ( rtn , index ) ; sparseIndex . put ( index , rtn ) ; } } } return rtn ; } | An optimization this lets clients inform the ConcatVectorNamespace of how many sparse feature components to expect again so that we can avoid resizing ConcatVectors . |
8,244 | public void setDenseFeature ( ConcatVector vector , String featureName , double [ ] value ) { vector . setDenseComponent ( ensureFeature ( featureName ) , value ) ; } | This adds a dense feature to a vector setting the appropriate component of the given vector to the passed in value . |
8,245 | public void setSparseFeature ( ConcatVector vector , String featureName , String index , double value ) { vector . setSparseComponent ( ensureFeature ( featureName ) , ensureSparseFeature ( featureName , index ) , value ) ; } | This adds a sparse feature to a vector setting the appropriate component of the given vector to the passed in value . |
8,246 | public void debugVector ( ConcatVector vector , BufferedWriter bw ) throws IOException { List < String > features = new ArrayList < > ( ) ; Map < String , List < Integer > > sortedFeatures = new HashMap < > ( ) ; for ( ObjectCursor < String > key : featureToIndex . keys ( ) ) { features . add ( key . value ) ; int i = featureToIndex . getOrDefault ( key . value , - 1 ) ; List < Integer > featureIndices = new ArrayList < > ( ) ; if ( vector . isComponentSparse ( i ) ) { int [ ] indices = vector . getSparseIndices ( i ) ; for ( int j : indices ) { featureIndices . add ( j ) ; } } else { double [ ] arr = vector . getDenseComponent ( i ) ; for ( int j = 0 ; j < arr . length ; j ++ ) { featureIndices . add ( j ) ; } } featureIndices . sort ( ( a , b ) -> { if ( Math . abs ( vector . getValueAt ( i , a ) ) < Math . abs ( vector . getValueAt ( i , b ) ) ) { return 1 ; } else if ( Math . abs ( vector . getValueAt ( i , a ) ) > Math . abs ( vector . getValueAt ( i , b ) ) ) { return - 1 ; } else { return 0 ; } } ) ; sortedFeatures . put ( key . value , featureIndices ) ; } features . sort ( ( a , b ) -> { double bestAValue = sortedFeatures . get ( a ) . size ( ) == 0 ? 0.0 : Math . abs ( vector . getValueAt ( featureToIndex . getOrDefault ( a , - 1 ) , sortedFeatures . get ( a ) . get ( 0 ) ) ) ; double bestBValue = sortedFeatures . get ( b ) . size ( ) == 0 ? 0.0 : Math . abs ( vector . getValueAt ( featureToIndex . getOrDefault ( b , - 1 ) , sortedFeatures . get ( b ) . get ( 0 ) ) ) ; if ( bestAValue < bestBValue ) { return 1 ; } else if ( bestAValue > bestBValue ) { return - 1 ; } else return 0 ; } ) ; for ( String key : features ) { bw . write ( "FEATURE: \"" + key ) ; bw . write ( "\"\n" ) ; for ( int j : sortedFeatures . get ( key ) ) { debugFeatureValue ( key , j , vector , bw ) ; } } bw . flush ( ) ; } | This prints out a ConcatVector by mapping to the namespace to make debugging learning algorithms easier . |
8,247 | private void debugFeatureValue ( String feature , int index , ConcatVector vector , BufferedWriter bw ) throws IOException { bw . write ( "\t" ) ; if ( sparseFeatureIndex . containsKey ( feature ) && sparseFeatureIndex . get ( feature ) . values ( ) . contains ( index ) ) { bw . write ( "SPARSE VALUE \"" ) ; bw . write ( reverseSparseFeatureIndex . get ( feature ) . get ( index ) ) ; bw . write ( "\"" ) ; } else { bw . write ( Integer . toString ( index ) ) ; } bw . write ( ": " ) ; bw . write ( Double . toString ( vector . getValueAt ( featureToIndex . getOrDefault ( feature , - 1 ) , index ) ) ) ; bw . write ( "\n" ) ; } | This writes a feature s individual value using the human readable name if possible to a StringBuilder |
8,248 | public String format ( Object ... array ) { if ( array == null ) { return StringUtils . EMPTY ; } if ( array . length == 1 && array [ 0 ] . getClass ( ) . isArray ( ) ) { return format ( Convert . convert ( array [ 0 ] , Iterable . class ) ) ; } return format ( Arrays . asList ( array ) . iterator ( ) ) ; } | Formats the items in an Array . |
8,249 | public static String sha1Hash ( File file ) throws IOException { try { DigestInputStream inputStream = new DigestInputStream ( new FileInputStream ( file ) , MessageDigest . getInstance ( "SHA-1" ) ) ; try { byte [ ] buffer = new byte [ 4098 ] ; while ( inputStream . read ( buffer ) != - 1 ) { } return bytesToHex ( inputStream . getMessageDigest ( ) . digest ( ) ) ; } finally { inputStream . close ( ) ; } } catch ( NoSuchAlgorithmException ex ) { throw new IllegalStateException ( ex ) ; } } | Generate a SHA . 1 Hash for a given file . |
8,250 | public static void off ( HammerTime hammerTime , EventType eventType , NativeHammmerHandler callback ) { off ( hammerTime , callback , eventType . getText ( ) ) ; } | Unregister hammer event . |
8,251 | public String getProxyURLString ( HttpServletRequest req ) throws MalformedURLException { String proxyUrlString = proxyURLPrefix ; if ( req . getPathInfo ( ) != null ) if ( req . getPathInfo ( ) . length ( ) > 0 ) proxyUrlString += req . getPathInfo ( ) ; if ( req . getQueryString ( ) != null ) if ( req . getQueryString ( ) . length ( ) > 0 ) proxyUrlString += "?" + req . getQueryString ( ) ; req . getContentType ( ) ; return proxyUrlString ; } | Create the url string for the proxy server . |
8,252 | public HttpRequestBase getHttpRequest ( HttpServletRequest req , String urlString ) { HttpRequestBase httpget = null ; String method = req . getMethod ( ) ; if ( GET . equalsIgnoreCase ( method ) ) httpget = new HttpGet ( urlString ) ; else if ( POST . equalsIgnoreCase ( method ) ) httpget = new HttpPost ( urlString ) ; else if ( PUT . equalsIgnoreCase ( method ) ) httpget = new HttpPut ( urlString ) ; else if ( DELETE . equalsIgnoreCase ( method ) ) httpget = new HttpDelete ( urlString ) ; else if ( HEAD . equalsIgnoreCase ( method ) ) httpget = new HttpHead ( urlString ) ; else if ( OPTIONS . equalsIgnoreCase ( method ) ) httpget = new HttpOptions ( urlString ) ; else if ( TRACE . equalsIgnoreCase ( method ) ) httpget = new HttpTrace ( urlString ) ; return httpget ; } | Get the correct client type for this request . |
8,253 | public void addHeaders ( HttpServletRequest reqSource , HttpRequestBase httpTarget ) { Enumeration < ? > headerNames = reqSource . getHeaderNames ( ) ; while ( headerNames . hasMoreElements ( ) ) { String key = headerNames . nextElement ( ) . toString ( ) ; if ( CONTENT_LENGTH . equalsIgnoreCase ( key ) ) continue ; Enumeration < ? > headers = reqSource . getHeaders ( key ) ; while ( headers . hasMoreElements ( ) ) { String value = ( String ) headers . nextElement ( ) ; if ( HOST . equalsIgnoreCase ( key ) ) { value = proxyURLPrefix ; if ( value . indexOf ( ":" ) != - 1 ) { value = value . substring ( value . indexOf ( ":" ) + 1 ) ; while ( value . startsWith ( "/" ) ) { value = value . substring ( 1 ) ; } } if ( value . indexOf ( "/" ) != - 1 ) value = value . substring ( 0 , value . indexOf ( "/" ) ) ; } httpTarget . setHeader ( new BasicHeader ( key , value ) ) ; } } } | Move the header info to the proxy request . |
8,254 | public void getDataFromClient ( HttpRequestBase httpget , OutputStream streamOut ) throws ClientProtocolException , IOException { HttpClient httpclient = new DefaultHttpClient ( ) ; HttpResponse response = httpclient . execute ( httpget ) ; HttpEntity entity = response . getEntity ( ) ; if ( entity != null ) { InputStream instream = entity . getContent ( ) ; ProxyServlet . transferURLStream ( instream , streamOut ) ; instream . close ( ) ; httpclient . getConnectionManager ( ) . shutdown ( ) ; } } | Get the data from the proxy and send it to the client . |
8,255 | public static void transferURLStream ( InputStream streamIn , OutputStream streamOut ) { try { byte [ ] cbuf = new byte [ 1000 ] ; int iLen = 0 ; while ( ( iLen = streamIn . read ( cbuf , 0 , cbuf . length ) ) > 0 ) { streamOut . write ( cbuf , 0 , iLen ) ; } streamIn . close ( ) ; if ( streamIn != null ) streamIn . close ( ) ; } catch ( MalformedURLException ex ) { ex . printStackTrace ( ) ; } catch ( IOException ex ) { ex . printStackTrace ( ) ; } } | Transfer the data stream from this URL to another stream . |
8,256 | File findSdkHome ( final String path ) { File dotCeylon = new File ( path ) ; File [ ] homes = null ; if ( ! dotCeylon . exists ( ) ) { return null ; } else { homes = dotCeylon . listFiles ( new FilenameFilter ( ) { public boolean accept ( final File dir , final String name ) { if ( name . startsWith ( "ceylon-1." ) ) { return true ; } return false ; } } ) ; } if ( homes . length == 0 ) { return null ; } else if ( homes . length == 1 & homes [ 0 ] . isDirectory ( ) ) { return homes [ 0 ] ; } else { Arrays . sort ( homes ) ; if ( homes [ homes . length - 1 ] . isDirectory ( ) ) { return homes [ homes . length - 1 ] ; } else { return null ; } } } | Find Ceylon SDK home in a folder in the form of ceylon - 1 . x . x . |
8,257 | public Class < ? > getType ( String key ) { if ( beanDescriptor . hasReadMethod ( key ) ) { return beanDescriptor . getReadMethod ( key ) . getReturnType ( ) ; } else if ( beanDescriptor . hasWriteMethod ( key ) ) { Class < ? > [ ] paramTypes = beanDescriptor . getWriteMethod ( key ) . getParameterTypes ( ) ; if ( paramTypes . length > 0 ) { return paramTypes [ 0 ] ; } } return null ; } | Gets the type of the parameter on the setter method . |
8,258 | public T get ( X primaryID ) { if ( primaryID == null ) { return null ; } T dbObject = this . mongoTemplate . findById ( primaryID , this . entityClass ) ; return dbObject ; } | Return the object as defined by this primary key . |
8,259 | public boolean insert ( T entity ) { if ( entity == null ) { return false ; } X primaryID = getPrimaryID ( entity ) ; if ( primaryID != null ) { if ( ! allowEmptyOrZeroID ( ) && AssertUtils . isEmpty ( primaryID ) ) { return false ; } } try { this . mongoTemplate . insert ( entity ) ; } catch ( RuntimeException e ) { return false ; } return true ; } | Insert the object into the data store . |
8,260 | public boolean update ( T entity ) { if ( entity == null ) { return false ; } X primaryID = getPrimaryID ( entity ) ; if ( primaryID == null ) { return false ; } if ( ! allowEmptyOrZeroID ( ) && AssertUtils . isEmpty ( primaryID ) ) { return false ; } this . mongoTemplate . save ( entity ) ; return true ; } | Update the entity in the data store . |
8,261 | public boolean addOrUpdate ( T object ) { if ( object == null ) { return false ; } X primaryID = getPrimaryID ( object ) ; if ( primaryID == null ) { this . mongoTemplate . save ( object ) ; return true ; } if ( ! allowEmptyOrZeroID ( ) && AssertUtils . isEmpty ( primaryID ) ) { return false ; } this . mongoTemplate . save ( object ) ; return true ; } | Add or update an existing object in the data store . |
8,262 | public T delete ( X primaryID ) { if ( primaryID == null ) { return null ; } T entity = get ( primaryID ) ; if ( entity == null ) { return null ; } this . mongoTemplate . remove ( entity ) ; return entity ; } | Delete the object against the given primary key . |
8,263 | public X getPrimaryID ( T entity ) { if ( mappingContext == null || conversionService == null ) { fetchMappingContextAndConversionService ( ) ; } MongoPersistentEntity < ? > persistentEntity = mappingContext . getPersistentEntity ( entity . getClass ( ) ) ; MongoPersistentProperty idProperty = persistentEntity . getIdProperty ( ) ; if ( idProperty == null ) { return null ; } X idValue = ( X ) this . mappingContext . getPersistentEntity ( this . entityClass ) . getPropertyAccessor ( entity ) . getProperty ( idProperty ) ; return idValue ; } | Extract the value of the primary ID of the entity object |
8,264 | private synchronized void fetchMappingContextAndConversionService ( ) { if ( mappingContext == null ) { MongoConverter mongoConverter = this . mongoTemplate . getConverter ( ) ; mappingContext = mongoConverter . getMappingContext ( ) ; conversionService = mongoConverter . getConversionService ( ) ; MongoPersistentEntity < ? > persistentEntity = mappingContext . getPersistentEntity ( entityClass ) ; MongoPersistentProperty idProperty = persistentEntity . getIdProperty ( ) ; this . idKey = idProperty == null ? "_id" : idProperty . getName ( ) ; } } | Get the basic services from mongo template |
8,265 | public void readConfiguration ( File configFile ) throws TracerFactory . Exception , FileNotFoundException { if ( ! configFile . exists ( ) ) throw new FileNotFoundException ( configFile + "doesn't exist." ) ; try ( FileInputStream fileInputStream = new FileInputStream ( configFile ) ) { readConfiguration ( fileInputStream ) ; } catch ( IOException ex ) { ex . printStackTrace ( System . err ) ; } } | Reads the given configuration file validates it against a XML - Schema and creates the tracer pool its mappings and the queue accordingly . This method should normally be invoked once at program start . Multiple calls with the same configuration file leads to instantiations of new tracer objects and mappings which will replace the old tracers and their mappings . |
8,266 | public AbstractTracer getTracer ( String name ) throws TracerFactory . Exception { this . poolReadLock . lock ( ) ; try { return getTracerByName ( name ) ; } finally { this . poolReadLock . unlock ( ) ; } } | Returns the pooled tracer with the given name . |
8,267 | public void reset ( ) { this . poolWriteLock . lock ( ) ; try { this . defaultTracer = TracerFactory . NULLTRACER ; this . threadName2Element . clear ( ) ; this . threadNames . clear ( ) ; this . tracerMap . clear ( ) ; this . tracerPool . clear ( ) ; } finally { this . poolWriteLock . unlock ( ) ; } this . queueWriteLock . lock ( ) ; try { this . queueConfig = new Queue ( ) ; } finally { this . queueWriteLock . unlock ( ) ; } } | Clears the pool the mappings and the queue . |
8,268 | public void openPoolTracer ( ) { this . poolWriteLock . lock ( ) ; try { for ( AbstractTracer tracer : this . tracerPool . values ( ) ) { tracer . open ( ) ; } } finally { this . poolWriteLock . unlock ( ) ; } } | Opens all pooled tracers . |
8,269 | public void closePoolTracer ( ) { this . poolWriteLock . lock ( ) ; try { for ( AbstractTracer tracer : this . tracerPool . values ( ) ) { tracer . close ( ) ; } } finally { this . poolWriteLock . unlock ( ) ; } } | Closes all pooled tracers . |
8,270 | public boolean openQueueTracer ( ) { final int TRIALS = 5 ; int tracerCounter = 0 , trialCounter = 0 ; boolean success = false ; do { this . queueWriteLock . lock ( ) ; try { if ( this . queueConfig . enabled ) { for ( QueueTracer < ? > queueTracer : this . queueConfig . blockingTracerDeque ) { if ( ! queueTracer . isOpened ( ) ) { queueTracer . open ( ) ; tracerCounter ++ ; if ( tracerCounter == this . queueConfig . size ) success = true ; } } } } finally { this . queueWriteLock . unlock ( ) ; } trialCounter ++ ; } while ( tracerCounter < this . queueConfig . size && trialCounter < TRIALS ) ; return success ; } | Tries to open all enqueued QueueTracer . |
8,271 | public QueueTracer < ? > getCurrentQueueTracer ( ) { this . queueReadLock . lock ( ) ; try { QueueTracer < ? > tracer ; if ( this . queueConfig . enabled ) { tracer = this . queueConfig . currentTracer . get ( ) ; if ( tracer == null ) { tracer = this . queueConfig . queueNullTracer ; } } else { tracer = this . queueConfig . queueNullTracer ; } return tracer ; } finally { this . queueReadLock . unlock ( ) ; } } | Returns the QueueTracer for the current thread . If no one was found a QueueNullTracer will be returned . |
8,272 | void setValue ( String optionValue ) { if ( StringUtils . isNullOrBlank ( optionValue ) && isBoolean ( ) ) { this . value = true ; } else if ( ! StringUtils . isNullOrBlank ( optionValue ) ) { if ( Collection . class . isAssignableFrom ( type ) ) { Class < ? > genericType = field == null ? String . class : ( Class < ? > ) ( ( ParameterizedType ) field . getGenericType ( ) ) . getActualTypeArguments ( ) [ 0 ] ; this . value = Convert . convert ( optionValue , type , genericType ) ; } else if ( Map . class . isAssignableFrom ( type ) ) { Class < ? > keyType = field == null ? String . class : ( Class < ? > ) ( ( ParameterizedType ) field . getGenericType ( ) ) . getActualTypeArguments ( ) [ 0 ] ; Class < ? > valueType = field == null ? String . class : ( Class < ? > ) ( ( ParameterizedType ) field . getGenericType ( ) ) . getActualTypeArguments ( ) [ 1 ] ; this . value = Convert . convert ( optionValue , type , keyType , valueType ) ; } else { this . value = Convert . convert ( optionValue , type ) ; } } } | Sets the value of the option . |
8,273 | public boolean includes ( T value , boolean inclusive ) { if ( inclusive ) { return value . compareTo ( getStart ( ) ) >= 0 && value . compareTo ( getEnd ( ) ) <= 0 ; } else { return value . compareTo ( getStart ( ) ) > 0 && value . compareTo ( getEnd ( ) ) < 0 ; } } | Checks whether the given value is included in this range . If inclusive is set to true checking for 1 in the range of 1 10 will return true . |
8,274 | public final void process ( final File file ) { if ( file == null ) { throw new IllegalArgumentException ( "Argument 'file' cannot be NULL" ) ; } if ( file . isFile ( ) ) { handler . handleFile ( file ) ; } else { processDir ( file ) ; } } | Processes a file or directory . |
8,275 | protected final Object getProperty ( final Object obj , final String property ) { if ( ( obj == null ) || ( property == null ) || ( property . trim ( ) . length ( ) == 0 ) ) { return null ; } final String [ ] getterNames = createGetterNames ( property ) ; for ( int i = 0 ; i < getterNames . length ; i ++ ) { final String getter = getterNames [ i ] ; try { final Class cl = obj . getClass ( ) ; final Method m = cl . getMethod ( getter , new Class [ ] { } ) ; return m . invoke ( obj , new Object [ ] { } ) ; } catch ( final IllegalAccessException e ) { throw new RuntimeException ( "Accessing " + getter + " method of property '" + property + "' failed (private? protected?)! [" + obj . getClass ( ) + "]" , e ) ; } catch ( final InvocationTargetException e ) { throw new RuntimeException ( "Exception within " + getter + " method of property '" + property + "'! [" + obj . getClass ( ) + "]" , e . getCause ( ) ) ; } catch ( final NoSuchMethodException e ) { if ( i == getter . length ( ) - 1 ) { throw new RuntimeException ( "No " + getter + " method found for property! '" + property + "'! [" + obj . getClass ( ) + "]" , e ) ; } } } throw new IllegalStateException ( "No getters defined in 'createGetterNames()'!" ) ; } | Return the value of a property via reflection . |
8,276 | public static String generateCompilationStacktrace ( final DiagnosticCollector < JavaFileObject > diagnosticCollectors ) { final StringBuilder sb = new StringBuilder ( ) ; for ( final Diagnostic < ? extends JavaFileObject > diagnostic : diagnosticCollectors . getDiagnostics ( ) ) { sb . append ( diagnostic . getMessage ( null ) ) ; sb . append ( SeparatorConstants . SEMI_COLON_WHITE_SPACE ) ; } return sb . toString ( ) ; } | Generate a compilation stacktrace from the given parameter . |
8,277 | public static String getClassNameWithExtension ( final String className ) { return new StringBuilder ( ) . append ( className ) . append ( Kind . SOURCE . extension ) . toString ( ) ; } | Gets the class name with java file extension . |
8,278 | public static String newQualifiedClassName ( final String packageName , final String className ) { if ( StringUtils . isBlank ( packageName ) ) { return className ; } return new StringBuilder ( ) . append ( packageName ) . append ( SeparatorConstants . DOT ) . append ( className ) . toString ( ) ; } | Factory method for create a qualified class name from the given arguments . |
8,279 | public void waitUntilNoMoreException ( final Runnable runnable , final List < Class < ? extends Exception > > expectedExceptions ) { final List < RuntimeException > actualExceptions = new ArrayList < > ( ) ; int tries = 0 ; while ( tries < maxTries ) { try { runnable . run ( ) ; return ; } catch ( final RuntimeException ex ) { if ( ! Utils4J . expectedException ( ex , expectedExceptions ) && ! Utils4J . expectedCause ( ex , expectedExceptions ) ) { throw ex ; } actualExceptions . add ( ex ) ; tries ++ ; Utils4J . sleep ( sleepMillis ) ; } } throw new IllegalStateException ( "Waited too long for execution without exception. Expected exceptions: " + expectedExceptions + ", Actual exceptions: " + actualExceptions ) ; } | Wait until no more expected exception is thrown or the number of wait cycles has been exceeded . |
8,280 | public void clear ( ) { this . min = Double . POSITIVE_INFINITY ; this . max = Double . NEGATIVE_INFINITY ; this . sum = 0 ; this . sumOfSq = 0 ; this . count = 0 ; } | Clears the accumulated values . |
8,281 | public double getPopulationVariance ( ) { if ( getCount ( ) <= 0 ) { return Double . NaN ; } else if ( getCount ( ) == 1 ) { return 0d ; } return Math . abs ( getSumOfSquares ( ) - getAverage ( ) * getSum ( ) ) / getCount ( ) ; } | Gets the population variance . |
8,282 | public Template getTemplate ( final String parentName , final String name ) throws ResourceNotFoundException { return getTemplate ( this . loader . concat ( parentName , name ) ) ; } | get template by parent template s name and it s relative name . |
8,283 | public Template getTemplate ( final String name ) throws ResourceNotFoundException { final Template template = this . cachedTemplates . get ( name ) ; if ( template != null ) { return template ; } return createTemplateIfAbsent ( name ) ; } | get template by name . |
8,284 | public boolean exists ( final String resourceName ) { final Loader myLoader = this . loader ; final String normalizedName = myLoader . normalize ( resourceName ) ; if ( normalizedName == null ) { return false ; } return myLoader . get ( normalizedName ) . exists ( ) ; } | if exists this resource . |
8,285 | public static Engine create ( final String configPath , final Map < String , Object > parameters ) { return create ( createConfigProps ( configPath ) , parameters ) ; } | Create a Engine with given configPath and extra - parameters . |
8,286 | public static Engine create ( final Props props , final Map < String , Object > parameters ) { final Petite petite = new Petite ( ) ; petite . config ( props , parameters ) ; petite . initComponents ( ) ; final Engine engine = petite . get ( Engine . class ) ; engine . getLogger ( ) . info ( "Loaded props: {}" , props . getModulesString ( ) ) ; try { engine . executeInits ( ) ; } catch ( ResourceNotFoundException ex ) { throw new IllegalConfigException ( "engine.inits" , ex ) ; } return engine ; } | Create a Engine with given baseProps and extra - parameters . |
8,287 | @ SuppressWarnings ( "unchecked" ) public static Sequence run ( Query query , QueryableIndex index ) { return findFactory ( query ) . createRunner ( new QueryableIndexSegment ( "" , index ) ) . run ( query , null ) ; } | Executes a Query by identifying the appropriate QueryRunner |
8,288 | public void executeJob ( ) { AbstractApplicationContext springContext = SpringContext . getContext ( getSpringConfigurationClass ( ) ) ; StreamingCinchJob cinchJob = springContext . getBean ( StreamingCinchJob . class ) ; cinchJob . execute ( this ) ; } | Executes your streaming job from the spring context . |
8,289 | public < T > ForeachRddFunction < T > foreachRddFunction ( Class < ? extends VoidFunction < T > > springBeanClass ) { return new ForeachRddFunction < > ( voidFunction ( springBeanClass ) ) ; } | Create a new ForeachRddFunction which implements Spark s VoidFunction interface . |
8,290 | final void renderTo ( final ByteBuffer out ) { final ByteBuffer code = this . code ; out . putShort ( access ) . putShort ( name ) . putShort ( desc ) ; int attributeCount = 0 ; if ( code . length > 0 ) { ++ attributeCount ; } int exceptionCount = exceptions . length ; if ( exceptionCount > 0 ) { ++ attributeCount ; } out . putShort ( attributeCount ) ; if ( code . length > 0 ) { int size = 12 + code . length + 8 * catchCount ; if ( localVar != null ) { size += 8 + localVar . length ; } out . putShort ( cw . newUTF8 ( "Code" ) ) . putInt ( size ) . putShort ( maxStack ) . putShort ( maxLocals ) . putInt ( code . length ) . put ( code ) . putShort ( catchCount ) ; if ( catchCount > 0 ) { out . put ( catchTable ) ; } attributeCount = 0 ; if ( localVar != null ) { ++ attributeCount ; } out . putShort ( attributeCount ) ; if ( localVar != null ) { out . putShort ( cw . newUTF8 ( "LocalVariableTable" ) ) . putInt ( localVar . length + 2 ) . putShort ( localVarCount ) . put ( localVar ) ; } } if ( exceptionCount > 0 ) { out . putShort ( cw . newUTF8 ( "Exceptions" ) ) . putInt ( 2 * exceptionCount + 2 ) . putShort ( exceptionCount ) ; for ( int i = 0 ; i < exceptionCount ; ++ i ) { out . putShort ( exceptions [ i ] ) ; } } } | Puts the bytecode of this method in the given byte vector . |
8,291 | public static < E > E notNull ( E obj , String msg ) { if ( obj == null ) { throw ( msg == null ) ? new NullPointerException ( ) : new NullPointerException ( msg ) ; } return obj ; } | An assertion method that makes null validation more fluent |
8,292 | public static Loader csv ( Reader reader , List < String > columns , List < String > dimensions , String timestampDimension ) { return new CSVLoader ( reader , columns , dimensions , timestampDimension ) ; } | CSVLoader implementation of the Loader |
8,293 | private Item newInteger ( final int value ) { Item result = get ( key . set ( INT , value ) ) ; if ( result == null ) { pool . putByte ( INT ) . putInt ( value ) ; result = new Item ( poolIndex ++ , key ) ; put ( result ) ; } return result ; } | Adds an integer to the constant pool of the class being build . Does nothing if the constant pool already contains a similar item . |
8,294 | private Item newFloat ( final float value ) { Item result = get ( key . set ( FLOAT , value ) ) ; if ( result == null ) { pool . putByte ( FLOAT ) . putInt ( Float . floatToIntBits ( value ) ) ; result = new Item ( poolIndex ++ , key ) ; put ( result ) ; } return result ; } | Adds a float to the constant pool of the class being build . Does nothing if the constant pool already contains a similar item . |
8,295 | private Item newLong ( final long value ) { Item result = get ( key . set ( LONG , value ) ) ; if ( result == null ) { pool . putByte ( LONG ) . putLong ( value ) ; result = new Item ( poolIndex , key ) ; put ( result ) ; poolIndex += 2 ; } return result ; } | Adds a long to the constant pool of the class being build . Does nothing if the constant pool already contains a similar item . |
8,296 | private Item newString ( final String value ) { Item result = get ( key2 . set ( STR , value , null , null ) ) ; if ( result == null ) { pool . putBS ( STR , newUTF8 ( value ) ) ; result = new Item ( poolIndex ++ , key2 ) ; put ( result ) ; } return result ; } | Adds a string to the constant pool of the class being build . Does nothing if the constant pool already contains a similar item . |
8,297 | private void put122 ( final int b , final int s1 , final int s2 ) { pool . putBS ( b , s1 ) . putShort ( s2 ) ; } | Puts one byte and two shorts into the constant pool . |
8,298 | public static ByteBuffer readFile ( File inFile ) throws IOException { ByteBuffer mBuf ; try ( FileInputStream fIn = new FileInputStream ( inFile ) ; FileChannel fChan = fIn . getChannel ( ) ) { long fSize = fChan . size ( ) ; mBuf = ByteBuffer . allocate ( ( int ) fSize ) ; fChan . read ( mBuf ) ; mBuf . rewind ( ) ; } return mBuf ; } | Helper method to read a file into a ByteBuffer |
8,299 | public static boolean shouldFilter ( final IVulnerabilityFilter filter , final List < PackageCoordinate > path , final String vid ) { return ( ( VulnerabilityFilterImpl ) filter ) . shouldFilter ( path , vid ) ; } | Kind of filthy this being here . It is in lieu of making a separate utility class for now . It allows us to run the filter without exposing private functionality to the users . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.