idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
13,400
public ValidationResult validate ( PMContext ctx ) { final ValidationResult res = new ValidationResult ( ) ; final Object fieldvalue = ctx . getFieldValue ( ) ; res . setSuccessful ( fieldvalue != null ) ; if ( ! res . isSuccessful ( ) ) { res . getMessages ( ) . add ( MessageFactory . error ( ctx . getEntity ( ) , ctx . getField ( ) , get ( "msg" , "pm.validator.not.null" ) , ctx . getField ( ) . getId ( ) ) ) ; } return res ; }
The validation method
13,401
public boolean isAccessible ( Map context , Object target , Member member , String propertyName ) { int modifiers = member . getModifiers ( ) ; boolean result = Modifier . isPublic ( modifiers ) ; if ( ! result ) { if ( Modifier . isPrivate ( modifiers ) ) { result = getAllowPrivateAccess ( ) ; } else { if ( Modifier . isProtected ( modifiers ) ) { result = getAllowProtectedAccess ( ) ; } else { result = getAllowPackageProtectedAccess ( ) ; } } } return result ; }
Returns true if the given member is accessible or can be made accessible by this object .
13,402
public void initialize ( final int sampleRate , final int channels , final int frequency , final float parameter ) { this . frequency = frequency ; this . sampleRate = sampleRate ; inArray = new float [ channels ] [ HISTORYSIZE ] ; outArray = new float [ channels ] [ HISTORYSIZE ] ; clearHistory ( ) ; }
Call this to initialize . Will set the memory to 0
13,403
public void clearHistory ( ) { int channels = inArray . length ; for ( int c = 0 ; c < channels ; c ++ ) { for ( int i = 0 ; i < HISTORYSIZE ; i ++ ) { inArray [ c ] [ i ] = outArray [ c ] [ i ] = 0f ; } } }
Clean the history
13,404
public int calculate_framesize ( ) { if ( h_layer == 1 ) { framesize = ( 12 * bitrates [ h_version ] [ 0 ] [ h_bitrate_index ] ) / frequencies [ h_version ] [ h_sample_frequency ] ; if ( h_padding_bit != 0 ) framesize ++ ; framesize <<= 2 ; nSlots = 0 ; } else { framesize = ( 144 * bitrates [ h_version ] [ h_layer - 1 ] [ h_bitrate_index ] ) / frequencies [ h_version ] [ h_sample_frequency ] ; if ( h_version == MPEG2_LSF || h_version == MPEG25_LSF ) framesize >>= 1 ; if ( h_padding_bit != 0 ) framesize ++ ; if ( h_layer == 3 ) { if ( h_version == MPEG1 ) { nSlots = framesize - ( ( h_mode == SINGLE_CHANNEL ) ? 17 : 32 ) - ( ( h_protection_bit != 0 ) ? 0 : 2 ) - 4 ; } else { nSlots = framesize - ( ( h_mode == SINGLE_CHANNEL ) ? 9 : 17 ) - ( ( h_protection_bit != 0 ) ? 0 : 2 ) - 4 ; } } else { nSlots = 0 ; } } framesize -= 4 ; return framesize ; }
Calculate Frame size . Calculates framesize in bytes excluding header size .
13,405
public void processMetadata ( Metadata metadata ) { synchronized ( frameListeners ) { Iterator < FrameListener > it = frameListeners . iterator ( ) ; while ( it . hasNext ( ) ) { FrameListener listener = it . next ( ) ; listener . processMetadata ( metadata ) ; } } }
Process metadata records .
13,406
public void processFrame ( Frame frame ) { synchronized ( frameListeners ) { Iterator < FrameListener > it = frameListeners . iterator ( ) ; while ( it . hasNext ( ) ) { FrameListener listener = it . next ( ) ; listener . processFrame ( frame ) ; } } }
Process data frames .
13,407
public void processError ( String msg ) { synchronized ( frameListeners ) { Iterator < FrameListener > it = frameListeners . iterator ( ) ; while ( it . hasNext ( ) ) { FrameListener listener = it . next ( ) ; listener . processError ( msg ) ; } } }
Called for each frame error detected .
13,408
public void setMeter ( float [ ] newSamples ) { if ( newSamples != null ) { anzSamples = newSamples . length ; if ( floatSamples == null || floatSamples . length != anzSamples ) floatSamples = new float [ anzSamples ] ; System . arraycopy ( newSamples , 0 , floatSamples , 0 , anzSamples ) ; float [ ] resultFFTSamples = fftCalc . calculate ( floatSamples ) ; for ( int a = 0 , bd = 0 ; bd < bands ; a += multiplier , bd ++ ) { float wFs = resultFFTSamples [ a ] ; for ( int b = 1 ; b < multiplier ; b ++ ) wFs += resultFFTSamples [ a + b ] ; wFs *= ( float ) FastMath . log ( bd + 2 ) ; if ( wFs > 1.0F ) wFs = 1.0F ; if ( wFs > fftLevels [ bd ] ) { fftLevels [ bd ] = wFs ; if ( fftLevels [ bd ] > maxFFTLevels [ bd ] ) { maxFFTLevels [ bd ] = fftLevels [ bd ] ; maxPeakLevelRampDownValue [ bd ] = maxPeakLevelRampDownDelay ; } } } } else { floatSamples = null ; } }
Will set new Values
13,409
protected void drawMeter ( Graphics g , int newTop , int newLeft , int newWidth , int newHeight , boolean doClear ) { if ( g != null ) { switch ( drawWhat ) { default : case DRAW_SA_METER : drawSAMeter ( g , newTop , newLeft , newWidth , newHeight , doClear ) ; break ; case DRAW_WAVE_METER : drawWaveMeter ( g , newTop , newLeft , newWidth , newHeight , doClear ) ; break ; case DRAW_SK_METER : drawSKMeter ( g , newTop , newLeft , newWidth , newHeight ) ; break ; } } for ( int i = 0 ; i < bands ; i ++ ) { fftLevels [ i ] -= rampDownValue ; if ( fftLevels [ i ] < 0.0F ) fftLevels [ i ] = 0.0F ; maxFFTLevels [ i ] -= maxPeakLevelRampDownValue [ i ] ; if ( maxFFTLevels [ i ] < 0.0F ) maxFFTLevels [ i ] = 0.0F ; else maxPeakLevelRampDownValue [ i ] += maxPeakLevelRampDownDelay ; } }
Internal method doing the drawing
13,410
private boolean isXMMod ( String kennung ) { if ( kennung . equals ( "Extended Module: " ) ) return true ; if ( kennung . toLowerCase ( ) . equals ( "extended module: " ) ) return true ; return false ; }
Get the ModType
13,411
public static String algString ( int alg ) throws UnsupportedAlgorithmException { switch ( alg ) { case Algorithm . RSAMD5 : return "MD5withRSA" ; case Algorithm . DSA : case Algorithm . DSA_NSEC3_SHA1 : return "SHA1withDSA" ; case Algorithm . RSASHA1 : case Algorithm . RSA_NSEC3_SHA1 : return "SHA1withRSA" ; case Algorithm . RSASHA256 : return "SHA256withRSA" ; case Algorithm . RSASHA512 : return "SHA512withRSA" ; default : throw new UnsupportedAlgorithmException ( alg ) ; } }
Convert an algorithm number to the corresponding JCA string .
13,412
public static boolean matches ( String pattern , String value ) { Pattern p = Pattern . compile ( pattern ) ; Matcher m = p . matcher ( value ) ; return m . matches ( ) ; }
Validate if the given value matches the pattern
13,413
public static boolean isLong ( String s ) { if ( s == null ) { return false ; } try { Long . parseLong ( s . trim ( ) ) ; } catch ( NumberFormatException e ) { return false ; } return true ; }
Validate if the given string is a long
13,414
public static < T > boolean containsNo ( Collection < T > baseList , Collection < T > valueList ) { for ( T v : valueList ) { if ( baseList . contains ( v ) ) { return false ; } } return true ; }
Checks if the given basic list contains any element of the given value list .
13,415
private static Integer toInteger ( String str ) { char [ ] chars = str . toCharArray ( ) ; int result = 0 ; int multiplier = 1 ; for ( int i = chars . length - 1 ; i >= 0 ; -- i , multiplier *= 10 ) { char c = chars [ i ] ; if ( '0' <= c && c <= '9' ) { result += ( c - '0' ) * multiplier ; } else { return null ; } } return result ; }
A very simplistic conversion of string to positive integer in only decimal radix .
13,416
public String getToken ( ) { if ( this . tokenPosition > 0 ) { String [ ] ar = StringUtils . split ( this . line , null , this . tokenPosition + 1 ) ; if ( ar != null && ar . length > ( this . tokenPosition - 1 ) ) { return StringUtils . trim ( ar [ this . tokenPosition - 1 ] ) ; } } return null ; }
Returns an array of all tokens being parsed .
13,417
public String getArgs ( ) { int count = ( this . tokenPosition == 0 ) ? 1 : this . tokenPosition + 1 ; String [ ] ar = StringUtils . split ( this . line , null , count ) ; if ( ar != null && ar . length > ( this . tokenPosition ) ) { return StringUtils . trim ( ar [ this . tokenPosition ] ) ; } return null ; }
Returns an string of all tokens that can be considered being command arguments using the current token position .
13,418
public ArrayList < String > getArgList ( ) { ArrayList < String > ret = new ArrayList < String > ( ) ; String [ ] ar = StringUtils . split ( this . getArgs ( ) ) ; if ( ar != null ) { for ( String s : ar ) { ret . add ( StringUtils . trim ( s ) ) ; } } return ret ; }
Returns a list of all tokens that can be considered being command arguments using the current token position .
13,419
public Map < String , String > getArgMap ( ) { Map < String , String > ret = new LinkedHashMap < String , String > ( ) ; String [ ] ar = StringUtils . split ( this . getArgs ( ) , ',' ) ; if ( ar != null ) { for ( String s : ar ) { String [ ] kv = StringUtils . split ( s , ":" , 2 ) ; if ( kv != null && kv . length == 2 ) { ret . put ( StringUtils . trim ( kv [ 0 ] ) , StringUtils . trim ( kv [ 1 ] ) ) ; } else { } } } return ret ; }
Returns a map of all tokens that can be considered being command arguments using the current token position .
13,420
public static void createKey ( String keyName ) throws RegistryException { int [ ] info = invoke ( Methods . REG_CREATE_KEY_EX . get ( ) , keyParts ( keyName ) ) ; checkError ( info [ InfoIndex . INFO_ERROR_CODE . get ( ) ] ) ; invoke ( Methods . REG_CLOSE_KEY . get ( ) , info [ InfoIndex . INFO_HANDLE . get ( ) ] ) ; }
Creates a key . Parent keys in the path will also be created if necessary . This method returns without error if the key already exists .
13,421
public static void deleteKey ( String keyName ) throws RegistryException { checkError ( invoke ( Methods . REG_DELETE_KEY . get ( ) , keyParts ( keyName ) ) ) ; }
Deletes a key and all values within it . If the key has subkeys an Access denied error will be thrown . Subkeys must be deleted separately .
13,422
public static void deleteValue ( String keyName , String valueName ) throws RegistryException { try ( Key key = Key . open ( keyName , KEY_WRITE ) ) { checkError ( invoke ( Methods . REG_DELETE_VALUE . get ( ) , key . id , toByteArray ( valueName ) ) ) ; } }
Deletes a value within a key .
13,423
public static boolean existsKey ( String keyName ) throws RegistryException { String [ ] keyNameParts = keyName . split ( REG_PATH_SEPARATOR_REGEX ) ; if ( Hive . getHive ( keyNameParts [ 0 ] ) == null ) { return false ; } for ( int i = 1 ; i < keyNameParts . length ; i ++ ) { StringBuilder path = new StringBuilder ( ) ; for ( int j = 0 ; j < i ; j ++ ) { path . append ( keyNameParts [ j ] ) ; if ( j < i ) { path . append ( REG_PATH_SEPARATOR ) ; } } List < String > subkeys = readSubkeys ( path . toString ( ) ) ; if ( ! subkeys . contains ( keyNameParts [ i ] ) ) { return false ; } } return true ; }
Checks if a given key exists .
13,424
public static List < String > readSubkeys ( String keyName ) throws RegistryException { try ( Key key = Key . open ( keyName , KEY_READ ) ) { int [ ] info = invoke ( Methods . REG_QUERY_INFO_KEY . get ( ) , key . id ) ; checkError ( info [ InfoIndex . INFO_ERROR_CODE . get ( ) ] ) ; int count = info [ InfoIndex . INFO_COUNT_KEYS . get ( ) ] ; int maxLength = info [ InfoIndex . INFO_MAX_KEY_LENGTH . get ( ) ] + 1 ; List < String > subkeys = new ArrayList < > ( count ) ; for ( int i = 0 ; i < count ; i ++ ) { subkeys . add ( fromByteArray ( invoke ( Methods . REG_ENUM_KEY_EX . get ( ) , key . id , i , maxLength ) ) ) ; } return subkeys ; } }
Returns a list of the names of all the subkeys of a key .
13,425
public static String readValue ( String keyName , String valueName ) throws RegistryException { try ( Key key = Key . open ( keyName , KEY_READ ) ) { return fromByteArray ( invoke ( Methods . REG_QUERY_VALUE_EX . get ( ) , key . id , toByteArray ( valueName ) ) ) ; } }
Reads a string value from the given key and value name .
13,426
public static Map < String , String > readValues ( String keyName ) throws RegistryException { try ( Key key = Key . open ( keyName , KEY_READ ) ) { int [ ] info = invoke ( Methods . REG_QUERY_INFO_KEY . get ( ) , key . id ) ; checkError ( info [ InfoIndex . INFO_ERROR_CODE . get ( ) ] ) ; int count = info [ InfoIndex . INFO_COUNT_VALUES . get ( ) ] ; int maxLength = info [ InfoIndex . INFO_MAX_VALUE_LENGTH . get ( ) ] + 1 ; Map < String , String > values = new HashMap < > ( ) ; for ( int i = 0 ; i < count ; i ++ ) { String valueName = fromByteArray ( invoke ( Methods . REG_ENUM_VALUE . get ( ) , key . id , i , maxLength ) ) ; values . put ( valueName , readValue ( keyName , valueName ) ) ; } return values ; } }
Returns a map of all the name - value pairs in the given key .
13,427
public static void writeValue ( String keyName , String valueName , String value ) throws RegistryException { try ( Key key = Key . open ( keyName , KEY_WRITE ) ) { checkError ( invoke ( Methods . REG_SET_VALUE_EX . get ( ) , key . id , toByteArray ( valueName ) , toByteArray ( value ) ) ) ; } }
Writes a string value with a given key and value name .
13,428
private HttpResponse execute ( HttpUriRequest request ) throws RestException { log . debug ( ">>>> " + request . getRequestLine ( ) ) ; for ( Header header : request . getAllHeaders ( ) ) { log . trace ( ">>>> " + header . getName ( ) + ": " + header . getValue ( ) ) ; } HttpResponse response ; try { response = getHttpClient ( ) . execute ( request ) ; log . debug ( "<<<< " + response . getStatusLine ( ) ) ; for ( Header header : response . getAllHeaders ( ) ) { log . trace ( "<<<< " + header . getName ( ) + ": " + header . getValue ( ) ) ; } if ( response . getStatusLine ( ) . getStatusCode ( ) == 204 ) { log . debug ( "Consuming quietly the response entity since server returned no content" ) ; EntityUtils . consumeQuietly ( response . getEntity ( ) ) ; } checkError ( response ) ; return response ; } catch ( KeyManagementException | NoSuchAlgorithmException | IOException e ) { throw new RuntimeRestException ( e ) ; } finally { DateUtils . clearThreadLocal ( ) ; } }
Internal execute log headers check for errors
13,429
protected void readInitialHeaders ( ) throws IOException { String line ; while ( ( line = readCRLFLine ( ) ) . length ( ) != 0 ) { int colonIndex = line . indexOf ( ':' ) ; if ( colonIndex == - 1 ) continue ; String tagName = line . substring ( 0 , colonIndex ) ; String value = line . substring ( colonIndex + 1 ) ; if ( value . toLowerCase ( ) . endsWith ( "<br>" ) ) value = value . substring ( 0 , value . length ( ) - 4 ) ; IcyTag tag = new IcyTag ( tagName , value ) ; addTag ( tag ) ; } }
Assuming we re at the top of the stream read lines one by one until we hit a completely blank \ r \ n . Parse the data as IcyTags .
13,430
protected String readCRLFLine ( ) throws IOException { int i = 0 ; while ( i < 1024 ) { byte aByte = ( byte ) read ( ) ; if ( aByte == '\n' ) break ; if ( aByte == '\r' ) continue ; crlfBuffer [ i ++ ] = aByte ; } return charsetDecoder . decode ( ByteBuffer . wrap ( crlfBuffer , 0 , i ) ) . toString ( ) ; }
Read everything up to the next CRLF return it as a String .
13,431
public synchronized int read ( ) throws IOException { if ( bytesUntilNextMetadata > 0 ) { bytesUntilNextMetadata -- ; return super . read ( ) ; } else if ( bytesUntilNextMetadata == 0 ) { readMetadata ( ) ; bytesUntilNextMetadata = metaint - 1 ; return super . read ( ) ; } else { return super . read ( ) ; } }
Reads and returns a single byte . If the next byte is a metadata block then that block is read stripped and parsed before reading and returning the first byte after the metadata block .
13,432
protected void addTag ( IcyTag tag ) { tags . put ( tag . getName ( ) , tag ) ; fireTagParsed ( this , tag ) ; }
adds the tag to the HashMap of tags we have encountered either in - stream or as headers replacing any previous tag with this name .
13,433
public void fireTagParseEvent ( TagParseEvent tpe ) { for ( int i = 0 ; i < tagParseListeners . size ( ) ; i ++ ) { TagParseListener l = tagParseListeners . get ( i ) ; l . tagParsed ( tpe ) ; } }
Fires the given event to all registered listeners
13,434
public PMEntitySupport getEntitySupport ( ) { PMEntitySupport r = ( PMEntitySupport ) getRequest ( ) . getSession ( ) . getAttribute ( ENTITY_SUPPORT ) ; return r ; }
Getter for the entity support helper object
13,435
private void prepareFFTTables ( ) { int n2 = ss2 ; int nu1 = nu - 1 ; int k = 0 ; int x = 0 ; for ( int l = 1 ; l <= nu ; l ++ ) { while ( k < ss ) { for ( int i = 1 ; i <= n2 ; i ++ ) { double p = ( double ) bitrev ( k >> nu1 , nu ) ; double arg = ( Math . PI * p * 2.0D ) / ( double ) ss ; fftSin [ x ] = ( long ) ( Math . sin ( arg ) * FRAC_FAC ) ; fftCos [ x ] = ( long ) ( Math . cos ( arg ) * FRAC_FAC ) ; k ++ ; x ++ ; } k += n2 ; } k = 0 ; nu1 -- ; n2 >>= 1 ; } for ( k = 0 ; k < ss ; k ++ ) fftBr [ k ] = bitrev ( k , nu ) ; }
We will here precalculate all sin and cos values and all other things we can store
13,436
private static long longSqrt ( long value ) { final int scale = 8 ; int bits = 64 ; long sqrt = 0 ; long rest = 0 ; for ( int i = 0 ; i < scale ; i ++ ) { bits -= 8 ; rest = ( rest << 8 ) | ( ( value >> bits ) & 0xFF ) ; long i2 = ( sqrt << 5 ) + 1 ; int k0 = 0 ; while ( true ) { long i3 = rest - i2 ; if ( i3 < 0 ) break ; rest = i3 ; i2 += 2 ; k0 ++ ; } sqrt = ( sqrt << 4 ) + k0 ; } return sqrt ; }
This will calculate the integer sqrt from a long value
13,437
protected void validate ( STGroup stg , Map < String , Set < String > > expectedChunks ) { for ( String s : expectedChunks . keySet ( ) ) { if ( s != null && ! "" . equals ( s ) ) { if ( stg . isDefined ( s ) ) { STValidator stv = new STValidator ( stg . getInstanceOf ( s ) , expectedChunks . get ( s ) ) ; this . errors . addAllErrors ( stv . getValidationErrors ( ) ) ; } else { this . errors . addError ( "STGroup <{}> does not define mandatory template <{}>" , GET_STG_NAME ( stg ) , s ) ; } } } }
Does the actual validation of the STGroup .
13,438
public static final String GET_STG_NAME ( STGroup stg ) { String ret = null ; if ( stg instanceof STGroupFile ) { ret = ( ( STGroupFile ) stg ) . fileName ; } else if ( stg instanceof STGroupString ) { ret = ( ( STGroupString ) stg ) . sourceName ; } else if ( stg instanceof STGroupDir ) { ret = ( ( STGroupDir ) stg ) . groupDirName ; } return StringUtils . substringBeforeLast ( ret , "." ) ; }
Returns the name of the STGroup . Any file extension will be removed from the returned name .
13,439
public MessageMgrBuilder setHandler ( E_MessageType type ) { if ( type != null ) { this . messageHandlers . put ( type , new MessageTypeHandler ( type ) ) ; } else { this . buildErrors . addError ( "{}: cannot add handler for empty type" , this . getClass ( ) . getSimpleName ( ) ) ; } return this ; }
Activate a message type and sets a type handler with max count set to 100 . An existing handler will be overwritten .
13,440
public static ThreadGroup findRootThreadGroup ( ) { ThreadGroup root = Thread . currentThread ( ) . getThreadGroup ( ) ; while ( root . getParent ( ) != null ) { root = root . getParent ( ) ; } return root ; }
Find the root thread group .
13,441
private static Thread findActiveThreadByName ( ThreadGroup group , String threadName ) { Thread result = null ; int numThreads = group . activeCount ( ) ; Thread [ ] threads = new Thread [ numThreads * 2 ] ; numThreads = group . enumerate ( threads , false ) ; for ( int i = 0 ; i < numThreads ; i ++ ) { if ( threads [ i ] . getName ( ) . equals ( threadName ) ) { return threads [ i ] ; } } int numGroups = group . activeGroupCount ( ) ; ThreadGroup [ ] groups = new ThreadGroup [ numGroups * 2 ] ; numGroups = group . enumerate ( groups , false ) ; for ( int i = 0 ; i < numGroups ; i ++ ) { result = findActiveThreadByName ( groups [ i ] , threadName ) ; if ( result != null ) { break ; } } return result ; }
This method recursively visits all thread groups under group searching for the active thread with name threadName .
13,442
public static ScopeListExtension findFirst ( Collection < ? extends Extension > extensions ) { for ( Extension extension : extensions ) { if ( SCOPE_LIST_EXTENSION_ID == extension . getId ( ) ) return ( ScopeListExtension ) extension ; } return null ; }
Returns the first ScopeListExtension found in the given collection of extensions or null if the extension collection does not contain a ScopeListExtension .
13,443
public static List < ScopeListExtension > findAll ( Collection < ? extends Extension > extensions ) { List < ScopeListExtension > result = new ArrayList < ScopeListExtension > ( ) ; for ( Extension extension : extensions ) { if ( SCOPE_LIST_EXTENSION_ID == extension . getId ( ) ) result . add ( ( ScopeListExtension ) extension ) ; } return result ; }
Returns all ScopeListExtension found in the given collection of extensions or an empty list if the extension collection does not contain ScopeListExtensions .
13,444
public void pushUlterior ( String key , Object value ) { assertArgumentNotNull ( "key" , key ) ; assertArgumentNotNull ( "value" , value ) ; if ( pushedUlteriorMap == null ) { pushedUlteriorMap = new LinkedHashMap < String , Object > ( 4 ) ; } pushedUlteriorMap . put ( key , value ) ; }
basically unused in mailflute this is for extension by application
13,445
public AsyncWork < OutputResultType , OutputErrorType > write ( InputType data ) throws IOException { do { SynchronizationPoint < NoException > lk ; synchronized ( waiting ) { if ( error != null ) return new AsyncWork < > ( null , error ) ; if ( cancelled != null ) return new AsyncWork < > ( null , null , cancelled ) ; AsyncWork < OutputResultType , OutputErrorType > op ; if ( isReady ) { isReady = false ; op = lastWrite = executor . execute ( data ) ; lastWrite . listenInline ( new WriteListener ( data , op , null ) ) ; return op ; } if ( ! waiting . isFull ( ) ) { op = new AsyncWork < > ( ) ; waiting . addLast ( new Pair < > ( data , op ) ) ; lastWrite = op ; return op ; } if ( lock != null ) throw new IOException ( "Concurrent write" ) ; lock = new SynchronizationPoint < > ( ) ; lk = lock ; } lk . block ( 0 ) ; } while ( true ) ; }
Queue the data to write . If there is no pending write the write operation is started . If too many write operations are pending the method is blocking .
13,446
public static void newLine ( DebugMode mode ) { if ( debugMode == DebugMode . SILENT ) return ; if ( mode . ordinal ( ) >= debugMode . ordinal ( ) ) { if ( outputMode == OutputMode . SYSOUT ) { printStream . println ( ) ; } else if ( outputMode == OutputMode . FILE ) { try { fileWriter . newLine ( ) ; } catch ( IOException e ) { printStream . println ( "Cannot write output to file: I/O Exception" ) ; } } } }
Prints a new line
13,447
public static XElement storeList ( String container , String item , Iterable < ? extends XSerializable > source ) { XElement result = new XElement ( container ) ; for ( XSerializable e : source ) { e . save ( result . add ( item ) ) ; } return result ; }
Create an XElement with the given name and items stored from the source sequence .
13,448
public void transferTo ( Decoder newDecoder ) { super . transferTo ( newDecoder ) ; if ( remainingBytesLength > 0 ) { if ( currentBuffer == null || ! currentBuffer . hasRemaining ( ) ) currentBuffer = ByteBuffer . wrap ( remainingBytes , 0 , remainingBytesLength ) ; else { byte [ ] b = new byte [ remainingBytesLength + currentBuffer . remaining ( ) ] ; System . arraycopy ( remainingBytes , 0 , b , 0 , remainingBytesLength ) ; currentBuffer . get ( b , remainingBytesLength , currentBuffer . remaining ( ) ) ; currentBuffer = ByteBuffer . wrap ( b ) ; } } }
used in case of overflow but this is usually an error
13,449
protected final boolean tryFS ( String directory , String fileName ) { String path = directory + "/" + fileName ; if ( directory == null ) { path = fileName ; } File file = new File ( path ) ; if ( this . testFile ( file ) == true ) { try { this . url = file . toURI ( ) . toURL ( ) ; this . file = file ; this . fullFileName = FilenameUtils . getName ( file . getAbsolutePath ( ) ) ; if ( directory != null ) { this . setRootPath = directory ; } return true ; } catch ( MalformedURLException e ) { this . errors . addError ( "init() - malformed URL for file with name " + this . file . getAbsolutePath ( ) + " and message: " + e . getMessage ( ) ) ; } } return false ; }
Try to locate a file in the file system .
13,450
protected final boolean tryResource ( String directory , String fileName ) { String path = directory + "/" + fileName ; if ( directory == null ) { path = fileName ; } URL url ; ClassLoader loader = Thread . currentThread ( ) . getContextClassLoader ( ) ; url = loader . getResource ( path ) ; if ( url == null ) { loader = AbstractFileInfo . class . getClassLoader ( ) ; url = loader . getResource ( path ) ; } if ( url == null ) { this . errors . addError ( "could not get Resource URL" ) ; return false ; } this . url = url ; this . fullFileName = FilenameUtils . getName ( fileName ) ; if ( directory != null ) { this . setRootPath = directory ; } return true ; }
Try to locate a file as resource .
13,451
public String getAbsolutePath ( ) { if ( this . isValid ( ) ) { if ( this . asFile ( ) != null ) { return FilenameUtils . getFullPathNoEndSeparator ( this . file . getAbsolutePath ( ) ) ; } else { return FilenameUtils . getFullPathNoEndSeparator ( this . url . getPath ( ) ) ; } } return null ; }
Returns the absolute path of the file without the file name
13,452
public StringBuilder generate ( Log log ) { StringBuilder s = new StringBuilder ( ) ; for ( int i = 0 ; i < parts . length ; ++ i ) parts [ i ] . append ( s , log ) ; if ( log . trace != null ) appendStack ( s , log . trace ) ; return s ; }
Generate a log string .
13,453
public void close ( ) { JWindow w ; synchronized ( this ) { if ( ! synch . isUnblocked ( ) ) synch . unblock ( ) ; if ( win == null ) return ; w = win ; win = null ; } if ( event != null ) event . fire ( ) ; w . setVisible ( false ) ; w . removeAll ( ) ; w . dispose ( ) ; RepaintManager . setCurrentManager ( null ) ; logoContainer = null ; titleContainer = null ; bottom = null ; progressText = null ; progressSubText = null ; progressBar = null ; poweredBy = null ; logo = null ; title = null ; text = null ; subText = null ; event = null ; }
Close this window .
13,454
public synchronized void setLogo ( ImageIcon logo , boolean isCustom ) { if ( win == null ) return ; this . logo = new JLabel ( logo ) ; Dimension dim = new Dimension ( logo . getIconWidth ( ) , logo . getIconHeight ( ) ) ; if ( dim . width > 400 ) dim . width = 400 ; if ( dim . height > 300 ) dim . height = 300 ; this . logo . setMaximumSize ( dim ) ; this . logo . setMinimumSize ( dim ) ; this . logo . setPreferredSize ( dim ) ; this . isCustomLogo = isCustom ; update ( ) ; }
Change the logo .
13,455
public void loadDefaultLogo ( ) { int pos = 0 ; int size = 18296 ; byte [ ] buffer = new byte [ size ] ; try ( InputStream in = getClass ( ) . getClassLoader ( ) . getResourceAsStream ( "net/lecousin/framework/core/logo_200x200.png" ) ) { do { int nb = in . read ( buffer , pos , size - pos ) ; if ( nb <= 0 ) break ; pos += nb ; } while ( pos < size ) ; } catch ( IOException e ) { } if ( pos == size ) setLogo ( new ImageIcon ( buffer ) , false ) ; }
Load the default logo .
13,456
public synchronized void endInit ( ) { if ( win == null ) return ; progressText . setText ( "Starting framework..." ) ; progressBar . setMinimum ( 0 ) ; progressBar . setMaximum ( 10050 ) ; progressBar . setValue ( 50 ) ; bottom . invalidate ( ) ; }
End of initial startup .
13,457
protected void validateSTG ( ) { if ( this . stg == null ) { throw new IllegalArgumentException ( "stg is null" ) ; } STGroupValidator stgv = new STGroupValidator ( this . stg , MessageRenderer . STG_CHUNKS ) ; if ( stgv . getValidationErrors ( ) . hasErrors ( ) ) { throw new IllegalArgumentException ( stgv . getValidationErrors ( ) . render ( ) ) ; } }
Validates the local STGroup
13,458
public String render ( Message5WH msg ) { if ( msg != null ) { ST ret = this . stg . getInstanceOf ( "message5wh" ) ; if ( msg . getWhereLocation ( ) != null ) { ST where = this . stg . getInstanceOf ( "where" ) ; where . add ( "location" , msg . getWhereLocation ( ) ) ; if ( msg . getWhereLine ( ) > 0 ) { where . add ( "line" , msg . getWhereLine ( ) ) ; } if ( msg . getWhereColumn ( ) > 0 ) { where . add ( "column" , msg . getWhereColumn ( ) ) ; } ret . add ( "where" , where ) ; } ret . add ( "reporter" , msg . getReporter ( ) ) ; if ( msg . getType ( ) != null ) { Map < String , Boolean > typeMap = new HashMap < > ( ) ; typeMap . put ( msg . getType ( ) . toString ( ) , true ) ; ret . add ( "type" , typeMap ) ; } if ( msg . getWhat ( ) != null && ! StringUtils . isBlank ( msg . getWhat ( ) . toString ( ) ) ) { ret . add ( "what" , msg . getWhat ( ) ) ; } ret . add ( "who" , msg . getWho ( ) ) ; ret . add ( "when" , msg . getWhen ( ) ) ; ret . add ( "why" , msg . getWhy ( ) ) ; ret . add ( "how" , msg . getHow ( ) ) ; return ret . render ( ) ; } return "" ; }
Renders a single message
13,459
public String render ( Collection < Message5WH > messages ) { StrBuilder ret = new StrBuilder ( 50 ) ; for ( Message5WH msg : messages ) { ret . appendln ( this . render ( msg ) ) ; } return ret . toString ( ) ; }
Renders a collection of messages .
13,460
public boolean nextStartElement ( ) throws XMLException , IOException { try { do { next ( ) ; } while ( ! Type . START_ELEMENT . equals ( event . type ) ) ; return true ; } catch ( EOFException e ) { return false ; } }
Shortcut to move forward to the next START_ELEMENT return false if no START_ELEMENT event was found .
13,461
public boolean nextInnerElement ( ElementContext parent ) throws XMLException , IOException { if ( event . context . isEmpty ( ) ) return false ; if ( Type . START_ELEMENT . equals ( event . type ) && event . context . getFirst ( ) == parent && event . isClosed ) return false ; if ( Type . END_ELEMENT . equals ( event . type ) && event . context . getFirst ( ) == parent ) return false ; try { do { next ( ) ; if ( Type . END_ELEMENT . equals ( event . type ) ) { if ( event . context . getFirst ( ) == parent ) return false ; } if ( Type . START_ELEMENT . equals ( event . type ) ) { if ( event . context . size ( ) > 1 && event . context . get ( 1 ) == parent ) return true ; } } while ( true ) ; } catch ( EOFException e ) { return false ; } }
Go to the next inner element . Return true if one is found false if the closing tag of the parent is found .
13,462
public boolean nextInnerElement ( ElementContext parent , String childName ) throws XMLException , IOException { while ( nextInnerElement ( parent ) ) { if ( event . text . equals ( childName ) ) return true ; } return false ; }
Go to the next inner element having the given name . Return true if one is found false if the closing tag of the parent is found .
13,463
public boolean matches ( String groupId , String artifactId ) { if ( ! "*" . equals ( this . groupId ) && ! this . groupId . equals ( groupId ) ) return false ; if ( ! "*" . equals ( this . artifactId ) && ! this . artifactId . equals ( artifactId ) ) return false ; return true ; }
Check the artifact referenced by this instance matches the given group and artifact id .
13,464
public List < File > getSourceAsFileSourceList ( ) { List < File > ret = new ArrayList < > ( ) ; for ( FileSource fs : this . getSource ( ) ) { ret . add ( fs . asFile ( ) ) ; } return ret ; }
Returns file list as a list of File objects .
13,465
public void set ( Language language ) { this . language = language ; Cookie cookie = new Cookie ( COOKIE_NAME , language . name ( ) ) ; cookie . setPath ( "/" ) ; cookie . setMaxAge ( Integer . MAX_VALUE ) ; VaadinService . getCurrentResponse ( ) . addCookie ( cookie ) ; }
Saves the new selected language in this session bean and in a cookie for future use
13,466
public static void close ( Iterable < ? extends Closeable > closeables ) throws IOException { IOException first = null ; for ( final Closeable c : closeables ) { if ( c == null ) { LOG . debug ( "trying to call .close() on null reference" ) ; continue ; } try { c . close ( ) ; } catch ( final IOException e ) { if ( first == null ) { first = e ; } else { first . addSuppressed ( e ) ; } } } if ( first != null ) { throw first ; } }
Closes the given Closeables and collects all occurring exceptions as suppressed exception to the exception that occurred first .
13,467
@ ConditionalOnMissingBean ( name = "swaggerSpringfoxApiDocket" ) public Docket swaggerSpringfoxApiDocket ( List < SwaggerCustomizer > swaggerCustomizers , ObjectProvider < AlternateTypeRule [ ] > alternateTypeRules ) { log . debug ( STARTING_MESSAGE ) ; StopWatch watch = new StopWatch ( ) ; watch . start ( ) ; Docket docket = createDocket ( ) ; swaggerCustomizers . forEach ( customizer -> customizer . customize ( docket ) ) ; Optional . ofNullable ( alternateTypeRules . getIfAvailable ( ) ) . ifPresent ( docket :: alternateTypeRules ) ; watch . stop ( ) ; log . debug ( STARTED_MESSAGE , watch . getTotalTimeMillis ( ) ) ; return docket ; }
Springfox configuration for the API Swagger docs .
13,468
public static AttributeListExtension findFirst ( Collection < ? extends Extension > extensions ) { for ( Extension extension : extensions ) { if ( ATTRIBUTE_LIST_EXTENSION_ID == extension . getId ( ) ) return ( AttributeListExtension ) extension ; } return null ; }
Returns the first AttributeListExtension found in the given collection of extensions or null if the extension collection does not contain an AttributeListExtension .
13,469
public static List < AttributeListExtension > findAll ( Collection < ? extends Extension > extensions ) { List < AttributeListExtension > result = new ArrayList < AttributeListExtension > ( ) ; for ( Extension extension : extensions ) { if ( ATTRIBUTE_LIST_EXTENSION_ID == extension . getId ( ) ) result . add ( ( AttributeListExtension ) extension ) ; } return result ; }
Returns all AttributeListExtensions found in the given collection of extensions or an empty list if the extension collection does not contain AttributeListExtensions .
13,470
public < T > Predicate < T > beNull ( Class < T > type ) { return create ( Objects :: isNull ) ; }
A predicate that tests if the object is null .
13,471
public Predicate < Exception > raise ( Class < ? extends Exception > exception ) { return create ( error -> error != null && exception . isAssignableFrom ( error . getClass ( ) ) ) ; }
Indicates that the operation should throw the given exception .
13,472
protected void moveElements ( HeaderIndexFile < Data > source , RangeHashFunction targetHashfunction , String workingDir ) throws IOException , FileLockException { ByteBuffer elem = ByteBuffer . allocate ( source . getElementSize ( ) ) ; HeaderIndexFile < Data > tmp = null ; newBucketIds = new IntArrayList ( ) ; long offset = 0 ; byte [ ] key = new byte [ gp . getKeySize ( ) ] ; int oldBucket = - 1 , newBucket ; while ( offset < source . getFilledUpFromContentStart ( ) ) { source . read ( offset , elem ) ; elem . rewind ( ) ; elem . get ( key ) ; newBucket = targetHashfunction . getBucketId ( key ) ; if ( newBucket != oldBucket ) { this . newBucketIds . add ( newBucket ) ; if ( tmp != null ) { tmp . close ( ) ; } String fileName = workingDir + "/" + targetHashfunction . getFilename ( newBucket ) ; tmp = new HeaderIndexFile < Data > ( fileName , AccessMode . READ_WRITE , 100 , gp ) ; oldBucket = newBucket ; } tmp . append ( elem ) ; offset += elem . limit ( ) ; } if ( tmp != null ) tmp . close ( ) ; }
moves elements from the source file to new smaller files . The filenames are generated automatically
13,473
protected int determineElementsPerPart ( int numberOfPartitions ) { double numberOfElementsWithinFile = sourceFile . getFilledUpFromContentStart ( ) / sourceFile . getElementSize ( ) ; double elementsPerPart = numberOfElementsWithinFile / numberOfPartitions ; int roundNumber = ( int ) Math . ceil ( elementsPerPart ) ; return roundNumber ; }
Determines the number of elements when the partitions must have equal sizes
13,474
private String getModType ( String kennung ) throws IOException { if ( ! kennung . equals ( "!Scream!" ) ) throw new IOException ( "Mod id: " + kennung + ": this is not a screamtracker mod" ) ; setNSamples ( 31 ) ; setNChannels ( 4 ) ; return "ScreamTracker" ; }
Get the current modtype
13,475
private PatternElement createNewPatternElement ( int pattNum , int row , int channel , int note ) { PatternElement pe = new PatternElement ( pattNum , row , channel ) ; pe . setInstrument ( ( note & 0xF80000 ) >> 19 ) ; int oktave = ( note & 0xF0000000 ) >> 28 ; if ( oktave != - 1 ) { int ton = ( note & 0x0F000000 ) >> 24 ; int index = ( oktave + 3 ) * 12 + ton ; pe . setPeriod ( ( index < Helpers . noteValues . length ) ? Helpers . noteValues [ index ] : 0 ) ; pe . setNoteIndex ( index + 1 ) ; } else { pe . setPeriod ( 0 ) ; pe . setNoteIndex ( 0 ) ; } pe . setEffekt ( ( note & 0xF00 ) >> 8 ) ; pe . setEffektOp ( note & 0xFF ) ; if ( pe . getEffekt ( ) == 0x01 ) { int effektOp = pe . getEffektOp ( ) ; pe . setEffektOp ( ( ( effektOp & 0x0F ) << 4 ) | ( ( effektOp & 0xF0 ) >> 4 ) ) ; } int volume = ( ( note & 0x70000 ) >> 16 ) | ( ( note & 0xF000 ) >> 9 ) ; if ( volume <= 64 ) { pe . setVolumeEffekt ( 1 ) ; pe . setVolumeEffektOp ( volume ) ; } return pe ; }
Read the STM pattern data
13,476
public static int [ ] cs_post ( int [ ] parent , int n ) { int j , k = 0 , post [ ] , w [ ] , head [ ] , next [ ] , stack [ ] ; if ( parent == null ) return ( null ) ; post = new int [ n ] ; w = new int [ 3 * n ] ; if ( w == null || post == null ) return ( cs_idone ( post , null , w , false ) ) ; head = w ; next = w ; int next_offset = n ; stack = w ; int stack_offset = 2 * n ; for ( j = 0 ; j < n ; j ++ ) head [ j ] = - 1 ; for ( j = n - 1 ; j >= 0 ; j -- ) { if ( parent [ j ] == - 1 ) continue ; next [ next_offset + j ] = head [ parent [ j ] ] ; head [ parent [ j ] ] = j ; } for ( j = 0 ; j < n ; j ++ ) { if ( parent [ j ] != - 1 ) continue ; k = cs_tdfs ( j , k , head , 0 , next , next_offset , post , 0 , stack , stack_offset ) ; } return ( post ) ; }
Postorders a tree of forest .
13,477
public static DelegateClassLoader forPlugins ( Stream < URL > urls , ClassLoader appClassLoader ) { Require . nonNull ( urls , "urls" ) ; Require . nonNull ( appClassLoader , "parent" ) ; final Collection < DependencyResolver > plugins = new ArrayList < > ( ) ; final Collection < PluginInformation > information = new ArrayList < > ( ) ; final DependencyResolver delegator = new DelegateDependencyResolver ( plugins ) ; final Iterator < URL > it = urls . iterator ( ) ; while ( it . hasNext ( ) ) { final URL pluginURL = it . next ( ) ; final PluginClassLoader pluginCl = PluginClassLoader . create ( pluginURL , appClassLoader , delegator ) ; plugins . add ( pluginCl ) ; information . add ( pluginCl . getPluginInformation ( ) ) ; } return AccessController . doPrivileged ( new PrivilegedAction < DelegateClassLoader > ( ) { public DelegateClassLoader run ( ) { return new DelegateClassLoader ( appClassLoader , delegator , information ) ; } } ) ; }
Creates a new ClassLoader which provides access to all plugins given by the collection of URLs .
13,478
public final Optional < PluginInformation > getInformation ( String pluginName ) { Require . nonNull ( pluginName , "pluginName" ) ; return Optional . ofNullable ( this . information . get ( pluginName ) ) ; }
Information about loaded plugin with given name .
13,479
protected < T > Page < T > loadEntities ( Pager pager , EntityConvertor < BE , E , T > conversionFunction ) { return inCommittableTx ( tx -> { Function < BE , Pair < BE , E > > conversion = ( e ) -> new Pair < > ( e , tx . convert ( e , context . entityClass ) ) ; Function < Pair < BE , E > , Boolean > filter = context . configuration . getResultFilter ( ) == null ? null : ( p ) -> context . configuration . getResultFilter ( ) . isApplicable ( p . second ) ; Page < Pair < BE , E > > intermediate = tx . < Pair < BE , E > > query ( context . select ( ) . get ( ) , pager , conversion , filter ) ; return new TransformingPage < Pair < BE , E > , T > ( intermediate , ( p ) -> conversionFunction . convert ( p . first , p . second , tx ) ) { public void close ( ) { try { tx . commit ( ) ; } catch ( CommitFailureException e ) { throw new IllegalStateException ( "Failed to commit the read operation." , e ) ; } super . close ( ) ; } } ; } ) ; }
Loads the entities given the pager and converts them using the provided conversion function to the desired type .
13,480
public Attribute getAttributeByName ( String name ) { for ( Attribute a : attributes ) if ( name . equals ( a . getName ( ) ) ) return a ; return null ; }
Get an attribute by its name .
13,481
public Attribute getAttributeByOriginalName ( String name ) { for ( Attribute a : attributes ) if ( name . equals ( a . getOriginalName ( ) ) ) return a ; return null ; }
Get an attribute by its original name .
13,482
public void replaceAttribute ( Attribute original , Attribute newAttribute ) { for ( ListIterator < Attribute > it = attributes . listIterator ( ) ; it . hasNext ( ) ; ) if ( it . next ( ) . equals ( original ) ) { it . set ( newAttribute ) ; break ; } }
Replace an attribute .
13,483
public void apply ( List < SerializationRule > rules , SerializationContext context , boolean serializing ) throws Exception { for ( SerializationRule rule : rules ) if ( rule . apply ( this , context , rules , serializing ) ) break ; }
Apply rules .
13,484
public static TypeDefinition searchAttributeType ( TypeDefinition containerType , String attributeName ) { try { Field f = containerType . getBase ( ) . getField ( attributeName ) ; if ( ( f . getModifiers ( ) & ( Modifier . STATIC | Modifier . FINAL ) ) != 0 ) return new TypeDefinition ( containerType , f . getGenericType ( ) ) ; } catch ( Throwable t ) { } try { Method m = containerType . getBase ( ) . getMethod ( "get" + Character . toUpperCase ( attributeName . charAt ( 0 ) ) + attributeName . substring ( 1 ) ) ; Class < ? > returnType = m . getReturnType ( ) ; if ( returnType != null && ! Void . class . equals ( returnType ) && ! void . class . equals ( returnType ) ) return new TypeDefinition ( containerType , m . getGenericReturnType ( ) ) ; } catch ( Throwable t ) { } try { Method m = containerType . getBase ( ) . getMethod ( "is" + Character . toUpperCase ( attributeName . charAt ( 0 ) ) + attributeName . substring ( 1 ) ) ; Class < ? > returnType = m . getReturnType ( ) ; if ( boolean . class . equals ( returnType ) || Boolean . class . equals ( returnType ) ) return new TypeDefinition ( containerType , m . getGenericReturnType ( ) ) ; } catch ( Throwable t ) { } return null ; }
Search an attribute in the given type .
13,485
public static boolean cs_ltsolve ( Dcs L , double [ ] x ) { int p , j , n , Lp [ ] , Li [ ] ; double Lx [ ] ; if ( ! Dcs_util . CS_CSC ( L ) || x == null ) return ( false ) ; n = L . n ; Lp = L . p ; Li = L . i ; Lx = L . x ; for ( j = n - 1 ; j >= 0 ; j -- ) { for ( p = Lp [ j ] + 1 ; p < Lp [ j + 1 ] ; p ++ ) { x [ j ] -= Lx [ p ] * x [ Li [ p ] ] ; } x [ j ] /= Lx [ Lp [ j ] ] ; } return ( true ) ; }
Solves an upper triangular system L x = b where x and b are dense . x = b on input solution on output .
13,486
public long skip ( long bytes ) throws IOException { long pos = randomFile . getFilePointer ( ) ; randomFile . seek ( pos + bytes ) ; return randomFile . getFilePointer ( ) - pos ; }
Skip bytes in the input file .
13,487
public int read ( byte [ ] buffer , int pos , int bytes ) throws IOException { return randomFile . read ( buffer , pos , bytes ) ; }
Read bytes into an array .
13,488
void isLegal ( boolean checkCdDaSubset ) throws Violation { if ( checkCdDaSubset ) { if ( leadIn < 2 * 44100 ) { throw new Violation ( "CD-DA cue sheet must have a lead-in length of at least 2 seconds" ) ; } if ( leadIn % 588 != 0 ) { throw new Violation ( "CD-DA cue sheet lead-in length must be evenly divisible by 588 samples" ) ; } } if ( numTracks == 0 ) { throw new Violation ( "cue sheet must have at least one track (the lead-out)" ) ; } if ( checkCdDaSubset && tracks [ numTracks - 1 ] . number != 170 ) { throw new Violation ( "CD-DA cue sheet must have a lead-out track number 170 (0xAA)" ) ; } for ( int i = 0 ; i < numTracks ; i ++ ) { if ( tracks [ i ] . number == 0 ) { throw new Violation ( "cue sheet may not have a track number 0" ) ; } if ( checkCdDaSubset ) { if ( ! ( ( tracks [ i ] . number >= 1 && tracks [ i ] . number <= 99 ) || tracks [ i ] . number == 170 ) ) { throw new Violation ( "CD-DA cue sheet track number must be 1-99 or 170" ) ; } } if ( checkCdDaSubset && tracks [ i ] . offset % 588 != 0 ) { throw new Violation ( "CD-DA cue sheet track offset must be evenly divisible by 588 samples" ) ; } if ( i < numTracks - 1 ) { if ( tracks [ i ] . numIndices == 0 ) { throw new Violation ( "cue sheet track must have at least one index point" ) ; } if ( tracks [ i ] . indices [ 0 ] . number > 1 ) { throw new Violation ( "cue sheet track's first index number must be 0 or 1" ) ; } } for ( int j = 0 ; j < tracks [ i ] . numIndices ; j ++ ) { if ( checkCdDaSubset && tracks [ i ] . indices [ j ] . offset % 588 != 0 ) { throw new Violation ( "CD-DA cue sheet track index offset must be evenly divisible by 588 samples" ) ; } if ( j > 0 ) { if ( tracks [ i ] . indices [ j ] . number != tracks [ i ] . indices [ j - 1 ] . number + 1 ) { throw new Violation ( "cue sheet track index numbers must increase by 1" ) ; } } } } }
Verifys the Cue Sheet .
13,489
public static XNElement createRequest ( String function , Object ... nameValue ) { XNElement result = new XNElement ( function ) ; for ( int i = 0 ; i < nameValue . length ; i += 2 ) { result . set ( ( String ) nameValue [ i ] , nameValue [ i + 1 ] ) ; } return result ; }
Create a request with the given function and name - value pairs .
13,490
public static < T extends XNSerializable > List < T > parseList ( XNElement container , String itemName , Supplier < T > creator ) { List < T > result = new ArrayList < > ( ) ; for ( XNElement e : container . childrenWithName ( itemName ) ) { T obj = creator . get ( ) ; obj . load ( e ) ; result . add ( obj ) ; } return result ; }
Parses an container for the given itemName elements and loads them into the given Java XNSerializable object .
13,491
public static XNElement storeList ( String container , String item , Iterable < ? extends XNSerializable > source ) { XNElement result = new XNElement ( container ) ; for ( XNSerializable e : source ) { e . save ( result . add ( item ) ) ; } return result ; }
Create an XNElement with the given name and items stored from the source sequence .
13,492
public static byte [ ] [ ] toByteArray ( long [ ] l ) { byte [ ] [ ] b = new byte [ l . length ] [ ] ; for ( int i = 0 ; i < b . length ; i ++ ) { b [ i ] = Bytes . toBytes ( l [ i ] ) ; } return b ; }
transforms the given array of longs to an array of byte - arrays
13,493
public static boolean isNull ( byte [ ] key , int length ) { if ( key == null ) { return true ; } for ( int i = 0 ; i < Math . min ( key . length , length ) ; i ++ ) { if ( key [ i ] != 0 ) { return false ; } } return true ; }
Checks if the elements of the given key up the given length are 0 or the whole array is null .
13,494
public static int compareKey ( byte [ ] key1 , byte [ ] key2 ) { return compareKey ( key1 , key2 , Math . min ( key1 . length , key2 . length ) ) ; }
Compares the two byte - arrays on the basis of unsigned bytes . The array will be compared by each element up to the length of the smaller array . If all elements are equal and the array are not equal sized the larger array is seen as larger .
13,495
public static String toStringUnsignedInt ( byte [ ] key ) { StringBuilder result = new StringBuilder ( ) ; for ( int i = 0 ; i < key . length ; i ++ ) { result . append ( key [ i ] & 0xFF ) ; result . append ( ' ' ) ; } return result . toString ( ) ; }
Generates a string representation of the given key
13,496
public boolean belongsTo ( String groupname ) { if ( groupname == null ) { return false ; } for ( PMSecurityUserGroup g : getGroups ( ) ) { if ( groupname . equalsIgnoreCase ( g . getName ( ) ) ) { return true ; } } return false ; }
Determine if the user belongs to the group
13,497
public String getGravatar ( ) { if ( getEmail ( ) == null ) { return "http://www.gravatar.com/avatar/00000000000000000000000000000000" ; } else { final MD5 md5 = new MD5 ( ) ; final String hash = md5 . calcMD5 ( getEmail ( ) ) ; return "http://www.gravatar.com/avatar/" + hash ; } }
Get a gravatar image
13,498
public void processStreamInfo ( StreamInfo info ) { synchronized ( pcmProcessors ) { Iterator < PCMProcessor > it = pcmProcessors . iterator ( ) ; while ( it . hasNext ( ) ) { PCMProcessor processor = ( PCMProcessor ) it . next ( ) ; processor . processStreamInfo ( info ) ; } } }
Process the StreamInfo block .
13,499
public void processPCM ( ByteData pcm ) { synchronized ( pcmProcessors ) { Iterator < PCMProcessor > it = pcmProcessors . iterator ( ) ; while ( it . hasNext ( ) ) { PCMProcessor processor = ( PCMProcessor ) it . next ( ) ; processor . processPCM ( pcm ) ; } } }
Process the decoded PCM bytes .