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 ( cause != null && cause != t ) { s . append ( "\nCaused by: " ) ; createStackTrace ( s , cause , true ) ; } } return s ; } | 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 ( ) ) ; } if ( e . getFileName ( ) != null ) { s . append ( '(' ) ; s . append ( e . getFileName ( ) ) ; s . append ( ':' ) ; s . append ( e . getLineNumber ( ) ) ; s . append ( ')' ) ; } } return s ; } | 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 ) extension ) ; } return result ; } | 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 ) || id . equals ( ID3v2Frames . POSITION_SYNCHRONISATION_FRAME ) || id . equals ( ID3v2Frames . SEEK_FRAME ) || id . equals ( ID3v2Frames . SYNCHRONISED_LYRIC ) || id . equals ( ID3v2Frames . SYNCHRONISED_TEMPO_CODES ) || id . equals ( ID3v2Frames . RELATIVE_VOLUME_ADJUSTMENT ) || id . equals ( ID3v2Frames . ENCODED_BY ) || id . equals ( ID3v2Frames . LENGTH ) ; } | 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 ; readOnly = ( flags [ 0 ] & 0x10 ) != 0 ; grouped = ( flags [ 1 ] & 0x40 ) != 0 ; compressed = ( flags [ 1 ] & 0x08 ) != 0 ; encrypted = ( flags [ 1 ] & 0x04 ) != 0 ; unsynchronised = ( flags [ 1 ] & 0x02 ) != 0 ; lengthIndicator = ( flags [ 1 ] & 0x01 ) != 0 ; if ( compressed && ! lengthIndicator ) { throw new ID3v2FormatException ( "Error parsing flags of frame: " + id + ". Compressed bit set without data length bit set." ) ; } } } | 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 ( unsynchronised ) flags [ 1 ] |= 0x02 ; if ( lengthIndicator ) flags [ 1 ] |= 0x01 ; return flags ; } | 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 byte [ data . length - bytesRead ] ; System . arraycopy ( data , bytesRead , frameData , 0 , frameData . length ) ; } | 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 ( ) ; System . arraycopy ( Helpers . convertIntToDWord ( length ) , 0 , b , bytesWritten , 4 ) ; bytesWritten += 4 ; System . arraycopy ( flags , 0 , b , bytesWritten , flags . length ) ; bytesWritten += flags . length ; System . arraycopy ( extra , 0 , b , bytesWritten , extra . length ) ; bytesWritten += extra . length ; System . arraycopy ( frameData , 0 , b , bytesWritten , frameData . length ) ; bytesWritten += frameData . length ; return b ; } | 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 . convertIntToDWord ( dataLength ) , 0 , buf , bytesCopied , 4 ) ; bytesCopied += 4 ; } ret = new byte [ bytesCopied ] ; System . arraycopy ( buf , 0 , ret , 0 , bytesCopied ) ; return ret ; } | 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 = Helpers . retrieveAsString ( frameData , 1 , frameData . length - 1 , enc_type ) ; } else if ( id . charAt ( 0 ) == 'W' ) { str = new String ( frameData ) ; } else if ( id . equals ( ID3v2Frames . USER_DEFINED_URL ) ) { str = Helpers . retrieveAsString ( frameData , 1 , frameData . length - 1 , enc_type ) ; if ( str . length ( ) < frameData . length - 1 ) { str += '\n' ; str += Helpers . retrieveAsString ( frameData , str . length ( ) + 2 , frameData . length - 2 - str . length ( ) , enc_type ) ; } } else if ( id . equals ( ID3v2Frames . UNSYNCHRONISED_LYRIC_TRANSCRIPTION ) || id . equals ( ID3v2Frames . COMMENTS ) || id . equals ( ID3v2Frames . TERMS_OF_USE ) ) { str = Helpers . retrieveAsString ( frameData , 4 , frameData . length - 4 , enc_type ) ; } } catch ( Throwable e ) { throw new ID3v2FormatException ( "Frame " + id + " had errors!" , e ) ; } } return str ; } | 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.menu" ) ; } } | 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_buffer ( 1 ) ; } catch ( RuntimeException ex ) { } return output ; } | 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 . convertSerializationValue ( value , typeDef , context ) ; Class < ? > type = value . getClass ( ) ; if ( type . isArray ( ) ) { if ( value instanceof byte [ ] ) return serializeByteArrayValue ( context , ( byte [ ] ) value , path , rules ) ; Class < ? > elementType = type . getComponentType ( ) ; CollectionContext ctx = new CollectionContext ( context , value , typeDef , new TypeDefinition ( elementType ) ) ; return serializeCollectionValue ( ctx , path , rules ) ; } if ( boolean . class . equals ( type ) || Boolean . class . equals ( type ) ) return serializeBooleanValue ( ( ( Boolean ) value ) . booleanValue ( ) ) ; if ( byte . class . equals ( type ) || short . class . equals ( type ) || int . class . equals ( type ) || long . class . equals ( type ) || float . class . equals ( type ) || double . class . equals ( type ) || Number . class . isAssignableFrom ( type ) ) return serializeNumericValue ( ( Number ) value ) ; if ( char . class . equals ( type ) || Character . class . equals ( type ) ) return serializeCharacterValue ( ( ( Character ) value ) . charValue ( ) ) ; if ( CharSequence . class . isAssignableFrom ( type ) ) return serializeStringValue ( ( CharSequence ) value ) ; if ( type . isEnum ( ) ) return serializeStringValue ( ( ( Enum < ? > ) value ) . name ( ) ) ; if ( Collection . class . isAssignableFrom ( type ) ) { TypeDefinition elementType ; if ( typeDef . getParameters ( ) . isEmpty ( ) ) elementType = null ; else elementType = typeDef . getParameters ( ) . get ( 0 ) ; CollectionContext ctx = new CollectionContext ( context , value , typeDef , elementType ) ; return serializeCollectionValue ( ctx , path , rules ) ; } if ( Map . class . isAssignableFrom ( type ) ) return serializeMapValue ( context , ( Map < ? , ? > ) value , typeDef , path , rules ) ; if ( InputStream . class . isAssignableFrom ( type ) ) return serializeInputStreamValue ( context , ( InputStream ) value , path , rules ) ; if ( IO . Readable . class . isAssignableFrom ( type ) ) return serializeIOReadableValue ( context , ( IO . Readable ) value , path , rules ) ; return serializeObjectValue ( context , value , typeDef , path , rules ) ; } | 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 -- ; if ( packByte == 0 ) { row ++ ; if ( row >= 64 ) break ; else currentRow = getPatternContainer ( ) . getPatternRow ( pattNum , row ) ; } else { int channel = packByte & 31 ; channel = channelMap [ channel ] ; int period = 0 ; int noteIndex = 0 ; int instrument = 0 ; int volume = - 1 ; int effekt = 0 ; int effektOp = 0 ; if ( ( packByte & 32 ) != 0 ) { int ton = inputStream . readByteAsInt ( ) ; count -- ; if ( ton == 254 ) { noteIndex = period = Helpers . NOTE_CUT ; } else { noteIndex = ( ( ton >> 4 ) + 1 ) * 12 + ( ton & 0xF ) ; if ( noteIndex >= Helpers . noteValues . length ) { period = 0 ; noteIndex = 0 ; } else { period = Helpers . noteValues [ noteIndex ] ; noteIndex ++ ; } } instrument = inputStream . readByteAsInt ( ) ; count -- ; } if ( ( packByte & 64 ) != 0 ) { volume = inputStream . readByteAsInt ( ) ; count -- ; } if ( ( packByte & 128 ) != 0 ) { effekt = inputStream . readByteAsInt ( ) ; count -- ; effektOp = inputStream . readByteAsInt ( ) ; count -- ; } if ( channel != - 1 ) { PatternElement currentElement = currentRow . getPatternElement ( channel ) ; currentElement . setNoteIndex ( noteIndex ) ; currentElement . setPeriod ( period ) ; currentElement . setInstrument ( instrument ) ; if ( volume != - 1 ) { currentElement . setVolumeEffekt ( 1 ) ; currentElement . setVolumeEffektOp ( volume ) ; } currentElement . setEffekt ( effekt ) ; currentElement . setEffektOp ( effektOp ) ; } } } } | 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 . tremorCount = 0 ; } | 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 if ( y != 0 ) { if ( x != 0 && y == 0xF ) aktMemo . currentSetVolume = aktMemo . currentVolume += x ; else aktMemo . currentSetVolume = aktMemo . currentVolume -= y ; } } | 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 == 0xF ) aktMemo . channelVolume += x ; else aktMemo . channelVolume -= y ; } if ( aktMemo . channelVolume > 64 ) aktMemo . channelVolume = 64 ; else if ( aktMemo . channelVolume < 0 ) aktMemo . channelVolume = 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 ; String msg = "Detected " + variableName + " Version: " + actualVersion ; if ( actualVersion . toString ( ) . equals ( requiredVersionRange ) ) { log . debug ( msg + " is allowed in the range " + requiredVersionRange + "." ) ; } else { try { vr = VersionRange . createFromVersionSpec ( requiredVersionRange ) ; if ( containsVersion ( vr , actualVersion ) ) { log . debug ( msg + " is allowed in the range " + requiredVersionRange + "." ) ; } else { String message = getMessage ( ) ; if ( StringUtils . isEmpty ( message ) ) { message = msg + " is not in the allowed range " + vr + "." ; } throw new EnforcerRuleException ( message ) ; } } catch ( InvalidVersionSpecificationException e ) { throw new EnforcerRuleException ( "The requested " + variableName + " version " + requiredVersionRange + " is invalid." , e ) ; } } } } | 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 = allowedRange . getRestrictions ( ) ; for ( Restriction restriction : restrictions ) { if ( restriction . containsVersion ( theVersion ) ) { matched = true ; break ; } } } else { @ SuppressWarnings ( "unchecked" ) int compareTo = recommendedVersion . compareTo ( theVersion ) ; matched = ( compareTo <= 0 ) ; } return matched ; } | 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 , wrapper ) ) ; } return wrapper ; } | 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 [ length + 4 ] = sample [ length + 3 ] = sample [ length + 2 ] = sample [ length + 1 ] = sample [ length ] = sample [ length - 1 ] ; if ( loopType == 1 && ( repeatStop + 4 > repeatLength || modType == Helpers . MODTYPE_MOD || modType == Helpers . MODTYPE_S3M ) ) { sample [ repeatStop ] = sample [ repeatStart ] ; sample [ repeatStop + 1 ] = sample [ repeatStart + 1 ] ; sample [ repeatStop + 2 ] = sample [ repeatStart + 2 ] ; sample [ repeatStop + 3 ] = sample [ repeatStart + 3 ] ; sample [ repeatStop + 4 ] = sample [ repeatStart + 4 ] ; } } | 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 ) currentTuningPos ) ) >> Helpers . SHIFT ) ) >> Helpers . SAMPLE_SHIFT ) ; } | 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 [ currentSamplePos - 1 ] ) + ( ( long ) CubicSpline . lut [ poslo + 1 ] * ( long ) sample [ currentSamplePos ] ) + ( ( long ) CubicSpline . lut [ poslo + 2 ] * ( long ) sample [ currentSamplePos + 1 ] ) + ( ( long ) CubicSpline . lut [ poslo + 3 ] * ( long ) sample [ currentSamplePos + 2 ] ) ; return ( int ) ( v1 >> CubicSpline . SPLINE_QUANTBITS ) ; } | 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 = ( ( ( currentSamplePos - 3 ) < 0 ) ? 0L : ( long ) WindowedFIR . lut [ firidx ] * ( long ) sample [ currentSamplePos - 3 ] ) + ( ( ( currentSamplePos - 2 ) < 0 ) ? 0L : ( long ) WindowedFIR . lut [ firidx + 1 ] * ( long ) sample [ currentSamplePos - 2 ] ) + ( ( ( currentSamplePos - 1 ) < 0 ) ? 0L : ( long ) WindowedFIR . lut [ firidx + 2 ] * ( long ) sample [ currentSamplePos - 1 ] ) + ( ( long ) WindowedFIR . lut [ firidx + 3 ] * ( long ) sample [ currentSamplePos ] ) ; final long v2 = ( ( long ) WindowedFIR . lut [ firidx + 4 ] * ( long ) sample [ currentSamplePos + 1 ] ) + ( ( long ) WindowedFIR . lut [ firidx + 5 ] * ( long ) sample [ currentSamplePos + 2 ] ) + ( ( long ) WindowedFIR . lut [ firidx + 6 ] * ( long ) sample [ currentSamplePos + 3 ] ) + ( ( long ) WindowedFIR . lut [ firidx + 7 ] * ( long ) sample [ currentSamplePos + 4 ] ) ; return ( int ) ( ( ( v1 >> 1 ) + ( v2 >> 1 ) ) >> WindowedFIR . WFIR_16BITSHIFT ) ; } | 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 ] . equals ( o ) ) return true ; for ( int i = 0 ; i < end ; ++ i ) if ( array [ i ] . equals ( o ) ) return true ; return false ; } for ( int i = start ; i < end ; ++ i ) if ( array [ i ] . equals ( o ) ) return true ; return false ; } | 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 >= start ; -- i ) if ( array [ i ] . equals ( element ) ) { removeAt ( i ) ; return true ; } for ( int i = 0 ; i < end ; ++ i ) if ( array [ i ] . equals ( element ) ) { removeAt ( i ) ; return true ; } return false ; } for ( int i = start ; i < end ; ++ i ) if ( array [ i ] . equals ( element ) ) { removeAt ( i ) ; return true ; } return false ; } | 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 ) if ( array [ i ] == element ) { removeAt ( i ) ; return true ; } for ( int i = 0 ; i < end ; ++ i ) if ( array [ i ] == element ) { removeAt ( i ) ; return true ; } return false ; } for ( int i = start ; i < end ; ++ i ) if ( array [ i ] == element ) { removeAt ( i ) ; return true ; } return false ; } | 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 ) { Object [ ] a = new Object [ end - start ] ; System . arraycopy ( array , start , a , 0 , end - start ) ; for ( int i = start ; i < end ; ++ i ) array [ i ] = null ; start = end = 0 ; return ( List < T > ) Arrays . asList ( a ) ; } Object [ ] a = new Object [ array . length - start + end ] ; System . arraycopy ( array , start , a , 0 , array . length - start ) ; if ( end > 0 ) System . arraycopy ( array , 0 , a , array . length - start , end ) ; for ( int i = array . length - 1 ; i >= 0 ; -- i ) array [ i ] = null ; start = end = 0 ; return ( List < T > ) Arrays . asList ( a ) ; } | 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 . keySet ( ) ; Iterator < String > containerNameIterator = containerNameSet . iterator ( ) ; while ( containerNameIterator . hasNext ( ) ) { String containerName = containerNameIterator . next ( ) ; String [ ] extensions = extensionMap . get ( containerName ) ; StringBuilder fileText = new StringBuilder ( containerName ) ; fileText . append ( " (" ) ; int ende = extensions . length - 1 ; for ( int i = 0 ; i <= ende ; i ++ ) { fileText . append ( "*." ) . append ( extensions [ i ] ) ; if ( i < ende ) fileText . append ( ", " ) ; } fileText . append ( ')' ) ; chooserFilterArray . add ( new FileChooserFilter ( extensions , fileText . toString ( ) ) ) ; } chooserFilterArray . add ( PlayList . PLAYLIST_FILE_FILTER ) ; String [ ] containerExtensions = MultimediaContainerManager . getSupportedFileExtensions ( ) ; String [ ] fullSupportedExtensions = new String [ containerExtensions . length + PlayList . SUPPORTEDPLAYLISTS . length ] ; System . arraycopy ( PlayList . SUPPORTEDPLAYLISTS , 0 , fullSupportedExtensions , 0 , PlayList . SUPPORTEDPLAYLISTS . length ) ; System . arraycopy ( containerExtensions , 0 , fullSupportedExtensions , PlayList . SUPPORTEDPLAYLISTS . length , containerExtensions . length ) ; chooserFilterArray . add ( new FileChooserFilter ( fullSupportedExtensions , "All playable files" ) ) ; fileFilterLoad = new FileFilter [ chooserFilterArray . size ( ) ] ; chooserFilterArray . toArray ( fileFilterLoad ) ; fileFilterExport = new FileFilter [ 1 ] ; fileFilterExport [ 0 ] = new FileChooserFilter ( javax . sound . sampled . AudioFileFormat . Type . WAVE . getExtension ( ) , javax . sound . sampled . AudioFileFormat . Type . WAVE . toString ( ) ) ; } | 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 . toString ( ) ) ; else showMessage ( message ) ; } } ) ; readPropertyFile ( ) ; setSystemTray ( ) ; setName ( WINDOW_NAME ) ; setTitle ( WINDOW_TITLE ) ; getTrayIcon ( ) . setToolTip ( WINDOW_TITLE ) ; java . net . URL iconURL = MainForm . class . getResource ( DEFAULTICONPATH ) ; if ( iconURL != null ) setIconImage ( java . awt . Toolkit . getDefaultToolkit ( ) . getImage ( iconURL ) ) ; setDefaultCloseOperation ( javax . swing . WindowConstants . DISPOSE_ON_CLOSE ) ; addWindowListener ( new java . awt . event . WindowAdapter ( ) { public void windowClosing ( java . awt . event . WindowEvent e ) { doClose ( ) ; } public void windowIconified ( WindowEvent e ) { if ( useSystemTray ) setVisible ( false ) ; } public void windowDeiconified ( WindowEvent e ) { if ( useSystemTray ) setVisible ( true ) ; } } ) ; setSize ( mainDialogSize ) ; setPreferredSize ( mainDialogSize ) ; setJMenuBar ( getBaseMenuBar ( ) ) ; setContentPane ( getBaseContentPane ( ) ) ; setPlayListIcons ( ) ; addMouseWheelListener ( new MouseWheelVolumeControl ( ) ) ; pack ( ) ; createAllWindows ( ) ; updateLookAndFeel ( uiClassName ) ; if ( mainDialogLocation == null || ( mainDialogLocation . getX ( ) == - 1 || mainDialogLocation . getY ( ) == - 1 ) ) mainDialogLocation = Helpers . getFrameCenteredLocation ( this , null ) ; setLocation ( mainDialogLocation ) ; getModInfoDialog ( ) . setVisible ( modInfoDialogVisable ) ; getPlaylistDialog ( ) . setVisible ( playlistDialogVisable ) ; getEffectDialog ( ) . setVisible ( effectDialogVisable ) ; getPlayerSetUpDialog ( ) . setVisible ( playerSetUpDialogVisable ) ; dropTargetList = new ArrayList < DropTarget > ( ) ; PlaylistDropListener myListener = new PlaylistDropListener ( this ) ; Helpers . registerDropListener ( dropTargetList , this , myListener ) ; MultimediaContainerManager . addMultimediaContainerEventListener ( this ) ; createFileFilter ( ) ; currentContainer = null ; showMessage ( "Ready..." ) ; } | 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 { lookAndFeelClassName = javax . swing . UIManager . getSystemLookAndFeelClassName ( ) ; javax . swing . UIManager . setLookAndFeel ( lookAndFeelClassName ) ; } catch ( Throwable e1 ) { Log . error ( "[MainForm]" , e1 ) ; } } } | 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 ( ) . pauseThread ( ) ; getLEDScrollPanel ( ) . pauseThread ( ) ; writePropertyFile ( ) ; if ( audioProcessor != null ) audioProcessor . removeListener ( this ) ; MultimediaContainerManager . removeMultimediaContainerEventListener ( this ) ; useSystemTray = false ; setSystemTray ( ) ; for ( Window win : windows ) { win . setVisible ( false ) ; win . dispose ( ) ; } setVisible ( false ) ; dispose ( ) ; System . exit ( 0 ) ; } | 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 ) ; loadMultimediaOrPlayListFile ( Helpers . createURLfromFile ( f ) ) ; } else if ( f . isDirectory ( ) ) { searchPath = f . getAbsolutePath ( ) ; } } else { playlistRecieved ( null , PlayList . createNewListWithFiles ( files , false , false ) , null ) ; } } } | 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 ) ; fileName = fileName . substring ( fileName . lastIndexOf ( File . separatorChar ) + 1 ) ; String exportToWav = exportPath + File . separatorChar + fileName + ".WAV" ; FileChooserResult selectedFile = Helpers . selectFileNameFor ( this , exportToWav , "Export to wave" , fileFilterExport , 1 , false , false ) ; if ( selectedFile != null ) { File f = selectedFile . getSelectedFile ( ) ; if ( f != null ) { if ( f . exists ( ) ) { int result = JOptionPane . showConfirmDialog ( this , "File already exists! Overwrite?" , "Overwrite confirmation" , JOptionPane . YES_NO_CANCEL_OPTION , JOptionPane . QUESTION_MESSAGE ) ; if ( result == JOptionPane . CANCEL_OPTION ) return ; if ( result == JOptionPane . NO_OPTION ) continue ; boolean ok = f . delete ( ) ; if ( ! ok ) { JOptionPane . showMessageDialog ( MainForm . this , "Overwrite failed. Is file write protected or in use?" , "Failed" , JOptionPane . ERROR_MESSAGE ) ; return ; } } String modFileName = f . getAbsolutePath ( ) ; int i = modFileName . lastIndexOf ( File . separatorChar ) ; exportPath = modFileName . substring ( 0 , i ) ; int result = JOptionPane . showConfirmDialog ( this , "Continue playback while exporting?" , "Playback?" , JOptionPane . YES_NO_OPTION , JOptionPane . QUESTION_MESSAGE ) ; Mixer mixer = createNewMixer ( ) ; mixer . setPlayDuringExport ( result == JOptionPane . YES_OPTION ) ; mixer . setExportFile ( f ) ; playerThread = new PlayThread ( mixer , this ) ; playerThread . start ( ) ; inExportMode = true ; } } return ; } while ( 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 < ? , ? > t : tasks ) { if ( t . isDone ( ) ) return ; t . getOutput ( ) . synchWithNoError ( sp ) ; } sp . block ( 0 ) ; } | 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..." ) ; Log . info ( " anything allowed, your soundhardware supports)" ) ; Log . info ( "-b8/16/24 : #Bits per sample" ) ; Log . info ( "-s+/- : Stereo/Mono" ) ; Log . info ( "-i0/1/2/3 : interpolation: 0:none; 1:linear; 2:cubic spline; 3:fir interpolation" ) ; Log . info ( "-tms : ms of buffer size (30 is minimum)" ) ; Log . info ( "-w+/- : do/don't wide stereo mix" ) ; Log . info ( "-n+/- : do/don't noise reduction" ) ; Log . info ( "-m+/- : do/don't mega bass" ) ; Log . info ( "-l0/1/2 : set infinit loop handling: 0:original; 1:fade out; 2:ignore" ) ; Log . info ( "-h+/- : do/don't shuffle playlists after loading" ) ; Log . info ( "-j+/- : do/don't repeat playlist" ) ; Log . info ( "-v0.0-1.0 : set volume" ) ; Log . info ( "-eWAVEFILE : export to wave file" ) ; } | 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 ) ; playerThread = new PlayThread ( mixer , this ) ; playerThread . start ( ) ; } } | 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 ) ; StringBuilder sb = new StringBuilder ( ) ; int start = 0 ; int index = 0 ; String rGroup = "" ; while ( matcher . find ( ) && rgroupInformation . size ( ) > 0 ) { rGroup = smiles . substring ( start , matcher . end ( ) ) ; rGroup = rGroup . replace ( matcher . group ( ) , "[*:" + rgroupInformation . get ( index ) + "]" ) ; sb . append ( rGroup ) ; index ++ ; start = matcher . end ( ) ; } if ( start < smiles . length ( ) ) { sb . append ( smiles . substring ( start ) ) ; } return sb . toString ( ) ; } } return data ; } | 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 ( "R" ) [ 1 ] ) ) ; } return listValues ; } | 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 are connected to chiral centers" ) ; } if ( firstContainer == secondContainer ) { firstContainer . dearomatize ( ) ; secondContainer . dearomatize ( ) ; IAtomBase atom1 = getNeighborAtom ( firstRgroup ) ; IAtomBase atom2 = getNeighborAtom ( secondRgroup ) ; firstContainer . removeAttachment ( firstRgroup ) ; firstContainer . removeAttachment ( secondRgroup ) ; setStereoInformation ( firstContainer , firstRgroup , firstContainer , secondRgroup , atom1 , atom2 ) ; firstContainer . removeINode ( firstRgroup ) ; firstContainer . removeINode ( secondRgroup ) ; } else { firstContainer . dearomatize ( ) ; secondContainer . dearomatize ( ) ; IAtomBase atom1 = getNeighborAtom ( firstRgroup ) ; IAtomBase atom2 = getNeighborAtom ( secondRgroup ) ; firstContainer . removeAttachment ( firstRgroup ) ; secondContainer . removeAttachment ( secondRgroup ) ; setStereoInformation ( firstContainer , firstRgroup , secondContainer , secondRgroup , atom1 , atom2 ) ; firstContainer . removeINode ( firstRgroup ) ; secondContainer . removeINode ( secondRgroup ) ; AttachmentList mergedAttachments = mergeAttachments ( firstContainer , secondContainer ) ; firstContainer . addIBase ( secondContainer ) ; firstContainer . setAttachments ( mergedAttachments ) ; } return firstContainer ; } | 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 ( firstRgroup ) ) { stereo = getStereoInformation ( firstContainer , firstRgroup , atom2 , atom1 ) ; } if ( secondContainer . isSingleStereo ( secondRgroup ) ) { stereo = getStereoInformation ( secondContainer , secondRgroup , atom1 , atom2 ) ; } if ( stereo != null ) { firstContainer . addIBase ( stereo ) ; result = true ; } return result ; } | 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 . append ( "0" ) ; result . append ( Integer . toHexString ( code ) ) ; } else { result . append ( c ) ; } } return result . toString ( ) ; } | 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 ( code < reservedChars . length && reservedChars [ code ] == code ) { result . append ( reservedChars [ code ] ) ; i += 2 ; } else { throw new ServiceLocationException ( "Unknown escaped character " + ESCAPE_PREFIX + codeString + " at position " + ( i + 1 ) + " of " + value , SLPError . PARSE_ERROR ) ; } } else { result . append ( c ) ; } } return result . toString ( ) ; } | 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 ) ; } writer . write ( '<' ) ; if ( rootNamespaceURI != null ) { String ns = namespaces . get ( rootNamespaceURI ) ; if ( ns != null && ns . length ( ) > 0 ) { writer . write ( ns ) ; writer . write ( ':' ) ; } } ISynchronizationPoint < IOException > result = writer . write ( rootLocalName ) ; if ( namespaces != null && ! namespaces . isEmpty ( ) ) { for ( Map . Entry < String , String > ns : namespaces . entrySet ( ) ) { writer . write ( XMLNS ) ; if ( ns . getValue ( ) . length ( ) > 0 ) { writer . write ( ':' ) ; writer . write ( ns . getValue ( ) ) ; } writer . write ( ATTRIBUTE_EQUALS ) ; writer . write ( escape ( ns . getKey ( ) ) ) ; result = writer . write ( '"' ) ; } } Context ctx = new Context ( ) ; ctx . namespaces = new HashMap < > ( ) ; if ( namespaces != null ) ctx . namespaces . putAll ( namespaces ) ; ctx . namespaceURI = rootNamespaceURI ; ctx . localName = rootLocalName ; ctx . open = true ; context . addFirst ( ctx ) ; return result ; } | 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 ( ( ) -> { output . flush ( ) . listenInline ( sp ) ; } , sp ) ; return sp ; } if ( write . hasError ( ) ) return write ; return output . flush ( ) ; } | 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 ( xml . getLocalName ( ) ) ) throw new Exception ( "Root element of an lc-project.xml file must be <project>" ) ; ApplicationConfiguration cfg = new ApplicationConfiguration ( ) ; boolean found = false ; while ( xml . hasNext ( ) ) { xml . next ( ) ; if ( xml . getEventType ( ) == XMLStreamConstants . START_ELEMENT ) { if ( "application" . equals ( xml . getLocalName ( ) ) ) { found = true ; cfg . load ( xml ) ; break ; } } } if ( ! found ) throw new Exception ( "No application element found in lc-project.xml file" ) ; return cfg ; } } throw new Exception ( "Nothing found in lc-project.xml file" ) ; } | 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 ( ) . equals ( key ) ) { attachments . remove ( i ) ; break ; } } } } } | 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 properties from Resources" ) ; fileStream = this . getClass ( ) . getClassLoader ( ) . getResourceAsStream ( parameterfile ) ; } Properties props = new Properties ( ) ; try { props . load ( fileStream ) ; } catch ( IOException ex ) { throw new RuntimeException ( ex ) ; } DATABASE_DIRECTORY = props . getProperty ( "DATABASE_DIRECTORY" ) ; BUCKET_MEMORY = parseSize ( props . getProperty ( "BUCKET_MEMORY" , "1G" ) ) ; MEMORY_CHUNK = ( int ) parseSize ( props . getProperty ( "MEMORY_CHUNK" , "10K" ) ) ; MAX_MEMORY_PER_BUCKET = parseSize ( props . getProperty ( "MAX_MEMORY_PER_BUCKET" , "100M" ) ) ; SYNC_CHUNK_SIZE = parseSize ( props . getProperty ( "SYNC_CHUNK_SIZE" , "2M" ) ) ; FILE_CHUNK_SIZE = parseSize ( props . getProperty ( "FILE_CHUNK_SIZE" , "32K" ) ) ; FILE_CHUNK_SIZE = FILE_CHUNK_SIZE - FILE_CHUNK_SIZE % prototype . getSize ( ) ; NUMBER_OF_SYNCHRONIZER_THREADS = Integer . valueOf ( props . getProperty ( "NUMBER_OF_SYNCHRONIZER_THREADS" , "1" ) ) ; MAX_BUCKET_STORAGE_TIME = Long . valueOf ( props . getProperty ( "MAX_BUCKET_STORAGE_TIME" , "84000000" ) ) ; MIN_ELEMENT_IN_BUCKET_BEFORE_SYNC = Integer . valueOf ( props . getProperty ( "MIN_ELEMENT_IN_BUCKET_BEFORE_SYNC" , "1" ) ) ; HEADER_FILE_LOCK_RETRY = Integer . valueOf ( props . getProperty ( "HEADER_FILE_LOCK_RETRY" , "100" ) ) ; INITIAL_FILE_SIZE = ( int ) parseSize ( props . getProperty ( "INITIAL_FILE_SIZE" , "16M" ) ) ; INITIAL_INCREMENT_SIZE = ( int ) parseSize ( props . getProperty ( "INITIAL_INCREMENT_SIZE" , "16M" ) ) ; configToLogInfo ( ) ; } | 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 ) ; logger . info ( "----- HeaderIndexFile -----" ) ; logger . info ( "INITIAL_FILE_SIZE = {}" , INITIAL_FILE_SIZE ) ; logger . info ( "INITIAL_INCREMENT_SIZE = {}" , INITIAL_INCREMENT_SIZE ) ; logger . info ( "CHUNK_SIZE = {}" , FILE_CHUNK_SIZE ) ; } | Outputs the configuration to the Logger . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.