idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
13,100 | private void readHeader ( RandomAccessInputStream raf ) throws IOException { raf . seek ( HEAD_LOCATION ) ; byte [ ] head = new byte [ HEAD_SIZE ] ; if ( raf . read ( head ) != HEAD_SIZE ) { throw new IOException ( "Error encountered reading id3v2 header" ) ; } majorVersion = ( int ) head [ 3 ] ; if ( majorVersion <= NEW_MAJOR_VERSION ) { minorVersion = ( int ) head [ 4 ] ; unsynchronisation = ( head [ 5 ] & 0x80 ) != 0 ; extended = ( head [ 5 ] & 0x40 ) != 0 ; experimental = ( head [ 5 ] & 0x20 ) != 0 ; footer = ( head [ 5 ] & 0x10 ) != 0 ; tagSize = Helpers . convertDWordToInt ( head , 6 ) ; } } | Extracts the information from the header . |
13,101 | public byte [ ] getBytes ( ) { byte [ ] b = new byte [ HEAD_SIZE ] ; int bytesCopied = 0 ; System . arraycopy ( Helpers . getBytesFromString ( TAG_START , TAG_START . length ( ) , ENC_TYPE ) , 0 , b , 0 , TAG_START . length ( ) ) ; bytesCopied += TAG_START . length ( ) ; b [ bytesCopied ++ ] = ( byte ) majorVersion ; b [ bytesCopied ++ ] = ( byte ) minorVersion ; b [ bytesCopied ++ ] = getFlagByte ( ) ; System . arraycopy ( Helpers . convertIntToDWord ( tagSize ) , 0 , b , bytesCopied , 4 ) ; bytesCopied += 4 ; return b ; } | Return an array of bytes representing the header . This can be used to easily write the header to a file . |
13,102 | private byte getFlagByte ( ) { byte ret = 0 ; if ( unsynchronisation ) ret |= 0x80 ; if ( extended ) ret |= 0x40 ; if ( experimental ) ret |= 0x20 ; if ( footer ) ret |= 0x10 ; return ret ; } | A helper function for the getBytes function that returns a byte with the proper flags set . |
13,103 | public double module ( ) { double v = 0 ; for ( int i = 0 ; i < vector . length ; i ++ ) { v = Math . pow ( vector [ i ] , 2 ) ; } return Math . sqrt ( v ) ; } | Calculates the module of this vector |
13,104 | public MyVector normalize ( ) { double vmodule = module ( ) ; double [ ] associatedVector = new double [ vector . length ] ; for ( int i = 0 ; i < vector . length ; i ++ ) { associatedVector [ i ] = ( 1 / vmodule ) * vector [ i ] ; } return new MyVector ( associatedVector ) ; } | Calculates the associated normalized Vector of this Vector |
13,105 | public Iterator < Object > valueIterator ( ) { final Iterator < String > iter = keyIterator ( ) ; return new Iterator < Object > ( ) { public boolean hasNext ( ) { return iter . hasNext ( ) ; } public Object next ( ) { String key = iter . next ( ) ; return get ( key ) ; } public void remove ( ) { throw new UnsupportedOperationException ( "remove() not supported for BeanMap" ) ; } } ; } | Convenience method for getting an iterator over the values . |
13,106 | public BeanInvoker getReadInvoker ( String name ) { BeanInvoker invoker ; if ( readInvokers . containsKey ( name ) ) { invoker = readInvokers . get ( name ) ; } else { invoker = getInvoker ( readHandleType . get ( name ) , name ) ; readInvokers . put ( name , invoker ) ; } return invoker ; } | Returns the accessor for the property with the given name . |
13,107 | public BeanInvoker getWriteInvoker ( String name ) { BeanInvoker invoker ; if ( writeInvokers . containsKey ( name ) ) { invoker = writeInvokers . get ( name ) ; } else { invoker = getInvoker ( HandleType . SET , name ) ; writeInvokers . put ( name , invoker ) ; } return invoker ; } | Returns the mutator for the property with the given name . |
13,108 | public static AsyncWork < XMLStreamReader , Exception > start ( IO . Readable . Buffered io , int charactersBufferSize , int maxBuffers ) { AsyncWork < XMLStreamReader , Exception > result = new AsyncWork < > ( ) ; new Task . Cpu . FromRunnable ( "Start reading XML " + io . getSourceDescription ( ) , io . getPriority ( ) , ( ) -> { XMLStreamReader reader = new XMLStreamReader ( io , charactersBufferSize , maxBuffers ) ; try { Starter start = new Starter ( io , reader . defaultEncoding , reader . charactersBuffersSize , reader . maxBuffers ) ; reader . stream = start . start ( ) ; reader . stream . canStartReading ( ) . listenAsync ( new Task . Cpu . FromRunnable ( "Start reading XML " + io . getSourceDescription ( ) , io . getPriority ( ) , ( ) -> { try { reader . next ( ) ; result . unblockSuccess ( reader ) ; } catch ( Exception e ) { result . unblockError ( e ) ; } } ) , true ) ; } catch ( Exception e ) { result . unblockError ( e ) ; } } ) . startOn ( io . canStartReading ( ) , true ) ; return result ; } | Utility method that initialize a XMLStreamReader initialize it and return an AsyncWork which is unblocked when characters are available to be read . |
13,109 | public void next ( ) throws XMLException , IOException { reset ( ) ; char c ; if ( ( c = stream . read ( ) ) == '<' ) readTag ( ) ; else readChars ( c ) ; } | Move forward to the next event . |
13,110 | protected boolean evaluateCondition ( String script , Log log ) throws EnforcerRuleException { Boolean evaluation = Boolean . FALSE ; try { evaluation = ( Boolean ) bsh . eval ( script ) ; log . debug ( "Echo evaluating : " + evaluation ) ; } catch ( EvalError ex ) { throw new EnforcerRuleException ( "Couldn't evaluate condition: " + script , ex ) ; } return evaluation . booleanValue ( ) ; } | Evaluate expression using Beanshell . |
13,111 | public void configurationSave ( Properties props ) { ModConfigPanel configPanel = ( ModConfigPanel ) getConfigPanel ( ) ; props . setProperty ( PROPERTY_PLAYER_FREQUENCY , configPanel . getPlayerSetUp_SampleRate ( ) . getSelectedItem ( ) . toString ( ) ) ; props . setProperty ( PROPERTY_PLAYER_MSBUFFERSIZE , configPanel . getPlayerSetUp_BufferSize ( ) . getSelectedItem ( ) . toString ( ) ) ; props . setProperty ( PROPERTY_PLAYER_BITSPERSAMPLE , configPanel . getPlayerSetUp_BitsPerSample ( ) . getSelectedItem ( ) . toString ( ) ) ; props . setProperty ( PROPERTY_PLAYER_STEREO , configPanel . getPlayerSetUp_Channels ( ) . getSelectedItem ( ) . toString ( ) ) ; props . setProperty ( PROPERTY_PLAYER_ISP , Integer . toString ( configPanel . getPlayerSetUp_Interpolation ( ) . getSelectedIndex ( ) ) ) ; props . setProperty ( PROPERTY_PLAYER_WIDESTEREOMIX , Boolean . toString ( configPanel . getPlayerSetUp_WideStereoMix ( ) . isSelected ( ) ) ) ; props . setProperty ( PROPERTY_PLAYER_NOISEREDUCTION , Boolean . toString ( configPanel . getPlayerSetUp_NoiseReduction ( ) . isSelected ( ) ) ) ; props . setProperty ( PROPERTY_PLAYER_MEGABASS , Boolean . toString ( configPanel . getPlayerSetUp_MegaBass ( ) . isSelected ( ) ) ) ; props . setProperty ( PROPERTY_PLAYER_NOLOOPS , Integer . toString ( configPanel . getLoopValue ( ) ) ) ; } | Get the values from the gui and store them into the main Propertys |
13,112 | public void set_chip_model ( chip_model model ) { if ( model == chip_model . MOS6581 ) { wave__ST = Wave . wave6581__ST ; wave_P_T = Wave . wave6581_P_T ; wave_PS_ = Wave . wave6581_PS_ ; wave_PST = Wave . wave6581_PST ; } else { wave__ST = Wave . wave8580__ST ; wave_P_T = Wave . wave8580_P_T ; wave_PS_ = Wave . wave8580_PS_ ; wave_PST = Wave . wave8580_PST ; } } | Set chip model . |
13,113 | public void writeCONTROL_REG ( int control ) { waveform = ( control >> 4 ) & 0x0f ; ring_mod = control & 0x04 ; sync = control & 0x02 ; int test_next = control & 0x08 ; if ( ANTTI_LANKILA_PATCH ) { if ( test_next != 0 && test == 0 ) { accumulator = 0 ; int bit19 = ( shift_register >> 19 ) & 1 ; shift_register = ( shift_register & 0x7ffffd ) | ( ( bit19 ^ 1 ) << 1 ) ; } else if ( test_next == 0 && test > 0 ) { int bit0 = ( ( shift_register >> 22 ) ^ ( shift_register >> 17 ) ) & 0x1 ; shift_register <<= 1 ; shift_register &= 0x7fffff ; shift_register |= bit0 ; } if ( waveform > 8 ) { shift_register &= 0x7fffff ^ ( 1 << 22 ) ^ ( 1 << 20 ) ^ ( 1 << 16 ) ^ ( 1 << 13 ) ^ ( 1 << 11 ) ^ ( 1 << 7 ) ^ ( 1 << 4 ) ^ ( 1 << 2 ) ; } } else { if ( test_next != 0 ) { accumulator = 0 ; shift_register = 0 ; } else if ( test != 0 ) { shift_register = 0x7ffff8 ; } } test = test_next ; } | Register functions . |
13,114 | public void reset ( ) { accumulator = 0 ; if ( ANTTI_LANKILA_PATCH ) shift_register = 0x7ffffc ; else shift_register = 0x7ffff8 ; freq = 0 ; pw = 0 ; test = 0 ; ring_mod = 0 ; sync = 0 ; msb_rising = false ; } | SID reset . |
13,115 | public void clock ( ) { if ( test != 0 ) { return ; } int accumulator_prev = accumulator ; accumulator += freq ; accumulator &= 0xffffff ; msb_rising = ! ( ( accumulator_prev & 0x800000 ) != 0 ) && ( ( accumulator & 0x800000 ) != 0 ) ; if ( ! ( ( accumulator_prev & 0x080000 ) != 0 ) && ( ( accumulator & 0x080000 ) != 0 ) ) { int bit0 = ( ( shift_register >> 22 ) ^ ( shift_register >> 17 ) ) & 0x1 ; shift_register <<= 1 ; shift_register &= 0x7fffff ; shift_register |= bit0 ; } } | SID clocking - 1 cycle . |
13,116 | public void clock ( int delta_t ) { if ( test != 0 ) { return ; } int accumulator_prev = accumulator ; int delta_accumulator = delta_t * freq ; accumulator += delta_accumulator ; accumulator &= 0xffffff ; msb_rising = ! ( ( accumulator_prev & 0x800000 ) != 0 ) && ( ( accumulator & 0x800000 ) != 0 ) ; int shift_period = 0x100000 ; while ( delta_accumulator != 0 ) { if ( delta_accumulator < shift_period ) { shift_period = delta_accumulator ; if ( shift_period <= 0x080000 ) { if ( ( ( ( accumulator - shift_period ) & 0x080000 ) != 0 ) || ! ( ( accumulator & 0x080000 ) != 0 ) ) { break ; } } else { if ( ( ( ( accumulator - shift_period ) & 0x080000 ) != 0 ) && ! ( ( accumulator & 0x080000 ) != 0 ) ) { break ; } } } int bit0 = ( ( shift_register >> 22 ) ^ ( shift_register >> 17 ) ) & 0x1 ; shift_register <<= 1 ; shift_register &= 0x7fffff ; shift_register |= bit0 ; delta_accumulator -= shift_period ; } } | SID clocking - delta_t cycles . |
13,117 | private void filterRelevantFields ( List < Field > fields ) { Iterator < Field > fieldIterator = fields . iterator ( ) ; while ( fieldIterator . hasNext ( ) ) { Field field = fieldIterator . next ( ) ; if ( Modifier . isStatic ( field . getModifiers ( ) ) ) { fieldIterator . remove ( ) ; } } } | Filters out fields for which we don t want matcher methods created . This currently only excludes static fields . |
13,118 | public void setLen ( int len ) { if ( len > data . length ) { len = data . length ; } this . len = len ; } | Set the length of this ByteData object without re - allocating the underlying array . It is not possible to set the length larger than the underlying byte array . |
13,119 | public void initializeMixer ( ) { calculateGlobalTuning ( ) ; frequencyTableType = mod . getFrequencyTable ( ) ; currentTempo = mod . getTempo ( ) ; currentBPM = mod . getBPMSpeed ( ) ; globalVolume = mod . getBaseVolume ( ) ; globalVolumSlideValue = 0 ; useFastSlides = mod . doFastSlides ( ) ; samplePerTicks = calculateSamplesPerTick ( ) ; currentTick = currentArrangement = currentRow = patternDelayCount = patternTicksDelayCount = 0 ; currentArrangement = 0 ; currentPatternIndex = mod . getArrangement ( ) [ currentArrangement ] ; currentPattern = mod . getPatternContainer ( ) . getPattern ( currentPatternIndex ) ; patternJumpPatternIndex = patternBreakRowIndex = patternBreakJumpPatternIndex = - 1 ; modFinished = false ; calculateVolRampLen ( ) ; mod . resetLoopRecognition ( ) ; doFadeOut = false ; fadeOutFac = 8 ; fadeOutValue = 1 << fadeOutFac ; fadeOutSub = 0x01 ; final int nChannels = mod . getNChannels ( ) ; for ( int c = 0 ; c < maxChannels ; c ++ ) { channelMemory [ c ] = new ChannelMemory ( ) ; if ( c < nChannels ) { final ChannelMemory aktMemo = channelMemory [ c ] ; aktMemo . panning = mod . getPanningValue ( c ) ; aktMemo . channelVolume = mod . getChannelVolume ( c ) ; initializeMixer ( c , aktMemo ) ; } } } | Call this first! |
13,120 | protected long cutOffToFrequency ( long cutOff , int flt_modifier , boolean isExFilterRange ) { double fac = ( isExFilterRange ) ? ( 20.0d * 512.0d ) : ( 24.0d * 512.0d ) ; double fc = 110.0d * Math . pow ( 2.0d , 0.25d + ( ( double ) ( cutOff * ( flt_modifier + 256 ) ) ) / fac ) ; long freq = ( long ) fc ; if ( freq < 120 ) return 120 ; if ( freq > 20000 ) return 20000 ; if ( ( freq << 1 ) > sampleRate ) return ( ( long ) sampleRate ) >> 1 ; return freq ; } | calc the cut off |
13,121 | protected void setupChannelFilter ( ChannelMemory aktMemo , boolean bReset , int flt_modifier ) { double cutOff = ( double ) ( ( aktMemo . nCutOff + aktMemo . nCutSwing ) & 0x7F ) ; double resonance = ( double ) ( ( aktMemo . nResonance + aktMemo . nResSwing ) & 0x7F ) ; double fc = cutOffToFrequency ( ( long ) cutOff , flt_modifier , ( mod . getSongFlags ( ) & Helpers . SONG_EXFILTERRANGE ) != 0 ) ; fc *= 2.0d * 3.14159265358 / ( ( double ) sampleRate ) ; double dmpfac = Math . pow ( 10.0d , - ( ( 24.0d / 128.0d ) * resonance ) / 20.0d ) ; double d = ( 1.0d - 2.0d * dmpfac ) * fc ; if ( d > 2.0d ) d = 2.0d ; d = ( 2.0d * dmpfac - d ) / fc ; double e = Math . pow ( 1.0d / fc , 2.0d ) ; double fg = 1.0d / ( 1.0d + d + e ) ; double fg1 = - e * fg ; double fg0 = 1.0d - fg - fg1 ; switch ( aktMemo . nFilterMode ) { case Helpers . FLTMODE_HIGHPASS : aktMemo . nFilter_A0 = ( long ) ( ( 1.0d - fg ) * Helpers . FILTER_PRECISION ) ; aktMemo . nFilter_B0 = ( long ) ( fg0 * Helpers . FILTER_PRECISION ) ; aktMemo . nFilter_B1 = ( long ) ( fg1 * Helpers . FILTER_PRECISION ) ; aktMemo . nFilter_HP = - 1 ; break ; default : aktMemo . nFilter_A0 = ( long ) ( fg * Helpers . FILTER_PRECISION ) ; aktMemo . nFilter_B0 = ( long ) ( fg0 * Helpers . FILTER_PRECISION ) ; aktMemo . nFilter_B1 = ( long ) ( fg1 * Helpers . FILTER_PRECISION ) ; aktMemo . nFilter_HP = 0 ; break ; } if ( bReset ) aktMemo . nFilter_Y1 = aktMemo . nFilter_Y2 = 0 ; aktMemo . filterOn = true ; } | Simple 2 - poles resonant filter |
13,122 | protected void resetInstrument ( ChannelMemory aktMemo ) { aktMemo . autoVibratoTablePos = aktMemo . autoVibratoAmplitude = aktMemo . currentDirection = aktMemo . currentTuningPos = aktMemo . currentSamplePos = 0 ; aktMemo . volEnvPos = aktMemo . panEnvPos = aktMemo . pitchEnvPos = - 1 ; aktMemo . filterOn = aktMemo . instrumentFinished = false ; } | Set all index values back to zero! |
13,123 | protected void doRowEvent ( ) { final PatternRow patternRow = currentPattern . getPatternRow ( currentRow ) ; if ( patternRow == null ) return ; patternRow . setRowPlayed ( ) ; final int nChannels = mod . getNChannels ( ) ; for ( int c = 0 ; c < nChannels ; c ++ ) { final PatternElement element = patternRow . getPatternElement ( c ) ; final ChannelMemory aktMemo = channelMemory [ c ] ; resetAllEffects ( aktMemo , element , false ) ; aktMemo . currentElement = element ; if ( element . getPeriod ( ) > 0 ) aktMemo . assignedNotePeriod = element . getPeriod ( ) ; if ( element . getNoteIndex ( ) > 0 ) aktMemo . assignedNoteIndex = element . getNoteIndex ( ) ; if ( element . getInstrument ( ) > 0 ) { aktMemo . assignedInstrumentIndex = element . getInstrument ( ) ; aktMemo . assignedInstrument = mod . getInstrumentContainer ( ) . getInstrument ( element . getInstrument ( ) - 1 ) ; } aktMemo . effekt = element . getEffekt ( ) ; aktMemo . effektParam = element . getEffektOp ( ) ; aktMemo . volumeEffekt = element . getVolumeEffekt ( ) ; aktMemo . volumeEffektOp = element . getVolumeEffektOp ( ) ; if ( element . getPeriod ( ) == Helpers . KEY_OFF || element . getNoteIndex ( ) == Helpers . KEY_OFF ) { aktMemo . keyOff = true ; } else if ( element . getPeriod ( ) == Helpers . NOTE_CUT || element . getNoteIndex ( ) == Helpers . NOTE_CUT ) { aktMemo . fadeOutVolume = 0 ; } else if ( ! isNoteDelayEffekt ( aktMemo ) ) { setNewInstrumentAndPeriod ( aktMemo ) ; } processEffekts ( false , aktMemo ) ; } } | Do the Events of a new Row! |
13,124 | protected boolean doTickEvents ( ) { if ( doFadeOut ) { fadeOutValue -= fadeOutSub ; if ( fadeOutValue <= 0 ) return true ; } final int nChannels = maxChannels ; if ( patternTicksDelayCount > 0 ) { for ( int c = 0 ; c < nChannels ; c ++ ) { final ChannelMemory aktMemo = channelMemory [ c ] ; processEffekts ( true , aktMemo ) ; } patternTicksDelayCount -- ; } else { currentTick -- ; if ( currentTick <= 0 ) { currentTick = currentTempo ; if ( patternDelayCount > 0 ) { for ( int c = 0 ; c < nChannels ; c ++ ) { final ChannelMemory aktMemo = channelMemory [ c ] ; processEffekts ( false , aktMemo ) ; } patternDelayCount -- ; } else if ( currentArrangement >= mod . getSongLength ( ) ) { return true ; } else { doRowEvent ( ) ; currentRow ++ ; if ( patternJumpPatternIndex != - 1 ) { currentRow = patternJumpPatternIndex ; patternJumpPatternIndex = - 1 ; } if ( currentRow >= currentPattern . getRowCount ( ) || patternBreakRowIndex != - 1 || patternBreakJumpPatternIndex != - 1 ) { mod . setArrangementPositionPlayed ( currentArrangement ) ; if ( patternBreakJumpPatternIndex != - 1 ) { final int checkRow = ( patternBreakRowIndex != - 1 ) ? patternBreakRowIndex : currentRow - 1 ; final boolean infinitLoop = isInfinitLoop ( patternBreakJumpPatternIndex , checkRow ) ; if ( infinitLoop && doNoLoops == Helpers . PLAYER_LOOP_IGNORE ) { patternBreakRowIndex = patternBreakJumpPatternIndex = - 1 ; resetJumpPositionSet ( ) ; currentArrangement ++ ; } else { currentArrangement = patternBreakJumpPatternIndex ; } patternBreakJumpPatternIndex = - 1 ; if ( infinitLoop && doNoLoops == Helpers . PLAYER_LOOP_FADEOUT ) doFadeOut = true ; } else { resetJumpPositionSet ( ) ; currentArrangement ++ ; } if ( patternBreakRowIndex != - 1 ) { currentRow = patternBreakRowIndex ; patternBreakRowIndex = - 1 ; } else currentRow = 0 ; if ( currentArrangement < mod . getSongLength ( ) ) { currentPatternIndex = mod . getArrangement ( ) [ currentArrangement ] ; currentPattern = mod . getPatternContainer ( ) . getPattern ( currentPatternIndex ) ; } else { currentPatternIndex = - 1 ; currentPattern = null ; } } } } else { for ( int c = 0 ; c < nChannels ; c ++ ) { final ChannelMemory aktMemo = channelMemory [ c ] ; processEffekts ( true , aktMemo ) ; } } } return false ; } | Do the events during a Tick . |
13,125 | protected void fitIntoLoops ( final ChannelMemory actMemo ) { final Sample ins = actMemo . currentSample ; if ( actMemo . currentDirection >= 0 ) { actMemo . currentTuningPos += actMemo . currentTuning ; if ( actMemo . currentTuningPos >= Helpers . SHIFT_ONE ) { actMemo . currentSamplePos += ( actMemo . currentTuningPos >> Helpers . SHIFT ) ; actMemo . currentTuningPos &= Helpers . SHIFT_MASK ; if ( ( ins . loopType & Helpers . LOOP_ON ) == 0 ) { actMemo . instrumentFinished = actMemo . currentSamplePos >= ins . length ; } else { if ( ( ins . loopType & Helpers . LOOP_IS_PINGPONG ) == 0 ) { if ( actMemo . currentSamplePos >= ins . repeatStop ) actMemo . currentSamplePos = ins . repeatStart + ( ( actMemo . currentSamplePos - ins . repeatStart ) % ins . repeatLength ) ; } else { if ( actMemo . currentSamplePos >= ins . repeatStop ) { actMemo . currentDirection = - 1 ; actMemo . currentSamplePos = ins . repeatStop - ( ( actMemo . currentSamplePos - ins . repeatStart ) % ins . repeatLength ) - 1 ; } } } } } else { actMemo . currentTuningPos -= actMemo . currentTuning ; if ( actMemo . currentTuningPos <= 0 ) { int hi = ( ( - actMemo . currentTuningPos ) >> Helpers . SHIFT ) + 1 ; actMemo . currentSamplePos -= hi ; actMemo . currentTuningPos += hi << Helpers . SHIFT ; if ( actMemo . currentSamplePos <= ins . repeatStart ) { actMemo . currentDirection = 1 ; actMemo . currentSamplePos = ins . repeatStart + ( ( ins . repeatStart - actMemo . currentSamplePos ) % ins . repeatLength ) ; } } } } | Add current speed to samplepos and fit currentSamplePos into loop values or signal Sample finished |
13,126 | private void mixChannelIntoBuffers ( final int [ ] leftBuffer , final int [ ] rightBuffer , final int startIndex , final int endIndex , final ChannelMemory actMemo ) { for ( int i = startIndex ; i < endIndex ; i ++ ) { long sample = actMemo . currentSample . getInterpolatedSample ( doISP , actMemo . currentSamplePos , actMemo . currentTuningPos ) ; if ( actMemo . filterOn ) sample = doResonance ( actMemo , sample ) ; long volL = actMemo . actRampVolLeft ; if ( ( actMemo . deltaVolLeft > 0 && volL > actMemo . actVolumeLeft ) || ( actMemo . deltaVolLeft < 0 && volL < actMemo . actVolumeLeft ) ) { volL = actMemo . actRampVolLeft = actMemo . actVolumeLeft ; actMemo . deltaVolLeft = 0 ; } else { actMemo . actRampVolLeft += actMemo . deltaVolLeft ; } long volR = actMemo . actRampVolRight ; if ( ( actMemo . deltaVolRight > 0 && volR > actMemo . actVolumeRight ) || ( actMemo . deltaVolRight < 0 && volR < actMemo . actVolumeRight ) ) { volR = actMemo . actRampVolRight = actMemo . actVolumeRight ; actMemo . deltaVolRight = 0 ; } else { actMemo . actRampVolRight += actMemo . deltaVolRight ; } leftBuffer [ i ] += ( int ) ( ( sample * volL ) >> Helpers . MAXVOLUMESHIFT ) ; rightBuffer [ i ] += ( int ) ( ( sample * volR ) >> Helpers . MAXVOLUMESHIFT ) ; fitIntoLoops ( actMemo ) ; if ( actMemo . instrumentFinished ) break ; } } | Fill the buffers with channel data |
13,127 | public static XslTransformer getTransformer ( Source source ) throws TransformerConfigurationException { if ( source == null ) { throw new IllegalArgumentException ( "source is null" ) ; } XslTransformer transformer = new XslTransformer ( ) ; transformer . transformerImpl = transformerFactory . newTransformer ( source ) ; return transformer ; } | Get a wrapped XSL transformer instance for supplied stylesheet source . |
13,128 | public static XslTransformer getTransformer ( File xslFile ) throws TransformerConfigurationException { if ( xslFile == null ) { throw new IllegalArgumentException ( "xslFile is null" ) ; } return getTransformer ( new StreamSource ( xslFile ) ) ; } | Get a wrapped XSL transformer instance for supplied stylesheet file . |
13,129 | public void transform ( Source xmlSource , URIResolver uriResolver , ErrorListener errorListener , Result outputTarget ) throws TransformerException { if ( xmlSource == null ) { throw new IllegalArgumentException ( "xmlSource is null" ) ; } if ( outputTarget == null ) { throw new IllegalArgumentException ( "outputTarget is null" ) ; } transformerImpl . reset ( ) ; transformerImpl . setOutputProperty ( OutputKeys . INDENT , "yes" ) ; transformerImpl . setOutputProperty ( "{http://xml.apache.org/xslt}indent-amount" , "4" ) ; transformerImpl . setURIResolver ( uriResolver ) ; transformerImpl . setErrorListener ( errorListener ) ; transformerImpl . transform ( xmlSource , outputTarget ) ; } | Transform XML source using the wrapped XSL transformer of this instance and output to supplied target . |
13,130 | public byte [ ] transform ( Source xmlSource , URIResolver uriResolver , ErrorListener errorListener ) throws TransformerException { if ( xmlSource == null ) { throw new IllegalArgumentException ( "xmlSource is null" ) ; } ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ; StreamResult result = new StreamResult ( out ) ; transform ( xmlSource , uriResolver , errorListener , result ) ; return out . toByteArray ( ) ; } | Transform XML source using the wrapped XSL transformer of this instance and return a byte array of the result . |
13,131 | public void execute ( String statement ) throws SQLException { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Executing SQL statement [" + statement + "]" ) ; } Connection connection = null ; Statement stm = null ; try { connection = ds . getConnection ( ) ; stm = connection . createStatement ( ) ; stm . execute ( statement ) ; } catch ( SQLException e ) { throw e ; } finally { if ( stm != null ) stm . close ( ) ; if ( connection != null ) connection . close ( ) ; } } | Execute a statement . |
13,132 | public int queryForInt ( String sql ) throws SQLException { Number number = queryForObject ( sql , Integer . class ) ; return ( number != null ? number . intValue ( ) : 0 ) ; } | Execute a query that returns a single int field . |
13,133 | public < T > T queryForObject ( String sql , Class < T > requiredType ) throws SQLException { return queryForObject ( sql , getSingleColumnRowMapper ( requiredType ) ) ; } | Execute a query that returns a single value that can be cast to the given type . |
13,134 | public void skipBitsNoCRC ( int bits ) throws IOException { if ( bits == 0 ) return ; int bitsToAlign = getBit & 7 ; if ( bitsToAlign != 0 ) { int bitsToTake = Math . min ( 8 - bitsToAlign , bits ) ; readRawUInt ( bitsToTake ) ; bits -= bitsToTake ; } int bytesNeeded = bits / 8 ; if ( bytesNeeded > 0 ) { readByteBlockAlignedNoCRC ( null , bytesNeeded ) ; bits %= 8 ; } if ( bits > 0 ) { readRawUInt ( bits ) ; } } | skip over bits in bit stream without updating CRC . |
13,135 | public int readBit ( ) throws IOException { while ( true ) { if ( availBits > 0 ) { int val = ( ( buffer [ getByte ] & ( 0x80 >> getBit ) ) != 0 ) ? 1 : 0 ; getBit ++ ; if ( getBit == BITS_PER_BLURB ) { readCRC16 = CRC16 . update ( buffer [ getByte ] , readCRC16 ) ; getByte ++ ; getBit = 0 ; } availBits -- ; totalBitsRead ++ ; return val ; } else { readFromStream ( ) ; } } } | read a single bit . |
13,136 | public int peekBitToInt ( int val , int bit ) throws IOException { while ( true ) { if ( bit < availBits ) { val <<= 1 ; if ( ( getBit + bit ) >= BITS_PER_BLURB ) { bit = ( getBit + bit ) % BITS_PER_BLURB ; val |= ( ( buffer [ getByte + 1 ] & ( 0x80 >> bit ) ) != 0 ) ? 1 : 0 ; } else { val |= ( ( buffer [ getByte ] & ( 0x80 >> ( getBit + bit ) ) ) != 0 ) ? 1 : 0 ; } return val ; } else { readFromStream ( ) ; } } } | peek at the next bit and add it to the input integer . The bits of the input integer are shifted left and the read bit is placed into bit 0 . |
13,137 | public int readRawUInt ( int bits ) throws IOException { int val = 0 ; for ( int i = 0 ; i < bits ; i ++ ) { val = readBitToInt ( val ) ; } return val ; } | read bits into an unsigned integer . |
13,138 | public int peekRawUInt ( int bits ) throws IOException { int val = 0 ; for ( int i = 0 ; i < bits ; i ++ ) { val = peekBitToInt ( val , i ) ; } return val ; } | peek at bits into an unsigned integer without advancing the input stream . |
13,139 | public int readRawInt ( int bits ) throws IOException { if ( bits == 0 ) { return 0 ; } int uval = 0 ; for ( int i = 0 ; i < bits ; i ++ ) { uval = readBitToInt ( uval ) ; } int val ; int bitsToleft = 32 - bits ; if ( bitsToleft != 0 ) { uval <<= bitsToleft ; val = uval ; val >>= bitsToleft ; } else { val = uval ; } return val ; } | read bits into a signed integer . |
13,140 | public long readRawULong ( int bits ) throws IOException { long val = 0 ; for ( int i = 0 ; i < bits ; i ++ ) { val = readBitToLong ( val ) ; } return val ; } | read bits into an unsigned long . |
13,141 | public int readRawIntLittleEndian ( ) throws IOException { int x32 = readRawUInt ( 8 ) ; int x8 = readRawUInt ( 8 ) ; x32 |= ( x8 << 8 ) ; x8 = readRawUInt ( 8 ) ; x32 |= ( x8 << 16 ) ; x8 = readRawUInt ( 8 ) ; x32 |= ( x8 << 24 ) ; return x32 ; } | read bits into an unsigned little endian integer . |
13,142 | private int updateElementInReadBuffer ( Data data , int indexInChunk ) { workingBuffer . position ( indexInChunk ) ; int minElement = indexInChunk / gp . getElementSize ( ) ; int numberOfEntries = workingBuffer . limit ( ) / gp . getElementSize ( ) ; byte [ ] actualKey = data . getKey ( ) ; int maxElement = numberOfEntries - 1 ; int midElement ; int compare ; byte [ ] tmpKey = new byte [ actualKey . length ] ; while ( minElement <= maxElement ) { midElement = minElement + ( maxElement - minElement ) / 2 ; indexInChunk = midElement * gp . getElementSize ( ) ; workingBuffer . position ( indexInChunk ) ; workingBuffer . get ( tmpKey ) ; compare = KeyUtils . compareKey ( actualKey , tmpKey ) ; if ( compare == 0 ) { workingBuffer . position ( indexInChunk ) ; byte [ ] b = new byte [ gp . getElementSize ( ) ] ; workingBuffer . get ( b ) ; @ SuppressWarnings ( "unchecked" ) Data toUpdate = ( Data ) prototype . fromByteBuffer ( ByteBuffer . wrap ( b ) ) ; toUpdate . update ( data ) ; workingBuffer . position ( indexInChunk ) ; workingBuffer . put ( data . toByteBuffer ( ) ) ; return indexInChunk ; } else if ( compare < 0 ) { maxElement = midElement - 1 ; } else { minElement = midElement + 1 ; } } return - 1 ; } | traverses the readBuffer |
13,143 | public static byte [ ] toGUID ( long p1 , int p2 , int p3 , int p4 , long p5 ) { byte [ ] guid = new byte [ 16 ] ; guid [ 0 ] = ( byte ) ( p1 & 0xFF ) ; guid [ 1 ] = ( byte ) ( ( p1 >> 8 ) & 0xFF ) ; guid [ 2 ] = ( byte ) ( ( p1 >> 16 ) & 0xFF ) ; guid [ 3 ] = ( byte ) ( ( p1 >> 24 ) & 0xFF ) ; guid [ 4 ] = ( byte ) ( p2 & 0xFF ) ; guid [ 5 ] = ( byte ) ( ( p2 >> 8 ) & 0xFF ) ; guid [ 6 ] = ( byte ) ( p3 & 0xFF ) ; guid [ 7 ] = ( byte ) ( ( p3 >> 8 ) & 0xFF ) ; guid [ 8 ] = ( byte ) ( ( p4 >> 8 ) & 0xFF ) ; guid [ 9 ] = ( byte ) ( p4 & 0xFF ) ; guid [ 10 ] = ( byte ) ( ( p5 >> 40 ) & 0xFF ) ; guid [ 11 ] = ( byte ) ( ( p5 >> 32 ) & 0xFF ) ; guid [ 12 ] = ( byte ) ( ( p5 >> 24 ) & 0xFF ) ; guid [ 13 ] = ( byte ) ( ( p5 >> 16 ) & 0xFF ) ; guid [ 14 ] = ( byte ) ( ( p5 >> 8 ) & 0xFF ) ; guid [ 15 ] = ( byte ) ( p5 & 0xFF ) ; return guid ; } | Create a GUID . |
13,144 | protected void init ( File file , String directory , String fileName , InfoLocationOptions option ) { super . init ( file , directory , fileName , option ) ; if ( ! this . errors . hasErrors ( ) ) { if ( ! "stg" . equals ( this . getFileExtension ( ) ) ) { this . errors . addError ( "file name must have '.stg' extension" ) ; this . reset ( ) ; } else { } } } | Initialize the file source with any parameters presented by the constructors . |
13,145 | public void afterPropertiesSet ( ) throws Exception { super . afterPropertiesSet ( ) ; Assert . notNull ( sql , "The SQL query must be provided" ) ; Assert . notNull ( rowMapper , "RowMapper must be provided" ) ; } | Assert that mandatory properties are set . |
13,146 | public static < T > T getRandomItem ( T [ ] arr ) { return arr [ rand . nextInt ( arr . length ) ] ; } | Returns a random element of the given array . |
13,147 | public static < T > T [ ] reverseArray ( T [ ] arr ) { for ( int left = 0 , right = arr . length - 1 ; left < right ; left ++ , right -- ) { T temp = arr [ left ] ; arr [ left ] = arr [ right ] ; arr [ right ] = temp ; } return arr ; } | Reverses the entries of a given array . |
13,148 | public static < T > void shuffleArray ( T [ ] arr ) { for ( int i = arr . length ; i > 1 ; i -- ) swap ( arr , i - 1 , rand . nextInt ( i ) ) ; } | Permutes the elements of the given array . |
13,149 | private static < T > String getFormat ( T [ ] arr , int precision , char valueSeparation ) { StringBuilder builder = new StringBuilder ( ) ; builder . append ( '[' ) ; for ( int i = 0 ; i < arr . length - 1 ; i ++ ) { builder . append ( FormatUtils . getFormat ( arr [ i ] , precision ) ) ; builder . append ( valueSeparation ) ; } builder . append ( FormatUtils . getFormat ( arr [ arr . length - 1 ] , precision ) ) ; builder . append ( ']' ) ; return builder . toString ( ) ; } | Returns a format - String that can be used to generate a String representation of an array using the String . format method . |
13,150 | public void setLoopValue ( int newLoopValue ) { if ( newLoopValue == Helpers . PLAYER_LOOP_DEACTIVATED ) { getPlayerSetUp_fadeOutLoops ( ) . setSelected ( false ) ; getPlayerSetUp_ignoreLoops ( ) . setSelected ( false ) ; } else if ( newLoopValue == Helpers . PLAYER_LOOP_FADEOUT ) { getPlayerSetUp_fadeOutLoops ( ) . setSelected ( true ) ; getPlayerSetUp_ignoreLoops ( ) . setSelected ( false ) ; } else if ( newLoopValue == Helpers . PLAYER_LOOP_IGNORE ) { getPlayerSetUp_fadeOutLoops ( ) . setSelected ( false ) ; getPlayerSetUp_ignoreLoops ( ) . setSelected ( true ) ; } } | Never ever call this Method from an event handler for those two buttons - endless loop! |
13,151 | public void removeTags ( int type ) throws FileNotFoundException , IOException { RandomAccessFile raf = null ; try { raf = new RandomAccessFile ( mp3File , "rw" ) ; if ( allow ( type & ID3V1 ) ) { id3v1 . removeTag ( raf ) ; } if ( allow ( type & ID3V2 ) ) { id3v2 . removeTag ( raf ) ; } } finally { if ( raf != null ) raf . close ( ) ; } } | Removes id3 tags from the file . The argument specifies which tags to remove . This can either be BOTH_TAGS ID3V1_ONLY ID3V2_ONLY or EXISTING_TAGS_ONLY . |
13,152 | public void writeTags ( ) throws FileNotFoundException , IOException { RandomAccessFile raf = null ; try { raf = new RandomAccessFile ( mp3File , "rw" ) ; if ( id3v2 . tagExists ( ) ) { id3v2 . writeTag ( raf ) ; } if ( id3v1 . tagExists ( ) ) { id3v1 . writeTag ( raf ) ; } } finally { if ( raf != null ) raf . close ( ) ; } } | Writes the current state of the id3 tags to the file . What tags are written depends upon the tagType passed to the constructor . |
13,153 | public void setTitle ( String title , int type ) { if ( allow ( type & ID3V1 ) ) { id3v1 . setTitle ( title ) ; } if ( allow ( type & ID3V2 ) ) { id3v2 . setTextFrame ( ID3v2Frames . TITLE , title ) ; } } | Set the title of this mp3 . |
13,154 | public void setAlbum ( String album , int type ) { if ( allow ( type & ID3V1 ) ) { id3v1 . setAlbum ( album ) ; } if ( allow ( type & ID3V2 ) ) { id3v2 . setTextFrame ( ID3v2Frames . ALBUM , album ) ; } } | Set the album of this mp3 . |
13,155 | public void setArtist ( String artist , int type ) { if ( allow ( type & ID3V1 ) ) { id3v1 . setArtist ( artist ) ; } if ( allow ( type & ID3V2 ) ) { id3v2 . setTextFrame ( ID3v2Frames . LEAD_PERFORMERS , artist ) ; } } | Set the artist of this mp3 . |
13,156 | public void setComment ( String comment , int type ) { if ( allow ( type & ID3V1 ) ) { id3v1 . setComment ( comment ) ; } if ( allow ( type & ID3V2 ) ) { id3v2 . setCommentFrame ( "" , comment ) ; } } | Add a comment to this mp3 . |
13,157 | public void setGenre ( String genre , int type ) { if ( allow ( type & ID3V1 ) ) { id3v1 . setGenreString ( genre ) ; } if ( allow ( type & ID3V2 ) ) { id3v2 . setTextFrame ( ID3v2Frames . CONTENT_TYPE , genre ) ; } } | Set the genre of this mp3 . |
13,158 | public void setYear ( String year , int type ) { if ( allow ( type & ID3V1 ) ) { id3v1 . setYear ( year ) ; } if ( allow ( type & ID3V2 ) ) { id3v2 . setTextFrame ( ID3v2Frames . YEAR , year ) ; } } | Set the year of this mp3 . |
13,159 | public void setTrack ( int track , int type ) { if ( allow ( type & ID3V1 ) ) { id3v1 . setTrack ( track ) ; } if ( allow ( type & ID3V2 ) ) { id3v2 . setTextFrame ( ID3v2Frames . TRACK_NUMBER , String . valueOf ( track ) ) ; } } | Set the track number of this mp3 . |
13,160 | public String getArtist ( int type ) { if ( allow ( type & ID3V1 ) ) { return id3v1 . getArtist ( ) ; } if ( allow ( type & ID3V2 ) ) { return id3v2 . getFrameDataString ( ID3v2Frames . LEAD_PERFORMERS ) ; } return null ; } | Returns the artist of the mp3 if set and the empty string if not . |
13,161 | public String getAlbum ( int type ) { if ( allow ( type & ID3V1 ) ) { return id3v1 . getAlbum ( ) ; } if ( allow ( type & ID3V2 ) ) { return id3v2 . getFrameDataString ( ID3v2Frames . ALBUM ) ; } return null ; } | Returns the album of the mp3 if set and the empty string if not . |
13,162 | public String getComment ( int type ) { if ( allow ( type & ID3V1 ) ) { return id3v1 . getComment ( ) ; } if ( allow ( type & ID3V2 ) ) { return id3v2 . getFrameDataString ( ID3v2Frames . COMMENTS ) ; } return null ; } | Returns the comment field of this mp3 if set and the empty string if not . |
13,163 | public String getGenre ( int type ) { if ( allow ( type & ID3V1 ) ) { return id3v1 . getGenreString ( ) ; } if ( allow ( type & ID3V2 ) ) { return id3v2 . getFrameDataString ( ID3v2Frames . CONTENT_TYPE ) ; } return null ; } | Returns the genre of this mp3 if set and the empty string if not . |
13,164 | public String getTitle ( int type ) { if ( allow ( type & ID3V1 ) ) { return id3v1 . getTitle ( ) ; } if ( allow ( type & ID3V2 ) ) { return id3v2 . getFrameDataString ( ID3v2Frames . TITLE ) ; } return null ; } | Returns the title of this mp3 if set and the empty string if not . |
13,165 | public String getTrack ( int type ) { if ( allow ( type & ID3V1 ) ) { return Integer . toString ( id3v1 . getTrack ( ) ) ; } if ( allow ( type & ID3V2 ) ) { return id3v2 . getFrameDataString ( ID3v2Frames . TRACK_NUMBER ) ; } return null ; } | Returns the track of this mp3 if set and the empty string if not . |
13,166 | public String getYear ( int type ) { if ( allow ( type & ID3V1 ) ) { return id3v1 . getYear ( ) ; } if ( allow ( type & ID3V2 ) ) { return id3v2 . getFrameDataString ( ID3v2Frames . YEAR ) ; } return null ; } | Returns the year of this mp3 if set and the empty string if not . |
13,167 | public String getFileName ( ) { if ( mp3File == null ) return "" ; try { return mp3File . getCanonicalPath ( ) ; } catch ( IOException ex ) { return mp3File . getAbsolutePath ( ) ; } } | returns the full path of this mp3 file |
13,168 | public Link deserialize ( JsonParser jp , DeserializationContext ctxt ) throws IOException { String tmp = jp . getText ( ) ; validate ( jp , tmp , "{" ) ; jp . nextToken ( ) ; String rel = jp . getText ( ) ; validateText ( jp , rel ) ; jp . nextToken ( ) ; tmp = jp . getText ( ) ; validate ( jp , tmp , "{" ) ; jp . nextToken ( ) ; tmp = jp . getText ( ) ; validate ( jp , tmp , "href" ) ; jp . nextToken ( ) ; String href = jp . getText ( ) ; validateText ( jp , href ) ; jp . nextToken ( ) ; tmp = jp . getText ( ) ; validate ( jp , tmp , "}" ) ; jp . nextToken ( ) ; tmp = jp . getText ( ) ; validate ( jp , tmp , "}" ) ; Link link = new Link ( rel , href ) ; return link ; } | Non whitespace ; could possibly be narrowed |
13,169 | public final AsyncWork < T , Exception > start ( ) { AsyncWork < T , Exception > result = new AsyncWork < > ( ) ; resume ( result ) ; return result ; } | Start to read lines in a separate task . |
13,170 | public final void listenInline ( AsyncWorkListener < T , TError > listener ) { synchronized ( this ) { if ( ! unblocked || listenersInline != null ) { if ( listenersInline == null ) listenersInline = new ArrayList < > ( 5 ) ; listenersInline . add ( listener ) ; return ; } } if ( error != null ) listener . error ( error ) ; else if ( cancel != null ) listener . cancelled ( cancel ) ; else listener . ready ( result ) ; } | Add a listener to be called when this AsyncWork is unblocked . |
13,171 | public final void listenInline ( Listener < T > onready , Listener < TError > onerror , Listener < CancelException > oncancel ) { listenInline ( new AsyncWorkListener < T , TError > ( ) { public void ready ( T result ) { onready . fire ( result ) ; } public void error ( TError error ) { onerror . fire ( error ) ; } public void cancelled ( CancelException event ) { oncancel . fire ( event ) ; } public String toString ( ) { return "AsyncWork.listenInline: " + onready ; } } ) ; } | Call one of the given listener depending on result . |
13,172 | public final void listenInline ( Listener < T > onSuccess ) { listenInline ( new AsyncWorkListener < T , TError > ( ) { public void ready ( T result ) { onSuccess . fire ( result ) ; } public void error ( TError error ) { } public void cancelled ( CancelException event ) { } public String toString ( ) { return "AsyncWork.listenInline: " + onSuccess ; } } ) ; } | Register a listener to be called only on success with the result . |
13,173 | public final void listenInlineGenericError ( AsyncWork < T , Exception > sp ) { listenInline ( new AsyncWorkListener < T , TError > ( ) { public void ready ( T result ) { sp . unblockSuccess ( result ) ; } public void error ( TError error ) { sp . unblockError ( error ) ; } public void cancelled ( CancelException event ) { sp . unblockCancel ( event ) ; } } ) ; } | Forward the result error or cancellation to the given AsyncWork . |
13,174 | public final void unblockSuccess ( T result ) { ArrayList < AsyncWorkListener < T , TError > > listeners ; synchronized ( this ) { if ( unblocked ) return ; unblocked = true ; this . result = result ; if ( listenersInline == null ) { this . notifyAll ( ) ; return ; } listeners = listenersInline ; listenersInline = new ArrayList < > ( 2 ) ; } Logger log = LCCore . getApplication ( ) . getLoggerFactory ( ) . getLogger ( SynchronizationPoint . class ) ; while ( true ) { if ( ! log . debug ( ) ) for ( int i = 0 ; i < listeners . size ( ) ; ++ i ) try { listeners . get ( i ) . ready ( result ) ; } catch ( Throwable t ) { log . error ( "Exception thrown by an inline listener of AsyncWork: " + listeners . get ( i ) , t ) ; } else for ( int i = 0 ; i < listeners . size ( ) ; ++ i ) { long start = System . nanoTime ( ) ; try { listeners . get ( i ) . ready ( result ) ; } catch ( Throwable t ) { log . error ( "Exception thrown by an inline listener of AsyncWork: " + listeners . get ( i ) , t ) ; } long time = System . nanoTime ( ) - start ; if ( time > 1000000 ) log . debug ( "Listener ready took " + ( time / 1000000.0d ) + "ms: " + listeners . get ( i ) ) ; } synchronized ( this ) { if ( listenersInline . isEmpty ( ) ) { listenersInline = null ; listeners = null ; this . notifyAll ( ) ; break ; } listeners . clear ( ) ; ArrayList < AsyncWorkListener < T , TError > > tmp = listeners ; listeners = listenersInline ; listenersInline = tmp ; } } } | Unblock this AsyncWork with the given result . |
13,175 | public final void unblockError ( TError error ) { ArrayList < AsyncWorkListener < T , TError > > listeners ; synchronized ( this ) { if ( unblocked ) return ; unblocked = true ; this . error = error ; if ( listenersInline == null ) { this . notifyAll ( ) ; return ; } listeners = listenersInline ; listenersInline = new ArrayList < > ( 2 ) ; } Logger log = LCCore . getApplication ( ) . getLoggerFactory ( ) . getLogger ( SynchronizationPoint . class ) ; while ( true ) { if ( ! log . debug ( ) ) for ( int i = 0 ; i < listeners . size ( ) ; ++ i ) try { listeners . get ( i ) . error ( error ) ; } catch ( Throwable t ) { log . error ( "Exception thrown by an inline listener of AsyncWork, cancel it: " + listeners . get ( i ) , t ) ; try { listeners . get ( i ) . cancelled ( new CancelException ( "Error in listener" , t ) ) ; } catch ( Throwable t2 ) { log . error ( "Exception thrown while cancelling inline listener of AsyncWork after error: " + listeners . get ( i ) , t2 ) ; } } else for ( int i = 0 ; i < listeners . size ( ) ; ++ i ) { long start = System . nanoTime ( ) ; try { listeners . get ( i ) . error ( error ) ; } catch ( Throwable t ) { log . error ( "Exception thrown by an inline listener of AsyncWork, cancel it: " + listeners . get ( i ) , t ) ; try { listeners . get ( i ) . cancelled ( new CancelException ( "Error in listener" , t ) ) ; } catch ( Throwable t2 ) { log . error ( "Exception thrown while cancelling inline listener of AsyncWork after error: " + listeners . get ( i ) , t2 ) ; } } long time = System . nanoTime ( ) - start ; if ( time > 1000000 ) log . debug ( "Listener error took " + ( time / 1000000.0d ) + "ms: " + listeners . get ( i ) ) ; } synchronized ( this ) { if ( listenersInline . isEmpty ( ) ) { listenersInline = null ; listeners = null ; this . notifyAll ( ) ; break ; } listeners . clear ( ) ; ArrayList < AsyncWorkListener < T , TError > > tmp = listeners ; listeners = listenersInline ; listenersInline = tmp ; } } } | Unblock this AsyncWork with an error . Equivalent to the method error . |
13,176 | public void unblockCancel ( CancelException event ) { ArrayList < AsyncWorkListener < T , TError > > listeners ; synchronized ( this ) { if ( unblocked ) return ; unblocked = true ; this . cancel = event ; if ( listenersInline == null ) { this . notifyAll ( ) ; return ; } listeners = listenersInline ; listenersInline = new ArrayList < > ( 2 ) ; } Logger log = LCCore . getApplication ( ) . getLoggerFactory ( ) . getLogger ( SynchronizationPoint . class ) ; while ( true ) { if ( ! log . debug ( ) ) for ( int i = 0 ; i < listeners . size ( ) ; ++ i ) try { listeners . get ( i ) . cancelled ( event ) ; } catch ( Throwable t ) { log . error ( "Exception thrown by an inline listener of AsyncWork: " + listeners . get ( i ) , t ) ; } else for ( int i = 0 ; i < listeners . size ( ) ; ++ i ) { long start = System . nanoTime ( ) ; try { listeners . get ( i ) . cancelled ( event ) ; } catch ( Throwable t ) { log . error ( "Exception thrown by an inline listener of AsyncWork: " + listeners . get ( i ) , t ) ; } long time = System . nanoTime ( ) - start ; if ( time > 1000000 ) log . debug ( "Listener cancelled took " + ( time / 1000000.0d ) + "ms: " + listeners . get ( i ) ) ; } synchronized ( this ) { if ( listenersInline . isEmpty ( ) ) { listenersInline = null ; listeners = null ; this . notifyAll ( ) ; break ; } listeners . clear ( ) ; ArrayList < AsyncWorkListener < T , TError > > tmp = listeners ; listeners = listenersInline ; listenersInline = tmp ; } } } | Cancel this AsyncWork . Equivalent to the method cancel . |
13,177 | public final T blockResult ( long timeout ) throws TError , CancelException { Thread t ; BlockedThreadHandler blockedHandler ; synchronized ( this ) { if ( unblocked && listenersInline == null ) { if ( error != null ) throw error ; if ( cancel != null ) throw cancel ; return result ; } t = Thread . currentThread ( ) ; blockedHandler = Threading . getBlockedThreadHandler ( t ) ; if ( blockedHandler == null ) while ( ! unblocked || listenersInline != null ) try { this . wait ( timeout < 0 ? 0 : timeout ) ; } catch ( InterruptedException e ) { return null ; } } if ( blockedHandler != null ) blockedHandler . blocked ( this , timeout ) ; if ( error != null ) throw error ; if ( cancel != null ) throw cancel ; return result ; } | Block until this AsyncWork is unblocked or the given timeout expired and return the result in case of success or throw the error or cancellation . |
13,178 | public final void reset ( ) { unblocked = false ; result = null ; error = null ; cancel = null ; listenersInline = null ; } | Reset this AsyncWork point to reuse it . This method remove any previous result error or cancellation and mark this AsyncWork as blocked . Any previous listener is also removed . |
13,179 | public String generarIdentificador ( ) { String UUID = Long . toHexString ( System . currentTimeMillis ( ) ) ; UUID = UUID . concat ( obtenerDireccionIP ( ) ) ; UUID = UUID . concat ( identityHashCode ) ; UUID = UUID . concat ( Integer . toHexString ( _oAleatorioSeguro . nextInt ( ) ) ) ; return UUID ; } | Este metodo genera una nueva cadena de identificador Unico . La cadena devuelta tiene un maximo de 40 caracteres . |
13,180 | public void fillInfoPanelWith ( Sequence currentSequence , String songName ) { getMidiDuration ( ) . setText ( Helpers . getTimeStringFromMilliseconds ( currentSequence . getMicrosecondLength ( ) / 1000L ) ) ; getMidiName ( ) . setText ( songName ) ; Track [ ] tracks = currentSequence . getTracks ( ) ; StringBuilder fullText = new StringBuilder ( ) ; for ( int t = 0 ; t < tracks . length ; t ++ ) { int size = tracks [ t ] . size ( ) ; for ( int ticks = 0 ; ticks < size ; ticks ++ ) { MidiEvent event = tracks [ t ] . get ( ticks ) ; MidiMessage message = event . getMessage ( ) ; if ( message instanceof MetaMessage ) { int type = ( ( MetaMessage ) message ) . getType ( ) ; if ( type <= 0x04 ) { fullText . append ( new String ( ( ( MetaMessage ) message ) . getData ( ) ) ) . append ( '\n' ) ; } } } } getMidiInfo ( ) . setText ( fullText . toString ( ) ) ; getMidiInfo ( ) . select ( 0 , 0 ) ; } | private static final int INSTRUMENTNAME = 0x04 ; |
13,181 | public < T > T getClone ( String key , Class < T > c ) { IPrototype prototype = prototypes . get ( new PrototypeKey ( key , c ) ) ; if ( prototype != null ) { return ( T ) prototype . clone ( ) ; } else return null ; } | Obtains a key associated clone of the prototype for the specified class and key |
13,182 | public void registerPrototype ( String key , IPrototype prototype ) { prototypes . put ( new PrototypeKey ( key , prototype . getClass ( ) ) , prototype ) ; } | Registers a new prototype associated to the specified key |
13,183 | public void unregisterPrototype ( String key , Class c ) { prototypes . remove ( new PrototypeKey ( key , c ) ) ; } | Unregisters a prototype associated to the specified key |
13,184 | public void displayOSInfo ( Log log , boolean info ) { String string = "OS Info: Arch: " + Os . OS_ARCH + " Family: " + Os . OS_FAMILY + " Name: " + Os . OS_NAME + " Version: " + Os . OS_VERSION ; if ( ! info ) { log . debug ( string ) ; } else { log . info ( string ) ; } } | Log the current OS information . |
13,185 | public boolean allParamsEmpty ( ) { return ( StringUtils . isEmpty ( family ) && StringUtils . isEmpty ( arch ) && StringUtils . isEmpty ( name ) && StringUtils . isEmpty ( version ) ) ; } | Helper method to check that at least one of family name version or arch is set . |
13,186 | private Activation createActivation ( ) { Activation activation = new Activation ( ) ; activation . setActiveByDefault ( false ) ; activation . setOs ( createOsBean ( ) ) ; return activation ; } | Creates an Activation object that contains the ActivationOS information . |
13,187 | private ActivationOS createOsBean ( ) { ActivationOS os = new ActivationOS ( ) ; os . setArch ( arch ) ; os . setFamily ( family ) ; os . setName ( name ) ; os . setVersion ( version ) ; return os ; } | Creates an ActivationOS object containing family name version and arch . |
13,188 | protected void determineCoordinates ( ) { for ( int i = 0 ; i < numPoints ; i ++ ) { coordinates . set ( i , getPointCoordinate ( i ) ) ; } } | Determines the properties of the underlying circle and the point coordinates . |
13,189 | public void handleMessage ( String message , E_MessageType type , ST max100 , Object appID ) { this . count ++ ; boolean doMax = false ; if ( this . maxCount != - 1 && this . count > this . maxCount ) { max100 . add ( "name" , appID ) ; max100 . add ( "number" , this . maxCount ) ; doMax = true ; } if ( this . useSkbConsole == true ) { switch ( type ) { case ERROR : MessageConsole . conError ( message ) ; if ( doMax == true ) { MessageConsole . conError ( max100 . render ( ) ) ; } break ; case INFO : MessageConsole . conInfo ( message ) ; if ( doMax == true ) { MessageConsole . conError ( max100 . render ( ) ) ; } break ; case WARNING : MessageConsole . conWarn ( message ) ; if ( doMax == true ) { MessageConsole . conError ( max100 . render ( ) ) ; } break ; } } else { switch ( type ) { case ERROR : this . logger . error ( message ) ; if ( doMax == true ) { this . logger . error ( max100 . render ( ) ) ; } break ; case INFO : this . logger . info ( message ) ; if ( doMax == true ) { this . logger . error ( max100 . render ( ) ) ; } break ; case WARNING : this . logger . warn ( message ) ; if ( doMax == true ) { this . logger . error ( max100 . render ( ) ) ; } break ; } } } | Handles the message . |
13,190 | public void executeInBackground ( ) { Thread t = new Thread ( ) { public void run ( ) { try { execute ( ) ; } catch ( Exception e ) { notifyException ( e ) ; } } } ; t . start ( ) ; } | A new thread is automatically created to execute the action |
13,191 | public E getNextValue ( ) throws ValueGenerationException { if ( ! isValid ( ) ) throw new ValueGenerationException ( "Cannot provide elements in invalid state." ) ; Double random = rand . nextDouble ( ) ; for ( int i = 0 ; i < limits . size ( ) ; i ++ ) if ( random <= limits . get ( i ) ) { return keys . get ( i ) ; } return null ; } | Conducts a stochastic element choice based on the maintained occurrence probabilities . |
13,192 | public static Extension deserialize ( byte [ ] extensionBytes ) throws ServiceLocationException { int extensionId = readInt ( extensionBytes , 0 , ID_BYTES_LENGTH ) ; Extension extension = createExtension ( extensionId ) ; if ( extension != null ) { byte [ ] bodyBytes = new byte [ extensionBytes . length - ID_BYTES_LENGTH - NEXT_EXTENSION_OFFSET_BYTES_LENGTH ] ; System . arraycopy ( extensionBytes , ID_BYTES_LENGTH + NEXT_EXTENSION_OFFSET_BYTES_LENGTH , bodyBytes , 0 , bodyBytes . length ) ; extension . deserializeBody ( bodyBytes ) ; } return extension ; } | Returns an Extension subclass object obtained deserializing the given bytes or null if the bytes contain an extension that is not understood . |
13,193 | public void addHeader ( String name , String value ) { headers . add ( name , value ) ; List < String > list = caseSensitiveHeaders . get ( name ) ; if ( list == null ) { list = new ArrayList < String > ( ) ; caseSensitiveHeaders . put ( name , list ) ; } list . add ( value ) ; } | Adds and normalizes the header . |
13,194 | public static Callable < String > getCallWTimeout ( BufferedReader reader , HasPrompt emptyPrint ) { return NonBlockingReader . getCallWTimeout ( reader , 200 , emptyPrint ) ; } | Returns a new callable for reading strings from a reader with a set timeout of 200ms . |
13,195 | public static Callable < String > getCallWTimeout ( BufferedReader reader , int timeout , HasPrompt emptyPrint ) { return new Callable < String > ( ) { public String call ( ) throws IOException { String ret = "" ; while ( "" . equals ( ret ) ) { try { while ( ! reader . ready ( ) ) { Thread . sleep ( timeout ) ; } ret = reader . readLine ( ) ; if ( "" . equals ( ret ) && emptyPrint != null ) { System . out . print ( emptyPrint . prompt ( ) ) ; } } catch ( InterruptedException e ) { return null ; } } return ret ; } } ; } | Returns a new callable for reading strings from a reader with a given timeout . |
13,196 | public boolean isAncestor ( XMLNode node ) { return node == parent || ( parent != null && parent . isAncestor ( node ) ) ; } | Check if the given node is an ancestor of this node . |
13,197 | public URIBuilder addParameter ( final String param , final String value ) { if ( this . queryParams == null ) { this . queryParams = new ArrayList < NameValuePair > ( ) ; } this . queryParams . add ( new BasicNameValuePair ( param , value ) ) ; this . encodedQuery = null ; this . encodedSchemeSpecificPart = null ; return this ; } | Adds parameter to URI query . The parameter name and value are expected to be unescaped and may contain non ASCII characters . |
13,198 | public URIBuilder setParameter ( final String param , final String value ) { if ( this . queryParams == null ) { this . queryParams = new ArrayList < NameValuePair > ( ) ; } if ( ! this . queryParams . isEmpty ( ) ) { for ( Iterator < NameValuePair > it = this . queryParams . iterator ( ) ; it . hasNext ( ) ; ) { NameValuePair nvp = it . next ( ) ; if ( nvp . getName ( ) . equals ( param ) ) { it . remove ( ) ; } } } this . queryParams . add ( new BasicNameValuePair ( param , value ) ) ; this . encodedQuery = null ; this . encodedSchemeSpecificPart = null ; return this ; } | Sets parameter of URI query overriding existing value if set . The parameter name and value are expected to be unescaped and may contain non ASCII characters . |
13,199 | public boolean has ( Element ele ) { return tmap . containsKey ( ele ) && ! tmap . get ( ele ) . isEmpty ( ) ; } | check the presence of ele in translation map |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.