idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
13,500
public static StringBuilder createStackTrace ( StringBuilder s , Throwable t , boolean includeCause ) { s . append ( t . getClass ( ) . getName ( ) ) ; s . append ( ": " ) ; s . append ( t . getMessage ( ) ) ; createStackTrace ( s , t . getStackTrace ( ) ) ; if ( includeCause ) { Throwable cause = t . getCause ( ) ; if...
Append a stack trace of the given Throwable to the StringBuilder .
13,501
public static StringBuilder createStackTrace ( StringBuilder s , StackTraceElement [ ] stack ) { if ( stack != null ) for ( StackTraceElement e : stack ) { s . append ( "\n\tat " ) ; s . append ( e . getClassName ( ) ) ; if ( e . getMethodName ( ) != null ) { s . append ( '.' ) ; s . append ( e . getMethodName ( ) ) ; ...
Append a stack trace to a StringBuilder .
13,502
public static LanguageExtension findFirst ( Collection < ? extends Extension > extensions ) { for ( Extension extension : extensions ) { if ( LANGUAGE_EXTENSION_ID == extension . getId ( ) ) return ( LanguageExtension ) extension ; } return null ; }
Returns the first LanguageExtension found in the given collection of extensions or null if the extension collection does not contain a LanguageExtension .
13,503
public static List < LanguageExtension > findAll ( Collection < ? extends Extension > extensions ) { List < LanguageExtension > result = new ArrayList < LanguageExtension > ( ) ; for ( Extension extension : extensions ) { if ( LANGUAGE_EXTENSION_ID == extension . getId ( ) ) result . add ( ( LanguageExtension ) extensi...
Returns all LanguageExtension found in the given collection of extensions or an empty list if the extension collection does not contain LanguageExtensions .
13,504
public ByteBuffer getBuffer ( ) { ByteBuffer buf = buffers . pollFirst ( ) ; if ( buf != null ) { buf . clear ( ) ; return buf ; } return ByteBuffer . wrap ( new byte [ bufferSize ] ) ; }
Get a buffer .
13,505
private boolean checkDefaultFileAlterDiscard ( ) { return id . equals ( ID3v2Frames . AUDIO_SEEK_POINT_INDEX ) || id . equals ( ID3v2Frames . AUDIO_ENCRYPTION ) || id . equals ( ID3v2Frames . EVENT_TIMING_CODES ) || id . equals ( ID3v2Frames . EQUALISATION ) || id . equals ( ID3v2Frames . MPEG_LOCATION_LOOKUP_TABLE ) |...
Returns true if this frame should have the file alter preservation bit set by default .
13,506
private void parseFlags ( byte [ ] flags ) throws ID3v2FormatException { if ( flags . length != FRAME_FLAGS_SIZE ) { throw new ID3v2FormatException ( "Error parsing flags of frame: " + id + ". Expected 2 bytes." ) ; } else { tagAlterDiscard = ( flags [ 0 ] & 0x40 ) != 0 ; fileAlterDiscard = ( flags [ 0 ] & 0x20 ) != 0...
Read the information from the flags array .
13,507
private byte [ ] getFlagBytes ( ) { byte flags [ ] = new byte [ 2 ] ; if ( tagAlterDiscard ) flags [ 0 ] |= 0x40 ; if ( fileAlterDiscard ) flags [ 0 ] |= 0x20 ; if ( readOnly ) flags [ 0 ] |= 0x10 ; if ( grouped ) flags [ 1 ] |= 0x40 ; if ( compressed ) flags [ 1 ] |= 0x08 ; if ( encrypted ) flags [ 1 ] |= 0x04 ; if ( ...
A helper function for the getFrameBytes method that processes the info in the frame and returns the 2 byte array of flags to be added to the header .
13,508
private void parseData ( byte [ ] data ) { int bytesRead = 0 ; if ( grouped ) { group = data [ bytesRead ] ; bytesRead ++ ; } if ( encrypted ) { encrType = data [ bytesRead ] ; bytesRead ++ ; } if ( lengthIndicator ) { dataLength = Helpers . convertDWordToInt ( data , bytesRead ) ; bytesRead += 4 ; } frameData = new by...
Pulls out extra information inserted in the frame data depending on what flags are set .
13,509
public int getFrameLength ( ) { int length = frameData . length + FRAME_HEAD_SIZE ; if ( grouped ) { length ++ ; } if ( encrypted ) { length ++ ; } if ( lengthIndicator ) { length += 4 ; } return length ; }
Return the length of this frame in bytes including the header .
13,510
public byte [ ] getFrameBytes ( ) { int length = getFrameLength ( ) ; int bytesWritten = 0 ; byte [ ] flags = getFlagBytes ( ) ; byte [ ] extra = getExtraDataBytes ( ) ; byte [ ] b ; b = new byte [ length ] ; System . arraycopy ( id . getBytes ( ) , 0 , b , 0 , id . length ( ) ) ; bytesWritten += id . length ( ) ; Syst...
Returns a byte array representation of this frame that can be written to a file . Includes the header and data .
13,511
private byte [ ] getExtraDataBytes ( ) { byte [ ] buf = new byte [ MAX_EXTRA_DATA ] ; byte [ ] ret ; int bytesCopied = 0 ; if ( grouped ) { buf [ bytesCopied ] = group ; bytesCopied ++ ; } if ( encrypted ) { buf [ bytesCopied ] = encrType ; bytesCopied ++ ; } if ( lengthIndicator ) { System . arraycopy ( Helpers . conv...
A helper function for the getFrameBytes function that returns an array of all the data contained in any extra fields that may be present in this frame . This includes the group the encryption type and the length indicator . The length of the array returned is variable length .
13,512
public String getDataString ( ) throws ID3v2FormatException { String str = null ; if ( frameData . length > 1 ) { final String enc_type = ( frameData [ 0 ] < ENC_TYPES . length ) ? ENC_TYPES [ frameData [ 0 ] ] : null ; try { if ( ( id . charAt ( 0 ) == 'T' ) || id . equals ( ID3v2Frames . OWNERSHIP_FRAME ) ) { str = H...
If possible this method attempts to convert textual part of the data into a string . If this frame does not contain textual information an empty string is returned .
13,513
public static Menu getMenu ( List < String > permissions ) throws PMException { try { MenuBuilder mb = new MenuBuilder ( PresentationManager . getPm ( ) . getMenu ( ) ) ; Menu menu = cleanWithoutPerms ( mb . getMenu ( ) , permissions ) ; return menu ; } catch ( Exception e ) { throw new PMException ( "pm_core.cant.load...
Builds the menu for the user .
13,514
public static String padleft ( String s , int len , char c ) { s = s . trim ( ) ; if ( s . length ( ) > len ) { return s ; } final StringBuilder sb = new StringBuilder ( len ) ; int fill = len - s . length ( ) ; while ( fill -- > 0 ) { sb . append ( c ) ; } sb . append ( s ) ; return sb . toString ( ) ; }
Pad to the left
13,515
public synchronized void storeConfiguration ( ) throws IOException { OutputStream out = new FileOutputStream ( configFilePath ) ; configuration . store ( out , configFilePath ) ; }
Saves the configuration
13,516
public Obuffer decodeFrame ( Header header , Bitstream stream ) throws DecoderException { try { if ( ! initialized ) { initialize ( header ) ; } int layer = header . layer ( ) ; output . clear_buffer ( ) ; FrameDecoder decoder = retrieveDecoder ( header , stream , layer ) ; decoder . decodeFrame ( ) ; output . write_bu...
Decodes one frame from an MPEG audio bitstream .
13,517
public synchronized void use ( Object user ) { usage ++ ; lastUsage = System . currentTimeMillis ( ) ; if ( users != null ) users . add ( user ) ; }
Add the given object as user of this cached data .
13,518
public synchronized void release ( Object user ) { usage -- ; if ( users != null ) { if ( ! users . remove ( user ) ) LCCore . getApplication ( ) . getDefaultLogger ( ) . error ( "CachedObject released by " + user + " but not in users list" , new Exception ( ) ) ; } }
Remove the given object as user of this cached data .
13,519
public ISynchronizationPoint < ? extends Exception > serializeValue ( SerializationContext context , Object value , TypeDefinition typeDef , String path , List < SerializationRule > rules ) { if ( value == null ) return serializeNullValue ( ) ; for ( SerializationRule rule : rules ) value = rule . convertSerializationV...
Serialize a value .
13,520
private void setPattern ( int pattNum , ModfileInputStream inputStream ) throws IOException { int row = 0 ; PatternRow currentRow = getPatternContainer ( ) . getPatternRow ( pattNum , row ) ; int count = inputStream . readIntelWord ( ) - 2 ; while ( count >= 0 ) { int packByte = inputStream . readByteAsInt ( ) ; count ...
Set a Pattern by interpreting
13,521
public boolean includes ( int [ ] v ) { if ( min != null && Version . compare ( v , min ) < 0 ) return false ; if ( max == null ) return true ; int c = Version . compare ( v , max ) ; if ( c > 0 ) return false ; if ( c < 0 ) return true ; return maxIncluded ; }
Return true if this VersionRange includes the given version .
13,522
public SelectBuilder from ( Class < ? > entityClass ) { if ( rootTable == null ) { rootTable = new TableInfo ( entityClass , dialect ) ; currentTable = rootTable ; } else { join ( entityClass ) ; } tables . add ( currentTable ) ; return this ; }
Retrieves the columns from the given entity and inner joins it to the previous entity given to the builder .
13,523
public SelectBuilder join ( Class < ? > from , Class < ? > to ) { currentTable = rootTable . join ( from , to ) ; return this ; }
Joins from and to . from becomes the current entity .
13,524
public SelectBuilder leftJoin ( Class < ? > entityClass ) { currentTable = rootTable . leftJoin ( entityClass , currentTable . entityClass ) ; return this ; }
Left joins this entity to the previous entity given to the builder .
13,525
public SelectBuilder rightJoin ( Class < ? > entityClass ) { currentTable = rootTable . rightJoin ( entityClass , currentTable . entityClass ) ; return this ; }
Right joins this entity to the previous entity given to the builder .
13,526
public SelectBuilder columns ( String ... columns ) { for ( String column : columns ) { column ( column , null ) ; } return this ; }
Adds the columns of the current entity to the select clause
13,527
protected void doTremorEffekt ( ChannelMemory aktMemo ) { if ( aktMemo . tremorCount < aktMemo . tremorOntime ) aktMemo . currentVolume = aktMemo . currentSetVolume ; else aktMemo . currentVolume = 0 ; aktMemo . tremorCount ++ ; if ( aktMemo . tremorCount > ( aktMemo . tremorOntime + aktMemo . tremorOfftime ) ) aktMemo...
The tremor effekt
13,528
protected void doVolumeSlideEffekt ( ChannelMemory aktMemo ) { int x = aktMemo . volumSlideValue >> 4 ; int y = aktMemo . volumSlideValue & 0xF ; if ( x != 0 ) { if ( x == 0xF && y != 0 ) aktMemo . currentSetVolume = aktMemo . currentVolume -= y ; else aktMemo . currentSetVolume = aktMemo . currentVolume += x ; } else ...
Convenient Method for the VolumeSlide Effekt
13,529
protected void doChannelVolumeSlideEffekt ( ChannelMemory aktMemo ) { int x = aktMemo . channelVolumSlideValue >> 4 ; int y = aktMemo . channelVolumSlideValue & 0xF ; if ( x != 0 ) { if ( x == 0xF && y != 0 ) aktMemo . channelVolume -= y ; else aktMemo . channelVolume += x ; } else if ( y != 0 ) { if ( x != 0 && y == 0...
Same as the volumeSlide but affects the channel volume
13,530
protected void doPanningSlideEffekt ( ChannelMemory aktMemo ) { aktMemo . doSurround = false ; aktMemo . panning += aktMemo . panningSlideValue ; }
Convenient Method for the panning slide Effekt
13,531
public void enforceVersion ( Log log , String variableName , String requiredVersionRange , ArtifactVersion actualVersion ) throws EnforcerRuleException { if ( StringUtils . isEmpty ( requiredVersionRange ) ) { throw new EnforcerRuleException ( variableName + " version can't be empty." ) ; } else { VersionRange vr ; Str...
Compares the specified version to see if it is allowed by the defined version range .
13,532
public static boolean containsVersion ( VersionRange allowedRange , ArtifactVersion theVersion ) { boolean matched = false ; ArtifactVersion recommendedVersion = allowedRange . getRecommendedVersion ( ) ; if ( recommendedVersion == null ) { @ SuppressWarnings ( "unchecked" ) List < Restriction > restrictions = allowedR...
Copied from Artifact . VersionRange . This is tweaked to handle singular ranges properly . Currently the default containsVersion method assumes a singular version means allow everything . This method assumes that 2 . 0 . 4 == [ 2 . 0 . 4 )
13,533
public static FilterFragment [ ] from ( Filter ... filters ) { FilterFragment [ ] ret = new FilterFragment [ filters . length ] ; Arrays . setAll ( ret , ( i ) -> new FilterFragment ( filters [ i ] ) ) ; return ret ; }
A new array of filter fragments each constructed using the corresponding filters in the provided array .
13,534
public PersistenceManager getPersistenceManager ( ) { if ( persistenceManager == null ) { try { persistenceManager = getPresentationManager ( ) . newPersistenceManager ( ) ; } catch ( Exception ex ) { getPresentationManager ( ) . error ( ex ) ; throw new ConnectionNotFoundException ( ) ; } } return persistenceManager ;...
Return the persistence manager
13,535
public EntityContainer getEntityContainer ( String id ) { EntityContainer ec = ( EntityContainer ) getPmsession ( ) . getContainer ( id ) ; if ( ec == null ) { ec = getPresentationManager ( ) . newEntityContainer ( id ) ; getPmsession ( ) . setContainer ( id , ec ) ; } return ec ; }
Retrieve the container with the given id from session . If not defined a new one is created .
13,536
public EntityContainer getEntityContainer ( boolean ignorenull ) throws PMException { if ( ignorenull ) { return entityContainer ; } if ( entityContainer == null ) { throw new PMException ( "pm_core.entity.not.found" ) ; } return entityContainer ; }
Returns the entity container
13,537
public EntityInstanceWrapper getSelected ( ) throws PMException { final EntityContainer container = getEntityContainer ( true ) ; if ( container == null ) { return null ; } return container . getSelected ( ) ; }
Return the selected item of the container
13,538
public Object getParameter ( String paramid ) { final Object v = get ( PARAM_PREFIX + paramid ) ; if ( v == null ) { return null ; } else { if ( v instanceof String [ ] ) { String [ ] s = ( String [ ] ) v ; if ( s . length == 1 ) { return s [ 0 ] ; } else { return s ; } } return v ; } }
Look for a parameter in the context with the given name .
13,539
public Object getParameter ( String paramid , Object def ) { final Object v = getParameter ( paramid ) ; if ( v == null ) { return def ; } else { return v ; } }
Look for a parameter in the context with the given name . If parmeter is null return def
13,540
public Object [ ] getParameters ( String paramid ) { final Object parameter = getParameter ( paramid ) ; if ( parameter == null ) { return null ; } if ( parameter instanceof Object [ ] ) { return ( Object [ ] ) parameter ; } else { final Object [ ] result = { parameter } ; return result ; } }
Obtain parameters based on paramid as an array .
13,541
public boolean getBoolean ( String key , boolean def ) { try { if ( ! contains ( key ) ) { return def ; } return ( Boolean ) get ( key ) ; } catch ( Exception e ) { return def ; } }
Getter for a boolean value .
13,542
public ContextPair getPair ( String key ) { if ( ! this . contains ( key ) ) { return null ; } return new ContextPair ( key , get ( key ) ) ; }
Obtains a pair based on the given key . In there is no key this method returns null
13,543
public EntityInstanceWrapper buildInstanceWrapper ( final Object instance ) throws PMException { final EntityInstanceWrapper wrapper = new EntityInstanceWrapper ( instance ) ; if ( hasEntity ( ) && ! getEntityContainer ( ) . isSelectedNew ( ) ) { wrapper . setInstanceId ( getDataAccess ( ) . getInstanceId ( this , wrap...
Creates a new instance wrapper with the instance and the instanceId .
13,544
public static SkbShell newShell ( MessageRenderer renderer , boolean useConsole ) { return SkbShellFactory . newShell ( null , renderer , useConsole ) ; }
Returns a new shell with given STG and console flag .
13,545
public static SkbShell newShell ( String id , boolean useConsole ) { return SkbShellFactory . newShell ( id , null , useConsole ) ; }
Returns a new shell with given identifier and console flag with standard STGroup .
13,546
public static SkbShell newShell ( String id , MessageRenderer renderer ) { return SkbShellFactory . newShell ( id , renderer , true ) ; }
Returns a new shell with a given identifier and STGroup plus console activated .
13,547
public static SkbShell newShell ( String id , MessageRenderer renderer , boolean useConsole ) { return new AbstractShell ( id , renderer , useConsole ) ; }
Returns a new shell with given identifier and console flag .
13,548
public static SkbShellCommand newCommand ( String command , SkbShellCommandCategory category , String description , String addedHelp ) { return new AbstractShellCommand ( command , null , category , description , addedHelp ) ; }
Returns a new shell command without formal arguments use the factory to create one .
13,549
public static SkbShellArgument newArgument ( String argument , boolean isOptional , SkbShellArgumentType type , Object [ ] valueSet , String description , String addedHelp ) { return new AbstractShellArgument ( argument , isOptional , type , valueSet , description , addedHelp ) ; }
Returns a new shell argument use the factory to create one .
13,550
public static SkbShellArgument [ ] newArgumentArray ( SkbShellArgument ... args ) { if ( args == null ) { return null ; } Set < SkbShellArgument > ret = new HashSet < > ( ) ; for ( SkbShellArgument arg : args ) { if ( arg != null ) { ret . add ( arg ) ; } } return ret . toArray ( new SkbShellArgument [ args . length ] ...
Returns a new argument array .
13,551
public void fixSampleLoops ( int modType ) { if ( sample == null || length == 0 ) return ; if ( repeatStop > length ) { repeatStop = length ; repeatLength = repeatStop - repeatStart ; } if ( repeatStart + 2 > repeatStop ) { repeatStop = repeatStart = 0 ; repeatLength = repeatStop - repeatStart ; loopType = 0 ; } sample...
Fits the loop - data given in instruments loaded These values are often not correkt
13,552
private int getLinearInterpolated ( final int currentSamplePos , final int currentTuningPos ) { final long s1 = ( ( long ) sample [ currentSamplePos ] ) << Helpers . SAMPLE_SHIFT ; final long s2 = ( ( long ) sample [ currentSamplePos + 1 ] ) << Helpers . SAMPLE_SHIFT ; return ( int ) ( ( s1 + ( ( ( s2 - s1 ) * ( ( long...
Does the linear interpolation with the next sample
13,553
private int getCubicInterpolated ( final int currentSamplePos , final int currentTuningPos ) { final int poslo = ( currentTuningPos >> CubicSpline . SPLINE_FRACSHIFT ) & CubicSpline . SPLINE_FRACMASK ; final long v1 = ( ( ( currentSamplePos - 1 ) < 0 ) ? 0L : ( long ) CubicSpline . lut [ poslo ] * ( long ) sample [ cur...
does cubic interpolation with the next sample
13,554
private int getFIRInterpolated ( final int currentSamplePos , final int currentTuningPos ) { final int poslo = currentTuningPos & WindowedFIR . WFIR_POSFRACMASK ; final int firidx = ( ( poslo + WindowedFIR . WFIR_FRACHALVE ) >> WindowedFIR . WFIR_FRACSHIFT ) & WindowedFIR . WFIR_FRACMASK ; final long v1 = ( ( ( current...
does a windowed fir interploation with the next sample
13,555
public synchronized boolean contains ( Object o ) { if ( start == end ) return false ; if ( end == - 1 ) { for ( int i = array . length - 1 ; i >= 0 ; -- i ) if ( array [ i ] . equals ( o ) ) return true ; return false ; } if ( end < start ) { for ( int i = array . length - 1 ; i >= start ; -- i ) if ( array [ i ] . eq...
other operation which may cost
13,556
public synchronized boolean removeAny ( Object element ) { if ( end == start ) return false ; if ( end == - 1 ) { for ( int i = array . length - 1 ; i >= 0 ; -- i ) if ( array [ i ] . equals ( element ) ) { removeAt ( i ) ; return true ; } return false ; } if ( end < start ) { for ( int i = array . length - 1 ; i >= st...
remove this element not necessarily the first or last occurrence .
13,557
public synchronized boolean removeInstance ( T element ) { if ( end == start ) return false ; if ( end == - 1 ) { for ( int i = array . length - 1 ; i >= 0 ; -- i ) if ( array [ i ] == element ) { removeAt ( i ) ; return true ; } return false ; } if ( end < start ) { for ( int i = array . length - 1 ; i >= start ; -- i...
Remove the given instance .
13,558
@ SuppressWarnings ( "unchecked" ) public synchronized List < T > removeAllNoOrder ( ) { if ( end == - 1 ) { List < Object > a = Arrays . asList ( array ) ; array = new Object [ array . length ] ; start = end = 0 ; return ( List < T > ) a ; } if ( start == end ) return Collections . EMPTY_LIST ; if ( end > start ) { Ob...
Remove all elements and return them but the returned list is not ordered . The reason it is not ordered is for performance when the order is not important .
13,559
private void createFileFilter ( ) { HashMap < String , String [ ] > extensionMap = MultimediaContainerManager . getSupportedFileExtensionsPerContainer ( ) ; ArrayList < FileFilter > chooserFilterArray = new ArrayList < FileFilter > ( extensionMap . size ( ) + 1 ) ; Set < String > containerNameSet = extensionMap . keySe...
Create the file filters so that we do have them for the dialogs
13,560
private void initialize ( ) { Log . addLogListener ( new LogMessageCallBack ( ) { public void debug ( String message ) { showMessage ( message ) ; } public void info ( String message ) { showMessage ( message ) ; } public void error ( String message , Throwable ex ) { if ( ex != null ) showMessage ( message + '|' + ex ...
Do main initials
13,561
private void setLookAndFeel ( String lookAndFeelClassName ) { try { javax . swing . UIManager . setLookAndFeel ( lookAndFeelClassName ) ; } catch ( Throwable e ) { showMessage ( "The selected Look&Feel is not supported or not reachable through the classpath. Switching to system default..." ) ; try { lookAndFeelClassNam...
set the selected look and feel
13,562
private void updateLookAndFeel ( String lookAndFeelClassName ) { setLookAndFeel ( lookAndFeelClassName ) ; MultimediaContainerManager . updateLookAndFeel ( ) ; SwingUtilities . updateComponentTreeUI ( this ) ; pack ( ) ; for ( Window window : windows ) { SwingUtilities . updateComponentTreeUI ( window ) ; window . pack...
Changes the look and feel to the new ClassName
13,563
private void doClose ( ) { if ( useSystemTray && ( getExtendedState ( ) & ICONIFIED ) != 0 ) setVisible ( true ) ; doStopPlaying ( ) ; getSeekBarPanel ( ) . pauseThread ( ) ; getVULMeterPanel ( ) . pauseThread ( ) ; getVURMeterPanel ( ) . pauseThread ( ) ; getSALMeterPanel ( ) . pauseThread ( ) ; getSARMeterPanel ( ) ....
Default Close Operation
13,564
public void doOpenFile ( File [ ] files ) { if ( files != null ) { if ( files . length == 1 ) { File f = files [ 0 ] ; if ( f . isFile ( ) ) { String modFileName = f . getAbsolutePath ( ) ; int i = modFileName . lastIndexOf ( File . separatorChar ) ; searchPath = modFileName . substring ( 0 , i ) ; loadMultimediaOrPlay...
Open a new File
13,565
private void doExportToWave ( ) { doStopPlaying ( ) ; if ( currentContainer == null ) { JOptionPane . showMessageDialog ( this , "You need to load a file first!" , "Ups!" , JOptionPane . ERROR_MESSAGE ) ; } else { do { String fileName = Helpers . createLocalFileStringFromURL ( currentContainer . getFileURL ( ) , true )...
Exports to a Wavefile
13,566
private void doStopPlaying ( ) { if ( playerThread != null ) { playerThread . stopMod ( ) ; getSoundOutputStream ( ) . closeAllDevices ( ) ; playerThread = null ; removeMixer ( ) ; } }
stop playback of a mod
13,567
private synchronized void showMessage ( final String msg ) { SwingUtilities . invokeLater ( new Runnable ( ) { public void run ( ) { getMessages ( ) . setText ( msg ) ; } } ) ; }
Shows the given Message
13,568
public static void registerResource ( Object resource , TaskManager tm ) { if ( resource == null ) return ; synchronized ( resources ) { resources . put ( resource , tm ) ; } }
Register a resource .
13,569
public static TaskManager unregisterResource ( Object resource ) { if ( resource == null ) return null ; synchronized ( resources ) { return resources . remove ( resource ) ; } }
Unregister a resource .
13,570
public static void registerBlockedThreadHandler ( BlockedThreadHandler handler , Thread thread ) { synchronized ( blockedHandlers ) { blockedHandlers . put ( thread , handler ) ; } }
Rregister the given thread .
13,571
public static void waitFinished ( Collection < ? extends Task < ? , ? > > tasks ) throws Exception { for ( Task < ? , ? > t : tasks ) { t . getOutput ( ) . blockThrow ( 0 ) ; } }
Wait for the given tasks to be done .
13,572
public static < TError extends Exception > void waitUnblockedWithError ( Collection < AsyncWork < ? , TError > > tasks ) throws TError , CancelException { for ( AsyncWork < ? , TError > t : tasks ) t . blockResult ( 0 ) ; }
Wait for the given tasks to finish if one has an error this error is immediately thrown without waiting for other tasks .
13,573
public static void waitOneFinished ( List < ? extends Task < ? , ? > > tasks ) { if ( tasks . isEmpty ( ) ) return ; if ( tasks . size ( ) == 1 ) try { tasks . get ( 0 ) . getOutput ( ) . block ( 0 ) ; } catch ( Throwable e ) { } SynchronizationPoint < Exception > sp = new SynchronizationPoint < > ( ) ; for ( Task < ? ...
Wait for one of the given task to be done .
13,574
public static String debug ( ) { StringBuilder s = new StringBuilder ( ) ; for ( TaskManager tm : resources . values ( ) ) tm . debug ( s ) ; return s . toString ( ) ; }
Return a string containing multi - threading status for debugging purposes .
13,575
public static int getMaxRicePartitionOrderFromBlocksize ( int blocksize ) { int maxRicePartitionOrder = 0 ; while ( ( blocksize & 1 ) == 0 ) { maxRicePartitionOrder ++ ; blocksize >>= 1 ; } return Math . min ( Constants . MAX_RICE_PARTITION_ORDER , maxRicePartitionOrder ) ; }
Return the maximum Rice partition order based on the block size .
13,576
private static void showHelp ( ) { Log . info ( "java -jar ./javamod [-rx] [-b{8,16,24}] [-s{+,-}] [-i{+,-}] [-w{+,-}] [-n{+,-}] [-m{+,-}] [-l{+,-}] [-h{+,-}] [-j{+,-}] [-v0.0-1.0]" ) ; Log . info ( " [-eWAVFILE] MODFILE\n" ) ; Log . info ( "-rx : use Samplerate x (8000/11025/22050/44100/96000...
Show a help screen ...
13,577
private void doStartPlaying ( ) { if ( currentContainer != null ) { doStopPlaying ( ) ; if ( currentContainer instanceof ModContainer ) { System . out . println ( ( ( ModContainer ) currentContainer ) . getCurrentMod ( ) . toString ( ) ) ; } Mixer mixer = createNewMixer ( ) ; mixer . setExportFile ( wavFileName ) ; pla...
Plays the modfile with the current parameters set
13,578
public Menu add ( Menu m ) { submenus . add ( m ) ; m . setParent ( this ) ; return m ; }
Add the given menu to the submenu list
13,579
public void set ( long value ) { if ( this . value == value ) return ; long previous = this . value ; this . value = value ; event . fire ( Long . valueOf ( previous ) ) ; }
Set a new value .
13,580
public String convertExtendedSmiles ( String data ) { if ( data != null ) { Pattern pattern = Pattern . compile ( "\\[\\*\\]|\\*" ) ; Matcher matcher = pattern . matcher ( data ) ; if ( matcher != null ) { String smiles = data . split ( "\\|" ) [ 0 ] ; List < Integer > rgroupInformation = extractRgroups ( data ) ; Stri...
convert extended smiles format to smiles with atom mappings
13,581
private List < Integer > extractRgroups ( String data ) { Pattern pattern = Pattern . compile ( "R[1-9]\\d*" ) ; Matcher matcher = pattern . matcher ( data ) ; List < Integer > listValues = new ArrayList < Integer > ( ) ; while ( matcher . find ( ) ) { listValues . add ( Integer . parseInt ( matcher . group ( ) . split...
extract Rgroups from extended smiles
13,582
public AbstractMolecule merge ( AbstractMolecule firstContainer , IAtomBase firstRgroup , AbstractMolecule secondContainer , IAtomBase secondRgroup ) throws CTKException { if ( firstContainer . isSingleStereo ( firstRgroup ) && secondContainer . isSingleStereo ( secondRgroup ) ) { throw new CTKException ( "Both R atoms...
merges second molecule to first using given rGroups
13,583
protected boolean setStereoInformation ( AbstractMolecule firstContainer , IAtomBase firstRgroup , AbstractMolecule secondContainer , IAtomBase secondRgroup , IAtomBase atom1 , IAtomBase atom2 ) throws CTKException { IStereoElementBase stereo = null ; boolean result = false ; if ( firstContainer . isSingleStereo ( firs...
recycles and set stereo information on firstContaner
13,584
public void appendSamples ( int channel , float [ ] f ) { for ( int i = 0 ; i < 32 ; ) { final float fs = f [ i ++ ] ; append ( channel , ( short ) ( fs > 32767.0f ? 32767.0f : ( fs < - 32768.0f ? - 32768.0f : fs ) ) ) ; } }
Accepts 32 new PCM samples .
13,585
public static Scopes from ( String ... scopes ) { if ( scopes == null || scopes . length == 0 ) return NONE ; return new Scopes ( scopes , true ) ; }
Creates a Scopes object from the given strings .
13,586
private String escape ( String value ) { StringBuilder result = new StringBuilder ( ) ; for ( int i = 0 ; i < value . length ( ) ; ++ i ) { char c = value . charAt ( i ) ; if ( c < reservedChars . length && reservedChars [ c ] == c ) { result . append ( ESCAPE_PREFIX ) ; int code = c & 0xFF ; if ( code < 16 ) result . ...
Escapes the scope string following RFC 2608 6 . 4 . 1
13,587
private String unescape ( String value ) { StringBuilder result = new StringBuilder ( ) ; for ( int i = 0 ; i < value . length ( ) ; ++ i ) { char c = value . charAt ( i ) ; if ( c == ESCAPE_PREFIX ) { String codeString = value . substring ( i + 1 , i + 3 ) ; int code = Integer . parseInt ( codeString , 16 ) ; if ( cod...
Unescapes the scope string following RFC 2608 6 . 4 . 1
13,588
public ISynchronizationPoint < IOException > start ( String rootNamespaceURI , String rootLocalName , Map < String , String > namespaces ) { if ( includeXMLDeclaration ) { writer . write ( XML_DECLARATION_START ) ; writer . write ( output . getEncoding ( ) . name ( ) ) ; writer . write ( XML_DECLARATION_END ) ; } write...
Start the document with the XML processing instruction if needed and opening the root element .
13,589
public ISynchronizationPoint < IOException > end ( ) { while ( ! context . isEmpty ( ) ) closeElement ( ) ; ISynchronizationPoint < IOException > write = writer . flush ( ) ; if ( ! write . isUnblocked ( ) ) { SynchronizationPoint < IOException > sp = new SynchronizationPoint < > ( ) ; write . listenInline ( ( ) -> { o...
End the document close any open element and flush the output stream .
13,590
public void reset ( ) { for ( int p = 0 ; p < 512 ; p ++ ) v1 [ p ] = v2 [ p ] = 0.0f ; for ( int p2 = 0 ; p2 < 32 ; p2 ++ ) samples [ p2 ] = 0.0f ; actual_v = v1 ; actual_write_pos = 15 ; }
Reset the synthesis filter .
13,591
public void calculate_pcm_samples ( Obuffer buffer ) { compute_new_v ( ) ; compute_pcm_samples ( buffer ) ; actual_write_pos = ( actual_write_pos + 1 ) & 0xf ; actual_v = ( actual_v == v1 ) ? v2 : v1 ; for ( int p = 0 ; p < 32 ; p ++ ) samples [ p ] = 0.0f ; }
Calculate 32 PCM samples and put the into the Obuffer - object .
13,592
static private float [ ] [ ] splitArray ( final float [ ] array , final int blockSize ) { int size = array . length / blockSize ; float [ ] [ ] split = new float [ size ] [ ] ; for ( int i = 0 ; i < size ; i ++ ) { split [ i ] = subArray ( array , i * blockSize , blockSize ) ; } return split ; }
Converts a 1D array into a number of smaller arrays . This is used to achieve offset + constant indexing into an array . Each sub - array represents a block of values of the original array .
13,593
static private float [ ] subArray ( final float [ ] array , final int offs , int len ) { if ( offs + len > array . length ) { len = array . length - offs ; } if ( len < 0 ) len = 0 ; float [ ] subarray = new float [ len ] ; for ( int i = 0 ; i < len ; i ++ ) { subarray [ i ] = array [ offs + i ] ; } return subarray ; }
Returns a subarray of an existing array .
13,594
public static < T > void removeValue ( Map < ? , T > map , T value ) { ArrayList < Object > keys = new ArrayList < > ( ) ; for ( Map . Entry < ? , T > e : map . entrySet ( ) ) if ( e . getValue ( ) . equals ( value ) ) keys . add ( e . getKey ( ) ) ; for ( Object key : keys ) map . remove ( key ) ; }
Remove all keys associated with the given value .
13,595
public static ApplicationConfiguration load ( File file ) throws Exception { try ( FileInputStream in = new FileInputStream ( file ) ) { return load ( in ) ; } }
Load the given file .
13,596
public static ApplicationConfiguration load ( InputStream input ) throws Exception { XMLStreamReader xml = XMLInputFactory . newFactory ( ) . createXMLStreamReader ( input ) ; while ( xml . hasNext ( ) ) { xml . next ( ) ; if ( xml . getEventType ( ) == XMLStreamConstants . START_ELEMENT ) { if ( ! "project" . equals (...
Load from the given stream .
13,597
public void removeAttachment ( IAtomBase toRemove ) throws CTKException { Map < String , IAtomBase > groups = getRgroups ( ) ; for ( String key : groups . keySet ( ) ) { if ( groups . get ( key ) . compare ( toRemove ) ) { for ( int i = 0 ; i < attachments . size ( ) ; i ++ ) { if ( attachments . get ( i ) . getLabel (...
removes a given attachment from molecule
13,598
private void initParameters ( ) throws FileNotFoundException { InputStream fileStream ; if ( new File ( parameterfile ) . exists ( ) ) { logger . info ( "Try reading properties directly from {}." , parameterfile ) ; fileStream = new FileInputStream ( new File ( parameterfile ) ) ; } else { logger . info ( "Try reading ...
Initialises all Parameters .
13,599
public void configToLogInfo ( ) { logger . info ( "----- MEMEORY USAGE -----" ) ; logger . info ( "BUCKET_MEMORY = {}" , BUCKET_MEMORY ) ; logger . info ( "MEMORY_CHUNK = {}" , MEMORY_CHUNK ) ; logger . info ( "MAX_MEMORY_PER_BUCKET = {}" , MAX_MEMORY_PER_BUCKET ) ; logger . info ( "CHUNKSIZE = {}" , SYNC_CHUNK_SIZE ) ...
Outputs the configuration to the Logger .