idx int64 0 41.2k | question stringlengths 83 4.15k | target stringlengths 5 715 |
|---|---|---|
2,800 | public void setTextSize ( int sizeSp ) { mTextSize = sizeSp * mDisplayMetrics . scaledDensity ; mTextPaint . setTextSize ( mTextSize ) ; invalidate ( ) ; } | Sets the text size . |
2,801 | public void setStrokeWidth ( int widthDp ) { mStrokeWidth = widthDp * mDisplayMetrics . density ; mStrokePaint . setStrokeWidth ( mStrokeWidth ) ; invalidate ( ) ; } | Set the stroke width . |
2,802 | public Lyrics getLyrics ( int trackID ) throws MusixMatchException { Lyrics lyrics = null ; LyricsGetMessage message = null ; Map < String , Object > params = new HashMap < String , Object > ( ) ; params . put ( Constants . API_KEY , apiKey ) ; params . put ( Constants . TRACK_ID , new String ( "" + trackID ) ) ; Strin... | Get Lyrics for the specific trackID . |
2,803 | public Snippet getSnippet ( int trackID ) throws MusixMatchException { Snippet snippet = null ; SnippetGetMessage message = null ; Map < String , Object > params = new HashMap < String , Object > ( ) ; params . put ( Constants . API_KEY , apiKey ) ; params . put ( Constants . TRACK_ID , new String ( "" + trackID ) ) ; ... | Get Snippet for the specified trackID . |
2,804 | public Subtitle getSubtitle ( int trackID ) throws MusixMatchException { Subtitle subtitle = null ; SubtitleGetMessage message = null ; Map < String , Object > params = new HashMap < String , Object > ( ) ; params . put ( Constants . API_KEY , apiKey ) ; params . put ( Constants . TRACK_ID , new String ( "" + trackID )... | Get Subtitle for the specific trackID . |
2,805 | public List < Track > searchTracks ( String q , String q_artist , String q_track , int page , int pageSize , boolean f_has_lyrics ) throws MusixMatchException { List < Track > trackList = null ; TrackSeachMessage message = null ; Map < String , Object > params = new HashMap < String , Object > ( ) ; params . put ( Cons... | Search tracks using the given criteria . |
2,806 | public Track getTrack ( int trackID ) throws MusixMatchException { Track track = new Track ( ) ; Map < String , Object > params = new HashMap < String , Object > ( ) ; params . put ( Constants . API_KEY , apiKey ) ; params . put ( Constants . TRACK_ID , new String ( "" + trackID ) ) ; track = getTrackResponse ( Methods... | Get the track details using the specified trackId . |
2,807 | public Track getMatchingTrack ( String q_track , String q_artist ) throws MusixMatchException { Track track = new Track ( ) ; Map < String , Object > params = new HashMap < String , Object > ( ) ; params . put ( Constants . API_KEY , apiKey ) ; params . put ( Constants . QUERY_TRACK , q_track ) ; params . put ( Constan... | Get the most matching track which was retrieved using the search . |
2,808 | private Track getTrackResponse ( String methodName , Map < String , Object > params ) throws MusixMatchException { Track track = new Track ( ) ; String response = null ; TrackGetMessage message = null ; response = MusixMatchRequest . sendRequest ( Helper . getURLString ( methodName , params ) ) ; Gson gson = new Gson (... | Returns the track response which was returned through the query . |
2,809 | private void handleErrorResponse ( String jsonResponse ) throws MusixMatchException { StatusCode statusCode ; Gson gson = new Gson ( ) ; System . out . println ( jsonResponse ) ; ErrorMessage errMessage = gson . fromJson ( jsonResponse , ErrorMessage . class ) ; int responseCode = errMessage . getMessageContainer ( ) .... | Handle the error response . |
2,810 | public static String getURLString ( String methodName , Map < String , Object > params ) throws MusixMatchException { String paramString = new String ( ) ; paramString += methodName + "?" ; for ( Map . Entry < String , Object > entry : params . entrySet ( ) ) { try { paramString += entry . getKey ( ) + "=" + URLEncoder... | This method is used to get a parameter string from the Map . |
2,811 | protected static List < Token > baseTokenize ( String text ) { String [ ] words = text . split ( " " ) ; List < Token > tokens = new LinkedList < Token > ( ) ; for ( String word : words ) { tokens . add ( new Token ( word ) ) ; } return tokens ; } | Split the text on spaces and convert each word into a Token |
2,812 | public static Span findWithin ( List < Repeater < ? > > tags , Span span , Pointer . PointerType pointer , Options options ) { if ( options . isDebug ( ) ) { System . out . println ( "Chronic.findWithin: " + tags + " in " + span ) ; } if ( tags . isEmpty ( ) ) { return span ; } Repeater < ? > head = tags . get ( 0 ) ; ... | Recursively finds repeaters within other repeaters . Returns a Span representing the innermost time span or nil if no repeater union could be found |
2,813 | public void untag ( Class < ? > tagClass ) { Iterator < Tag < ? > > tagIter = _tags . iterator ( ) ; while ( tagIter . hasNext ( ) ) { Tag < ? > tag = tagIter . next ( ) ; if ( tagClass . isInstance ( tag ) ) { tagIter . remove ( ) ; } } } | Remove all tags of the given class |
2,814 | public Span nextSpan ( Pointer . PointerType pointer ) { if ( getNow ( ) == null ) { throw new IllegalStateException ( "Start point must be set before calling #next" ) ; } return _nextSpan ( pointer ) ; } | returns the next occurance of this repeatable . |
2,815 | private TreeNode < T > balanceOut ( ) { int balance = height ( left ) - height ( right ) ; if ( balance < - 1 ) { if ( height ( right . left ) > height ( right . right ) ) { this . right = this . right . rightRotate ( ) ; return leftRotate ( ) ; } else { return leftRotate ( ) ; } } else if ( balance > 1 ) { if ( height... | Checks if the subtree rooted at the current node is balanced and balances it if necessary . |
2,816 | private TreeNode < T > assimilateOverlappingIntervals ( TreeNode < T > from ) { ArrayList < Interval < T > > tmp = new ArrayList < > ( ) ; if ( midpoint . compareTo ( from . midpoint ) < 0 ) { for ( Interval < T > next : from . increasing ) { if ( next . isRightOf ( midpoint ) ) break ; tmp . add ( next ) ; } } else { ... | Transfers all intervals from a target node to the current node if they intersect the middlepoint of the current node . After this operation it is possible that the target node remains empty . If so it needs to be deleted possible causing the subtree to be rebalanced . |
2,817 | private static < T extends Comparable < ? super T > > TreeNode < T > deleteNode ( TreeNode < T > root ) { if ( root . left == null && root . right == null ) return null ; if ( root . left == null ) { return root . right ; } else { TreeNode < T > node = root . left ; Stack < TreeNode < T > > stack = new Stack < > ( ) ; ... | Deletes a node from the tree . The caller of this method needs to check if the node is actually empty because this method only performs the deletion . |
2,818 | static < T extends Comparable < ? super T > > void rangeQueryLeft ( TreeNode < T > node , Interval < T > query , Set < Interval < T > > result ) { while ( node != null ) { if ( query . contains ( node . midpoint ) ) { result . addAll ( node . increasing ) ; if ( node . right != null ) { for ( Interval < T > next : node... | A helper method for the range search used in the interval intersection query in the tree . This corresponds to the left branch of the range search once we find a node whose midpoint is contained in the query interval . All intervals in the left subtree of that node are guaranteed to intersect with the query if they hav... |
2,819 | static < T extends Comparable < ? super T > > void rangeQueryRight ( TreeNode < T > node , Interval < T > query , Set < Interval < T > > result ) { while ( node != null ) { if ( query . contains ( node . midpoint ) ) { result . addAll ( node . increasing ) ; if ( node . left != null ) { for ( Interval < T > next : node... | A helper method for the range search used in the interval intersection query in the tree . This corresponds to the right branch of the range search once we find a node whose midpoint is contained in the query interval . All intervals in the right subtree of that node are guaranteed to intersect with the query if they h... |
2,820 | public boolean isEmpty ( ) { if ( start == null || end == null ) return false ; int compare = start . compareTo ( end ) ; if ( compare > 0 ) return true ; if ( compare == 0 && ( ! isEndInclusive || ! isStartInclusive ) ) return true ; return false ; } | Checks if the current interval contains no points . |
2,821 | public boolean isPoint ( ) { if ( start == null || end == null ) { return false ; } return start . compareTo ( end ) == 0 && isStartInclusive && isEndInclusive ; } | Determines if the current interval is a single point . |
2,822 | public boolean contains ( T query ) { if ( isEmpty ( ) || query == null ) { return false ; } int startCompare = start == null ? 1 : query . compareTo ( start ) ; int endCompare = end == null ? - 1 : query . compareTo ( end ) ; if ( startCompare > 0 && endCompare < 0 ) { return true ; } return ( startCompare == 0 && isS... | Determines if the current interval contains a query point . |
2,823 | public static String getRequestBody ( HttpServletRequest request ) { if ( request . getMethod ( ) . equals ( "GET" ) || request . getMethod ( ) . equals ( "DELETE" ) ) { return null ; } StringBuilder stringBuilder = new StringBuilder ( ) ; BufferedReader bufferedReader = null ; try { InputStream inputStream = request .... | not easily tested |
2,824 | private void updatePrograms ( final Uri channelUri , final List < Program > newPrograms ) { new Thread ( new Runnable ( ) { public void run ( ) { final int fetchedProgramsCount = newPrograms . size ( ) ; if ( fetchedProgramsCount == 0 ) { return ; } List < Program > oldPrograms = TvContractUtils . getPrograms ( mContex... | Updates the system database TvProvider with the given programs . |
2,825 | public static void parseGenericFileUri ( String uri , FileIdentifier identifier ) { if ( uri . startsWith ( "file://" ) ) identifier . onLocalFile ( ) ; else if ( uri . startsWith ( "http://" ) ) identifier . onHttpFile ( ) ; else if ( uri . startsWith ( "android.resource://" ) ) identifier . onAsset ( ) ; } | In order to determine the correct file parser you can provide the URI and this method will find the appropriate parser to use |
2,826 | public void play ( final String uri ) { Log . d ( TAG , "Start playing " + uri ) ; notifyVideoUnavailable ( REASON_BUFFERING ) ; isWeb = false ; TvInputPlayer . Callback callback = new TvInputPlayer . Callback ( ) { public void onPrepared ( ) { notifyVideoAvailable ( ) ; setOverlayEnabled ( false ) ; } public void onPl... | Tries to load a video file . If one cannot be played it will be interpreted as a website and begin to load it in a web browser |
2,827 | public void play ( String uri ) { tvInputPlayer . setSurface ( mSurface ) ; try { Log . d ( TAG , "Play " + uri + "; " + uri . indexOf ( "asset:///" ) ) ; if ( uri . contains ( "asset:///" ) ) { Log . i ( TAG , "Is a local file" ) ; DataSource dataSource = new AssetDataSource ( getApplicationContext ( ) ) ; ExtractorSa... | Will load and begin to play any RTMP HLS or MPEG2 - DASH stream Should also be able to play local videos and audio files |
2,828 | public static Account getAccount ( Context mContext ) { String ACCOUNT_NAME = mContext . getString ( R . string . app_name ) ; return new Account ( ACCOUNT_NAME , ACCOUNT_NAME ) ; } | public static final String ACCOUNT_NAME = ; |
2,829 | public List < Channel > getCurrentChannels ( Context mContext ) { try { ApplicationInfo app = getApplicationContext ( ) . getPackageManager ( ) . getApplicationInfo ( getApplicationContext ( ) . getPackageName ( ) , PackageManager . GET_META_DATA ) ; Bundle bundle = app . metaData ; final String service = bundle . getS... | Goes into the TV guide and obtains the channels currently registered |
2,830 | public Program getGenericProgram ( Channel channel ) { TvContentRating rating = RATING_PG ; return new Program . Builder ( ) . setTitle ( channel . getName ( ) + " Live" ) . setProgramId ( channel . getServiceId ( ) ) . setDescription ( "Currently streaming" ) . setLongDescription ( channel . getName ( ) + " is current... | If you don t have access to an EPG or don t want to supply programs you can simply add several instances of this generic program object . |
2,831 | public String getLocalVideoUri ( String assetname ) { File f = new File ( assetname ) ; Log . d ( TAG , "Video path " + f . getAbsolutePath ( ) ) ; String uri = Uri . fromFile ( f ) . toString ( ) ; Log . d ( TAG , "Uri " + uri ) ; return uri ; } | Gets a valid Uri of a local video file |
2,832 | private InputStream downloadUrl ( String myurl ) throws IOException { InputStream is = null ; try { URL url = new URL ( myurl ) ; HttpURLConnection conn = ( HttpURLConnection ) url . openConnection ( ) ; conn . setReadTimeout ( 28000 ) ; conn . setConnectTimeout ( 30000 ) ; conn . setRequestMethod ( "GET" ) ; conn . se... | Given a URL establishes an HttpUrlConnection and retrieves the web page content as a InputStream which it returns as a string . |
2,833 | public long getCurrentPosition ( ) { try { return mPlayer . getCurrentPosition ( ) ; } catch ( Exception e ) { Log . e ( TAG , e . getMessage ( ) ) ; return - 1 ; } } | Returns the current position of the media in milliseconds if applicable |
2,834 | public static TvInputProvider getTvInputProvider ( Context mContext , final TvInputProviderCallback callback ) { ApplicationInfo app = null ; try { Log . d ( TAG , mContext . getPackageName ( ) + " >" ) ; app = mContext . getPackageManager ( ) . getApplicationInfo ( mContext . getPackageName ( ) , PackageManager . GET_... | Returns the TvInputProvider that was defined by the project s manifest |
2,835 | public void setReal ( T value , int m , int n ) { setReal ( value , getIndex ( m , n ) ) ; } | Sets single real array element . |
2,836 | public void setReal ( T [ ] vector ) { if ( vector . length != getSize ( ) ) { throw new IllegalArgumentException ( "Matrix dimensions do not match. " + getSize ( ) + " not " + vector . length ) ; } System . arraycopy ( vector , 0 , real , 0 , vector . length ) ; } | Sets real part of matrix |
2,837 | public void setImaginary ( T value , int m , int n ) { setImaginary ( value , getIndex ( m , n ) ) ; } | Sets single imaginary array element . |
2,838 | public void set ( String value , int idx ) { int rowOffset = getM ( ) ; for ( int i = 0 ; i < getN ( ) ; i ++ ) { if ( i < value . length ( ) ) { setChar ( value . charAt ( i ) , idx + ( rowOffset * i ) ) ; } else { setChar ( ' ' , idx + ( rowOffset * i ) ) ; } } } | Set one row specifying the row . |
2,839 | public int [ ] getIR ( ) { int [ ] ir = new int [ nzmax ] ; int i = 0 ; for ( IndexMN index : indexSet ) { ir [ i ++ ] = index . m ; } return ir ; } | Gets row indices |
2,840 | public int [ ] getIC ( ) { int [ ] ic = new int [ nzmax ] ; int i = 0 ; for ( IndexMN index : indexSet ) { ic [ i ++ ] = index . n ; } return ic ; } | Gets column indices |
2,841 | public int [ ] getJC ( ) { int [ ] jc = new int [ getN ( ) + 1 ] ; for ( IndexMN index : indexSet ) { for ( int column = index . n + 1 ; column < jc . length ; column ++ ) { jc [ column ] ++ ; } } return jc ; } | Gets column indices . |
2,842 | public void setField ( String name , MLArray value , int index ) { keys . add ( name ) ; currentIndex = index ; if ( mlStructArray . isEmpty ( ) || mlStructArray . size ( ) <= index ) { mlStructArray . add ( index , new LinkedHashMap < String , MLArray > ( ) ) ; } mlStructArray . get ( index ) . put ( name , value ) ; ... | Sets filed for structure described by index in struct array |
2,843 | public int getMaxFieldLenth ( ) { int maxLen = 0 ; for ( String s : keys ) { maxLen = s . length ( ) > maxLen ? s . length ( ) : maxLen ; } return maxLen + 1 ; } | Gets the maximum length of field descriptor |
2,844 | public byte [ ] getKeySetToByteArray ( ) { ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; DataOutputStream dos = new DataOutputStream ( baos ) ; char [ ] buffer = new char [ getMaxFieldLenth ( ) ] ; try { for ( String s : keys ) { Arrays . fill ( buffer , ( char ) 0 ) ; System . arraycopy ( s . toCharArra... | Dumps field names to byte array . Field names are written as Zero End Strings |
2,845 | public Collection < MLArray > getAllFields ( ) { ArrayList < MLArray > fields = new ArrayList < MLArray > ( ) ; for ( Map < String , MLArray > struct : mlStructArray ) { fields . addAll ( struct . values ( ) ) ; } return fields ; } | Gets all field from sruct array as flat list of fields . |
2,846 | public MLArray getField ( String name , int index ) { if ( mlStructArray . isEmpty ( ) ) { return null ; } return mlStructArray . get ( index ) . get ( name ) ; } | Gets a value of the field described by name from index th struct in struct array or null if the field doesn t exist . |
2,847 | public synchronized Map < String , MLArray > read ( InputStream stream , MatFileFilter filter ) throws IOException { this . filter = filter ; data . clear ( ) ; ByteBuffer buf = null ; final ByteArrayOutputStream2 baos = new ByteArrayOutputStream2 ( ) ; copy ( stream , baos ) ; buf = ByteBuffer . wrap ( baos . getBuf (... | Read a mat file from a stream . Internally this will read the stream fully into memory before parsing it . |
2,848 | private int [ ] readFlags ( ByteBuffer buf ) throws IOException { ISMatTag tag = new ISMatTag ( buf ) ; int [ ] flags = tag . readToIntArray ( ) ; return flags ; } | Reads Matrix flags . |
2,849 | private int [ ] readDimension ( ByteBuffer buf ) throws IOException { ISMatTag tag = new ISMatTag ( buf ) ; int [ ] dims = tag . readToIntArray ( ) ; return dims ; } | Reads Matrix dimensions . |
2,850 | private String readName ( ByteBuffer buf ) throws IOException { ISMatTag tag = new ISMatTag ( buf ) ; return tag . readToString ( ) ; } | Reads Matrix name . |
2,851 | private void readHeader ( ByteBuffer buf ) throws IOException { String description ; int version ; byte [ ] endianIndicator = new byte [ 2 ] ; if ( matType == MatFileType . Regular ) { byte [ ] descriptionBuffer = new byte [ 116 ] ; buf . get ( descriptionBuffer ) ; description = zeroEndByteArrayToString ( descriptionB... | Reads MAT - file header . |
2,852 | public static int sizeOf ( int type ) { switch ( type ) { case MatDataTypes . miINT8 : return miSIZE_INT8 ; case MatDataTypes . miUINT8 : return miSIZE_UINT8 ; case MatDataTypes . miINT16 : return miSIZE_INT16 ; case MatDataTypes . miUINT16 : return miSIZE_UINT16 ; case MatDataTypes . miINT32 : return miSIZE_INT32 ; ca... | Return number of bytes for given type . |
2,853 | public static String typeToString ( int type ) { String s ; switch ( type ) { case MatDataTypes . miUNKNOWN : s = "unknown" ; break ; case MatDataTypes . miINT8 : s = "int8" ; break ; case MatDataTypes . miUINT8 : s = "uint8" ; break ; case MatDataTypes . miINT16 : s = "int16" ; break ; case MatDataTypes . miUINT16 : s... | Get String representation of a data type |
2,854 | public double [ ] [ ] getArray ( ) { double [ ] [ ] result = new double [ getM ( ) ] [ ] ; for ( int m = 0 ; m < getM ( ) ; m ++ ) { result [ m ] = new double [ getN ( ) ] ; for ( int n = 0 ; n < getN ( ) ; n ++ ) { result [ m ] [ n ] = getReal ( m , n ) ; } } return result ; } | Gets two - dimensional real array . |
2,855 | private String [ ] getParameterNames ( Method method ) { if ( notSupportParameterNameDiscoverer ) { return null ; } else { try { ParameterNameDiscoverer parameterNameDiscoverer = new DefaultParameterNameDiscoverer ( ) ; String [ ] strs = parameterNameDiscoverer . getParameterNames ( method ) ; if ( strs == null ) { not... | DefaultParameterNameDiscoverer is supported spring 4 . 0 |
2,856 | private static EvaluationContext buildEvaluationContext ( final String expression ) { return new DDRSpelEvaluationContext ( ) { public Object lookupVariable ( String name ) { Object val = null ; if ( isReservedWords ( name ) ) { val = super . lookupVariable ( name ) ; if ( val == null ) { throw new ExpressionValueNotFo... | load order 1 . reserved words 2 . function 3 . user - define var |
2,857 | public static void main ( String [ ] args ) { ShardRouter shardRouter = buildShardRouter ( ) ; String createDatabaseSql = "CREATE DATABASE IF NOT EXISTS `%s` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;" ; String createTableSql = "CREATE TABLE `%s`(`id` bigint(20) NOT NULL, `name` varchar(32) NOT NULL, PRIMARY KEY... | run this method |
2,858 | public void visit ( Delete delete ) { if ( enableLimitCheck && delete . getLimit ( ) == null ) { throw new IllegalStateException ( "no limit in sql: " + sql ) ; } this . getStack ( ) . push ( new FrameContext ( StatementType . DELETE ) ) ; visit0 ( delete ) ; afterVisitBaseStatement ( ) ; } | mysql delete doesn t support alais |
2,859 | public void type ( final String text ) { autoHover ( ) ; if ( text == null ) return ; waitUntilEnabled ( ) ; runWithRetries ( ( ) -> { elementImpl . locateElement ( ) . clear ( ) ; elementImpl . locateElement ( ) . sendKeys ( text ) ; } ) ; } | Clears out the value of the input field first then types specified text . |
2,860 | private List < WebElement > getListWebElements ( Callable < List < WebElement > > callable ) { int retries = 0 ; long expireTime = Instant . now ( ) . toEpochMilli ( ) + SECONDS . toMillis ( INTERACT_WAIT_S ) ; while ( Instant . now ( ) . toEpochMilli ( ) < expireTime && retries < LOCATE_RETRIES ) { try { List < WebEle... | If nothing found by the timeout return an empty list |
2,861 | public void switchWindow ( ) { List < String > windowHandles = new ArrayList < > ( getWindowHandles ( ) ) ; getDriver ( ) . switchTo ( ) . window ( windowHandles . get ( windowHandles . size ( ) - 1 ) ) ; } | switches to the last opened window |
2,862 | private static void putCachedResource ( String baseName , Resources resources ) { synchronized ( ResourceManager . class ) { WeakReference < Resources > ref = new WeakReference < Resources > ( resources ) ; RESOURCES . put ( baseName , ref ) ; } } | Cache specified resource in weak reference . |
2,863 | private static Resources getCachedResource ( String baseName ) { synchronized ( ResourceManager . class ) { WeakReference weakReference = RESOURCES . get ( baseName ) ; if ( null == weakReference ) { return null ; } else { return ( Resources ) weakReference . get ( ) ; } } } | Retrieve cached resource . |
2,864 | public static Resources getPackageResources ( Class clazz , Locale locale ) { return getBaseResources ( getPackageResourcesBaseName ( clazz ) , locale , clazz . getClassLoader ( ) ) ; } | Retrieve resource for specified Classes package . The basename is determined by name of classes package postfixed with . Resources . |
2,865 | public static Resources getClassResources ( Class clazz , Locale locale ) { return getBaseResources ( getClassResourcesBaseName ( clazz ) , locale , clazz . getClassLoader ( ) ) ; } | Retrieve resource for specified Class . The basename is determined by name of Class postfixed with Resources . |
2,866 | public static String getPackageResourcesBaseName ( Class clazz ) { final Package pkg = clazz . getPackage ( ) ; String baseName ; if ( null == pkg ) { String name = clazz . getName ( ) ; if ( - 1 == name . lastIndexOf ( "." ) ) { baseName = "Resources" ; } else { baseName = name . substring ( 0 , name . lastIndexOf ( "... | Retrieve resource basename for specified Classes package . The basename is determined by name of classes package postfixed with . Resources . |
2,867 | public static < T > List < T > findServiceProviders ( Class < T > klass ) { ServiceLoader < T > loader = ServiceLoader . load ( klass ) ; List < T > providers = new ArrayList < T > ( ) ; Iterator < T > it = loader . iterator ( ) ; while ( it . hasNext ( ) ) { providers . add ( it . next ( ) ) ; } return providers ; } | Finds all providers for a given service . |
2,868 | public static < T > T findAnyServiceProvider ( Class < T > klass ) { ServiceLoader < T > loader = ServiceLoader . load ( klass ) ; Iterator < T > it = loader . iterator ( ) ; return it . hasNext ( ) ? it . next ( ) : null ; } | Finds any provider for a given service . |
2,869 | public static < T > T loadAnyServiceProvider ( Class < T > klass ) { T provider = findAnyServiceProvider ( klass ) ; if ( provider == null ) { throw new NoServiceProviderException ( klass . getName ( ) + ": no service provider found in META-INF/services on classpath" ) ; } return provider ; } | Returns any provider for a given service and throws an exception when no provider is found on the classpath . |
2,870 | public static < T > T loadUniqueServiceProvider ( Class < T > klass ) { List < T > providers = findServiceProviders ( klass ) ; if ( providers . isEmpty ( ) ) { throw new NoServiceProviderException ( klass . getName ( ) + ": no service provider found in META-INF/services on classpath" ) ; } else if ( providers . size (... | Returns the unique service provider for a given service and throws an exception if there is no unique provider |
2,871 | public synchronized Pipe start ( final String name ) { if ( null == m_pump && null != m_in && null != m_out ) { m_pump = startPump ( m_in ) ; m_pump . setName ( name ) ; m_pump . connect ( m_out ) ; } return this ; } | Start piping data from input to output . |
2,872 | public synchronized void stop ( ) { if ( null != m_pump ) { m_pump . connect ( null ) ; m_pump . setName ( m_pump . getName ( ) + " (disconnected)" ) ; m_pump = null ; } } | Stop piping data from input to output . |
2,873 | public static File getFileFromClasspath ( final String filePath ) throws FileNotFoundException { try { URL fileURL = FileUtils . class . getClassLoader ( ) . getResource ( filePath ) ; if ( fileURL == null ) { throw new FileNotFoundException ( "File [" + filePath + "] could not be found in classpath" ) ; } return new F... | Searches the classpath for the file denoted by the file path and returns the corresponding file . |
2,874 | public static boolean delete ( final File file ) { boolean delete = false ; if ( file != null && file . exists ( ) ) { delete = file . delete ( ) ; if ( ! delete && file . isDirectory ( ) ) { File [ ] childs = file . listFiles ( ) ; if ( childs != null && childs . length > 0 ) { for ( File child : childs ) { delete ( c... | Deletes the file or recursively deletes a directory depending on the file passed . |
2,875 | public static Pattern parseFilter ( final String spec ) { StringBuffer sb = new StringBuffer ( ) ; for ( int j = 0 ; j < spec . length ( ) ; j ++ ) { char c = spec . charAt ( j ) ; switch ( c ) { case '.' : sb . append ( "\\." ) ; break ; case '*' : if ( j < spec . length ( ) - 1 && spec . charAt ( j + 1 ) == '*' ) { s... | Parses a usual filter into a regex pattern . |
2,876 | public static Element getRootElement ( InputStream input ) throws ParserConfigurationException , IOException , SAXException { DocumentBuilderFactory factory = DocumentBuilderFactory . newInstance ( ) ; factory . setValidating ( false ) ; factory . setNamespaceAware ( false ) ; try { factory . setFeature ( "http://xml.o... | Return the root element of the supplied input stream . |
2,877 | public static Element getChild ( Element root , String name ) { if ( null == root ) { return null ; } NodeList list = root . getElementsByTagName ( name ) ; int n = list . getLength ( ) ; if ( n < 1 ) { return null ; } return ( Element ) list . item ( 0 ) ; } | Return a named child relative to a supplied element . |
2,878 | public static Element [ ] getChildren ( Element root , String name ) { if ( null == root ) { return new Element [ 0 ] ; } NodeList list = root . getElementsByTagName ( name ) ; int n = list . getLength ( ) ; ArrayList < Element > result = new ArrayList < Element > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { Node item = li... | Return all children matching the supplied element name . |
2,879 | public static String getValue ( Element node ) { if ( null == node ) { return null ; } String value ; if ( node . getChildNodes ( ) . getLength ( ) > 0 ) { value = node . getFirstChild ( ) . getNodeValue ( ) ; } else { value = node . getNodeValue ( ) ; } return normalize ( value ) ; } | Return the value of an element . |
2,880 | private static String normalize ( String value , Properties props ) { return PropertyResolver . resolve ( props , value ) ; } | Parse the value for any property tokens relative to the supplied properties . |
2,881 | public URLConnection get ( Object key ) { synchronized ( this ) { Entry entry = m_hardStore . get ( key ) ; if ( entry == null ) { return null ; } return entry . m_connection ; } } | Returns the URLConnection associated with the given key . |
2,882 | public void put ( Object key , URLConnection conn ) { synchronized ( this ) { Entry entry = new Entry ( conn ) ; m_hardStore . put ( key , entry ) ; if ( m_thread == null ) { m_thread = new Thread ( this , "ConnectionCache-cleaner" ) ; m_thread . setDaemon ( true ) ; m_thread . start ( ) ; } } } | Stores a URLConnection in association with a key . |
2,883 | private boolean mainLoop ( ) throws InterruptedException { long now = System . currentTimeMillis ( ) ; Iterator list = m_hardStore . values ( ) . iterator ( ) ; while ( list . hasNext ( ) ) { Entry entry = ( Entry ) list . next ( ) ; if ( entry . m_collectTime < now ) { m_weakStore . put ( entry . m_connection , DUMMY ... | The main loop of the cache which checks for expirations . |
2,884 | public void unregisterExceptionMonitor ( ExceptionMonitor monitor ) { synchronized ( this ) { if ( monitor == null || ! monitor . equals ( m_exceptionMonitor ) ) { return ; } m_exceptionMonitor = null ; } } | Unregister a ExceptionMonitor with the source . |
2,885 | public List < ExceptionMonitor > getExceptionMonitors ( ) { synchronized ( this ) { ArrayList < ExceptionMonitor > result = new ArrayList < ExceptionMonitor > ( ) ; result . add ( m_exceptionMonitor ) ; return result ; } } | Returns all ExceptionMonitors that are registered . |
2,886 | public static Properties readProps ( URL propsUrl , Properties mappings ) throws IOException { InputStream stream = propsUrl . openStream ( ) ; return readProperties ( stream , mappings , true ) ; } | Read a set of properties from a property file specificed by a url . |
2,887 | public static String resolveProperty ( Properties props , String value ) { return PropertyResolver . resolve ( props , value ) ; } | Resolve symbols in a supplied value against supplied known properties . |
2,888 | public static String getProperty ( Properties props , String key , String def ) { String value = props . getProperty ( key , def ) ; if ( value == null ) { return null ; } if ( "" . equals ( value ) ) { return value ; } value = PropertyResolver . resolve ( props , value ) ; return value ; } | Return the value of a property . |
2,889 | public static String [ ] readListFile ( URL listFile ) throws IOException { ArrayList < String > list = new ArrayList < String > ( ) ; InputStream stream = listFile . openStream ( ) ; try { InputStreamReader isr = new InputStreamReader ( stream , "UTF-8" ) ; BufferedReader reader = new BufferedReader ( isr ) ; String l... | Read a file and return the list of lines in an array of strings . |
2,890 | private static String toFirstCap ( String applicationname ) { char first = applicationname . charAt ( 0 ) ; first = Character . toUpperCase ( first ) ; String name = first + applicationname . substring ( 1 ) ; return name ; } | Capitalizes the first character . |
2,891 | public static String getEnvVariable ( String name ) throws EnvironmentException { if ( isUnix ( ) ) { Properties properties = getUnixShellVariables ( ) ; return properties . getProperty ( name ) ; } else if ( isWindows ( ) ) { Properties properties = getWindowsShellVariables ( ) ; return properties . getProperty ( name... | Gets the value of a shell environment variable . |
2,892 | public static Properties getEnvVariables ( ) throws EnvironmentException { if ( isUnix ( ) ) { return getUnixShellVariables ( ) ; } if ( isWindows ( ) ) { return getWindowsShellVariables ( ) ; } String message = "Environment operations not supported on unrecognized operatings system" ; UnsupportedOperationException cau... | Gets all environment variables within a Properties instance where the key is the environment variable name and value is the value of the property . |
2,893 | public static String getUserShell ( ) throws EnvironmentException { if ( isMacOsX ( ) ) { return getMacUserShell ( ) ; } if ( isWindows ( ) ) { return getWindowsUserShell ( ) ; } if ( isUnix ( ) ) { return getUnixUserShell ( ) ; } String message = "Environment operations not supported on unrecognized operatings system"... | Gets the user s shell executable . |
2,894 | private static String getWindowsUserShell ( ) { if ( null != m_SHELL ) { return m_SHELL ; } if ( - 1 != OSNAME . indexOf ( "98" ) || - 1 != OSNAME . indexOf ( "95" ) || - 1 != OSNAME . indexOf ( "Me" ) ) { m_SHELL = "command.com" ; return m_SHELL ; } m_SHELL = "cmd.exe" ; return m_SHELL ; } | Gets the shell used by the Windows user . |
2,895 | private static String getMacUserShell ( ) throws EnvironmentException { if ( null != m_SHELL ) { return m_SHELL ; } String [ ] args = { "nidump" , "passwd" , "/" } ; return readShellFromPasswdFile ( args ) ; } | Gets the default login shell used by a mac user . |
2,896 | private static String getUnixUserShell ( ) throws EnvironmentException { if ( null != m_SHELL ) { return m_SHELL ; } String [ ] args = { "cat" , "/etc/passwd" } ; return readShellFromPasswdFile ( args ) ; } | Gets the default login shell used by a unix user . |
2,897 | private static void processPasswdFile ( BufferedReader reader ) throws IOException { String entry = reader . readLine ( ) ; while ( null != entry ) { if ( entry . startsWith ( USERNAME ) ) { int index = entry . lastIndexOf ( ':' ) ; if ( index == - 1 ) { String message = "passwd database contains malformed user entry f... | Process a password file . |
2,898 | private static String getUnixEnv ( ) throws EnvironmentException { File env = new File ( "/bin/env" ) ; if ( env . exists ( ) && env . canRead ( ) && env . isFile ( ) ) { return env . getAbsolutePath ( ) ; } env = new File ( "/usr/bin/env" ) ; if ( env . exists ( ) && env . canRead ( ) && env . isFile ( ) ) { return en... | Gets the UNIX env executable path . |
2,899 | private static void processLinesOfEnvironmentVariables ( BufferedReader reader , Properties properties ) throws IOException { String line = reader . readLine ( ) ; while ( null != line ) { int index = line . indexOf ( '=' ) ; if ( - 1 == index && line . length ( ) != 0 ) { String message = "Skipping line - could not fi... | Process the lines of the environment variables returned . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.