idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
6,400 | public static Number leftShift ( Number self , Number operand ) { return NumberMath . leftShift ( self , operand ) ; } | Implementation of the left shift operator for integral types . Non integral Number types throw UnsupportedOperationException . |
6,401 | public static Number rightShift ( Number self , Number operand ) { return NumberMath . rightShift ( self , operand ) ; } | Implementation of the right shift operator for integral types . Non integral Number types throw UnsupportedOperationException . |
6,402 | @ SuppressWarnings ( "unchecked" ) public static List < Byte > getAt ( byte [ ] array , Range range ) { return primitiveArrayGet ( array , range ) ; } | Support the subscript operator with a range for a byte array |
6,403 | @ SuppressWarnings ( "unchecked" ) public static List < Character > getAt ( char [ ] array , Range range ) { return primitiveArrayGet ( array , range ) ; } | Support the subscript operator with a range for a char array |
6,404 | @ SuppressWarnings ( "unchecked" ) public static List < Short > getAt ( short [ ] array , Range range ) { return primitiveArrayGet ( array , range ) ; } | Support the subscript operator with a range for a short array |
6,405 | @ SuppressWarnings ( "unchecked" ) public static List < Integer > getAt ( int [ ] array , Range range ) { return primitiveArrayGet ( array , range ) ; } | Support the subscript operator with a range for an int array |
6,406 | @ SuppressWarnings ( "unchecked" ) public static List < Long > getAt ( long [ ] array , Range range ) { return primitiveArrayGet ( array , range ) ; } | Support the subscript operator with a range for a long array |
6,407 | @ SuppressWarnings ( "unchecked" ) public static List < Float > getAt ( float [ ] array , Range range ) { return primitiveArrayGet ( array , range ) ; } | Support the subscript operator with a range for a float array |
6,408 | @ SuppressWarnings ( "unchecked" ) public static List < Double > getAt ( double [ ] array , Range range ) { return primitiveArrayGet ( array , range ) ; } | Support the subscript operator with a range for a double array |
6,409 | @ SuppressWarnings ( "unchecked" ) public static List < Boolean > getAt ( boolean [ ] array , Range range ) { return primitiveArrayGet ( array , range ) ; } | Support the subscript operator with a range for a boolean array |
6,410 | @ SuppressWarnings ( "unchecked" ) public static List < Long > getAt ( long [ ] array , IntRange range ) { RangeInfo info = subListBorders ( array . length , range ) ; List < Long > answer = primitiveArrayGet ( array , new IntRange ( true , info . from , info . to - 1 ) ) ; return info . reverse ? reverse ( answer ) : answer ; } | Support the subscript operator with an IntRange for a long array |
6,411 | @ SuppressWarnings ( "unchecked" ) public static List < Character > getAt ( char [ ] array , ObjectRange range ) { return primitiveArrayGet ( array , range ) ; } | Support the subscript operator with an ObjectRange for a char array |
6,412 | @ SuppressWarnings ( "unchecked" ) public static List < Short > getAt ( short [ ] array , ObjectRange range ) { return primitiveArrayGet ( array , range ) ; } | Support the subscript operator with an ObjectRange for a short array |
6,413 | @ SuppressWarnings ( "unchecked" ) public static List < Integer > getAt ( int [ ] array , ObjectRange range ) { return primitiveArrayGet ( array , range ) ; } | Support the subscript operator with an ObjectRange for an int array |
6,414 | @ SuppressWarnings ( "unchecked" ) public static List < Long > getAt ( long [ ] array , ObjectRange range ) { return primitiveArrayGet ( array , range ) ; } | Support the subscript operator with an ObjectRange for a long array |
6,415 | @ SuppressWarnings ( "unchecked" ) public static List < Float > getAt ( float [ ] array , ObjectRange range ) { return primitiveArrayGet ( array , range ) ; } | Support the subscript operator with an ObjectRange for a float array |
6,416 | @ SuppressWarnings ( "unchecked" ) public static List < Double > getAt ( double [ ] array , ObjectRange range ) { return primitiveArrayGet ( array , range ) ; } | Support the subscript operator with an ObjectRange for a double array |
6,417 | @ SuppressWarnings ( "unchecked" ) public static List < Byte > getAt ( byte [ ] array , Collection indices ) { return primitiveArrayGet ( array , indices ) ; } | Support the subscript operator with a collection for a byte array |
6,418 | @ SuppressWarnings ( "unchecked" ) public static List < Character > getAt ( char [ ] array , Collection indices ) { return primitiveArrayGet ( array , indices ) ; } | Support the subscript operator with a collection for a char array |
6,419 | @ SuppressWarnings ( "unchecked" ) public static List < Short > getAt ( short [ ] array , Collection indices ) { return primitiveArrayGet ( array , indices ) ; } | Support the subscript operator with a collection for a short array |
6,420 | @ SuppressWarnings ( "unchecked" ) public static List < Integer > getAt ( int [ ] array , Collection indices ) { return primitiveArrayGet ( array , indices ) ; } | Support the subscript operator with a collection for an int array |
6,421 | @ SuppressWarnings ( "unchecked" ) public static List < Long > getAt ( long [ ] array , Collection indices ) { return primitiveArrayGet ( array , indices ) ; } | Support the subscript operator with a collection for a long array |
6,422 | @ SuppressWarnings ( "unchecked" ) public static List < Float > getAt ( float [ ] array , Collection indices ) { return primitiveArrayGet ( array , indices ) ; } | Support the subscript operator with a collection for a float array |
6,423 | @ SuppressWarnings ( "unchecked" ) public static List < Double > getAt ( double [ ] array , Collection indices ) { return primitiveArrayGet ( array , indices ) ; } | Support the subscript operator with a collection for a double array |
6,424 | @ SuppressWarnings ( "unchecked" ) public static List < Boolean > getAt ( boolean [ ] array , Collection indices ) { return primitiveArrayGet ( array , indices ) ; } | Support the subscript operator with a collection for a boolean array |
6,425 | public static boolean getAt ( BitSet self , int index ) { int i = normaliseIndex ( index , self . length ( ) ) ; return self . get ( i ) ; } | Support the subscript operator for a Bitset |
6,426 | public static BitSet getAt ( BitSet self , IntRange range ) { RangeInfo info = subListBorders ( self . length ( ) , range ) ; BitSet result = new BitSet ( ) ; int numberOfBits = info . to - info . from ; int adjuster = 1 ; int offset = info . from ; if ( info . reverse ) { adjuster = - 1 ; offset = info . to - 1 ; } for ( int i = 0 ; i < numberOfBits ; i ++ ) { result . set ( i , self . get ( offset + ( adjuster * i ) ) ) ; } return result ; } | Support retrieving a subset of a BitSet using a Range |
6,427 | public static void putAt ( BitSet self , IntRange range , boolean value ) { RangeInfo info = subListBorders ( self . length ( ) , range ) ; self . set ( info . from , info . to , value ) ; } | Support assigning a range of values with a single assignment statement . |
6,428 | public static < T > Set < T > toSet ( Iterator < T > self ) { Set < T > answer = new HashSet < T > ( ) ; while ( self . hasNext ( ) ) { answer . add ( self . next ( ) ) ; } return answer ; } | Convert an iterator to a Set . The iterator will become exhausted of elements after making this conversion . |
6,429 | public static < T > Set < T > toSet ( Enumeration < T > self ) { Set < T > answer = new HashSet < T > ( ) ; while ( self . hasMoreElements ( ) ) { answer . add ( self . nextElement ( ) ) ; } return answer ; } | Convert an enumeration to a Set . |
6,430 | public static boolean contains ( byte [ ] self , Object value ) { for ( byte next : self ) { if ( DefaultTypeTransformation . compareEqual ( value , next ) ) return true ; } return false ; } | Checks whether the array contains the given value . |
6,431 | public static Number intdiv ( Number left , Number right ) { return NumberMath . intdiv ( left , right ) ; } | Integer Divide two Numbers . |
6,432 | public static Number or ( Number left , Number right ) { return NumberMath . or ( left , right ) ; } | Bitwise OR together two numbers . |
6,433 | public static Number and ( Number left , Number right ) { return NumberMath . and ( left , right ) ; } | Bitwise AND together two Numbers . |
6,434 | public static BitSet and ( BitSet left , BitSet right ) { BitSet result = ( BitSet ) left . clone ( ) ; result . and ( right ) ; return result ; } | Bitwise AND together two BitSets . |
6,435 | public static BitSet xor ( BitSet left , BitSet right ) { BitSet result = ( BitSet ) left . clone ( ) ; result . xor ( right ) ; return result ; } | Bitwise XOR together two BitSets . Called when the ^ operator is used between two bit sets . |
6,436 | public static BitSet bitwiseNegate ( BitSet self ) { BitSet result = ( BitSet ) self . clone ( ) ; result . flip ( 0 , result . size ( ) - 1 ) ; return result ; } | Bitwise NEGATE a BitSet . |
6,437 | public static BitSet or ( BitSet left , BitSet right ) { BitSet result = ( BitSet ) left . clone ( ) ; result . or ( right ) ; return result ; } | Bitwise OR together two BitSets . Called when the | operator is used between two bit sets . |
6,438 | public static Number xor ( Number left , Number right ) { return NumberMath . xor ( left , right ) ; } | Bitwise XOR together two Numbers . Called when the ^ operator is used . |
6,439 | public static Number mod ( Number left , Number right ) { return NumberMath . mod ( left , right ) ; } | Performs a division modulus operation . Called by the % operator . |
6,440 | public static void downto ( Float self , Number to , @ ClosureParams ( FirstParam . class ) Closure closure ) { float to1 = to . floatValue ( ) ; if ( self >= to1 ) { for ( float i = self ; i >= to1 ; i -- ) { closure . call ( i ) ; } } else throw new GroovyRuntimeException ( "The argument (" + to + ") to downto() cannot be greater than the value (" + self + ") it's called on." ) ; } | Iterates from this number down to the given number inclusive decrementing by one each time . |
6,441 | public static Double toDouble ( Number self ) { if ( ( self instanceof Double ) || ( self instanceof Long ) || ( self instanceof Integer ) || ( self instanceof Short ) || ( self instanceof Byte ) ) { return self . doubleValue ( ) ; } return Double . valueOf ( self . toString ( ) ) ; } | Transform a Number into a Double |
6,442 | public static BigDecimal toBigDecimal ( Number self ) { if ( ( self instanceof Long ) || ( self instanceof Integer ) || ( self instanceof Short ) || ( self instanceof Byte ) ) { return BigDecimal . valueOf ( self . longValue ( ) ) ; } return new BigDecimal ( self . toString ( ) ) ; } | Transform a Number into a BigDecimal |
6,443 | public static BigInteger toBigInteger ( Number self ) { if ( self instanceof BigInteger ) { return ( BigInteger ) self ; } else if ( self instanceof BigDecimal ) { return ( ( BigDecimal ) self ) . toBigInteger ( ) ; } else if ( self instanceof Double ) { return new BigDecimal ( ( Double ) self ) . toBigInteger ( ) ; } else if ( self instanceof Float ) { return new BigDecimal ( ( Float ) self ) . toBigInteger ( ) ; } else { return new BigInteger ( Long . toString ( self . longValue ( ) ) ) ; } } | Transform this Number into a BigInteger . |
6,444 | public static Boolean and ( Boolean left , Boolean right ) { return left && Boolean . TRUE . equals ( right ) ; } | Logical conjunction of two boolean operators . |
6,445 | public static Boolean or ( Boolean left , Boolean right ) { return left || Boolean . TRUE . equals ( right ) ; } | Logical disjunction of two boolean operators |
6,446 | public static Boolean implies ( Boolean left , Boolean right ) { return ! left || Boolean . TRUE . equals ( right ) ; } | Logical implication of two boolean operators |
6,447 | public static Boolean xor ( Boolean left , Boolean right ) { return left ^ Boolean . TRUE . equals ( right ) ; } | Exclusive disjunction of two boolean operators |
6,448 | public static TimerTask runAfter ( Timer timer , int delay , final Closure closure ) { TimerTask timerTask = new TimerTask ( ) { public void run ( ) { closure . call ( ) ; } } ; timer . schedule ( timerTask , delay ) ; return timerTask ; } | Allows a simple syntax for using timers . This timer will execute the given closure after the given delay . |
6,449 | public static void eachByte ( Byte [ ] self , @ ClosureParams ( FirstParam . Component . class ) Closure closure ) { each ( self , closure ) ; } | Traverse through each byte of this Byte array . Alias for each . |
6,450 | public static int findIndexOf ( Object self , int startIndex , Closure condition ) { return findIndexOf ( InvokerHelper . asIterator ( self ) , condition ) ; } | Iterates over the elements of an aggregate of items starting from a specified startIndex and returns the index of the first item that matches the condition specified in the closure . |
6,451 | public static < T > int findIndexOf ( Iterator < T > self , @ ClosureParams ( FirstParam . FirstGenericType . class ) Closure condition ) { return findIndexOf ( self , 0 , condition ) ; } | Iterates over the elements of an Iterator and returns the index of the first item that satisfies the condition specified by the closure . |
6,452 | public static < T > int findIndexOf ( Iterator < T > self , int startIndex , @ ClosureParams ( FirstParam . FirstGenericType . class ) Closure condition ) { int result = - 1 ; int i = 0 ; BooleanClosureWrapper bcw = new BooleanClosureWrapper ( condition ) ; while ( self . hasNext ( ) ) { Object value = self . next ( ) ; if ( i ++ < startIndex ) { continue ; } if ( bcw . call ( value ) ) { result = i - 1 ; break ; } } return result ; } | Iterates over the elements of an Iterator starting from a specified startIndex and returns the index of the first item that satisfies the condition specified by the closure . |
6,453 | public static < T > int findIndexOf ( T [ ] self , int startIndex , @ ClosureParams ( FirstParam . Component . class ) Closure condition ) { return findIndexOf ( new ArrayIterator < T > ( self ) , startIndex , condition ) ; } | Iterates over the elements of an Array starting from a specified startIndex and returns the index of the first item that satisfies the condition specified by the closure . |
6,454 | public static int findLastIndexOf ( Object self , int startIndex , Closure condition ) { return findLastIndexOf ( InvokerHelper . asIterator ( self ) , startIndex , condition ) ; } | Iterates over the elements of an aggregate of items starting from a specified startIndex and returns the index of the last item that matches the condition specified in the closure . |
6,455 | public static List < Number > findIndexValues ( Object self , Closure condition ) { return findIndexValues ( self , 0 , condition ) ; } | Iterates over the elements of an aggregate of items and returns the index values of the items that match the condition specified in the closure . |
6,456 | public static List < Number > findIndexValues ( Object self , Number startIndex , Closure condition ) { return findIndexValues ( InvokerHelper . asIterator ( self ) , startIndex , condition ) ; } | Iterates over the elements of an aggregate of items starting from a specified startIndex and returns the index values of the items that match the condition specified in the closure . |
6,457 | public static < T > List < Number > findIndexValues ( Iterator < T > self , Number startIndex , @ ClosureParams ( FirstParam . FirstGenericType . class ) Closure condition ) { List < Number > result = new ArrayList < Number > ( ) ; long count = 0 ; long startCount = startIndex . longValue ( ) ; BooleanClosureWrapper bcw = new BooleanClosureWrapper ( condition ) ; while ( self . hasNext ( ) ) { Object value = self . next ( ) ; if ( count ++ < startCount ) { continue ; } if ( bcw . call ( value ) ) { result . add ( count - 1 ) ; } } return result ; } | Iterates over the elements of an Iterator starting from a specified startIndex and returns the index values of the items that match the condition specified in the closure . |
6,458 | public static < T > List < Number > findIndexValues ( Iterable < T > self , @ ClosureParams ( FirstParam . FirstGenericType . class ) Closure condition ) { return findIndexValues ( self , 0 , condition ) ; } | Iterates over the elements of an Iterable and returns the index values of the items that match the condition specified in the closure . |
6,459 | public static < T > List < Number > findIndexValues ( T [ ] self , @ ClosureParams ( FirstParam . Component . class ) Closure condition ) { return findIndexValues ( self , 0 , condition ) ; } | Iterates over the elements of an Array and returns the index values of the items that match the condition specified in the closure . |
6,460 | @ SuppressWarnings ( "unchecked" ) public static < T > T asType ( Object obj , Class < T > type ) { if ( String . class == type ) { return ( T ) InvokerHelper . toString ( obj ) ; } try { return ( T ) DefaultTypeTransformation . castToType ( obj , type ) ; } catch ( GroovyCastException e ) { MetaClass mc = InvokerHelper . getMetaClass ( obj ) ; if ( mc instanceof ExpandoMetaClass ) { ExpandoMetaClass emc = ( ExpandoMetaClass ) mc ; Object mixedIn = emc . castToMixedType ( obj , type ) ; if ( mixedIn != null ) return ( T ) mixedIn ; } if ( type . isInterface ( ) ) { try { List < Class > interfaces = new ArrayList < Class > ( ) ; interfaces . add ( type ) ; return ( T ) ProxyGenerator . INSTANCE . instantiateDelegate ( interfaces , obj ) ; } catch ( GroovyRuntimeException cause ) { } } throw e ; } } | Converts a given object to a type . This method is used through the as operator and is overloadable as any other operator . |
6,461 | @ SuppressWarnings ( "unchecked" ) public static < T > T newInstance ( Class < T > c ) { return ( T ) InvokerHelper . invokeConstructorOf ( c , null ) ; } | Convenience method to dynamically create a new instance of this class . Calls the default constructor . |
6,462 | public static MetaClass getMetaClass ( Object obj ) { MetaClass mc = InvokerHelper . getMetaClass ( obj ) ; return new HandleMetaClass ( mc , obj ) ; } | Obtains a MetaClass for an object either from the registry or in the case of a GroovyObject from the object itself . |
6,463 | public static void setMetaClass ( Class self , MetaClass metaClass ) { final MetaClassRegistry metaClassRegistry = GroovySystem . getMetaClassRegistry ( ) ; if ( metaClass == null ) metaClassRegistry . removeMetaClass ( self ) ; else { if ( metaClass instanceof HandleMetaClass ) { metaClassRegistry . setMetaClass ( self , ( ( HandleMetaClass ) metaClass ) . getAdaptee ( ) ) ; } else { metaClassRegistry . setMetaClass ( self , metaClass ) ; } if ( self == NullObject . class ) { NullObject . getNullObject ( ) . setMetaClass ( metaClass ) ; } } } | Sets the metaclass for a given class . |
6,464 | public static void setMetaClass ( Object self , MetaClass metaClass ) { if ( metaClass instanceof HandleMetaClass ) metaClass = ( ( HandleMetaClass ) metaClass ) . getAdaptee ( ) ; if ( self instanceof Class ) { GroovySystem . getMetaClassRegistry ( ) . setMetaClass ( ( Class ) self , metaClass ) ; } else { ( ( MetaClassRegistryImpl ) GroovySystem . getMetaClassRegistry ( ) ) . setMetaClass ( self , metaClass ) ; } } | Set the metaclass for an object . |
6,465 | public static void setMetaClass ( GroovyObject self , MetaClass metaClass ) { if ( metaClass instanceof HandleMetaClass ) metaClass = ( ( HandleMetaClass ) metaClass ) . getAdaptee ( ) ; self . setMetaClass ( metaClass ) ; disablePrimitiveOptimization ( self ) ; } | Set the metaclass for a GroovyObject . |
6,466 | public static < T > Iterator < T > iterator ( T [ ] a ) { return DefaultTypeTransformation . asCollection ( a ) . iterator ( ) ; } | Attempts to create an Iterator for the given object by first converting it to a Collection . |
6,467 | public static groovy . lang . groovydoc . Groovydoc getGroovydoc ( AnnotatedElement holder ) { Groovydoc groovydocAnnotation = holder . < Groovydoc > getAnnotation ( Groovydoc . class ) ; return null == groovydocAnnotation ? EMPTY_GROOVYDOC : new groovy . lang . groovydoc . Groovydoc ( groovydocAnnotation . value ( ) , holder ) ; } | Get runtime groovydoc |
6,468 | public static Number multiply ( Number left , Number right ) { return NumberMath . multiply ( left , right ) ; } | those classes implement a method with a better exact match . |
6,469 | public URLConnection getResourceConnection ( String name ) throws ResourceException { name = removeNamePrefix ( name ) . replace ( '\\' , '/' ) ; if ( name . startsWith ( "WEB-INF/groovy/" ) ) { name = name . substring ( 15 ) ; } else if ( name . startsWith ( "/" ) ) { name = name . substring ( 1 ) ; } try { URL url = servletContext . getResource ( '/' + name ) ; if ( url == null ) { url = servletContext . getResource ( "/WEB-INF/groovy/" + name ) ; } if ( url == null ) { throw new ResourceException ( "Resource \"" + name + "\" not found!" ) ; } return url . openConnection ( ) ; } catch ( IOException e ) { throw new ResourceException ( "Problems getting resource named \"" + name + "\"!" , e ) ; } } | Interface method for ResourceContainer . This is used by the GroovyScriptEngine . |
6,470 | protected String getScriptUri ( HttpServletRequest request ) { if ( logGROOVY861 ) { log ( "Logging request class and its class loader:" ) ; log ( " c = request.getClass() :\"" + request . getClass ( ) + "\"" ) ; log ( " l = c.getClassLoader() :\"" + request . getClass ( ) . getClassLoader ( ) + "\"" ) ; log ( " l.getClass() :\"" + request . getClass ( ) . getClassLoader ( ) . getClass ( ) + "\"" ) ; logGROOVY861 = verbose ; } String uri = null ; String info = null ; uri = ( String ) request . getAttribute ( INC_SERVLET_PATH ) ; if ( uri != null ) { info = ( String ) request . getAttribute ( INC_PATH_INFO ) ; if ( info != null ) { uri += info ; } return applyResourceNameMatcher ( uri ) ; } uri = request . getServletPath ( ) ; info = request . getPathInfo ( ) ; if ( info != null ) { uri += info ; } return applyResourceNameMatcher ( uri ) ; } | Returns the include - aware uri of the script or template file . |
6,471 | protected File getScriptUriAsFile ( HttpServletRequest request ) { String uri = getScriptUri ( request ) ; String real = servletContext . getRealPath ( uri ) ; if ( real == null ) { return null ; } return new File ( real ) . getAbsoluteFile ( ) ; } | Parses the http request for the real script or template source file . |
6,472 | public void init ( ServletConfig config ) throws ServletException { super . init ( config ) ; this . servletContext = config . getServletContext ( ) ; String value = config . getInitParameter ( "verbose" ) ; if ( value != null ) { this . verbose = Boolean . valueOf ( value ) ; } value = config . getInitParameter ( "encoding" ) ; if ( value != null ) { this . encoding = value ; } if ( verbose ) { log ( "Parsing init parameters..." ) ; } String regex = config . getInitParameter ( INIT_PARAM_RESOURCE_NAME_REGEX ) ; if ( regex != null ) { String replacement = config . getInitParameter ( "resource.name.replacement" ) ; if ( replacement == null ) { Exception npex = new NullPointerException ( "resource.name.replacement" ) ; String message = "Init-param 'resource.name.replacement' not specified!" ; log ( message , npex ) ; throw new ServletException ( message , npex ) ; } else if ( "EMPTY_STRING" . equals ( replacement ) ) { replacement = "" ; } int flags = 0 ; String flagsStr = config . getInitParameter ( INIT_PARAM_RESOURCE_NAME_REGEX_FLAGS ) ; if ( flagsStr != null && flagsStr . length ( ) > 0 ) { flags = Integer . decode ( flagsStr . trim ( ) ) ; } resourceNamePattern = Pattern . compile ( regex , flags ) ; this . resourceNameReplacement = replacement ; String all = config . getInitParameter ( "resource.name.replace.all" ) ; if ( all != null ) { this . resourceNameReplaceAll = Boolean . valueOf ( all . trim ( ) ) ; } } value = config . getInitParameter ( "logGROOVY861" ) ; if ( value != null ) { this . logGROOVY861 = Boolean . valueOf ( value ) ; } if ( verbose ) { log ( "(Abstract) init done. Listing some parameter name/value pairs:" ) ; log ( "verbose = " + verbose ) ; log ( "reflection = " + reflection ) ; log ( "logGROOVY861 = " + logGROOVY861 ) ; log ( INIT_PARAM_RESOURCE_NAME_REGEX + " = " + resourceNamePattern ) ; log ( "resource.name.replacement = " + resourceNameReplacement ) ; } } | Overrides the generic init method to set some debug flags . |
6,473 | public Class parseClass ( File file ) throws CompilationFailedException , IOException { return parseClass ( new GroovyCodeSource ( file , config . getSourceEncoding ( ) ) ) ; } | Parses the given file into a Java class capable of being run |
6,474 | protected String [ ] getClassPath ( ) { URL [ ] urls = getURLs ( ) ; String [ ] ret = new String [ urls . length ] ; for ( int i = 0 ; i < ret . length ; i ++ ) { ret [ i ] = urls [ i ] . getFile ( ) ; } return ret ; } | gets the currently used classpath . |
6,475 | protected ClassCollector createCollector ( CompilationUnit unit , SourceUnit su ) { InnerLoader loader = AccessController . doPrivileged ( new PrivilegedAction < InnerLoader > ( ) { public InnerLoader run ( ) { return new InnerLoader ( GroovyClassLoader . this ) ; } } ) ; return new ClassCollector ( loader , unit , su ) ; } | creates a ClassCollector for a new compilation . |
6,476 | public Class loadClass ( final String name , boolean lookupScriptFiles , boolean preferClassOverScript , boolean resolve ) throws ClassNotFoundException , CompilationFailedException { Class cls = getClassCacheEntry ( name ) ; boolean recompile = isRecompilable ( cls ) ; if ( ! recompile ) return cls ; ClassNotFoundException last = null ; try { Class parentClassLoaderClass = super . loadClass ( name , resolve ) ; if ( cls != parentClassLoaderClass ) return parentClassLoaderClass ; } catch ( ClassNotFoundException cnfe ) { last = cnfe ; } catch ( NoClassDefFoundError ncdfe ) { if ( ncdfe . getMessage ( ) . indexOf ( "wrong name" ) > 0 ) { last = new ClassNotFoundException ( name ) ; } else { throw ncdfe ; } } SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) { String className = name . replace ( '/' , '.' ) ; int i = className . lastIndexOf ( '.' ) ; if ( i != - 1 && ! className . startsWith ( "sun.reflect." ) ) { sm . checkPackageAccess ( className . substring ( 0 , i ) ) ; } } if ( cls != null && preferClassOverScript ) return cls ; if ( lookupScriptFiles ) { try { final Class classCacheEntry = getClassCacheEntry ( name ) ; if ( classCacheEntry != cls ) return classCacheEntry ; URL source = resourceLoader . loadGroovySource ( name ) ; Class oldClass = cls ; cls = null ; cls = recompile ( source , name , oldClass ) ; } catch ( IOException ioe ) { last = new ClassNotFoundException ( "IOException while opening groovy source: " + name , ioe ) ; } finally { if ( cls == null ) { removeClassCacheEntry ( name ) ; } else { setClassCacheEntry ( cls ) ; } } } if ( cls == null ) { if ( last == null ) throw new AssertionError ( true ) ; throw last ; } return cls ; } | loads a class from a file or a parent classloader . |
6,477 | protected Class loadClass ( final String name , boolean resolve ) throws ClassNotFoundException { return loadClass ( name , true , true , resolve ) ; } | Implemented here to check package access prior to returning an already loaded class . |
6,478 | protected boolean isSourceNewer ( URL source , Class cls ) throws IOException { long lastMod ; if ( isFile ( source ) ) { String path = source . getPath ( ) . replace ( '/' , File . separatorChar ) . replace ( '|' , ':' ) ; File file = new File ( path ) ; lastMod = file . lastModified ( ) ; } else { URLConnection conn = source . openConnection ( ) ; lastMod = conn . getLastModified ( ) ; conn . getInputStream ( ) . close ( ) ; } long classTime = getTimeStamp ( cls ) ; return classTime + config . getMinimumRecompilationInterval ( ) < lastMod ; } | Decides if the given source is newer than a class . |
6,479 | public void addClasspath ( final String path ) { AccessController . doPrivileged ( new PrivilegedAction < Void > ( ) { public Void run ( ) { URI newURI ; try { newURI = new URI ( path ) ; newURI . toURL ( ) ; } catch ( URISyntaxException | IllegalArgumentException | MalformedURLException e ) { newURI = new File ( path ) . toURI ( ) ; } URL [ ] urls = getURLs ( ) ; for ( URL url : urls ) { try { if ( newURI . equals ( url . toURI ( ) ) ) return null ; } catch ( URISyntaxException e ) { throw new RuntimeException ( e ) ; } } try { addURL ( newURI . toURL ( ) ) ; } catch ( MalformedURLException e ) { throw new RuntimeException ( e ) ; } return null ; } } ) ; } | adds a classpath to this classloader . |
6,480 | public int read ( final char [ ] array , final int offset , final int length ) { if ( idx >= charSequence . length ( ) ) { return EOF ; } if ( array == null ) { throw new NullPointerException ( "Character array is missing" ) ; } if ( length < 0 || offset < 0 || offset + length > array . length ) { throw new IndexOutOfBoundsException ( "Array Size=" + array . length + ", offset=" + offset + ", length=" + length ) ; } int count = 0 ; for ( int i = 0 ; i < length ; i ++ ) { final int c = read ( ) ; if ( c == EOF ) { return count ; } array [ offset + i ] = ( char ) c ; count ++ ; } return count ; } | Read the sepcified number of characters into the array . |
6,481 | public long skip ( final long n ) { if ( n < 0 ) { throw new IllegalArgumentException ( "Number of characters to skip is less than zero: " + n ) ; } if ( idx >= charSequence . length ( ) ) { return EOF ; } final int dest = ( int ) Math . min ( charSequence . length ( ) , idx + n ) ; final int count = dest - idx ; idx = dest ; return count ; } | Skip the specified number of characters . |
6,482 | public ListWithDefault < T > subList ( int fromIndex , int toIndex ) { return new ListWithDefault < T > ( delegate . subList ( fromIndex , toIndex ) , lazyDefaultValues , ( Closure ) initClosure . clone ( ) ) ; } | Returns a view of a portion of this list . This method returns a list with the same lazy list settings as the original list . |
6,483 | public static String encodeAngleBracketsInTagBody ( String text , Pattern regex ) { Matcher matcher = regex . matcher ( text ) ; if ( matcher . find ( ) ) { matcher . reset ( ) ; StringBuffer sb = new StringBuffer ( ) ; while ( matcher . find ( ) ) { String tagName = matcher . group ( 1 ) ; String tagBody = matcher . group ( 2 ) ; String encodedBody = Matcher . quoteReplacement ( encodeAngleBrackets ( tagBody ) ) ; String replacement = "{@" + tagName + " " + encodedBody + "}" ; matcher . appendReplacement ( sb , replacement ) ; } matcher . appendTail ( sb ) ; return sb . toString ( ) ; } else { return text ; } } | Replaces angle brackets inside a tag . |
6,484 | public Object getProperty ( String name ) { if ( "configFile" . equals ( name ) ) return this . configFile ; if ( ! containsKey ( name ) ) { ConfigObject prop = new ConfigObject ( this . configFile ) ; put ( name , prop ) ; return prop ; } return get ( name ) ; } | Overrides the default getProperty implementation to create nested ConfigObject instances on demand for non - existent keys |
6,485 | public Map flatten ( Map target ) { if ( target == null ) target = new ConfigObject ( ) ; populate ( "" , target , this ) ; return target ; } | Flattens this ConfigObject populating the results into the target Map |
6,486 | public Properties toProperties ( ) { Properties props = new Properties ( ) ; flatten ( props ) ; props = convertValuesToString ( props ) ; return props ; } | Converts this ConfigObject into a the java . util . Properties format flattening the tree structure beforehand |
6,487 | public Properties toProperties ( String prefix ) { Properties props = new Properties ( ) ; populate ( prefix + "." , props , this ) ; props = convertValuesToString ( props ) ; return props ; } | Converts this ConfigObject ino the java . util . Properties format flatten the tree and prefixing all entries with the given prefix |
6,488 | public static void displayVersion ( final PrintWriter writer ) { for ( String line : new VersionProvider ( ) . getVersion ( ) ) { writer . println ( line ) ; } } | Prints version information to the specified PrintWriter . |
6,489 | public static Container leftShift ( Container self , Component c ) { self . add ( c ) ; return self ; } | Overloads the left shift operator to provide an easy way to add components to a Container . |
6,490 | public static AbstractButton getAt ( ButtonGroup self , int index ) { int size = self . getButtonCount ( ) ; if ( index < 0 || index >= size ) return null ; Enumeration buttons = self . getElements ( ) ; for ( int i = 0 ; i <= index ; i ++ ) { AbstractButton b = ( AbstractButton ) buttons . nextElement ( ) ; if ( i == index ) return b ; } return null ; } | Support the subscript operator for ButtonGroup . |
6,491 | public static ButtonGroup leftShift ( ButtonGroup self , AbstractButton b ) { self . add ( b ) ; return self ; } | Overloads the left shift operator to provide an easy way to add buttons to a ButtonGroup . |
6,492 | public static DefaultListModel leftShift ( DefaultListModel self , Object e ) { self . addElement ( e ) ; return self ; } | Overloads the left shift operator to provide an easy way to add elements to a DefaultListModel . |
6,493 | public static JComboBox leftShift ( JComboBox self , Object i ) { self . addItem ( i ) ; return self ; } | Overloads the left shift operator to provide an easy way to add items to a JComboBox . |
6,494 | public static MutableComboBoxModel leftShift ( MutableComboBoxModel self , Object i ) { self . addElement ( i ) ; return self ; } | Overloads the left shift operator to provide an easy way to add items to a MutableComboBoxModel . |
6,495 | public static Object [ ] getAt ( TableModel self , int index ) { int cols = self . getColumnCount ( ) ; Object [ ] rowData = new Object [ cols ] ; for ( int col = 0 ; col < cols ; col ++ ) { rowData [ col ] = self . getValueAt ( index , col ) ; } return rowData ; } | Support the subscript operator for TableModel . |
6,496 | public static TableColumnModel leftShift ( TableColumnModel self , TableColumn column ) { self . addColumn ( column ) ; return self ; } | Overloads the left shift operator to provide an easy way to add columns to a TableColumnModel . |
6,497 | public static void setMnemonic ( AbstractButton button , String mnemonic ) { char c = ShortTypeHandling . castToChar ( mnemonic ) ; button . setMnemonic ( c ) ; } | Allows the usage of a one - element string for a mnemonic |
6,498 | private static void copyClassAnnotations ( final ClassNode cNode , final ClassNode helper ) { List < AnnotationNode > annotations = cNode . getAnnotations ( ) ; for ( AnnotationNode annotation : annotations ) { if ( ! annotation . getClassNode ( ) . equals ( Traits . TRAIT_CLASSNODE ) ) { helper . addAnnotation ( annotation ) ; } } } | Copies annotation from the trait to the helper excluding the trait annotation itself |
6,499 | public void each ( @ ClosureParams ( value = SimpleType . class , options = "groovy.sql.GroovyResultSet" ) Closure closure ) throws SQLException { eachRow ( getSql ( ) , getParameters ( ) , closure ) ; } | Calls the provided closure for each of the rows of the table represented by this DataSet . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.