idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
19,100
public void addCounter ( String field , Class < ? extends Execution > cls ) { counters . put ( field , cls ) ; }
Adds a query for counts on a specified field .
19,101
public void addSearch ( String field , Class < ? extends Execution > cls ) { searches . put ( field , cls ) ; }
Adds a query for searches on a specified field .
19,102
public void addSingleton ( String field , Class < ? extends Execution > cls ) { singletons . put ( field , cls ) ; }
Adds a query for searches on a specified field . These searches return unique values .
19,103
public long count ( String field , Object val ) throws PersistenceException { logger . debug ( "enter - count(String,Object)" ) ; try { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "For: " + cache . getTarget ( ) . getName ( ) + "/" + field + "/" + val ) ; } Class < ? extends Execution > cls ; SearchTerm [ ] t...
Counts the total number of objects in the database matching the specified criteria .
19,104
public long count ( Class < ? extends Execution > cls , Map < String , Object > criteria ) throws PersistenceException { logger . debug ( "enter - count(Class,Map)" ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "For: " + cache . getTarget ( ) . getName ( ) + "/" + cls + "/" + criteria ) ; } try { Transactio...
Counts the number of items matching an arbitrary query . This method expects the passed in query to have one field called count in the map it returns . Anything else is ignored
19,105
public Collection < T > find ( String field , Object val ) throws PersistenceException { logger . debug ( "enter - find(String,Object" ) ; try { return find ( field , val , null ) ; } finally { logger . debug ( "exit - find(String,Object)" ) ; } }
Executes a search that may return multiple values . The specified field must have been set up by a call to
19,106
public Collection < T > find ( Class < ? extends Execution > cls , Map < String , Object > criteria ) throws PersistenceException { logger . debug ( "enter - find(Class,Map)" ) ; try { Collection < String > keys = criteria . keySet ( ) ; SearchTerm [ ] terms = new SearchTerm [ keys . size ( ) ] ; int i = 0 ; for ( Stri...
Executes an arbitrary search using the passed in search class and criteria . This is useful for searches that simply do not fit well into the rest of the API .
19,107
public Iterable < LbEndpointType > listSupportedEndpointTypes ( ) throws CloudException , InternalException { return Collections . unmodifiableList ( Arrays . asList ( LbEndpointType . VM ) ) ; }
Describes what kind of endpoints may be added to a load balancer .
19,108
public Iterable < LbProtocol > listSupportedProtocols ( ) throws CloudException , InternalException { return Collections . unmodifiableList ( Arrays . asList ( LbProtocol . HTTP , LbProtocol . HTTPS ) ) ; }
Lists the network protocols supported for load balancer listeners .
19,109
private String getCamelCaseFromUnderscoreSeparated ( String underScoreSeparatedStr ) { final StringGrabber underScoreSeparatedSg = new StringGrabber ( underScoreSeparatedStr ) ; final StringGrabberList wordBlockList = underScoreSeparatedSg . split ( "_" ) ; final StringGrabber resultSg = new StringGrabber ( ) ; for ( i...
Convert underscore separated text into camel case text
19,110
protected < X extends IzouPermissionException > void registerOrThrow ( AddOnModel addOn , Supplier < X > exceptionSupplier , Function < PluginDescriptor , Boolean > checkPermission ) { getMain ( ) . getAddOnManager ( ) . getPluginWrapper ( addOn ) . map ( PluginWrapper :: getDescriptor ) . map ( checkPermission ) . ifP...
registers the addon if checkPermission returns true else throws the exception provided by the exceptionSupplier . If the Addon was not added through PF4J it gets ignored
19,111
public InputSource resolveEntity ( String publicId , String systemId ) { String r = map . get ( publicId ) ; return r == null ? null : new InputSource ( Resources . stream ( r ) ) ; }
Get input source for entity definition file identified by public and system ID .
19,112
synchronized String serializeNativeFlowContext ( ) { StringBuilder result = new StringBuilder ( uniqueId ) ; if ( showTxCounter ) { if ( innerTxCounter . get ( ) != 0 ) { result = result . append ( TX_DELIM ) . append ( innerTxCounter ) ; } } return result . toString ( ) ; }
Get String represent FlowContextImpl
19,113
public static final byte [ ] toAsciiBytes ( final String value ) { byte [ ] result = new byte [ value . length ( ) ] ; for ( int i = 0 ; i < value . length ( ) ; i ++ ) { result [ i ] = ( byte ) value . charAt ( i ) ; } return result ; }
Convert specified String to a byte array .
19,114
public final void setTemplate ( ) { template = new HashMap ( ) ; if ( isEventExist ( ) ) { template . putAll ( events . get ( next ) ) ; } template . put ( "event" , eventType ) ; }
Set template with selected event type
19,115
public HashMap addEvent ( String date , boolean useTemp ) { HashMap ret = new HashMap ( ) ; if ( useTemp ) { ret . putAll ( template ) ; } else { ret . put ( "event" , eventType ) ; } ret . put ( "date" , date ) ; getInertIndex ( ret ) ; events . add ( next , ret ) ; return ret ; }
Add a new event into array with selected event type and input date .
19,116
private void getNextEventIndex ( ) { for ( int i = next + 1 ; i < events . size ( ) ; i ++ ) { String evName = getValueOr ( events . get ( i ) , "event" , "" ) ; if ( evName . equals ( eventType ) ) { next = i ; return ; } } next = events . size ( ) ; }
Move index to the next planting event
19,117
private void getInertIndex ( HashMap event ) { int iDate ; try { iDate = Integer . parseInt ( getValueOr ( event , "date" , "" ) ) ; } catch ( Exception e ) { next = events . size ( ) ; return ; } for ( int i = isEventExist ( ) ? next : 0 ; i < events . size ( ) ; i ++ ) { try { if ( iDate < Integer . parseInt ( getVal...
Find out the insert position for the new event . If date is not available for the new event will return the last position of array
19,118
static int wrap ( int value , int max ) { int result = value % max ; if ( result < 0 ) { return result + ( max > 0 ? max : - max ) ; } return result ; }
Wrap the given value to be in [ 0 |max| )
19,119
public static boolean areElementsLessThanOrEqual ( LongTuple t , long value ) { for ( int i = 0 ; i < t . getSize ( ) ; i ++ ) { if ( t . get ( i ) > value ) { return false ; } } return true ; }
Returns whether all elements of the given tuple are less than or equal to the given value .
19,120
protected void engineReset ( ) { int i = 60 ; do { pad [ i ] = ( byte ) 0x00 ; pad [ i + 1 ] = ( byte ) 0x00 ; pad [ i + 2 ] = ( byte ) 0x00 ; pad [ i + 3 ] = ( byte ) 0x00 ; } while ( ( i -= 4 ) >= 0 ) ; padding = 0 ; bytes = 0 ; init ( ) ; }
Reset athen initialize the digest context .
19,121
public void engineUpdate ( byte input ) { bytes ++ ; if ( padding < 63 ) { pad [ padding ++ ] = input ; return ; } pad [ 63 ] = input ; computeBlock ( pad , 0 ) ; padding = 0 ; }
Updates the digest using the specified byte . Requires internal buffering and may be slow .
19,122
public void saveGlobalProperties ( ) throws IOException { File propFile = new File ( getGlobalPropertiesFile ( ) ) ; if ( propFile . createNewFile ( ) || propFile . isFile ( ) ) { java . util . Properties prop = new java . util . Properties ( ) ; if ( getRoundingMode ( ) != null ) prop . put ( "roundingMode" , getRound...
File location .. \ bin \ org . jdice . calc . properties
19,123
private boolean checkEventsControllers ( EventModel event ) { List < CompletableFuture < Boolean > > collect = eventsControllers . stream ( ) . map ( controller -> submit ( ( ) -> controller . controlEventDispatcher ( event ) ) . thenApply ( result -> { if ( ! result ) debug ( "Event: " + event + " is canceled by " + c...
Checks whether to dispatch an event
19,124
private void processEvent ( EventModel < ? > event ) { if ( ! event . getSource ( ) . isCreatedFromInstance ( ) ) { error ( "event: " + event + "has invalid source" ) ; return ; } debug ( "EventFired: " + event . toString ( ) + " from " + event . getSource ( ) . getID ( ) ) ; submit ( ( ) -> event . lifecycleCallback (...
process the Event
19,125
public int compareTo ( Tuple other ) { int temp = compareItems ( other ) ; if ( temp != 0 ) return temp ; return getClass ( ) == other . getClass ( ) ? 0 : - 1 ; }
Compares this Tuple with another Tuple for order .
19,126
protected static boolean elementsEquals ( Object e1 , Object e2 ) { return ( e1 == null && e2 == null ) || e1 . equals ( e2 ) ; }
Helper - method to check if two elements are equal .
19,127
public void setId ( String id ) { if ( StringUtils . isNullOrBlank ( id ) ) { this . id = UUID . randomUUID ( ) . toString ( ) ; } else { this . id = id ; } }
Sets the id of the document . If a null or blank id is given a random id will generated .
19,128
public String toJson ( ) { try { Resource stringResource = Resources . fromString ( ) ; write ( stringResource ) ; return stringResource . readToString ( ) . trim ( ) ; } catch ( IOException e ) { throw Throwables . propagate ( e ) ; } }
Converts the document to json
19,129
public final boolean includes ( Version version ) { if ( minimum != null ) { int minimumComparison = minimum . compareTo ( version ) ; if ( minimumComparison > 0 ) { return false ; } if ( ( ! minimumIncluded ) && ( minimumComparison == 0 ) ) { return false ; } } if ( maximum != null ) { int maximumComparison = maximum ...
Checks whether a specified version is included in the version range or not .
19,130
public ZipExtractor into ( File directory ) throws IOException { try { ensureThatDirectoryExists ( directory ) ; writeEntriesIntoDirectory ( directory ) ; return this ; } catch ( IOException cause ) { close ( ) ; throw cause ; } }
Extracts the zip content into a file . It only automatically closes the stream when an exception is thrown .
19,131
public ConfigParams readConfig ( String correlationId , ConfigParams parameters ) throws ApplicationException { Object value = readObject ( correlationId , parameters ) ; return ConfigParams . fromValue ( value ) ; }
Reads configuration and parameterize it with given values .
19,132
private void detectImplmentedExtension ( ) { if ( isImplExtRegistered == false ) { Object o = getThis ( ) ; Class thisClass = o . getClass ( ) ; Class [ ] declared = thisClass . getSuperclass ( ) . getInterfaces ( ) ; for ( Class declare : declared ) { detectImplmentedExtension ( declare ) ; } declared = thisClass . ge...
Read implemented extensions by subclass
19,133
private void detectImplmentedExtension ( Class declare ) { Class c = BindExtensionProvider . getExtension ( declare ) ; if ( c == null && declare . isAnnotationPresent ( BindExtension . class ) ) { BindExtension impl = ( BindExtension ) declare . getAnnotation ( BindExtension . class ) ; if ( impl != null ) c = impl . ...
Register defined operation or function class to global cache
19,134
protected final CALC operator ( Class < ? extends Operator > operator , Object value ) { Num tmp = null ; if ( value instanceof Num ) tmp = ( Num ) value ; else tmp = new Num ( value ) ; infix . add ( CacheExtension . getOperator ( operator ) ) ; infix . add ( tmp ) ; return getThis ( ) ; }
Append operator and number to expression
19,135
protected final CALC operator ( Class < ? extends Operator > operator , String value , char decimalSeparator ) { return operator ( operator , new Num ( value , decimalSeparator ) ) ; }
Append operator and parsed String value with custom decimal separator used in String representation of value
19,136
public final CALC function ( Class < ? extends Function > function , Object ... values ) { Function fn = CacheExtension . getFunction ( function ) ; FunctionData fd = new FunctionData ( fn , values ) ; this . infix . addFunction ( fd ) ; return getThis ( ) ; }
Append function with value to expression .
19,137
public final CALC expression ( String expression ) throws ParseException { detectImplmentedExtension ( ) ; if ( infixParser == null ) infixParser = new InfixParser ( ) ; CList infix = infixParser . parse ( useExtensions , getProperties ( ) , expression ) ; expression ( infix , false ) ; return getThis ( ) ; }
Parse and append given expression to existing expression
19,138
public CALC setDecimalSeparator ( char decimalSeparator ) { getProperties ( ) . setInputDecimalSeparator ( decimalSeparator ) ; getProperties ( ) . setOutputDecimalSeparator ( decimalSeparator ) ; return getThis ( ) ; }
Set decimal separator for entire expression
19,139
public Num calculate ( ) { unbind ( ) ; prepareForNewCalculation ( ) ; PostfixCalculator pc = convertToPostfix ( ) ; Num cv = pc . calculate ( this , postfix , trackSteps ) ; lastCalculatedValue = cv . clone ( ) ; return cv ; }
Calculate prepared expression .
19,140
public < T extends AbstractCalculator > T bind ( Class < T > clazz ) { T childCalc = null ; try { childCalc = clazz . newInstance ( ) ; } catch ( Exception e ) { throw new CalculatorException ( e ) ; } if ( childCalc instanceof AbstractCalculator ) { AbstractCalculator < CALC > bParent = this ; while ( bParent != null ...
Bind another Calculator class functionalities to expression .
19,141
private CALC unbindAll ( AbstractCalculator < CALC > undbindFrom ) { AbstractCalculator root = undbindFrom . parentCalculator != null ? undbindFrom . parentCalculator : undbindFrom ; AbstractCalculator child = root . childCalculator ; while ( root != null ) { AbstractCalculator tmpParent = root . parentCalculator ; if ...
Unbind all binded calculators
19,142
private PostfixCalculator convertToPostfix ( ) { if ( postfix == null || postfix . size ( ) == 0 || isInfixChanged ) { postfixCalculator . toPostfix ( infix ) ; postfix = postfixCalculator . getPostfix ( ) ; isInfixChanged = false ; } return postfixCalculator ; }
Convert infix to postfix Conversion is made only first time or after any change in structure of infix expression
19,143
static public Angle sum ( Angle angle1 , Angle angle2 ) { return new Angle ( angle1 . value + angle2 . value ) ; }
This function returns the normalized sum of two angles .
19,144
static public Angle difference ( Angle angle1 , Angle angle2 ) { return new Angle ( angle1 . value - angle2 . value ) ; }
This function returns the normalized difference of two angles .
19,145
static public double sine ( Angle angle ) { double result = lock ( Math . sin ( angle . value ) ) ; return result ; }
This function returns the sine of the specified angle .
19,146
static public double cosine ( Angle angle ) { double result = lock ( Math . cos ( angle . value ) ) ; return result ; }
This function returns the cosine of the specified angle .
19,147
static public double tangent ( Angle angle ) { double result = lock ( Math . tan ( angle . value ) ) ; return result ; }
This function returns the tangent of the specified angle .
19,148
public void register ( String correlationId , ConnectionParams connection ) throws ApplicationException { boolean result = registerInDiscovery ( correlationId , connection ) ; if ( result ) _connections . add ( connection ) ; }
Registers the given connection in all referenced discovery services . This method can be used for dynamic service discovery .
19,149
public ConnectionParams resolve ( String correlationId ) throws ApplicationException { if ( _connections . size ( ) == 0 ) return null ; for ( ConnectionParams connection : _connections ) { if ( ! connection . useDiscovery ( ) ) return connection ; } for ( ConnectionParams connection : _connections ) { if ( connection ...
Resolves a single component connection . If connections are configured to be retrieved from Discovery service it finds a IDiscovery and resolves the connection there .
19,150
public List < ConnectionParams > resolveAll ( String correlationId ) throws ApplicationException { List < ConnectionParams > resolved = new ArrayList < ConnectionParams > ( ) ; List < ConnectionParams > toResolve = new ArrayList < ConnectionParams > ( ) ; for ( ConnectionParams connection : _connections ) { if ( connec...
Resolves all component connection . If connections are configured to be retrieved from Discovery service it finds a IDiscovery and resolves the connection there .
19,151
public static int getAppVersion ( final Context context ) { try { final PackageInfo packageInfo = context . getPackageManager ( ) . getPackageInfo ( context . getPackageName ( ) , 0 ) ; return packageInfo . versionCode ; } catch ( PackageManager . NameNotFoundException ignore ) { } return Integer . MIN_VALUE ; }
Returns the version code of the application .
19,152
public static String getPackageInstaller ( final Context context ) { final PackageManager packageManager = context . getPackageManager ( ) ; return packageManager . getInstallerPackageName ( context . getPackageName ( ) ) ; }
Returns the package name of the application installer .
19,153
public void start ( ) { boolean succeeded = true ; Iterator i = mappingFilesMap . keySet ( ) . iterator ( ) ; while ( i . hasNext ( ) ) { String mappingName = ( String ) i . next ( ) ; String fileName = mappingFilesMap . getProperty ( mappingName ) ; System . out . println ( new LogEntry ( "loading mapping '" + mapping...
Loads mappings .
19,154
public void setProperties ( Properties properties ) throws ConfigurationException { autoReload = Boolean . valueOf ( properties . getProperty ( "autoreload" , "true" ) ) ; defaultMappingName = properties . getProperty ( "defaultmapping" , defaultMappingName ) ; mappingFilesMap = PropertiesSupport . getSubsection ( prop...
Loads mapping values .
19,155
public static void executeMojo ( Plugin plugin , String goal , Xpp3Dom configuration , ExecutionEnvironment env ) throws MojoExecutionException { if ( configuration == null ) { throw new NullPointerException ( "configuration may not be null" ) ; } try { String executionId = null ; if ( goal != null && goal . length ( )...
Entry point for executing a mojo
19,156
public static Xpp3Dom configuration ( Element ... elements ) { Xpp3Dom dom = new Xpp3Dom ( "configuration" ) ; for ( Element e : elements ) { dom . addChild ( e . toDom ( ) ) ; } return dom ; }
Builds the configuration for the goal using Elements
19,157
public static Plugin plugin ( String groupId , String artifactId ) { return plugin ( groupId , artifactId , null ) ; }
Defines the plugin without its version
19,158
public static Plugin plugin ( String groupId , String artifactId , String version ) { Plugin plugin = new Plugin ( ) ; plugin . setArtifactId ( artifactId ) ; plugin . setGroupId ( groupId ) ; plugin . setVersion ( version ) ; return plugin ; }
Defines a plugin
19,159
public static boolean isRMIRegistryRunning ( Configuration configuration , int port ) { try { final Registry registry = RegistryFinder . getInstance ( ) . getRegistry ( configuration , port ) ; registry . list ( ) ; return true ; } catch ( RemoteException ex ) { return false ; } catch ( Exception e ) { return false ; }...
Checks if rmiregistry is running on the specified port .
19,160
public static boolean isServiceExported ( Configuration configuration , int port , String serviceName ) { if ( serviceName == null ) return false ; try { final Registry registry = RegistryFinder . getInstance ( ) . getRegistry ( configuration , port ) ; String [ ] list = registry . list ( ) ; if ( list != null ) { for ...
Checks if a service is exported on the rmi registry with specified port .
19,161
public static boolean startRMIRegistry ( Configuration configuration , int port ) { if ( isRMIRegistryRunning ( configuration , port ) ) return true ; if ( configuration . getBoolean ( FoundationMonitoringConstants . IN_PROC_RMI ) ) { return startInProcRMIRegistry ( port ) ; } else { return startOutProcRMIRegistry ( co...
Starts rmiregistry on the specified port . If property service . monitor . inProcess is set to true in configSchema . xml then an in - process rmiregistry is started . Otherwise rmiregistry will be started in a seperate process .
19,162
public static boolean startInProcRMIRegistry ( final int port ) { LOGGER . info ( "Starting In-Process rmiregistry on port " + port ) ; boolean result = true ; try { LocateRegistry . createRegistry ( port ) ; LOGGER . info ( "In-Process rmiregistry started on port " + port ) ; } catch ( RemoteException e ) { LOGGER . e...
Starts in - process rmiregistry on the specified port .
19,163
public static boolean startOutProcRMIRegistry ( Configuration configuration , final int port ) { LOGGER . info ( "Starting rmiregistry on port " + port ) ; try { Registry registryStarted = RegistryFinder . getInstance ( ) . getRegistry ( configuration , port ) ; if ( registryStarted != null ) { LOGGER . info ( "rmiregi...
Starts rmiregistry in a separate process on the specified port .
19,164
public static String computePasswordHash ( final String password , final byte [ ] salt ) { if ( StringMan . isEmpty ( password ) ) return ( StringMan . encodeBytesToString ( salt ) ) ; final KeySpec spec = new PBEKeySpec ( password . toCharArray ( ) , salt , 2048 , 160 ) ; SecretKeyFactory f ; try { f = SecretKeyFactor...
Uses PBKDF2WithHmacSHA1 to hash the password using the given salt returning the has in encoded hexadecimal form . If the password is empty returns the salt .
19,165
public static byte [ ] stringToSalt ( final String string ) { try { final MessageDigest digest = MessageDigest . getInstance ( "SHA-1" ) ; digest . reset ( ) ; return digest . digest ( string . getBytes ( "UTF-8" ) ) ; } catch ( final NoSuchAlgorithmException ex ) { throw new RuntimeException ( ex ) ; } catch ( final U...
Uses SHA - 1 to hash the given string and returns the byte array .
19,166
public static void execute ( CopyResourcesMojo copyResourcesMojo , Resource resource , File outputDirectory ) throws ResourceExecutionException { copyResourcesMojo . getLog ( ) . debug ( "Execute resource : " + resource ) ; File workspacePlugin = PathUtils . getWorkspace ( copyResourcesMojo ) ; if ( workspacePlugin . e...
execute with a resource
19,167
@ SuppressWarnings ( "unchecked" ) private static Enumeration < LogEntry > getLogEntries ( LogReaderService lrs ) { return ( Enumeration < LogEntry > ) lrs . getLog ( ) ; }
Utility method to reduce unchecked area .
19,168
public void readConnections ( ConfigParams connections ) { synchronized ( _lock ) { _items . clear ( ) ; for ( Map . Entry < String , String > entry : connections . entrySet ( ) ) { DiscoveryItem item = new DiscoveryItem ( ) ; item . key = entry . getKey ( ) ; item . connection = ConnectionParams . fromString ( entry ....
Reads connections from configuration parameters . Each section represents an individual Connection params
19,169
public void register ( String correlationId , String key , ConnectionParams connection ) { synchronized ( _lock ) { DiscoveryItem item = new DiscoveryItem ( ) ; item . key = key ; item . connection = connection ; _items . add ( item ) ; } }
Registers connection parameters into the discovery service .
19,170
public ConnectionParams resolveOne ( String correlationId , String key ) { ConnectionParams connection = null ; synchronized ( _lock ) { for ( DiscoveryItem item : _items ) { if ( item . key == key && item . connection != null ) { connection = item . connection ; break ; } } } return connection ; }
Resolves a single connection parameters by its key .
19,171
public List < ConnectionParams > resolveAll ( String correlationId , String key ) { List < ConnectionParams > connections = new ArrayList < ConnectionParams > ( ) ; synchronized ( _lock ) { for ( DiscoveryItem item : _items ) { if ( item . key == key && item . connection != null ) connections . add ( item . connection ...
Resolves all connection parameters by their key .
19,172
private JScrollPane getScrollPane ( ) { if ( scrollPane == null ) { scrollPane = new JScrollPane ( ) ; scrollPane . setViewportView ( getTable ( ) ) ; } return scrollPane ; }
This method initializes scrollPane
19,173
private JTable getTable ( ) { if ( table == null ) { table = new JTable ( ) ; table . setModel ( getModel ( ) ) ; ProgressBarRenderer . applyTo ( table ) ; } return table ; }
This method initializes table
19,174
public static double dot ( DoubleTuple t0 , DoubleTuple t1 ) { Utils . checkForEqualSize ( t0 , t1 ) ; double result = 0 ; for ( int i = 0 ; i < t0 . getSize ( ) ; i ++ ) { result += t0 . get ( i ) * t1 . get ( i ) ; } return result ; }
Computes the dot product of the given tuples
19,175
private static void appendRange ( StringBuilder sb , DoubleTuple tuple , Locale locale , String format , int min , int max ) { for ( int i = min ; i < max ; i ++ ) { if ( i > min ) { sb . append ( ", " ) ; } if ( locale != null && format != null ) { sb . append ( String . format ( locale , format , tuple . get ( i ) ) ...
Append the string representation of the specified range of the given tuple to the given string builder
19,176
public static void randomize ( MutableDoubleTuple t , double min , double max , Random random ) { double delta = max - min ; for ( int i = 0 ; i < t . getSize ( ) ; i ++ ) { t . set ( i , min + random . nextDouble ( ) * delta ) ; } }
Fill the given tuple with random values in the specified range using the given random number generator
19,177
public static MutableDoubleTuple createRandom ( int size , Random random ) { MutableDoubleTuple t = create ( size ) ; randomize ( t , random ) ; return t ; }
Creates a tuple with the given size that is filled with random values in [ 0 1 )
19,178
public static void randomizeGaussian ( MutableDoubleTuple t , Random random ) { for ( int i = 0 ; i < t . getSize ( ) ; i ++ ) { double value = random . nextGaussian ( ) ; t . set ( i , value ) ; } }
Randomize the given tuple with a gaussian distribution with a mean of 0 . 0 and standard deviation of 1 . 0
19,179
public static MutableDoubleTuple createRandomGaussian ( int size , Random random ) { MutableDoubleTuple t = create ( size ) ; randomizeGaussian ( t , random ) ; return t ; }
Creates a tuple with the given size that was filled with values from a gaussian distribution with mean 0 . 0 and standard deviation 1 . 0
19,180
public static MutableDoubleTuple normalizeElements ( DoubleTuple t , double min , double max , MutableDoubleTuple result ) { return rescaleElements ( t , min ( t ) , max ( t ) , min , max , result ) ; }
Normalize the elements of the given tuple so that its minimum and maximum elements match the given minimum and maximum values .
19,181
public static MutableDoubleTuple normalizeElements ( DoubleTuple t , DoubleTuple min , DoubleTuple max , MutableDoubleTuple result ) { result = validate ( t , result ) ; for ( int i = 0 ; i < result . getSize ( ) ; i ++ ) { double value = t . get ( i ) ; double minValue = min . get ( i ) ; double maxValue = max . get (...
Normalize the elements of the given tuple so that each element will be linearly rescaled to the interval defined by the corresponding elements of the given minimum and maximum tuple . Each element that is equal to the corresponding minimum element will be 0 . 0 in the resulting tuple . Each element that is equal to the...
19,182
public static MutableDoubleTuple rescaleElements ( DoubleTuple t , double oldMin , double oldMax , double newMin , double newMax , MutableDoubleTuple result ) { double invDelta = 1.0 / ( oldMax - oldMin ) ; double newRange = newMax - newMin ; double scaling = invDelta * newRange ; return DoubleTupleFunctions . apply ( ...
Rescale the elements of the given tuple so that the specified old range is mapped to the specified new range .
19,183
public static double geometricMean ( DoubleTuple t ) { double product = DoubleTupleFunctions . reduce ( t , 1.0 , ( a , b ) -> ( a * b ) ) ; return Math . pow ( product , 1.0 / t . getSize ( ) ) ; }
Returns the geometric mean of the given tuple
19,184
public static double harmonicMean ( DoubleTuple t ) { double s = DoubleTupleFunctions . reduce ( t , 0.0 , ( a , b ) -> ( a + ( 1.0 / b ) ) ) ; return t . getSize ( ) / s ; }
Returns the harmonic mean of the given tuple
19,185
public static MutableDoubleTuple standardize ( DoubleTuple t , MutableDoubleTuple result ) { result = DoubleTuples . validate ( t , result ) ; double mean = arithmeticMean ( t ) ; double standardDeviation = standardDeviationFromMean ( t , mean ) ; double invStandardDeviation = 1.0 / standardDeviation ; return DoubleTup...
Standardize the given tuple . This means that the mean of the elements is subtracted from them and they are divided by the standard deviation .
19,186
public static double arithmeticMean ( DoubleTuple t ) { double sum = DoubleTupleFunctions . reduce ( t , 0.0 , ( a , b ) -> ( a + b ) ) ; return sum / t . getSize ( ) ; }
Returns the arithmetic mean of the given tuple
19,187
public static double variance ( DoubleTuple t , double mean ) { int d = t . getSize ( ) ; double variance = 0 ; for ( int i = 0 ; i < d ; i ++ ) { double difference = t . get ( i ) - mean ; variance += difference * difference ; } return variance / ( d - 1 ) ; }
Returns the bias - corrected sample variance of the given tuple .
19,188
public static boolean containsNaN ( DoubleTuple tuple ) { for ( int i = 0 ; i < tuple . getSize ( ) ; i ++ ) { if ( Double . isNaN ( tuple . get ( i ) ) ) { return true ; } } return false ; }
Returns whether the given tuple contains an element that is Not A Number
19,189
public static MutableDoubleTuple replaceNaN ( DoubleTuple t , double newValue , MutableDoubleTuple result ) { return DoubleTupleFunctions . apply ( t , d -> Double . isNaN ( d ) ? newValue : d , result ) ; }
Replace all occurrences of Not A Number in the given tuple with the given value and store the result in the given result tuple
19,190
static Line getAndRegisterLine ( Line line ) { AddOnModel addOnModel ; Optional < AddOnModel > addOnModelForClassLoader = main . getSecurityManager ( ) . getAddOnModelForClassLoader ( ) ; if ( ! addOnModelForClassLoader . isPresent ( ) ) { logger . debug ( "the SoundManager will not manage this line, obtained by system...
creates the appropriate IzouSoundLine if the request originates from an AddOn .
19,191
public String getReport ( ) { StringBuffer info = new StringBuffer ( ) ; if ( ! isCachingEnabled ( ) ) { info . append ( "cache behaviour: DISABLED\n" ) ; } else if ( isCachingPermanent ( ) ) { info . append ( "cache behaviour: PERMANENT\n" ) ; } else { info . append ( "cache behaviour: NORMAL\n" ) ; } info . append ( ...
Returns a status report containing behavior and statistics .
19,192
public void stop ( ) { hits = 0 ; misses = 0 ; unavailable = 0 ; delayedHits = 0 ; delayedMisses = 0 ; data . clear ( ) ; mirror . clear ( ) ; isStarted = false ; }
Clears storage . Resets statistics . Is invoked by superclass .
19,193
public Object retrieve ( K key , int timeout ) { Object retval = null ; if ( isCachingEnabled ( ) ) { CachedObject < V > co = getCachedObject ( key ) ; if ( co == null || isCachedObjectExpired ( co ) ) { misses ++ ; co = new CachedObject < V > ( ) ; co . setBeingRetrieved ( ) ; this . storeCachedObject ( key , co ) ; }...
Retrieves an object from cache . This method should be used if a programmer suspects bursts of requests for a particular object . If this is the case the first thread will retrieve the object the others will wait for some time in order to save overhead .
19,194
private Object storeCachedObject ( K key , CachedObject < V > co ) { synchronized ( data ) { data . put ( key , co ) ; } synchronized ( mirror ) { mirror . put ( key , co ) ; } System . out . println ( new LogEntry ( "object with key " + key + " stored in cache" ) ) ; return co ; }
Places an empty wrapper in the cache to indicate that some thread should be busy retrieving the object after which it should be cached after all .
19,195
public V retrieve ( K key ) { V retval = null ; if ( isCachingEnabled ( ) ) { CachedObject < V > co = getCachedObject ( key ) ; if ( co == null || ( isCachedObjectExpired ( co ) ) ) { misses ++ ; } else if ( co . getObject ( ) == null ) { unavailable ++ ; } else { hits ++ ; retval = co . getObject ( ) ; } } return retv...
Retrieves an object from cache .
19,196
public long cleanup ( ) { int garbageSize = 0 ; if ( isCachingEnabled ( ) ) { System . out . println ( new LogEntry ( Level . VERBOSE , "Identifying expired objects" ) ) ; ArrayList < K > garbage = getExpiredObjects ( ) ; garbageSize = garbage . size ( ) ; System . out . println ( new LogEntry ( "cache cleanup: expired...
Removes all expired objects .
19,197
public void clear ( Object key ) { Object removed ; if ( isCachingEnabled ( ) ) { synchronized ( mirror ) { synchronized ( data ) { removed = data . remove ( key ) ; mirror . remove ( key ) ; } } System . out . println ( new LogEntry ( "object with key " + key + ( removed == null ? " NOT" : "" ) + " removed from cache"...
Removes an object from cache .
19,198
public void clear ( Collection keys ) { synchronized ( mirror ) { synchronized ( data ) { Iterator i = keys . iterator ( ) ; while ( i . hasNext ( ) ) { Object key = i . next ( ) ; data . remove ( key ) ; mirror . remove ( key ) ; } } } }
Removes a collection of objects from cache .
19,199
public void readCredentials ( ConfigParams credentials ) { synchronized ( _lock ) { _items . clear ( ) ; for ( Map . Entry < String , String > entry : credentials . entrySet ( ) ) _items . put ( entry . getKey ( ) , CredentialParams . fromString ( entry . getValue ( ) ) ) ; } }
Reads credentials from configuration parameters . Each section represents an individual CredentialParams