idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
6,700 | public GroovyRunner remove ( Object key ) { if ( key == null ) { return null ; } Map < String , GroovyRunner > map = getMap ( ) ; writeLock . lock ( ) ; try { cachedValues = null ; return map . remove ( key ) ; } finally { writeLock . unlock ( ) ; } } | Removes a registered runner from the registry . |
6,701 | public void clear ( ) { Map < String , GroovyRunner > map = getMap ( ) ; writeLock . lock ( ) ; try { cachedValues = null ; map . clear ( ) ; loadDefaultRunners ( ) ; } finally { writeLock . unlock ( ) ; } } | Clears all registered runners from the registry and resets the registry so that it contains only the default set of runners . |
6,702 | public Collection < GroovyRunner > values ( ) { List < GroovyRunner > values = cachedValues ; if ( values == null ) { Map < String , GroovyRunner > map = getMap ( ) ; readLock . lock ( ) ; try { if ( ( values = cachedValues ) == null ) { cachedValues = values = Collections . unmodifiableList ( new ArrayList < > ( map .... | Returns a collection of all registered runners . This is a snapshot of the registry and any subsequent registry changes will not be reflected in the collection . |
6,703 | public Set < Entry < String , GroovyRunner > > entrySet ( ) { Map < String , GroovyRunner > map = getMap ( ) ; readLock . lock ( ) ; try { if ( map . isEmpty ( ) ) { return Collections . emptySet ( ) ; } return Collections . unmodifiableSet ( new LinkedHashSet < > ( map . entrySet ( ) ) ) ; } finally { readLock . unloc... | Returns a set of entries for registered runners . This is a snapshot of the registry and any subsequent registry changes will not be reflected in the set . |
6,704 | public int read ( char cbuf [ ] , int off , int len ) throws IOException { int c = 0 ; int count = 0 ; while ( count < len && ( c = read ( ) ) != - 1 ) { cbuf [ off + count ] = ( char ) c ; count ++ ; } return ( count == 0 && c == - 1 ) ? - 1 : count ; } | Reads characters from the underlying reader . |
6,705 | public int read ( ) throws IOException { if ( hasNextChar ) { hasNextChar = false ; write ( nextChar ) ; return nextChar ; } if ( previousLine != lexer . getLine ( ) ) { numUnicodeEscapesFoundOnCurrentLine = 0 ; previousLine = lexer . getLine ( ) ; } int c = reader . read ( ) ; if ( c != '\\' ) { write ( c ) ; return c... | Gets the next character from the underlying reader translating escapes as required . |
6,706 | private void checkHexDigit ( int c ) throws IOException { if ( c >= '0' && c <= '9' ) { return ; } if ( c >= 'a' && c <= 'f' ) { return ; } if ( c >= 'A' && c <= 'F' ) { return ; } hasNextChar = true ; nextChar = c ; throw new IOException ( "Did not find four digit hex character code." + " line: " + lexer . getLine ( )... | Checks that the given character is indeed a hex digit . |
6,707 | public void run ( ) { try { ServerSocket serverSocket = new ServerSocket ( url . getPort ( ) ) ; while ( true ) { Script script = groovy . parse ( source ) ; new GroovyClientConnection ( script , autoOutput , serverSocket . accept ( ) ) ; } } catch ( Exception e ) { e . printStackTrace ( ) ; } } | Runs this server . There is typically no need to call this method as the object s constructor creates a new thread and runs this object automatically . |
6,708 | private boolean run ( ) { try { if ( processSockets ) { processSockets ( ) ; } else if ( processFiles ) { processFiles ( ) ; } else { processOnce ( ) ; } return true ; } catch ( CompilationFailedException e ) { System . err . println ( e ) ; return false ; } catch ( Throwable e ) { if ( e instanceof InvokerInvocationEx... | Run the script . |
6,709 | private void processSockets ( ) throws CompilationFailedException , IOException , URISyntaxException { GroovyShell groovy = new GroovyShell ( conf ) ; new GroovySocketServer ( groovy , getScriptSource ( isScriptFile , script ) , autoOutput , port ) ; } | Process Sockets . |
6,710 | public static File searchForGroovyScriptFile ( String input ) { String scriptFileName = input . trim ( ) ; File scriptFile = new File ( scriptFileName ) ; String [ ] standardExtensions = { ".groovy" , ".gvy" , ".gy" , ".gsh" } ; int i = 0 ; while ( i < standardExtensions . length && ! scriptFile . exists ( ) ) { script... | Search for the script file doesn t bother if it is named precisely . |
6,711 | private static void setupContextClassLoader ( GroovyShell shell ) { final Thread current = Thread . currentThread ( ) ; class DoSetContext implements PrivilegedAction { ClassLoader classLoader ; public DoSetContext ( ClassLoader loader ) { classLoader = loader ; } public Object run ( ) { current . setContextClassLoader... | GROOVY - 6771 |
6,712 | private void processFiles ( ) throws CompilationFailedException , IOException , URISyntaxException { GroovyShell groovy = new GroovyShell ( conf ) ; setupContextClassLoader ( groovy ) ; Script s = groovy . parse ( getScriptSource ( isScriptFile , script ) ) ; if ( args . isEmpty ( ) ) { try ( BufferedReader reader = ne... | Process the input files . |
6,713 | private void processFile ( Script s , File file ) throws IOException { if ( ! file . exists ( ) ) throw new FileNotFoundException ( file . getName ( ) ) ; if ( ! editFiles ) { try ( BufferedReader reader = new BufferedReader ( new FileReader ( file ) ) ) { PrintWriter writer = new PrintWriter ( System . out ) ; process... | Process a single input file . |
6,714 | private void processReader ( Script s , BufferedReader reader , PrintWriter pw ) throws IOException { String line ; String lineCountName = "count" ; s . setProperty ( lineCountName , BigInteger . ZERO ) ; String autoSplitName = "split" ; s . setProperty ( "out" , pw ) ; try { InvokerHelper . invokeMethod ( s , "begin" ... | Process a script against a single input file . |
6,715 | private void processOnce ( ) throws CompilationFailedException , IOException , URISyntaxException { GroovyShell groovy = new GroovyShell ( conf ) ; setupContextClassLoader ( groovy ) ; groovy . run ( getScriptSource ( isScriptFile , script ) , args ) ; } | Process the standard single script with args . |
6,716 | protected List < Expression > transformExpressions ( List < ? extends Expression > expressions , ExpressionTransformer transformer ) { List < Expression > list = new ArrayList < Expression > ( expressions . size ( ) ) ; for ( Expression expr : expressions ) { list . add ( transformer . transform ( expr ) ) ; } return l... | Transforms the list of expressions |
6,717 | protected < T extends Expression > List < T > transformExpressions ( List < ? extends Expression > expressions , ExpressionTransformer transformer , Class < T > transformedType ) { List < T > list = new ArrayList < T > ( expressions . size ( ) ) ; for ( Expression expr : expressions ) { Expression transformed = transfo... | Transforms the list of expressions and checks that all transformed expressions have the given type . |
6,718 | public static ClassNode [ ] make ( Class [ ] classes ) { ClassNode [ ] cns = new ClassNode [ classes . length ] ; for ( int i = 0 ; i < cns . length ; i ++ ) { cns [ i ] = make ( classes [ i ] ) ; } return cns ; } | Creates an array of ClassNodes using an array of classes . For each of the given classes a new ClassNode will be created |
6,719 | public static ClassNode make ( String name ) { if ( name == null || name . length ( ) == 0 ) return DYNAMIC_TYPE ; for ( int i = 0 ; i < primitiveClassNames . length ; i ++ ) { if ( primitiveClassNames [ i ] . equals ( name ) ) return types [ i ] ; } for ( int i = 0 ; i < classes . length ; i ++ ) { String cname = clas... | Creates a ClassNode using a given class . If the name is one of the predefined ClassNodes then the corresponding ClassNode instance will be returned . If the name is null or of length 0 the dynamic type is returned |
6,720 | public static ClassNode getNextSuperClass ( ClassNode clazz , ClassNode goalClazz ) { if ( clazz . isArray ( ) ) { if ( ! goalClazz . isArray ( ) ) return null ; ClassNode cn = getNextSuperClass ( clazz . getComponentType ( ) , goalClazz . getComponentType ( ) ) ; if ( cn != null ) cn = cn . makeArray ( ) ; return cn ;... | Returns a super class or interface for a given class depending on a given target . If the target is no super class or interface then null will be returned . For a non - primitive array type returns an array of the componentType s super class or interface if the target is also an array . |
6,721 | public static Number minus ( Number left , Number right ) { return NumberMath . subtract ( left , right ) ; } | Subtraction of two Numbers . |
6,722 | public static OutputStream leftShift ( Socket self , byte [ ] value ) throws IOException { return IOGroovyMethods . leftShift ( self . getOutputStream ( ) , value ) ; } | Overloads the left shift operator to provide an append mechanism to add bytes to the output stream of a socket |
6,723 | public static Socket accept ( ServerSocket serverSocket , @ ClosureParams ( value = SimpleType . class , options = "java.net.Socket" ) final Closure closure ) throws IOException { return accept ( serverSocket , true , closure ) ; } | Accepts a connection and passes the resulting Socket to the closure which runs in a new Thread . |
6,724 | public static Socket accept ( ServerSocket serverSocket , final boolean runInANewThread , @ ClosureParams ( value = SimpleType . class , options = "java.net.Socket" ) final Closure closure ) throws IOException { final Socket socket = serverSocket . accept ( ) ; if ( runInANewThread ) { new Thread ( new Runnable ( ) { p... | Accepts a connection and passes the resulting Socket to the closure which runs in a new Thread or the calling thread as needed . |
6,725 | private void passThisReference ( ConstructorCallExpression call ) { ClassNode cn = call . getType ( ) . redirect ( ) ; if ( ! shouldHandleImplicitThisForInnerClass ( cn ) ) return ; boolean isInStaticContext = true ; if ( currentMethod != null ) isInStaticContext = currentMethod . getVariableScope ( ) . isInStaticConte... | passed as the first argument implicitly . |
6,726 | public static Sql newInstance ( String url ) throws SQLException { Connection connection = DriverManager . getConnection ( url ) ; return new Sql ( connection ) ; } | Creates a new Sql instance given a JDBC connection URL . |
6,727 | public static Sql newInstance ( String url , String user , String password ) throws SQLException { Connection connection = DriverManager . getConnection ( url , user , password ) ; return new Sql ( connection ) ; } | Creates a new Sql instance given a JDBC connection URL a username and a password . |
6,728 | public static Sql newInstance ( String url , String user , String password , String driverClassName ) throws SQLException , ClassNotFoundException { loadDriver ( driverClassName ) ; return newInstance ( url , user , password ) ; } | Creates a new Sql instance given a JDBC connection URL a username a password and a driver class name . |
6,729 | public static Sql newInstance ( String url , String driverClassName ) throws SQLException , ClassNotFoundException { loadDriver ( driverClassName ) ; return newInstance ( url ) ; } | Creates a new Sql instance given a JDBC connection URL and a driver class name . |
6,730 | public static void loadDriver ( String driverClassName ) throws ClassNotFoundException { try { Class . forName ( driverClassName ) ; } catch ( ClassNotFoundException e ) { try { Thread . currentThread ( ) . getContextClassLoader ( ) . loadClass ( driverClassName ) ; } catch ( ClassNotFoundException e2 ) { try { Sql . c... | Attempts to load the JDBC driver on the thread current or system class loaders |
6,731 | public static InParameter in ( final int type , final Object value ) { return new InParameter ( ) { public int getType ( ) { return type ; } public Object getValue ( ) { return value ; } } ; } | Create a new InParameter |
6,732 | public static InOutParameter inout ( final InParameter in ) { return new InOutParameter ( ) { public int getType ( ) { return in . getType ( ) ; } public Object getValue ( ) { return in . getValue ( ) ; } } ; } | Create an inout parameter using this in parameter . |
6,733 | public void commit ( ) throws SQLException { if ( useConnection == null ) { LOG . info ( "Commit operation not supported when using datasets unless using withTransaction or cacheConnection - attempt to commit ignored" ) ; return ; } try { useConnection . commit ( ) ; } catch ( SQLException e ) { LOG . warning ( "Caught... | If this SQL object was created with a Connection then this method commits the connection . If this SQL object was created from a DataSource then this method does nothing . |
6,734 | public void cacheConnection ( Closure closure ) throws SQLException { boolean savedCacheConnection = cacheConnection ; cacheConnection = true ; Connection connection = null ; try { connection = createConnection ( ) ; callClosurePossiblyWithConnection ( closure , connection ) ; } finally { cacheConnection = false ; clos... | Caches the connection used while the closure is active . If the closure takes a single argument it will be called with the connection otherwise it will be called with no arguments . |
6,735 | protected final ResultSet executePreparedQuery ( String sql , List < Object > params ) throws SQLException { AbstractQueryCommand command = createPreparedQueryCommand ( sql , params ) ; ResultSet rs = null ; try { rs = command . execute ( ) ; } finally { command . closeResources ( ) ; } return rs ; } | Useful helper method which handles resource management when executing a prepared query which returns a result set . Derived classes of Sql can override createPreparedQueryCommand and then call this method to access the ResultSet returned from the provided query . |
6,736 | protected String asSql ( GString gstring , List < Object > values ) { String [ ] strings = gstring . getStrings ( ) ; if ( strings . length <= 0 ) { throw new IllegalArgumentException ( "No SQL specified in GString: " + gstring ) ; } boolean nulls = false ; StringBuilder buffer = new StringBuilder ( ) ; boolean warned ... | Hook to allow derived classes to override sql generation from GStrings . |
6,737 | protected String nullify ( String sql ) { int firstWhere = findWhereKeyword ( sql ) ; if ( firstWhere >= 0 ) { Pattern [ ] patterns = { Pattern . compile ( "(?is)^(.{" + firstWhere + "}.*?)!=\\s{0,1}(\\s*)\\?'\"\\?(.*)" ) , Pattern . compile ( "(?is)^(.{" + firstWhere + "}.*?)<>\\s{0,1}(\\s*)\\?'\"\\?(.*)" ) , Pattern ... | Hook to allow derived classes to override null handling . Default behavior is to replace ? ? references with NULLish |
6,738 | protected int findWhereKeyword ( String sql ) { char [ ] chars = sql . toLowerCase ( ) . toCharArray ( ) ; char [ ] whereChars = "where" . toCharArray ( ) ; int i = 0 ; boolean inString = false ; int inWhere = 0 ; while ( i < chars . length ) { switch ( chars [ i ] ) { case '\'' : inString = ! inString ; break ; defaul... | Hook to allow derived classes to override where clause sniffing . Default behavior is to find the first where keyword in the sql doing simple avoidance of the word where within quotes . |
6,739 | protected List < Object > getParameters ( GString gstring ) { return new ArrayList < Object > ( Arrays . asList ( gstring . getValues ( ) ) ) ; } | Hook to allow derived classes to override behavior associated with extracting params from a GString . |
6,740 | protected void setObject ( PreparedStatement statement , int i , Object value ) throws SQLException { if ( value instanceof InParameter || value instanceof OutParameter ) { if ( value instanceof InParameter ) { InParameter in = ( InParameter ) value ; Object val = in . getValue ( ) ; if ( null == val ) { statement . se... | Strategy method allowing derived classes to handle types differently such as for CLOBs etc . |
6,741 | protected Connection createConnection ( ) throws SQLException { if ( ( cacheStatements || cacheConnection ) && useConnection != null ) { return useConnection ; } if ( dataSource != null ) { Connection con ; try { con = AccessController . doPrivileged ( new PrivilegedExceptionAction < Connection > ( ) { public Connectio... | An extension point allowing derived classes to change the behavior of connection creation . The default behavior is to either use the supplied connection or obtain it from the supplied datasource . |
6,742 | protected void closeResources ( Connection connection , Statement statement , ResultSet results ) { if ( results != null ) { try { results . close ( ) ; } catch ( SQLException e ) { LOG . finest ( "Caught exception closing resultSet: " + e . getMessage ( ) + " - continuing" ) ; } } closeResources ( connection , stateme... | An extension point allowing derived classes to change the behavior of resource closing . |
6,743 | protected void closeResources ( Connection connection ) { if ( cacheConnection ) return ; if ( connection != null && dataSource != null ) { try { connection . close ( ) ; } catch ( SQLException e ) { LOG . finest ( "Caught exception closing connection: " + e . getMessage ( ) + " - continuing" ) ; } } } | An extension point allowing the behavior of resource closing to be overridden in derived classes . |
6,744 | protected void configure ( Statement statement ) { Closure configureStatement = this . configureStatement ; if ( configureStatement != null ) { configureStatement . call ( statement ) ; } } | Provides a hook for derived classes to be able to configure JDBC statements . Default behavior is to call a previously saved closure if any using the statement as a parameter . |
6,745 | protected SqlWithParams buildSqlWithIndexedProps ( String sql ) { if ( ! enableNamedQueries || ! ExtractIndexAndSql . hasNamedParameters ( sql ) ) { return null ; } String newSql ; List < Tuple > propList ; if ( cacheNamedQueries && namedParamSqlCache . containsKey ( sql ) ) { newSql = namedParamSqlCache . get ( sql ) ... | Hook to allow derived classes to override behavior associated with the parsing and indexing of parameters from a given sql statement . |
6,746 | protected AbstractQueryCommand createPreparedQueryCommand ( String sql , List < Object > queryParams ) { return new PreparedQueryCommand ( sql , queryParams ) ; } | Factory for the PreparedQueryCommand command pattern object allows subclass to supply implementations of the command class . |
6,747 | public void printf ( String format , Object value ) { Object object ; try { object = getProperty ( "out" ) ; } catch ( MissingPropertyException e ) { DefaultGroovyMethods . printf ( System . out , format , value ) ; return ; } InvokerHelper . invokeMethod ( object , "printf" , new Object [ ] { format , value } ) ; } | Prints a formatted string using the specified format string and argument . |
6,748 | public void run ( File file , String [ ] arguments ) throws CompilationFailedException , IOException { GroovyShell shell = new GroovyShell ( getClass ( ) . getClassLoader ( ) , binding ) ; shell . run ( file , arguments ) ; } | A helper method to allow scripts to be run taking command line arguments |
6,749 | public static GroovyRowResult toRowResult ( ResultSet rs ) throws SQLException { ResultSetMetaData metadata = rs . getMetaData ( ) ; Map < String , Object > lhm = new LinkedHashMap < String , Object > ( metadata . getColumnCount ( ) , 1 ) ; for ( int i = 1 ; i <= metadata . getColumnCount ( ) ; i ++ ) { lhm . put ( met... | Returns a GroovyRowResult given a ResultSet . |
6,750 | public static < T > T min ( Iterable < T > items ) { T answer = null ; for ( T value : items ) { if ( value != null ) { if ( answer == null || ScriptBytecodeAdapter . compareLessThan ( value , answer ) ) { answer = value ; } } } return answer ; } | Selects the minimum value found in an Iterable of items . |
6,751 | public static < T > T max ( Iterable < T > items ) { T answer = null ; for ( T value : items ) { if ( value != null ) { if ( answer == null || ScriptBytecodeAdapter . compareGreaterThan ( value , answer ) ) { answer = value ; } } } return answer ; } | Selects the maximum value found in an Iterable . |
6,752 | public static Expression transformListOfConstants ( ListExpression origList , ClassNode attrType ) { ListExpression newList = new ListExpression ( ) ; boolean changed = false ; for ( Expression e : origList . getExpressions ( ) ) { try { Expression transformed = transformInlineConstants ( e , attrType ) ; newList . add... | Given a list of constants transform each item in the list . |
6,753 | public Template createTemplate ( final Reader reader ) throws CompilationFailedException , ClassNotFoundException , IOException { return new StreamingTemplate ( reader , parentLoader ) ; } | Creates a template instance using the template source from the provided Reader . |
6,754 | private void fillMethodIndex ( ) { mainClassMethodHeader = metaMethodIndex . getHeader ( theClass ) ; LinkedList < CachedClass > superClasses = getSuperClasses ( ) ; CachedClass firstGroovySuper = calcFirstGroovySuperClass ( superClasses ) ; Set < CachedClass > interfaces = theCachedClass . getInterfaces ( ) ; addInter... | Fills the method index |
6,755 | private Object getMethods ( Class sender , String name , boolean isCallToSuper ) { Object answer ; final MetaMethodIndex . Entry entry = metaMethodIndex . getMethods ( sender , name ) ; if ( entry == null ) answer = FastArray . EMPTY_LIST ; else if ( isCallToSuper ) { answer = entry . methodsForSuper ; } else { answer ... | Gets all instance methods available on this class for the given name |
6,756 | private Object getStaticMethods ( Class sender , String name ) { final MetaMethodIndex . Entry entry = metaMethodIndex . getMethods ( sender , name ) ; if ( entry == null ) return FastArray . EMPTY_LIST ; Object answer = entry . staticMethods ; if ( answer == null ) return FastArray . EMPTY_LIST ; return answer ; } | Returns all the normal static methods on this class for the given name |
6,757 | public void addNewInstanceMethod ( Method method ) { final CachedMethod cachedMethod = CachedMethod . find ( method ) ; NewInstanceMetaMethod newMethod = new NewInstanceMetaMethod ( cachedMethod ) ; final CachedClass declaringClass = newMethod . getDeclaringClass ( ) ; addNewInstanceMethodToIndex ( newMethod , metaMeth... | Adds an instance method to this metaclass . |
6,758 | public void addNewStaticMethod ( Method method ) { final CachedMethod cachedMethod = CachedMethod . find ( method ) ; NewStaticMetaMethod newMethod = new NewStaticMetaMethod ( cachedMethod ) ; final CachedClass declaringClass = newMethod . getDeclaringClass ( ) ; addNewStaticMethodToIndex ( newMethod , metaMethodIndex ... | Adds a static method to this metaclass . |
6,759 | public Object invokeMethod ( Object object , String methodName , Object arguments ) { if ( arguments == null ) { return invokeMethod ( object , methodName , MetaClassHelper . EMPTY_ARRAY ) ; } if ( arguments instanceof Tuple ) { Tuple tuple = ( Tuple ) arguments ; return invokeMethod ( object , methodName , tuple . toA... | Invoke a method on the given object with the given arguments . |
6,760 | public Object invokeMissingMethod ( Object instance , String methodName , Object [ ] arguments ) { return invokeMissingMethod ( instance , methodName , arguments , null , false ) ; } | Invoke a missing method on the given object with the given arguments . |
6,761 | public Object invokeMissingProperty ( Object instance , String propertyName , Object optionalValue , boolean isGetter ) { Class theClass = instance instanceof Class ? ( Class ) instance : instance . getClass ( ) ; CachedClass superClass = theCachedClass ; while ( superClass != null && superClass != ReflectionCache . OB... | Invoke a missing property on the given object with the given arguments . |
6,762 | protected Object invokeStaticMissingProperty ( Object instance , String propertyName , Object optionalValue , boolean isGetter ) { MetaClass mc = instance instanceof Class ? registry . getMetaClass ( ( Class ) instance ) : this ; if ( isGetter ) { MetaMethod propertyMissing = mc . getMetaMethod ( STATIC_PROPERTY_MISSIN... | Hook to deal with the case of MissingProperty for static properties . The method will look attempt to look up propertyMissing handlers and invoke them otherwise thrown a MissingPropertyException |
6,763 | public Object invokeMethod ( Object object , String methodName , Object [ ] originalArguments ) { return invokeMethod ( theClass , object , methodName , originalArguments , false , false ) ; } | Invokes a method on the given receiver for the specified arguments . The MetaClass will attempt to establish the method to invoke based on the name and arguments provided . |
6,764 | private MetaMethod getMethodWithCachingInternal ( Class sender , CallSite site , Class [ ] params ) { if ( GroovyCategorySupport . hasCategoryInCurrentThread ( ) ) return getMethodWithoutCaching ( sender , site . getName ( ) , params , false ) ; final MetaMethodIndex . Entry e = metaMethodIndex . getMethods ( sender , ... | This method should be called by CallSite only |
6,765 | public MetaMethod retrieveConstructor ( Object [ ] arguments ) { checkInitalised ( ) ; if ( arguments == null ) arguments = EMPTY_ARGUMENTS ; Class [ ] argClasses = MetaClassHelper . convertToTypeArray ( arguments ) ; MetaClassHelper . unwrap ( arguments ) ; Object res = chooseMethod ( "<init>" , constructors , argClas... | This is a helper method added in Groovy 2 . 1 . 0 which is used only by indy . This method is for internal use only . |
6,766 | public void setProperties ( Object bean , Map map ) { checkInitalised ( ) ; for ( Iterator iter = map . entrySet ( ) . iterator ( ) ; iter . hasNext ( ) ; ) { Map . Entry entry = ( Map . Entry ) iter . next ( ) ; String key = entry . getKey ( ) . toString ( ) ; Object value = entry . getValue ( ) ; setProperty ( bean ,... | Sets a number of bean properties from the given Map where the keys are the String names of properties and the values are the values of the properties to set |
6,767 | public List < MetaProperty > getProperties ( ) { checkInitalised ( ) ; SingleKeyHashMap propertyMap = classPropertyIndex . getNullable ( theCachedClass ) ; if ( propertyMap == null ) { propertyMap = new SingleKeyHashMap ( ) ; } List ret = new ArrayList ( propertyMap . size ( ) ) ; for ( ComplexKeyHashMap . EntryIterato... | Get all the properties defined for this type |
6,768 | public void addMetaBeanProperty ( MetaBeanProperty mp ) { MetaProperty staticProperty = establishStaticMetaProperty ( mp ) ; if ( staticProperty != null ) { staticPropertyIndex . put ( mp . getName ( ) , mp ) ; } else { SingleKeyHashMap propertyMap = classPropertyIndex . getNotNull ( theCachedClass ) ; CachedField fiel... | Adds a new MetaBeanProperty to this MetaClass |
6,769 | public ClassNode getClassNode ( ) { if ( classNode == null && GroovyObject . class . isAssignableFrom ( theClass ) ) { String groovyFile = theClass . getName ( ) ; int idx = groovyFile . indexOf ( '$' ) ; if ( idx > 0 ) { groovyFile = groovyFile . substring ( 0 , idx ) ; } groovyFile = groovyFile . replace ( '.' , '/' ... | Obtains a reference to the original AST for the MetaClass if it is available at runtime |
6,770 | protected final void checkIfGroovyObjectMethod ( MetaMethod metaMethod ) { if ( metaMethod instanceof ClosureMetaMethod || metaMethod instanceof MixinInstanceMetaMethod ) { if ( isGetPropertyMethod ( metaMethod ) ) { getPropertyMethod = metaMethod ; } else if ( isInvokeMethod ( metaMethod ) ) { invokeMethodMethod = met... | Checks if the metaMethod is a method from the GroovyObject interface such as setProperty getProperty and invokeMethod |
6,771 | protected Object chooseMethod ( String methodName , Object methodOrList , Class [ ] arguments ) { Object method = chooseMethodInternal ( methodName , methodOrList , arguments ) ; if ( method instanceof GeneratedMetaMethod . Proxy ) return ( ( GeneratedMetaMethod . Proxy ) method ) . proxy ( ) ; return method ; } | Chooses the correct method to use from a list of methods which match by name . |
6,772 | public MetaMethod pickMethod ( String methodName , Class [ ] arguments ) { return getMethodWithoutCaching ( theClass , methodName , arguments , false ) ; } | Selects a method by name and argument classes . This method does not search for an exact match it searches for a compatible method . For this the method selection mechanism is used as provided by the implementation of this MetaClass . pickMethod may or may not be used during the method selection process when invoking a... |
6,773 | public static SourceUnit create ( String name , String source ) { CompilerConfiguration configuration = new CompilerConfiguration ( ) ; configuration . setTolerance ( 1 ) ; return new SourceUnit ( name , source , configuration , null , new ErrorCollector ( configuration ) ) ; } | A convenience routine to create a standalone SourceUnit on a String with defaults for almost everything that is configurable . |
6,774 | public static Number div ( Number left , Number right ) { return NumberMath . divide ( left , right ) ; } | Divide two Numbers . |
6,775 | private final void print_30_permut ( ) { final int [ ] permutation = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { permutation [ i ] = i ; System . out . print ( ( 1 + i ) ) ; } System . out . println ( ) ; final int [ ] perm_remain = new int [ n ] ; for ( int i = 1 ; i <= n ; i ++ ) perm_remain [ i - 1 ] = i ; in... | this function will correctly print first 30 permutations |
6,776 | private static final int count_flip ( final int [ ] perm_flip ) { int v0 = perm_flip [ 0 ] ; int tmp ; int flip_count = 0 ; do { for ( int i = 1 , j = v0 - 1 ; i < j ; ++ i , -- j ) { tmp = perm_flip [ i ] ; perm_flip [ i ] = perm_flip [ j ] ; perm_flip [ j ] = tmp ; } tmp = perm_flip [ v0 ] ; perm_flip [ v0 ] = v0 ; v... | Return flipping times |
6,777 | public static < T1 , T2 , T3 > Tuple3 < T1 , T2 , T3 > tuple ( T1 v1 , T2 v2 , T3 v3 ) { return new Tuple3 < > ( v1 , v2 , v3 ) ; } | Construct a tuple of degree 3 . |
6,778 | public DefaultTableColumn addPropertyColumn ( Object headerValue , String property , Class type ) { return addColumn ( headerValue , property , new PropertyModel ( rowModel , property , type ) ) ; } | Adds a property model column to the table |
6,779 | public DefaultTableColumn addClosureColumn ( Object headerValue , Closure readClosure , Closure writeClosure , Class type ) { return addColumn ( headerValue , new ClosureModel ( rowModel , readClosure , writeClosure , type ) ) ; } | Adds a closure based column to the table |
6,780 | public void addColumn ( DefaultTableColumn column ) { column . setModelIndex ( columnModel . getColumnCount ( ) ) ; columnModel . addColumn ( column ) ; } | Adds a new column definition to the table |
6,781 | public void setRedirect ( ClassNode cn ) { if ( isPrimaryNode ) throw new GroovyBugError ( "tried to set a redirect for a primary ClassNode (" + getName ( ) + "->" + cn . getName ( ) + ")." ) ; if ( cn != null ) cn = cn . redirect ( ) ; if ( cn == this ) return ; redirect = cn ; } | Sets this instance as proxy for the given ClassNode . |
6,782 | public ClassNode makeArray ( ) { if ( redirect != null ) { ClassNode res = redirect ( ) . makeArray ( ) ; res . componentType = this ; return res ; } ClassNode cn ; if ( clazz != null ) { Class ret = Array . newInstance ( clazz , 0 ) . getClass ( ) ; cn = new ClassNode ( ret , this ) ; } else { cn = new ClassNode ( thi... | Returns a ClassNode representing an array of the class represented by this ClassNode |
6,783 | private void lazyClassInit ( ) { if ( lazyInitDone ) return ; synchronized ( lazyInitLock ) { if ( redirect != null ) { throw new GroovyBugError ( "lazyClassInit called on a proxy ClassNode, that must not happen." + "A redirect() call is missing somewhere!" ) ; } if ( lazyInitDone ) return ; VMPluginFactory . getPlugin... | The complete class structure will be initialized only when really needed to avoid having too many objects during compilation |
6,784 | public ConstructorNode getDeclaredConstructor ( Parameter [ ] parameters ) { for ( ConstructorNode method : getDeclaredConstructors ( ) ) { if ( parametersEqual ( method . getParameters ( ) , parameters ) ) { return method ; } } return null ; } | Finds a constructor matching the given parameters in this class . |
6,785 | public MethodNode addSyntheticMethod ( String name , int modifiers , ClassNode returnType , Parameter [ ] parameters , ClassNode [ ] exceptions , Statement code ) { MethodNode answer = addMethod ( name , modifiers | ACC_SYNTHETIC , returnType , parameters , exceptions , code ) ; answer . setSynthetic ( true ) ; return ... | Adds a synthetic method as part of the compilation process |
6,786 | public FieldNode getDeclaredField ( String name ) { if ( redirect != null ) return redirect ( ) . getDeclaredField ( name ) ; lazyClassInit ( ) ; return fieldIndex == null ? null : fieldIndex . get ( name ) ; } | Finds a field matching the given name in this class . |
6,787 | public FieldNode getField ( String name ) { ClassNode node = this ; while ( node != null ) { FieldNode fn = node . getDeclaredField ( name ) ; if ( fn != null ) return fn ; node = node . getSuperClass ( ) ; } return null ; } | Finds a field matching the given name in this class or a parent class . |
6,788 | public List < MethodNode > getDeclaredMethods ( String name ) { if ( redirect != null ) return redirect ( ) . getDeclaredMethods ( name ) ; lazyClassInit ( ) ; return methods . getNotNull ( name ) ; } | This methods returns a list of all methods of the given name defined in the current class |
6,789 | public List < MethodNode > getMethods ( String name ) { List < MethodNode > answer = new ArrayList < MethodNode > ( ) ; ClassNode node = this ; while ( node != null ) { answer . addAll ( node . getDeclaredMethods ( name ) ) ; node = node . getSuperClass ( ) ; } return answer ; } | This methods creates a list of all methods with this name of the current class and of all super classes |
6,790 | public MethodNode getDeclaredMethod ( String name , Parameter [ ] parameters ) { for ( MethodNode method : getDeclaredMethods ( name ) ) { if ( parametersEqual ( method . getParameters ( ) , parameters ) ) { return method ; } } return null ; } | Finds a method matching the given name and parameters in this class . |
6,791 | public MethodNode getMethod ( String name , Parameter [ ] parameters ) { for ( MethodNode method : getMethods ( name ) ) { if ( parametersEqual ( method . getParameters ( ) , parameters ) ) { return method ; } } return null ; } | Finds a method matching the given name and parameters in this class or any parent class . |
6,792 | public static String getMopMethodName ( MethodNode method , boolean useThis ) { ClassNode declaringNode = method . getDeclaringClass ( ) ; int distance = 0 ; for ( ; declaringNode != null ; declaringNode = declaringNode . getSuperClass ( ) ) { distance ++ ; } return ( useThis ? "this" : "super" ) + "$" + distance + "$"... | creates a MOP method name from a method |
6,793 | public static void serialize ( Element element , OutputStream os ) { Source source = new DOMSource ( element ) ; serialize ( source , os ) ; } | Write a pretty version of the Element to the OutputStream . |
6,794 | public static void serialize ( Element element , Writer w ) { Source source = new DOMSource ( element ) ; serialize ( source , w ) ; } | Write a pretty version of the Element to the Writer . |
6,795 | public static SAXParser newSAXParser ( String schemaLanguage , Source ... schemas ) throws SAXException , ParserConfigurationException { return newSAXParser ( schemaLanguage , true , false , schemas ) ; } | Factory method to create a SAXParser configured to validate according to a particular schema language and optionally providing the schema sources to validate with . The created SAXParser will be namespace - aware and not validate against DTDs . |
6,796 | public static SAXParser newSAXParser ( String schemaLanguage , boolean namespaceAware , boolean validating , Source ... schemas ) throws SAXException , ParserConfigurationException { SAXParserFactory factory = SAXParserFactory . newInstance ( ) ; factory . setValidating ( validating ) ; factory . setNamespaceAware ( na... | Factory method to create a SAXParser configured to validate according to a particular schema language and optionally providing the schema sources to validate with . |
6,797 | public static SAXParser newSAXParser ( String schemaLanguage , File schema ) throws SAXException , ParserConfigurationException { return newSAXParser ( schemaLanguage , true , false , schema ) ; } | Factory method to create a SAXParser configured to validate according to a particular schema language and a File containing the schema to validate against . The created SAXParser will be namespace - aware and not validate against DTDs . |
6,798 | public static SAXParser newSAXParser ( String schemaLanguage , boolean namespaceAware , boolean validating , File schema ) throws SAXException , ParserConfigurationException { SchemaFactory schemaFactory = SchemaFactory . newInstance ( schemaLanguage ) ; return newSAXParser ( namespaceAware , validating , schemaFactory... | Factory method to create a SAXParser configured to validate according to a particular schema language and a File containing the schema to validate against . |
6,799 | public Object run ( final File scriptFile , String [ ] args ) throws CompilationFailedException , IOException { String scriptName = scriptFile . getName ( ) ; int p = scriptName . lastIndexOf ( "." ) ; if ( p ++ >= 0 ) { if ( scriptName . substring ( p ) . equals ( "java" ) ) { throw new CompilationFailedException ( 0 ... | Runs the given script file name with the given command line arguments |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.