idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
126,500
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 .
126,501
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
126,502
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
126,503
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
126,504
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 .
126,505
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 .
126,506
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 .
126,507
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 .
126,508
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...
126,509
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...
126,510
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 .
126,511
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 .
126,512
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 .
126,513
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
126,514
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 .
126,515
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
126,516
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
126,517
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
126,518
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 = ;
126,519
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
126,520
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 .
126,521
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
126,522
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 .
126,523
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
126,524
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
126,525
public void setReal ( T value , int m , int n ) { setReal ( value , getIndex ( m , n ) ) ; }
Sets single real array element .
126,526
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
126,527
public void setImaginary ( T value , int m , int n ) { setImaginary ( value , getIndex ( m , n ) ) ; }
Sets single imaginary array element .
126,528
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 .
126,529
public int [ ] getIR ( ) { int [ ] ir = new int [ nzmax ] ; int i = 0 ; for ( IndexMN index : indexSet ) { ir [ i ++ ] = index . m ; } return ir ; }
Gets row indices
126,530
public int [ ] getIC ( ) { int [ ] ic = new int [ nzmax ] ; int i = 0 ; for ( IndexMN index : indexSet ) { ic [ i ++ ] = index . n ; } return ic ; }
Gets column indices
126,531
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 .
126,532
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
126,533
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
126,534
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
126,535
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 .
126,536
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 .
126,537
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 .
126,538
private int [ ] readFlags ( ByteBuffer buf ) throws IOException { ISMatTag tag = new ISMatTag ( buf ) ; int [ ] flags = tag . readToIntArray ( ) ; return flags ; }
Reads Matrix flags .
126,539
private int [ ] readDimension ( ByteBuffer buf ) throws IOException { ISMatTag tag = new ISMatTag ( buf ) ; int [ ] dims = tag . readToIntArray ( ) ; return dims ; }
Reads Matrix dimensions .
126,540
private String readName ( ByteBuffer buf ) throws IOException { ISMatTag tag = new ISMatTag ( buf ) ; return tag . readToString ( ) ; }
Reads Matrix name .
126,541
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 .
126,542
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 .
126,543
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
126,544
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 .
126,545
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
126,546
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
126,547
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
126,548
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
126,549
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 .
126,550
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
126,551
public void switchWindow ( ) { List < String > windowHandles = new ArrayList < > ( getWindowHandles ( ) ) ; getDriver ( ) . switchTo ( ) . window ( windowHandles . get ( windowHandles . size ( ) - 1 ) ) ; }
switches to the last opened window
126,552
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 .
126,553
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 .
126,554
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 .
126,555
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 .
126,556
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 .
126,557
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 .
126,558
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 .
126,559
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 .
126,560
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
126,561
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 .
126,562
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 .
126,563
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 .
126,564
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 .
126,565
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 .
126,566
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 .
126,567
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 .
126,568
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 .
126,569
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 .
126,570
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 .
126,571
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 .
126,572
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 .
126,573
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 .
126,574
public void unregisterExceptionMonitor ( ExceptionMonitor monitor ) { synchronized ( this ) { if ( monitor == null || ! monitor . equals ( m_exceptionMonitor ) ) { return ; } m_exceptionMonitor = null ; } }
Unregister a ExceptionMonitor with the source .
126,575
public List < ExceptionMonitor > getExceptionMonitors ( ) { synchronized ( this ) { ArrayList < ExceptionMonitor > result = new ArrayList < ExceptionMonitor > ( ) ; result . add ( m_exceptionMonitor ) ; return result ; } }
Returns all ExceptionMonitors that are registered .
126,576
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 .
126,577
public static String resolveProperty ( Properties props , String value ) { return PropertyResolver . resolve ( props , value ) ; }
Resolve symbols in a supplied value against supplied known properties .
126,578
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 .
126,579
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 .
126,580
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 .
126,581
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 .
126,582
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 .
126,583
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 .
126,584
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 .
126,585
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 .
126,586
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 .
126,587
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 .
126,588
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 .
126,589
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 .
126,590
private static Process startProcess ( String [ ] exec ) throws IOException { Process process = Runtime . getRuntime ( ) . exec ( exec ) ; return process ; }
Starts a OS level process .
126,591
private static BufferedReader createReader ( Process process ) { InputStream inputStream = process . getInputStream ( ) ; InputStreamReader in = new InputStreamReader ( inputStream ) ; BufferedReader reader = new BufferedReader ( in ) ; return reader ; }
Creates a Reader instance for the process output .
126,592
private static int readEnvironment ( String cmdExec , Properties properties ) { BufferedReader reader = null ; Process process = null ; int exitValue = 99 ; try { String [ ] args = new String [ ] { cmdExec } ; process = startProcess ( args ) ; reader = createReader ( process ) ; processLinesOfEnvironmentVariables ( rea...
Reads the environment variables and stores them in a Properties object .
126,593
public PropertiesWriter append ( final String key , final String value ) { NullArgumentException . validateNotEmpty ( key , "Key" ) ; String valueToAdd = value ; if ( value == null ) { valueToAdd = "" ; } Integer position = m_positions . get ( key ) ; List < String > values = m_values . get ( key ) ; if ( values == nul...
Appends a property to be written .
126,594
public PropertiesWriter append ( final String comment ) { String commentToAdd = "#" + comment ; if ( comment == null ) { commentToAdd = "#" ; } m_content . add ( commentToAdd ) ; return this ; }
Appends a comment to be written .
126,595
public void write ( ) throws IOException { BufferedWriter writer = new BufferedWriter ( new OutputStreamWriter ( m_outputStream ) ) ; for ( String line : m_content ) { writer . write ( line ) ; writer . newLine ( ) ; } writer . flush ( ) ; writer . close ( ) ; }
Write properties to output stream .
126,596
public void exception ( ExceptionSource source , Throwable exception ) { synchronized ( m_monitors ) { for ( ExceptionMonitor monitor : m_monitors ) { monitor . exception ( source , exception ) ; } } }
This method is called when an Exception or Throwable occurs .
126,597
private boolean matchesIncludes ( final String fileName ) { if ( m_includes . length == 0 ) { return true ; } for ( Pattern include : m_includes ) { if ( include . matcher ( fileName ) . matches ( ) ) { return true ; } } return false ; }
Checks if the file name matches inclusion patterns .
126,598
private boolean matchesExcludes ( final String fileName ) { for ( Pattern include : m_excludes ) { if ( include . matcher ( fileName ) . matches ( ) ) { return true ; } } return false ; }
Checks if the file name matches exclusion patterns .
126,599
private List < String > listFiles ( final File dir , final String parentName ) { final List < String > fileNames = new ArrayList < String > ( ) ; File [ ] files = null ; if ( dir . canRead ( ) ) { files = dir . listFiles ( ) ; } if ( files != null ) { for ( File file : files ) { if ( file . isDirectory ( ) ) { fileName...
Lists recursively files form a directory