idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
13,200 | public void reset ( ) { numberOfErrors = 0 ; numberOfFatalErrors = 0 ; numberOfWarnings = 0 ; errors . clear ( ) ; fatalErrors . clear ( ) ; warnings . clear ( ) ; } | Reset accumulated errors counters . |
13,201 | private synchronized void initialize ( String fileName , String path ) throws ParameterException { if ( ! path . equals ( this . path ) ) { checkPath ( path ) ; this . path = path ; } if ( ! fileName . equals ( this . fileName ) ) { checkFileName ( fileName ) ; this . fileName = fileName ; } } | Initializes the file writer with the given file and path names . |
13,202 | private synchronized void checkPath ( String logPath ) throws ParameterException { Validate . notNull ( path ) ; File cPath = new File ( logPath ) ; if ( ! cPath . exists ( ) ) cPath . mkdirs ( ) ; if ( ! cPath . isDirectory ( ) ) throw new ParameterException ( ErrorCode . INCOMPATIBILITY , logPath + " is not a valid path!" ) ; } | Sets the path for the file writer where output files are put in . |
13,203 | private synchronized void checkFileName ( String fileName ) throws ParameterException { Validate . notNull ( fileName ) ; File cFile = new File ( fileName ) ; if ( cFile . getName ( ) . length ( ) == 0 ) throw new ParameterException ( ErrorCode . INCOMPATIBILITY , fileName + " is not a valid file-name!" ) ; } | Sets the name for the output file . |
13,204 | private synchronized void prepareFile ( ) throws IOException { outputFile = new File ( getFileName ( ) ) ; if ( outputFile . exists ( ) ) outputFile . delete ( ) ; if ( outputFile . isDirectory ( ) ) throw new IOException ( "I/O Error on creating file: File is a directory!" ) ; outputFile . createNewFile ( ) ; if ( ! outputFile . canWrite ( ) ) throw new IOException ( "I/O Error on creating file: Unable to write into file!" ) ; } | Creates the output file on the file system . |
13,205 | public ArrayList < Field > getAllFields ( ) { final ArrayList < Field > r = new ArrayList < Field > ( ) ; final List < String > ids = new ArrayList < String > ( ) ; if ( getFields ( ) != null ) { for ( Field field : getFields ( ) ) { r . add ( field ) ; ids . add ( field . getId ( ) ) ; } } if ( getExtendzEntity ( ) != null ) { for ( Field field : getExtendzEntity ( ) . getAllFields ( ) ) { if ( ! ids . contains ( field . getId ( ) ) ) { r . add ( field ) ; } } } return r ; } | Return the list of fields including inherited ones . |
13,206 | public List < ? > getList ( PMContext ctx , EntityFilter filter ) throws PMException { return getList ( ctx , filter , null , null , null ) ; } | Returns a list of this entity instances with null from and count and with the given filter |
13,207 | public List < ? > getList ( PMContext ctx ) throws PMException { final EntityFilter filter = ( ctx != null && this . equals ( ctx . getEntity ( ) ) ) ? ctx . getEntityContainer ( ) . getFilter ( ) : null ; return getList ( ctx , filter , null , null , null ) ; } | Return a list of this entity instances with null from and count and the filter took from the entity container of the context |
13,208 | public List < ? > getList ( PMContext ctx , EntityFilter filter , ListSort sort , Integer from , Integer count ) throws PMException { return getDataAccess ( ) . list ( ctx , filter , null , sort , from , count ) ; } | Returns a list taken from data access with the given parameters . |
13,209 | private Map < String , Field > getFieldsbyid ( ) { if ( fieldsbyid == null ) { fieldsbyid = new HashMap < String , Field > ( ) ; for ( Field f : getAllFields ( ) ) { fieldsbyid . put ( f . getId ( ) , f ) ; } } return fieldsbyid ; } | Getter for fieldsbyid . If its null this methods fill it |
13,210 | public ArrayList < Field > getOrderedFields ( ) { try { if ( isOrdered ( ) ) { ArrayList < Field > r = new ArrayList < Field > ( getAllFields ( ) ) ; Collections . sort ( r , new FieldComparator ( getOrder ( ) ) ) ; return r ; } } catch ( Exception e ) { getPm ( ) . error ( e ) ; } return getAllFields ( ) ; } | This method sorts the fields and returns them |
13,211 | public void fillFields ( Entity entity ) { for ( Field field : entity . getAllFields ( ) ) { if ( ! containsField ( field . getId ( ) ) ) { getFields ( ) . add ( field ) ; } } } | This method fills the extendsFields variable with the parent Fields . If some field is redefined parent field is ignored |
13,212 | public Entity getWeak ( Field field ) { for ( Entity entity : getWeaks ( ) ) { if ( entity . getOwner ( ) . getEntityProperty ( ) . equals ( field . getProperty ( ) ) ) { return entity ; } } return null ; } | Looks for the weak entity corresponding to the given field in this string entity |
13,213 | public Highlight getHighlight ( Field field , Object instance ) { if ( getHighlights ( ) == null ) { return null ; } return getHighlights ( ) . getHighlight ( this , field , instance ) ; } | Looks for an apropiate highlight for this field + instance |
13,214 | public List < Highlight > getHighlights ( Field field , Object instance ) { if ( getHighlights ( ) == null ) { return null ; } return getHighlights ( ) . getHighlights ( this , field , instance ) ; } | Looks for all the apropiate highlight for this field + instance |
13,215 | public String getTitle ( ) { final String key = String . format ( "pm.entity.%s" , getId ( ) ) ; final String message = pm . message ( key ) ; if ( key . equals ( message ) ) { if ( getExtendzEntity ( ) != null ) { return getExtendzEntity ( ) . getTitle ( ) ; } } return message ; } | Returns the internationalized entity title |
13,216 | public void add ( Operation operation ) { synchronized ( operations ) { operations . addLast ( operation ) ; if ( waiting ) sp . unblock ( ) ; } if ( autoStart && operations . size ( ) == 1 && getStatus ( ) == Task . STATUS_NOT_STARTED ) start ( ) ; } | Append an operation . |
13,217 | public void parseLocation ( String location , String value ) { setLocationValue ( value ) ; setLocation ( PresentationManager . getPm ( ) . getLocation ( location ) ) ; } | Recover from the service the location object and set it and the value to this item . |
13,218 | public List < String > dumpAllOpenedResources ( ) { List < String > dumps = new ArrayList < String > ( ) ; for ( LeakDetectorConnection connection : openConnections ) { dumps . add ( connection . dumpCreationContext ( "" ) ) ; for ( LeakDetectorSession session : connection . getOpenSessions ( ) ) { dumps . add ( session . dumpCreationContext ( " " ) ) ; for ( LeakDetectorMessageProducer producer : session . getOpenMessageProducers ( ) ) { dumps . add ( producer . dumpCreationContext ( " " ) ) ; } for ( LeakDetectorMessageConsumer consumer : session . getOpenMessageConsumers ( ) ) { dumps . add ( consumer . dumpCreationContext ( " " ) ) ; } } } return dumps ; } | List all the currently opened connection session message producer message consumer |
13,219 | public AbstractClassLoader add ( File location , Collection < String > exportedJars ) { AbstractClassLoader cl ; if ( location . isDirectory ( ) ) cl = new DirectoryClassLoader ( this , location ) ; else cl = new ZipClassLoader ( this , new FileIOProvider ( location ) ) ; if ( exportedJars != null ) for ( String jar : exportedJars ) cl . addSubLoader ( new ZipClassLoader ( this , new InnerJARProvider ( cl , jar ) ) ) ; synchronized ( libs ) { libs . add ( cl ) ; } return cl ; } | Add a library . |
13,220 | public URL getResourceURL ( String name ) { if ( name . length ( ) == 0 ) return null ; if ( name . charAt ( 0 ) == '/' ) name = name . substring ( 1 ) ; for ( int i = 0 ; i < libs . size ( ) ; i ++ ) { AbstractClassLoader cl = libs . get ( i ) ; URL url = cl . loadResourceURL ( name ) ; if ( url != null ) return url ; } return AppClassLoader . class . getClassLoader ( ) . getResource ( name ) ; } | Search a resource . |
13,221 | @ SuppressWarnings ( "resource" ) public InputStream getResourceAsStreamFrom ( String name , AbstractClassLoader first ) { if ( name . length ( ) == 0 ) return null ; if ( name . charAt ( 0 ) == '/' ) name = name . substring ( 1 ) ; IO . Readable io = null ; if ( first != null ) try { io = first . open ( name , Task . PRIORITY_RATHER_IMPORTANT ) ; } catch ( IOException e ) { } if ( io == null ) { for ( int i = 0 ; i < libs . size ( ) ; i ++ ) { AbstractClassLoader cl = libs . get ( i ) ; if ( cl == first ) continue ; try { io = cl . open ( name , Task . PRIORITY_RATHER_IMPORTANT ) ; } catch ( IOException e ) { } if ( io != null ) break ; } } if ( io != null ) return IOAsInputStream . get ( io , true ) ; return AppClassLoader . class . getClassLoader ( ) . getResourceAsStream ( name ) ; } | Load a resource looking first into the given library . |
13,222 | public URL getResourceFrom ( String name , AbstractClassLoader first ) { if ( name . length ( ) == 0 ) return null ; if ( name . charAt ( 0 ) == '/' ) name = name . substring ( 1 ) ; URL url = null ; if ( first != null ) url = first . getResourceURL ( name ) ; if ( url == null ) { for ( int i = 0 ; i < libs . size ( ) ; i ++ ) { AbstractClassLoader cl = libs . get ( i ) ; if ( cl == first ) continue ; url = cl . getResourceURL ( name ) ; if ( url != null ) break ; } } if ( url == null ) url = AppClassLoader . class . getClassLoader ( ) . getResource ( name ) ; return url ; } | Search a resource looking first into the given library . |
13,223 | public Enumeration < URL > getResources ( String name ) throws IOException { if ( name . length ( ) == 0 ) return null ; if ( name . charAt ( 0 ) == '/' ) name = name . substring ( 1 ) ; CompoundCollection < URL > list = new CompoundCollection < > ( ) ; for ( int i = 0 ; i < libs . size ( ) ; i ++ ) { AbstractClassLoader cl = libs . get ( i ) ; Iterable < URL > urls = cl . getResourcesURL ( name ) ; if ( urls != null ) list . add ( urls ) ; } list . add ( AppClassLoader . class . getClassLoader ( ) . getResources ( name ) ) ; return list . enumeration ( ) ; } | Search for resources . |
13,224 | public void scanLibraries ( String rootPackage , boolean includeSubPackages , Filter < String > packageFilter , Filter < String > classFilter , Listener < Class < ? > > classScanner ) { for ( AbstractClassLoader cl : libs ) cl . scan ( rootPackage , includeSubPackages , packageFilter , classFilter , classScanner ) ; } | Scan libraries to find classes . |
13,225 | public static Decoder get ( Charset charset ) throws Exception { Class < ? extends Decoder > cl = decoders . get ( charset . name ( ) ) ; if ( cl == null ) { CharsetDecoder decoder = charset . newDecoder ( ) ; decoder . onMalformedInput ( CodingErrorAction . REPLACE ) ; decoder . onUnmappableCharacter ( CodingErrorAction . REPLACE ) ; return new DefaultDecoder ( decoder ) ; } return cl . newInstance ( ) ; } | Get a decoder for the given charset . |
13,226 | public static void register ( Charset charset , Class < ? extends Decoder > decoder ) { decoders . put ( charset . name ( ) , decoder ) ; } | Register a decoder implementation . |
13,227 | public void setInput ( IO . Readable . Buffered io ) { this . io = io ; this . nextBuffer = io . readNextBufferAsync ( ) ; } | Set readable IO to decode . |
13,228 | public void transferTo ( Decoder newDecoder ) { newDecoder . io = io ; newDecoder . nextBuffer = nextBuffer ; newDecoder . currentBuffer = currentBuffer ; } | Change charset by transfering the current state of this decoder to the new one . |
13,229 | public int decode ( char [ ] chars , int pos , int len , MutableBoolean interrupt , int min ) throws IOException , CancelException { if ( min > len ) min = len ; int nb = 0 ; do { if ( currentBuffer == null ) { if ( nextBuffer . isUnblocked ( ) ) currentBuffer = nextBuffer . blockResult ( 0 ) ; else return nb > 0 ? nb : - 2 ; if ( currentBuffer != null ) nextBuffer = io . readNextBufferAsync ( ) ; } int decoded = decode ( currentBuffer , chars , pos + nb , len - nb , interrupt , min - nb ) ; if ( decoded < 0 || ( decoded == 0 && currentBuffer == null ) ) return nb > 0 ? nb : - 1 ; nb += decoded ; if ( currentBuffer != null && ! currentBuffer . hasRemaining ( ) ) currentBuffer = null ; if ( nb == len ) return nb ; if ( nb >= min && interrupt . get ( ) ) return nb ; } while ( true ) ; } | Decode characters from the IO . |
13,230 | public int decode ( ByteBuffer b , char [ ] chars , int pos , int len ) { if ( io != null ) throw new IllegalStateException ( ) ; return decode ( b , chars , pos , len , null , 1 ) ; } | Decode characters without IO . |
13,231 | public String getString ( String key ) { if ( key == null ) { String msg = "key may not have a null value" ; throw new IllegalArgumentException ( msg ) ; } String str = null ; try { if ( bundle != null ) { str = bundle . getString ( key ) ; } } catch ( MissingResourceException mre ) { str = null ; } return str ; } | Get a string from the underlying resource bundle or return null if the String is not found . |
13,232 | public static StringManager getManager ( String packageName , Enumeration < Locale > requestedLocales ) { while ( requestedLocales . hasMoreElements ( ) ) { Locale locale = requestedLocales . nextElement ( ) ; StringManager result = getManager ( packageName , locale ) ; if ( result . getLocale ( ) . equals ( locale ) ) { return result ; } } return getManager ( packageName ) ; } | Retrieve the StringManager for a list of Locales . The first StringManager found will be returned . |
13,233 | public void write ( ByteBuffer buffer ) throws IOException { synchronized ( buffers ) { if ( writing == null ) { writing = io . writeAsync ( buffer ) ; writing . listenInline ( listener ) ; return ; } if ( writing . hasError ( ) ) throw writing . getError ( ) ; buffers . add ( buffer ) ; } } | Write the given buffer . |
13,234 | public SynchronizationPoint < IOException > onDone ( ) { synchronized ( buffers ) { if ( writing == null ) return new SynchronizationPoint < > ( true ) ; if ( writing . hasError ( ) ) return new SynchronizationPoint < IOException > ( writing . getError ( ) ) ; if ( writing . isCancelled ( ) ) return new SynchronizationPoint < IOException > ( writing . getCancelEvent ( ) ) ; if ( waitDone == null ) waitDone = new SynchronizationPoint < > ( ) ; } return waitDone ; } | Must be called once all write operations have been done and only one time . |
13,235 | private void sort ( ) { RangeHashSorter sortMachine ; sortMachine = new RangeHashSorter ( maxRangeValues , filenames ) ; sortMachine . quickSort ( ) ; generateBucketIds ( ) ; } | Sorts the max range values corresponding to the file names and the bucket sizes . |
13,236 | private void generateBucketIds ( ) { this . buckets = 0 ; bucketIds = new int [ filenames . length ] ; HashMap < String , Integer > tmpSeenFilenames = new HashMap < String , Integer > ( ) ; for ( int i = 0 ; i < filenames . length ; i ++ ) { if ( ! tmpSeenFilenames . containsKey ( filenames [ i ] ) ) { tmpSeenFilenames . put ( filenames [ i ] , this . buckets ++ ) ; } bucketIds [ i ] = tmpSeenFilenames . get ( filenames [ i ] ) ; } this . buckets = bucketIds . length ; } | generates the correct index structure namely the bucketIds to the already initialized filenames and maxRangeValues |
13,237 | private String makeOneLine ( byte [ ] value , String filename ) { StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < value . length ; i ++ ) { sb . append ( value [ i ] ) . append ( '\t' ) ; } sb . append ( filename ) ; return sb . toString ( ) ; } | Concatenates the given range value and the file name to one string . It is used to write the hash function file . |
13,238 | protected String generateFileName ( int subBucket , String oldName ) { int dotPos = oldName . lastIndexOf ( "." ) ; int slashPos = Math . max ( oldName . lastIndexOf ( "/" ) , oldName . lastIndexOf ( "\\" ) ) ; String prefix ; String suffix ; if ( dotPos > slashPos ) { prefix = oldName . substring ( 0 , dotPos ) ; suffix = oldName . substring ( dotPos ) ; } else { prefix = oldName ; suffix = "" ; } return prefix + "_" + subBucket + suffix ; } | generates a new filename for a subbucket from the given oldName |
13,239 | public static int stringToByteCount ( String code ) { @ SuppressWarnings ( "serial" ) HashMap < String , Integer > codingMap = new HashMap < String , Integer > ( ) { { put ( "b" , 1 ) ; put ( "byte" , 1 ) ; put ( "bool" , 1 ) ; put ( "boolean" , 1 ) ; put ( "c" , 2 ) ; put ( "char" , 2 ) ; put ( "character" , 2 ) ; put ( "i" , 4 ) ; put ( "int" , 4 ) ; put ( "integer" , 4 ) ; put ( "f" , 4 ) ; put ( "float" , 4 ) ; put ( "d" , 8 ) ; put ( "double" , 8 ) ; put ( "l" , 8 ) ; put ( "long" , 8 ) ; put ( "1" , 1 ) ; put ( "2" , 2 ) ; put ( "3" , 3 ) ; put ( "4" , 4 ) ; put ( "5" , 5 ) ; put ( "6" , 6 ) ; put ( "7" , 7 ) ; put ( "8" , 8 ) ; } } ; if ( codingMap . containsKey ( code ) ) { return codingMap . get ( code . toLowerCase ( ) ) ; } else { return 0 ; } } | The header of could contain characters which are not numbers . Some of them can be translated into bytes . E . g . char would be two byte . |
13,240 | public String get ( String name , String def ) { if ( properties != null ) { Object obj = properties . get ( name ) ; if ( obj instanceof String ) return obj . toString ( ) ; } return def ; } | Helper for a property |
13,241 | public Integer getInt ( String name ) { try { return Integer . parseInt ( get ( name , "" ) . trim ( ) ) ; } catch ( Exception e ) { return null ; } } | Helper for an int property |
13,242 | float [ ] unquantize ( ) { if ( maptype == 1 || maptype == 2 ) { int quantvals ; float mindel = float32_unpack ( q_min ) ; float delta = float32_unpack ( q_delta ) ; float [ ] r = new float [ entries * dim ] ; switch ( maptype ) { case 1 : quantvals = maptype1_quantvals ( ) ; for ( int j = 0 ; j < entries ; j ++ ) { float last = 0.f ; int indexdiv = 1 ; for ( int k = 0 ; k < dim ; k ++ ) { int index = ( j / indexdiv ) % quantvals ; float val = quantlist [ index ] ; val = Math . abs ( val ) * delta + mindel + last ; if ( q_sequencep != 0 ) last = val ; r [ j * dim + k ] = val ; indexdiv *= quantvals ; } } break ; case 2 : for ( int j = 0 ; j < entries ; j ++ ) { float last = 0.f ; for ( int k = 0 ; k < dim ; k ++ ) { float val = quantlist [ j * dim + k ] ; val = Math . abs ( val ) * delta + mindel + last ; if ( q_sequencep != 0 ) last = val ; r [ j * dim + k ] = val ; } } } return ( r ) ; } return ( null ) ; } | in in an explicit list . Both value lists must be unpacked |
13,243 | public Object execute ( ) throws Exception { Object ret = executeChange ( ) ; if ( changesManager != null ) changesManager . modelChanged ( ) ; return ret ; } | Template method to factorize the execution of the change model notification . |
13,244 | public static AsyncWork < Properties , Exception > loadPropertiesFile ( IO . Readable input , Charset charset , byte priority , IO . OperationType closeInputAtEnd , Listener < Properties > onDone ) { if ( ! ( input instanceof IO . Readable . Buffered ) ) input = new PreBufferedReadable ( input , 512 , priority , 1024 , priority , 16 ) ; return loadPropertiesFile ( ( IO . Readable . Buffered ) input , charset , priority , closeInputAtEnd , onDone ) ; } | Load properties from a Readable IO . |
13,245 | @ SuppressWarnings ( "resource" ) public static AsyncWork < Properties , Exception > loadPropertiesFile ( IO . Readable . Buffered input , Charset charset , byte priority , IO . OperationType closeInputAtEnd , Listener < Properties > onDone ) { BufferedReadableCharacterStream cs = new BufferedReadableCharacterStream ( input , charset , 512 , 32 ) ; return loadPropertiesFile ( cs , priority , closeInputAtEnd , onDone ) ; } | Load properties from a Buffered IO . |
13,246 | public static AsyncWork < Properties , Exception > loadPropertiesFile ( BufferedReadableCharacterStream stream , byte priority , IO . OperationType closeStreamAtEnd , Listener < Properties > onDone ) { LoadPropertiesFileTask task = new LoadPropertiesFileTask ( stream , priority , closeStreamAtEnd , onDone ) ; return task . start ( ) ; } | Load properties from a character stream . |
13,247 | private String checkRequestMethod ( HttpServletRequest request , JCorsConfig config ) { String requestMethod = request . getHeader ( CorsHeaders . ACCESS_CONTROL_REQUEST_METHOD_HEADER ) ; Constraint . ensureNotEmpty ( requestMethod , "Request Method Header must be supplied" ) ; Constraint . ensureTrue ( config . isMethodAllowed ( requestMethod ) , String . format ( "The specified method is not allowed: '%s'" , requestMethod ) ) ; return requestMethod ; } | Checks if the requested method is allowed |
13,248 | public static void ensureNotEmpty ( String string , String errorMessage ) { ensureNotNull ( string , errorMessage ) ; ensure ( string . trim ( ) . length ( ) > 0 , errorMessage ) ; } | Ensures that a String is not empty |
13,249 | public static ISynchronizationPoint < IOException > rename ( File source , File destination , byte priority ) { TaskManager t1 = Threading . getDrivesTaskManager ( ) . getTaskManager ( source ) ; TaskManager t2 = Threading . getDrivesTaskManager ( ) . getTaskManager ( destination ) ; if ( t1 == t2 ) return new RenameFileTask ( t1 , source , destination , priority ) . start ( ) . getOutput ( ) ; AsyncWork < Long , IOException > copy = IOUtil . copy ( source , destination , priority , source . length ( ) , null , 0 , null ) ; SynchronizationPoint < IOException > result = new SynchronizationPoint < > ( ) ; copy . listenInline ( ( ) -> { new RemoveFileTask ( source , priority ) . start ( ) . getOutput ( ) . listenInline ( result ) ; } , result ) ; return result ; } | Rename a file . It may do a copy then a delete or a simple rename depending if the source and destination are on the same drive or not . |
13,250 | public ISynchronizationPoint < Exception > nextStartElement ( ) { ISynchronizationPoint < Exception > next = next ( ) ; if ( next . isUnblocked ( ) ) { if ( next . hasError ( ) ) return next ; if ( Type . START_ELEMENT . equals ( event . type ) ) return next ; return nextStartElement ( ) ; } SynchronizationPoint < Exception > sp = new SynchronizationPoint < > ( ) ; next . listenInline ( ( ) -> { if ( Type . START_ELEMENT . equals ( event . type ) ) { sp . unblock ( ) ; return ; } new Next ( sp ) { protected void onNext ( ) { if ( Type . START_ELEMENT . equals ( event . type ) ) sp . unblock ( ) ; else nextStartElement ( ) . listenInline ( sp ) ; } } . start ( ) ; } , sp ) ; return sp ; } | Shortcut to move forward to the next START_ELEMENT . |
13,251 | public AsyncWork < Boolean , Exception > nextInnerElement ( ElementContext parent ) { if ( event . context . isEmpty ( ) ) return new AsyncWork < > ( Boolean . FALSE , null ) ; if ( Type . START_ELEMENT . equals ( event . type ) && event . context . getFirst ( ) == parent && event . isClosed ) return new AsyncWork < > ( Boolean . FALSE , null ) ; if ( Type . END_ELEMENT . equals ( event . type ) && event . context . getFirst ( ) == parent ) return new AsyncWork < > ( Boolean . FALSE , null ) ; boolean parentPresent = false ; for ( ElementContext ctx : event . context ) if ( ctx == parent ) { parentPresent = true ; break ; } if ( ! parentPresent ) return new AsyncWork < > ( null , new Exception ( "Invalid context: parent element " + parent . localName + " is not in the current context" ) ) ; ISynchronizationPoint < Exception > next = next ( ) ; do { if ( next . isUnblocked ( ) ) { if ( next . hasError ( ) ) return new AsyncWork < > ( null , next . getError ( ) ) ; if ( Type . END_ELEMENT . equals ( event . type ) ) { if ( event . context . getFirst ( ) == parent ) return new AsyncWork < > ( Boolean . FALSE , null ) ; } else if ( Type . START_ELEMENT . equals ( event . type ) ) { if ( event . context . size ( ) > 1 && event . context . get ( 1 ) == parent ) return new AsyncWork < > ( Boolean . TRUE , null ) ; } next = next ( ) ; continue ; } break ; } while ( true ) ; AsyncWork < Boolean , Exception > result = new AsyncWork < > ( ) ; ISynchronizationPoint < Exception > n = next ; next . listenInline ( ( ) -> { if ( n . hasError ( ) ) result . error ( n . getError ( ) ) ; else if ( Type . END_ELEMENT . equals ( event . type ) && event . context . getFirst ( ) == parent ) result . unblockSuccess ( Boolean . FALSE ) ; else if ( Type . START_ELEMENT . equals ( event . type ) && event . context . size ( ) > 1 && event . context . get ( 1 ) == parent ) result . unblockSuccess ( Boolean . TRUE ) ; else new ParsingTask ( ( ) -> { nextInnerElement ( parent ) . listenInline ( result ) ; } ) . start ( ) ; } , result ) ; return result ; } | Go to the next inner element . The result is false if the parent element has been closed . |
13,252 | public AsyncWork < Boolean , Exception > nextInnerElement ( ElementContext parent , String childName ) { AsyncWork < Boolean , Exception > next = nextInnerElement ( parent ) ; do { if ( next . isUnblocked ( ) ) { if ( next . hasError ( ) ) return next ; if ( ! next . getResult ( ) . booleanValue ( ) ) return next ; if ( event . text . equals ( childName ) ) return next ; next = nextInnerElement ( parent ) ; continue ; } break ; } while ( true ) ; AsyncWork < Boolean , Exception > result = new AsyncWork < > ( ) ; AsyncWork < Boolean , Exception > n = next ; next . listenInline ( ( ) -> { if ( n . hasError ( ) ) result . error ( n . getError ( ) ) ; else if ( ! n . getResult ( ) . booleanValue ( ) ) result . unblockSuccess ( Boolean . FALSE ) ; else if ( event . text . equals ( childName ) ) result . unblockSuccess ( Boolean . TRUE ) ; else new ParsingTask ( ( ) -> { nextInnerElement ( parent , childName ) . listenInline ( result ) ; } ) . start ( ) ; } , result ) ; return result ; } | Go to the next inner element having the given name . The result is false if the parent element has been closed . |
13,253 | public ISynchronizationPoint < Exception > closeElement ( ElementContext ctx ) { ISynchronizationPoint < Exception > next = next ( ) ; do { if ( ! next . isUnblocked ( ) ) break ; if ( next . hasError ( ) ) return next ; if ( Type . END_ELEMENT . equals ( event . type ) ) { if ( event . context . getFirst ( ) == ctx ) return next ; } next = next ( ) ; } while ( true ) ; SynchronizationPoint < Exception > result = new SynchronizationPoint < > ( ) ; ISynchronizationPoint < Exception > n = next ; next . listenInline ( ( ) -> { if ( ! check ( n , result ) ) return ; if ( Type . END_ELEMENT . equals ( event . type ) ) { if ( event . context . getFirst ( ) == ctx ) { result . unblock ( ) ; return ; } } new ParsingTask ( ( ) -> { closeElement ( ctx ) . listenInline ( result ) ; } ) . start ( ) ; } , result ) ; return result ; } | Move forward until the closing tag of the given element is found . |
13,254 | public UnprotectedStringBuffer nextLine ( ) throws IOException { if ( input . endReached ( ) ) return null ; UnprotectedStringBuffer line = new UnprotectedStringBuffer ( ) ; boolean prevCR = false ; do { try { char c = input . read ( ) ; if ( c == '\n' ) break ; if ( c == '\r' && ! prevCR ) { prevCR = true ; continue ; } if ( prevCR ) { line . append ( '\r' ) ; prevCR = false ; } if ( c == '\r' ) { prevCR = true ; continue ; } line . append ( c ) ; } catch ( EOFException e ) { break ; } } while ( true ) ; return line ; } | Read a new line return null if the end of the character stream is reached . |
13,255 | public static StandardUserAgentClient newInstance ( Settings settings ) { UDPConnector . Factory udpFactory = Factories . newInstance ( settings , UDP_CONNECTOR_FACTORY_KEY ) ; TCPConnector . Factory tcpFactory = Factories . newInstance ( settings , TCP_CONNECTOR_FACTORY_KEY ) ; return new StandardUserAgentClient ( udpFactory . newUDPConnector ( settings ) , tcpFactory . newTCPConnector ( settings ) , settings ) ; } | Creates and configures a new StandardUserAgentClient instance . |
13,256 | public Message5WH_Builder setWhere ( Object where , int line , int column ) { this . whereLocation = where ; this . whereLine = line ; this . whereColumn = column ; return this ; } | Sets the Where? part of the message . Nothing will be set if the first parameter is null . |
13,257 | public Message5WH_Builder setWhere ( Object where , RecognitionException lineAndColumn ) { if ( where != null && lineAndColumn != null ) { IsAntlrRuntimeObject iaro = IsAntlrRuntimeObject . create ( lineAndColumn ) ; this . setWhere ( where , iaro . getLine ( ) , iaro . getColumn ( ) ) ; } return this ; } | Sets the Where? part of the message . Line and column information are taken from the recognition exception if they are larger than 0 . Nothing will be set if the two parameters are null . |
13,258 | public Message5WH build ( ) { return new Message5WH ( this . who , this . what , this . whereLocation , this . whereLine , this . whereColumn , this . when , this . why , this . how , this . reporter , this . type ) ; } | Builds a message object with the set parameters . |
13,259 | public static boolean cs_utsolve ( Dcs U , double [ ] x ) { int p , j , n , Up [ ] , Ui [ ] ; double Ux [ ] ; if ( ! Dcs_util . CS_CSC ( U ) || x == null ) return ( false ) ; n = U . n ; Up = U . p ; Ui = U . i ; Ux = U . x ; for ( j = 0 ; j < n ; j ++ ) { for ( p = Up [ j ] ; p < Up [ j + 1 ] - 1 ; p ++ ) { x [ j ] -= Ux [ p ] * x [ Ui [ p ] ] ; } x [ j ] /= Ux [ Up [ j + 1 ] - 1 ] ; } return ( true ) ; } | Solves a lower triangular system U x = b where x and b are dense vectors . The diagonal of U must be the last entry of each column . |
13,260 | public static void computeResidual ( int [ ] data , int dataLen , int order , int [ ] residual ) { int idataLen = ( int ) dataLen ; switch ( order ) { case 0 : for ( int i = 0 ; i < idataLen ; i ++ ) { residual [ i ] = data [ i ] ; } break ; case 1 : for ( int i = 0 ; i < idataLen ; i ++ ) { residual [ i ] = data [ i ] - data [ i - 1 ] ; } break ; case 2 : for ( int i = 0 ; i < idataLen ; i ++ ) { residual [ i ] = data [ i ] - ( data [ i - 1 ] << 1 ) + data [ i - 2 ] ; } break ; case 3 : for ( int i = 0 ; i < idataLen ; i ++ ) { residual [ i ] = data [ i ] - ( ( ( data [ i - 1 ] - data [ i - 2 ] ) << 1 ) + ( data [ i - 1 ] - data [ i - 2 ] ) ) - data [ i - 3 ] ; } break ; case 4 : for ( int i = 0 ; i < idataLen ; i ++ ) { residual [ i ] = data [ i ] - ( ( data [ i - 1 ] + data [ i - 3 ] ) << 2 ) + ( ( data [ i - 2 ] << 2 ) + ( data [ i - 2 ] << 1 ) ) + data [ i - 4 ] ; } break ; default : } } | Compute the residual from the compressed signal . |
13,261 | public static void restoreSignal ( int [ ] residual , int dataLen , int order , int [ ] data , int startAt ) { int idataLen = ( int ) dataLen ; switch ( order ) { case 0 : for ( int i = 0 ; i < idataLen ; i ++ ) { data [ i + startAt ] = residual [ i ] ; } break ; case 1 : for ( int i = 0 ; i < idataLen ; i ++ ) { data [ i + startAt ] = residual [ i ] + data [ i + startAt - 1 ] ; } break ; case 2 : for ( int i = 0 ; i < idataLen ; i ++ ) { data [ i + startAt ] = residual [ i ] + ( data [ i + startAt - 1 ] << 1 ) - data [ i + startAt - 2 ] ; } break ; case 3 : for ( int i = 0 ; i < idataLen ; i ++ ) { data [ i + startAt ] = residual [ i ] + ( ( ( data [ i + startAt - 1 ] - data [ i + startAt - 2 ] ) << 1 ) + ( data [ i + startAt - 1 ] - data [ i + startAt - 2 ] ) ) + data [ i + startAt - 3 ] ; } break ; case 4 : for ( int i = 0 ; i < idataLen ; i ++ ) { data [ i + startAt ] = residual [ i ] + ( ( data [ i + startAt - 1 ] + data [ i + startAt - 3 ] ) << 2 ) - ( ( data [ i + startAt - 2 ] << 2 ) + ( data [ i + startAt - 2 ] << 1 ) ) - data [ i + startAt - 4 ] ; } break ; default : } } | Restore the signal from the fixed predictor . |
13,262 | private static Map < String , String > createMyFilterHeader ( String value ) { Map < String , String > map = new HashMap < String , String > ( 1 ) ; map . put ( "MyFilter" , value ) ; return map ; } | return the header that our sample MDBs selectors will look at |
13,263 | public ISynchronizationPoint < IOException > decode ( ByteBuffer buffer ) { SynchronizationPoint < IOException > result = new SynchronizationPoint < > ( ) ; new Task . Cpu < Void , NoException > ( "Decoding base 64" , output . getPriority ( ) ) { public Void run ( ) { if ( nbPrev > 0 ) { while ( nbPrev < 4 && buffer . hasRemaining ( ) ) previous [ nbPrev ++ ] = buffer . get ( ) ; if ( nbPrev < 4 ) { result . unblock ( ) ; return null ; } byte [ ] out = new byte [ 3 ] ; try { Base64 . decode4BytesBase64 ( previous , out ) ; } catch ( IOException e ) { result . error ( e ) ; return null ; } nbPrev = 0 ; if ( ! buffer . hasRemaining ( ) ) { write ( out , result ) ; return null ; } write ( out , null ) ; } byte [ ] out ; try { out = Base64 . decode ( buffer ) ; } catch ( IOException e ) { result . error ( e ) ; return null ; } while ( buffer . hasRemaining ( ) ) previous [ nbPrev ++ ] = buffer . get ( ) ; write ( out , result ) ; return null ; } } . start ( ) ; return result ; } | Start a new Task to decode the given buffer . |
13,264 | public ISynchronizationPoint < IOException > flush ( ) { if ( nbPrev == 0 ) return lastWrite ; while ( nbPrev < 4 ) previous [ nbPrev ++ ] = '=' ; try { write ( Base64 . decode ( previous ) , null ) ; } catch ( IOException e ) { return new SynchronizationPoint < > ( e ) ; } return lastWrite ; } | Decode any pending bytes then return a synchronization point that will be unblocked once the last writing operation is done . |
13,265 | public static boolean checkpw ( String plaintext , String hashed ) { return ( hashed . compareTo ( hashpw ( plaintext , hashed ) ) == 0 ) ; } | Check that a plaintext password matches a previously hashed one |
13,266 | private Block < Void > toBlock ( final Runnable code ) { return new Block < Void > ( ) { public Void run ( ) { code . run ( ) ; return null ; } } ; } | Transforms a Runnable into a Block so that we need only one implementation of the time - traveling code |
13,267 | private void parseFrames ( RandomAccessInputStream raf ) throws FileNotFoundException , IOException , ID3v2FormatException { int offset = head . getHeaderSize ( ) ; int framesLength = head . getTagSize ( ) ; if ( head . getExtendedHeader ( ) ) { framesLength -= ext_head . getSize ( ) ; offset += ext_head . getSize ( ) ; } raf . seek ( offset ) ; int bytesRead = 0 ; boolean done = false ; while ( ( bytesRead < framesLength ) && ! done ) { byte [ ] buf = new byte [ 4 ] ; bytesRead += raf . read ( buf ) ; if ( buf [ 0 ] != 0 ) { String id = new String ( buf ) ; bytesRead += raf . read ( buf ) ; int curLength = Helpers . convertDWordToInt ( buf , 0 ) ; byte [ ] flags = new byte [ 2 ] ; bytesRead += raf . read ( flags ) ; byte [ ] data = new byte [ curLength ] ; bytesRead += raf . read ( data ) ; ID3v2Frame frame = new ID3v2Frame ( id , flags , data ) ; frames . put ( id , frame ) ; } else { done = true ; padding = framesLength - bytesRead - buf . length ; } } } | Read the frames from the file and create ID3v2Frame objects from the data found . |
13,268 | public void writeTag ( RandomAccessFile raf ) throws FileNotFoundException , IOException { int curSize = getSize ( ) ; origPadding = padding ; padding = getUpdatedPadding ( ) ; if ( ( padding > origPadding ) || ( ( padding == origPadding ) && ( curSize == origSize ) ) ) { byte [ ] out = getBytes ( ) ; raf . seek ( 0 ) ; raf . write ( out ) ; } else { int bufSize = ( int ) ( raf . length ( ) + curSize ) ; byte [ ] out = new byte [ bufSize ] ; System . arraycopy ( getBytes ( ) , 0 , out , 0 , curSize ) ; int bufSize2 = ( int ) ( raf . length ( ) - origSize ) ; byte [ ] in = new byte [ bufSize2 ] ; raf . seek ( origSize ) ; if ( raf . read ( in ) != in . length ) { throw new IOException ( "Error reading mp3 file before writing" ) ; } System . arraycopy ( in , 0 , out , curSize , in . length ) ; raf . setLength ( bufSize2 ) ; raf . seek ( 0 ) ; raf . write ( out ) ; } origSize = curSize ; exists = true ; } | Saves all the information in the tag to the file passed to the constructor . If a tag doesn t exist a tag is prepended to the file . If the padding has not changed since the creation of this object and the size is less than the original size + the original padding then the previous tag and part of the previous padding will be overwritten . Otherwise a new tag will be prepended to the file . |
13,269 | public void removeTag ( RandomAccessFile raf ) throws FileNotFoundException , IOException { if ( exists ) { int bufSize = ( int ) ( raf . length ( ) - origSize ) ; byte [ ] buf = new byte [ bufSize ] ; raf . seek ( origSize ) ; if ( raf . read ( buf ) != buf . length ) { throw new IOException ( "Error encountered while removing " + "id3v2 tag." ) ; } raf . setLength ( bufSize ) ; raf . seek ( 0 ) ; raf . write ( buf ) ; exists = false ; } } | Remove an existing id3v2 tag from the file passed to the constructor . |
13,270 | private int getUpdatedPadding ( ) { int curSize = getSize ( ) ; int pad = 0 ; if ( ( origPadding == padding ) && ( curSize > origSize ) && ( padding >= ( curSize - origSize ) ) ) { pad = padding - ( curSize - origSize ) ; } else if ( curSize < origSize ) { pad = ( origSize - curSize ) + padding ; } return pad ; } | Determines the new amount of padding to use . If the user has not changed the amount of padding then existing padding will be overwritten instead of increasing the size of the file . That is only if there is a sufficient amount of padding for the updated tag . |
13,271 | public void setTextFrame ( String id , String data ) { if ( ( id . charAt ( 0 ) == 'T' ) && ! id . equals ( ID3v2Frames . USER_DEFINED_TEXT_INFO ) ) { try { byte [ ] b = new byte [ data . length ( ) + 1 ] ; b [ 0 ] = 0 ; System . arraycopy ( data . getBytes ( ENC_TYPE ) , 0 , b , 1 , data . length ( ) ) ; updateFrameData ( id , b ) ; } catch ( UnsupportedEncodingException e ) { e . printStackTrace ( ) ; } } } | Set the data contained in a text frame . This includes all frames with an id that starts with T but excludes TXXX . If an improper id is passed then nothing will happen . |
13,272 | public void setURLFrame ( String id , String data ) { if ( ( id . charAt ( 0 ) == 'W' ) && ! id . equals ( ID3v2Frames . USER_DEFINED_URL ) ) { updateFrameData ( id , data . getBytes ( ) ) ; } } | Set the data contained in a URL frame . This includes all frames with an id that starts with W but excludes WXXX . If an improper id is passed then nothing will happen . |
13,273 | public void updateFrameData ( String id , byte [ ] data ) { if ( frames . containsKey ( id ) ) { ( ( ID3v2Frame ) frames . get ( id ) ) . setFrameData ( data ) ; } else { ID3v2Frame frame = new ID3v2Frame ( id , data ) ; frames . put ( id , frame ) ; } updateSize ( ) ; } | Updates the data for the frame specified by id . If no frame exists for the id specified a new frame with that id is created . |
13,274 | public String getFrameDataString ( String id ) { try { if ( frames . containsKey ( id ) ) { return ( ( ID3v2Frame ) frames . get ( id ) ) . getDataString ( ) ; } } catch ( ID3v2FormatException ex ) { Log . error ( "ID3v2Tag:" , ex ) ; } return null ; } | Returns the textual information contained in the frame specified by the id . Not every type of frame has textual information . If an id is specified that will not work the empty string is returned . |
13,275 | public byte [ ] getFrameData ( String id ) { if ( frames . containsKey ( id ) ) { return ( ( ID3v2Frame ) frames . get ( id ) ) . getFrameData ( ) ; } return null ; } | Returns the data found in the frame specified by the id . If the frame doesn t exist then a zero length array is returned . |
13,276 | public int getSize ( ) { int retval = head . getTagSize ( ) + head . getHeaderSize ( ) ; if ( head . getFooter ( ) ) { retval += foot . getFooterSize ( ) ; } return retval ; } | Returns the size of this id3v2 tag . This includes the header extended header frames padding and footer . |
13,277 | protected Icon getIcon ( JTable table , int column ) { SortKey sortKey = getSortKey ( table , column ) ; if ( sortKey != null && table . convertColumnIndexToView ( sortKey . getColumn ( ) ) == column ) { SortOrder sortOrder = sortKey . getSortOrder ( ) ; switch ( sortOrder ) { case ASCENDING : return VerticalSortIcon . ASCENDING ; case DESCENDING : return VerticalSortIcon . DESCENDING ; case UNSORTED : return VerticalSortIcon . ASCENDING ; } } return null ; } | Overridden to return a rotated version of the sort icon . |
13,278 | public static OSFamily getOSFamily ( ) { String name = System . getProperty ( "os.name" ) . toLowerCase ( Locale . US ) ; if ( name . contains ( "windows" ) ) { if ( name . contains ( "95" ) || name . contains ( "98" ) || name . contains ( "me" ) || name . contains ( "ce" ) ) return OSFamily . win9x ; return OSFamily . windows ; } if ( name . contains ( "os/2" ) ) return OSFamily . os2 ; if ( name . contains ( "netware" ) ) return OSFamily . netware ; String sep = System . getProperty ( "path.separator" ) ; if ( sep . equals ( ";" ) ) return OSFamily . dos ; if ( name . contains ( "nonstop_kernel" ) ) return OSFamily . tandem ; if ( name . contains ( "openvms" ) ) return OSFamily . openvms ; if ( sep . equals ( ":" ) && ( ! name . contains ( "mac" ) || name . endsWith ( "x" ) ) ) return OSFamily . unix ; if ( name . contains ( "mac" ) ) return OSFamily . mac ; if ( name . contains ( "z/os" ) || name . contains ( "os/390" ) ) return OSFamily . zos ; if ( name . contains ( "os/400" ) ) return OSFamily . os400 ; return null ; } | Returns the type of operating system . |
13,279 | public Node < T > getMin ( ) { if ( size == 0 ) return null ; Node < RedBlackTreeLong < T > > e = ranges . getMin ( ) ; return e . getElement ( ) . getMin ( ) ; } | Return the first node . |
13,280 | public Node < T > getMax ( ) { if ( size == 0 ) return null ; Node < RedBlackTreeLong < T > > e = ranges . getMax ( ) ; return e . getElement ( ) . getMax ( ) ; } | Return the last node . |
13,281 | public static boolean isPowerPacker ( RandomAccessInputStream input ) throws IOException { long pos = input . getFilePointer ( ) ; input . seek ( 0 ) ; byte [ ] ppId = new byte [ 4 ] ; input . read ( ppId , 0 , 4 ) ; input . seek ( pos ) ; return Helpers . retrieveAsString ( ppId , 0 , 4 ) . equals ( "PP20" ) ; } | Will check for a power packer file |
13,282 | private void pp20DoUnpack ( RandomAccessInputStream source , byte [ ] buffer ) throws IOException { BitBuffer bitBuffer = new BitBuffer ( source , ( int ) source . getLength ( ) - 4 ) ; source . seek ( source . getLength ( ) - 1 ) ; int skip = source . read ( ) ; bitBuffer . getBits ( skip ) ; int nBytesLeft = buffer . length ; while ( nBytesLeft > 0 ) { if ( bitBuffer . getBits ( 1 ) == 0 ) { int n = 1 ; while ( n < nBytesLeft ) { int code = ( int ) bitBuffer . getBits ( 2 ) ; n += code ; if ( code != 3 ) break ; } for ( int i = 0 ; i < n ; i ++ ) { buffer [ -- nBytesLeft ] = ( byte ) bitBuffer . getBits ( 8 ) ; } if ( nBytesLeft == 0 ) break ; } int n = bitBuffer . getBits ( 2 ) + 1 ; source . seek ( n + 3 ) ; int nbits = source . read ( ) ; int nofs ; if ( n == 4 ) { nofs = bitBuffer . getBits ( ( bitBuffer . getBits ( 1 ) != 0 ) ? nbits : 7 ) ; while ( n < nBytesLeft ) { int code = bitBuffer . getBits ( 3 ) ; n += code ; if ( code != 7 ) break ; } } else { nofs = bitBuffer . getBits ( nbits ) ; } for ( int i = 0 ; i <= n ; i ++ ) { buffer [ nBytesLeft - 1 ] = ( nBytesLeft + nofs < buffer . length ) ? buffer [ nBytesLeft + nofs ] : 0 ; if ( ( -- nBytesLeft ) == 0 ) break ; } } } | Will unpack powerpacker 2 . 0 packed contend while reading from the packed Stream and unpacking into memory |
13,283 | protected List < T > manycastSendAndReceive ( DatagramSocket datagramSocket , byte [ ] rqstBytes , int timeout ) { List < T > result = new ArrayList < T > ( ) ; udpConnector . manycastSend ( datagramSocket , rqstBytes ) ; DatagramPacket packet = null ; while ( ( packet = udpConnector . receive ( datagramSocket , timeout ) ) != null ) { byte [ ] data = new byte [ packet . getLength ( ) ] ; System . arraycopy ( packet . getData ( ) , packet . getOffset ( ) , data , 0 , data . length ) ; InetSocketAddress address = ( InetSocketAddress ) packet . getSocketAddress ( ) ; T rply = convert ( data , address ) ; if ( rply != null ) { rply . setResponder ( address . getAddress ( ) . getHostAddress ( ) ) ; result . add ( rply ) ; } } return result ; } | Sends the given request bytes then waits at most for the given timeout for replies . For each reply sets the responder address . |
13,284 | public static < T > T getRandomItem ( List < T > list ) { return list . get ( rand . nextInt ( list . size ( ) ) ) ; } | Returns a random element of the given list . |
13,285 | public static < T > void insertHeader ( List < T > list , T headerValue , int headerSize ) { for ( int i = 0 ; i < headerSize ; i ++ ) list . add ( 0 , headerValue ) ; } | Inserts a header |
13,286 | public static < T > List < List < T > > divideAsList ( List < T > coll ) { List < List < T > > result = new ArrayList < > ( ) ; for ( T t : coll ) { List < T > list = new ArrayList < > ( ) ; list . add ( t ) ; result . add ( list ) ; } return result ; } | Returns a list of lists containing exactly one element of the given list each . |
13,287 | public DataSource dataSourceByName ( String dbName ) { return new com . danidemi . jlubricant . embeddable . BasicDataSource ( dbByName ( dbName ) ) ; } | Returns a DataSource on the given database . |
13,288 | DataSource getFastDataSource ( HsqlDatabaseDescriptor hsqlDatabase ) { BasicDataSource bds = new BasicDataSource ( ) ; bds . setDriverClassName ( hsqlDatabase . getDriverClassName ( ) ) ; bds . setUsername ( hsqlDatabase . getUsername ( ) ) ; bds . setPassword ( hsqlDatabase . getPassword ( ) ) ; bds . setUrl ( hsqlDatabase . getUrl ( ) ) ; return bds ; } | Return a quick datasource for the given hsqldatabase . |
13,289 | public void closeFastDataSource ( DataSource ds ) throws SQLException { BasicDataSource bds = ( BasicDataSource ) ds ; bds . close ( ) ; } | Close the fast datasource . |
13,290 | public static int cs_dfs ( int j , Dcs G , int top , int [ ] xi , int xi_offset , int [ ] pstack , int pstack_offset , int [ ] pinv , int pinv_offset ) { int i , p , p2 , jnew , head = 0 , Gp [ ] , Gi [ ] ; boolean done ; if ( ! Dcs_util . CS_CSC ( G ) || xi == null || pstack == null ) return ( - 1 ) ; Gp = G . p ; Gi = G . i ; xi [ xi_offset + 0 ] = j ; while ( head >= 0 ) { j = xi [ xi_offset + head ] ; jnew = pinv != null ? ( pinv [ pinv_offset + j ] ) : j ; if ( ! Dcs_util . CS_MARKED ( Gp , j ) ) { Dcs_util . CS_MARK ( Gp , j ) ; pstack [ pstack_offset + head ] = ( jnew < 0 ) ? 0 : Dcs_util . CS_UNFLIP ( Gp [ jnew ] ) ; } done = true ; p2 = ( jnew < 0 ) ? 0 : Dcs_util . CS_UNFLIP ( Gp [ jnew + 1 ] ) ; for ( p = pstack [ pstack_offset + head ] ; p < p2 ; p ++ ) { i = Gi [ p ] ; if ( Dcs_util . CS_MARKED ( Gp , i ) ) continue ; pstack [ pstack_offset + head ] = p ; xi [ xi_offset + ++ head ] = i ; done = false ; break ; } if ( done ) { head -- ; xi [ xi_offset + -- top ] = j ; } } return ( top ) ; } | Depth - first - search of the graph of a matrix starting at node j . |
13,291 | public synchronized void setVolume ( float gain ) { if ( currentVolume != gain ) { currentVolume = gain ; if ( sourceLine != null && sourceLine . isControlSupported ( FloatControl . Type . MASTER_GAIN ) ) { FloatControl gainControl = ( FloatControl ) sourceLine . getControl ( FloatControl . Type . MASTER_GAIN ) ; float dB = ( float ) ( Helpers . getDBValueFrom ( gain ) ) ; if ( dB > gainControl . getMaximum ( ) ) dB = gainControl . getMaximum ( ) ; else if ( dB < gainControl . getMinimum ( ) ) dB = gainControl . getMinimum ( ) ; gainControl . setValue ( dB ) ; } } } | Set the Gain of the sourceLine |
13,292 | public synchronized void setBalance ( float balance ) { if ( currentBalance != balance ) { currentBalance = balance ; if ( sourceLine != null && sourceLine . isControlSupported ( FloatControl . Type . BALANCE ) ) { FloatControl balanceControl = ( FloatControl ) sourceLine . getControl ( FloatControl . Type . BALANCE ) ; if ( balance <= balanceControl . getMaximum ( ) && balance >= balanceControl . getMinimum ( ) ) balanceControl . setValue ( balance ) ; } } } | Set the Balance of the sourceLine |
13,293 | public static ObfuscatedData fromString ( String obfuscatedString ) { String [ ] parts = obfuscatedString . split ( "\\$" ) ; if ( parts . length != 5 ) { throw new IllegalArgumentException ( "Invalid obfuscated data" ) ; } if ( ! parts [ 1 ] . equals ( SIGNATURE ) ) { throw new IllegalArgumentException ( "Invalid obfuscated data" ) ; } return new ObfuscatedData ( Integer . parseInt ( parts [ 2 ] ) , Base64 . decode ( parts [ 3 ] ) , Base64 . decode ( parts [ 4 ] ) ) ; } | Parse string containing obfuscated data . |
13,294 | public static Set < Entity > sort ( Set < Entity > entities , Order sortingBy ) { EntityComparator comparator = new EntityComparator ( sortingBy ) ; List < Entity > list = new ArrayList < Entity > ( entities ) ; Collections . sort ( list , comparator ) ; Set < Entity > sortedEntities = new LinkedHashSet < > ( list ) ; return sortedEntities ; } | Sort the entities . |
13,295 | protected synchronized void openSourceLine ( ) { try { if ( audioFormat != null && ( sourceLine == null || ( sourceLine != null && ! sourceLine . getFormat ( ) . matches ( audioFormat ) ) ) ) { super . openSourceLine ( ) ; } else if ( sourceLine != null ) { if ( ! sourceLine . isOpen ( ) ) sourceLine . open ( ) ; if ( ! sourceLine . isRunning ( ) ) sourceLine . start ( ) ; } } catch ( Exception ex ) { sourceLine = null ; Log . error ( "Error occured when opening audio device" , ex ) ; } } | This method will only create a new line if a ) an AudioFormat is set and b ) no line is open c ) or the already open Line is not matching the audio format needed After creating or reusing the line status open and running are ensured |
13,296 | protected void validate ( ST st , Set < String > expectedArguments ) { Map < ? , ? > formalArgs = st . impl . formalArguments ; if ( formalArgs == null ) { for ( String s : expectedArguments ) { this . errors . addError ( "ST <{}> does not define argument <{}>" , st . getName ( ) , s ) ; } } else { for ( String s : expectedArguments ) { if ( ! formalArgs . containsKey ( s ) ) { this . errors . addError ( "ST <{}> does not define argument <{}>" , st . getName ( ) , s ) ; } } } } | Validates the ST object and marks all missing arguments . |
13,297 | public static XNElement parseXML ( URL url ) throws IOException , XMLStreamException { try ( InputStream in = new BufferedInputStream ( url . openStream ( ) ) ) { return parseXML ( in ) ; } } | Parse an XML from the supplied URL . |
13,298 | public XNElement add ( String name ) { XNElement e = new XNElement ( name ) ; e . parent = this ; children . add ( e ) ; return e ; } | Add a new XElement with the given local name and no namespace . |
13,299 | public XNElement add ( XNElement child ) { child . parent = this ; children . add ( child ) ; return child ; } | Add the given existing child to this element . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.