idx int64 0 41.2k | question stringlengths 83 4.15k | target stringlengths 5 715 |
|---|---|---|
19,700 | public ServiceInformation get ( String key ) { ServiceInformation info = null ; long hash = algorithm . hash ( key ) ; final SortedMap < Long , ServiceInformation > tailMap = ring . tailMap ( hash ) ; hash = tailMap . isEmpty ( ) ? ring . firstKey ( ) : tailMap . firstKey ( ) ; info = ring . get ( hash ) ; return info ... | Returns the appropriate server for the given key . |
19,701 | public void addScenario ( Class < ? extends Scenario > scenarioClass , String scenarioID , String initialState , Properties properties , String gatewayDeviceID , String externalLinkID ) throws ShanksException { Constructor < ? extends Scenario > c ; Scenario scenario ; try { c = scenarioClass . getConstructor ( new Cla... | Add the scenario to the complex scenario . |
19,702 | public void addPossiblesFailuresComplex ( ) { Set < Scenario > scenarios = this . getScenarios ( ) ; for ( Scenario s : scenarios ) { for ( Class < ? extends Failure > c : s . getPossibleFailures ( ) . keySet ( ) ) { if ( ! this . getPossibleFailures ( ) . containsKey ( c ) ) { this . addPossibleFailure ( c , s . getPo... | Idem que con los eventos y los dupes |
19,703 | public void addPossiblesEventsComplex ( ) { Set < Scenario > scenarios = this . getScenarios ( ) ; for ( Scenario s : scenarios ) { for ( Class < ? extends Event > c : s . getPossibleEventsOfNE ( ) . keySet ( ) ) { if ( ! this . getPossibleEventsOfNE ( ) . containsKey ( c ) ) { this . addPossibleEventsOfNE ( c , s . ge... | J Anadido eventos de escenario y evitado la adiccion de duplicados |
19,704 | public < T > void setOption ( GestureOption < T > option , T value ) { hammertime . setOption ( option , value ) ; } | Change initial settings of this widget . |
19,705 | public void unregisterHandler ( EventType eventType ) { if ( ! jsHandlersMap . containsKey ( eventType ) ) { return ; } HammerGwt . off ( hammertime , eventType , ( NativeHammmerHandler ) jsHandlersMap . remove ( eventType ) ) ; } | Unregister Hammer Gwt handler . |
19,706 | private List < String > getChildrenList ( ) { if ( childrenList != null ) return childrenList ; SharedPreferences prefs = loadSharedPreferences ( "children" ) ; String list = prefs . getString ( getId ( ) , null ) ; childrenList = ( list == null ) ? new ArrayList < String > ( ) : new ArrayList < > ( Arrays . asList ( l... | Get a list of child objects ids . |
19,707 | public void addChild ( C child ) { SharedPreferences prefs = loadSharedPreferences ( "children" ) ; List < String > objects = getChildrenList ( ) ; Model toPut = ( Model ) child ; if ( objects . indexOf ( toPut . getId ( ) ) != ArrayUtils . INDEX_NOT_FOUND ) { return ; } objects . add ( toPut . getId ( ) ) ; toPut . sa... | Adds the object to the child ids list . |
19,708 | public boolean removeChild ( String id ) { SharedPreferences prefs = loadSharedPreferences ( "children" ) ; List < String > objects = getChildrenList ( ) ; if ( objects . indexOf ( id ) == ArrayUtils . INDEX_NOT_FOUND ) { return false ; } objects . remove ( id ) ; prefs . edit ( ) . putString ( String . valueOf ( getId... | Removes the object from the child ids list . |
19,709 | public C findChild ( String id ) { int index = getChildrenList ( ) . indexOf ( id ) ; if ( index == ArrayUtils . INDEX_NOT_FOUND ) { return null ; } C child = null ; try { Model dummy = ( Model ) childClazz . newInstance ( ) ; dummy . setContext ( context ) ; child = ( C ) dummy . find ( id ) ; } catch ( InstantiationE... | Find a specific object from the child list . |
19,710 | public List < C > findAllChildren ( ) { List < String > objects = getChildrenList ( ) ; List < C > children = new ArrayList < C > ( ) ; try { Model dummy = ( Model ) childClazz . newInstance ( ) ; dummy . setContext ( context ) ; for ( String id : objects ) { children . add ( ( C ) dummy . find ( id ) ) ; } } catch ( I... | Find all objects from the child list . |
19,711 | private Collection < Facet > filter ( Collection < Facet > facets ) { if ( NotStopWordPredicate == null ) { return facets ; } return facets . stream ( ) . filter ( NotStopWordPredicate ) . collect ( Collectors . toList ( ) ) ; } | Filter stop word facets |
19,712 | public ConsistentHashRing getRing ( String type ) { ConsistentHashRing ring = rings . get ( type ) ; if ( ring != null ) { return ring ; } if ( type == null ) { int selection = rand . nextInt ( ) % totalServers ; for ( ConsistentHashRing candidateRing : rings . values ( ) ) { if ( selection <= 0 ) { return candidateRin... | Get the server ring for a particular type . |
19,713 | public void add ( DOCUMENT doc ) { if ( doc != null ) { documents . add ( doc ) ; int id = documents . size ( ) - 1 ; for ( KEY key : documentMapper . apply ( doc ) ) { index . put ( key , id ) ; } } } | Add void . |
19,714 | public ScriptEnvironment getEnvironment ( String environmentName ) { Preconditions . checkArgument ( StringUtils . isNotNullOrBlank ( environmentName ) , "Environment name cannot be null or empty" ) ; ScriptEngine engine = engineManager . getEngineByName ( environmentName ) ; Preconditions . checkArgument ( engine != n... | Gets the scripting environment given the environment name . |
19,715 | public static ScriptEnvironment getTemporaryEnvironment ( String environmentName ) { Preconditions . checkArgument ( StringUtils . isNotNullOrBlank ( environmentName ) , "Environment name cannot be null or empty" ) ; ScriptEngine engine = ScriptEnvironmentManager . getInstance ( ) . engineManager . getEngineByName ( en... | Gets a temporary scripting environment given the environment name . |
19,716 | public String getEnvironmentNameForExtension ( String extension ) { Preconditions . checkArgument ( StringUtils . isNotNullOrBlank ( extension ) , "Extension name cannot be null or empty" ) ; ScriptEngine engine = engineManager . getEngineByExtension ( extension ) ; Preconditions . checkArgument ( engine != null , exte... | Gets the scripting environment name given the script extension . |
19,717 | public Set < Constructor < ? > > getConstructors ( boolean privileged ) { if ( privileged ) { return Collections . unmodifiableSet ( Sets . union ( constructors , declaredConstructors ) ) ; } else { return Collections . unmodifiableSet ( constructors ) ; } } | Gets constructors . |
19,718 | public Set < Field > getFields ( boolean privileged ) { if ( privileged ) { return Collections . unmodifiableSet ( Sets . union ( fields , declaredFields ) ) ; } else { return Collections . unmodifiableSet ( fields ) ; } } | Gets fields . |
19,719 | protected T getParentFromConfig ( ) { String parentName = Config . get ( canonicalName ( ) , "parent" ) . asString ( null ) ; if ( parentName != null && DynamicEnum . isDefined ( Cast . as ( getClass ( ) ) , parentName ) ) { return DynamicEnum . valueOf ( Cast . as ( getClass ( ) ) , parentName ) ; } else if ( parentNa... | Determines the parent via a configuration setting . |
19,720 | public static HttpHandler createRootHandler ( List < MappedEndpoint > mappedEndpoints , List < Interceptor > rootInterceptors , List < Interceptor > endpointInterceptors , ExceptionMapper exceptionMapper , String basePath , boolean httpTracer ) { final RoutingHandler routingRestHandler = new HttpRootHandler ( false ) ;... | chain of responsibility |
19,721 | private void increaseLevel ( boolean list ) { level ++ ; if ( hasData . length == level ) { hasData = Arrays . copyOf ( hasData , hasData . length * 2 ) ; lists = Arrays . copyOf ( lists , hasData . length * 2 ) ; } hasData [ level ] = false ; lists [ level ] = list ; } | Increase the level by one . |
19,722 | private void writeName ( String name ) throws IOException { if ( shouldOutputName ( ) ) { out . write ( TAG_KEY ) ; writeStringNoTag ( name ) ; } } | Write the name if needed . |
19,723 | private void writeIntegerNoTag ( int value ) throws IOException { while ( true ) { if ( ( value & ~ 0x7F ) == 0 ) { out . write ( value ) ; break ; } else { out . write ( ( value & 0x7f ) | 0x80 ) ; value >>>= 7 ; } } } | Write an integer to the output stream without tagging it . |
19,724 | private void writeInteger ( int value ) throws IOException { if ( value < 0 ) { out . write ( TAG_NEGATIVE_INT ) ; writeIntegerNoTag ( - value ) ; } else { out . write ( TAG_POSITIVE_INT ) ; writeIntegerNoTag ( value ) ; } } | Write an integer to the output stream . |
19,725 | public static boolean check ( String passwd , String hashed ) { try { String [ ] parts = hashed . split ( "\\$" ) ; if ( parts . length != 5 || ! parts [ 1 ] . equals ( "s0" ) ) { throw new IllegalArgumentException ( "Invalid hashed value" ) ; } long params = Long . parseLong ( parts [ 2 ] , 16 ) ; byte [ ] salt = deco... | Compare the supplied plaintext password to a hashed password . |
19,726 | public static Platform detect ( ) throws UnsupportedPlatformException { String osArch = getProperty ( "os.arch" ) ; String osName = getProperty ( "os.name" ) ; for ( Arch arch : Arch . values ( ) ) { if ( arch . pattern . matcher ( osArch ) . matches ( ) ) { for ( OS os : OS . values ( ) ) { if ( os . pattern . matcher... | Attempt to detect the current platform . |
19,727 | public < T > T getNodeMetaData ( Object key ) { if ( metaDataMap == null ) { return ( T ) null ; } return ( T ) metaDataMap . get ( key ) ; } | Gets the node meta data . |
19,728 | public void copyNodeMetaData ( ASTNode other ) { if ( other . metaDataMap == null ) { return ; } if ( metaDataMap == null ) { metaDataMap = new ListHashMap ( ) ; } metaDataMap . putAll ( other . metaDataMap ) ; } | Copies all node meta data from the other node to this one |
19,729 | public void setNodeMetaData ( Object key , Object value ) { if ( key == null ) throw new GroovyBugError ( "Tried to set meta data with null key on " + this + "." ) ; if ( metaDataMap == null ) { metaDataMap = new ListHashMap ( ) ; } Object old = metaDataMap . put ( key , value ) ; if ( old != null ) throw new GroovyBug... | Sets the node meta data . |
19,730 | public Object putNodeMetaData ( Object key , Object value ) { if ( key == null ) throw new GroovyBugError ( "Tried to set meta data with null key on " + this + "." ) ; if ( metaDataMap == null ) { metaDataMap = new ListHashMap ( ) ; } return metaDataMap . put ( key , value ) ; } | Sets the node meta data but allows overwriting values . |
19,731 | public void removeNodeMetaData ( Object key ) { if ( key == null ) throw new GroovyBugError ( "Tried to remove meta data with null key " + this + "." ) ; if ( metaDataMap == null ) { return ; } metaDataMap . remove ( key ) ; } | Removes a node meta data entry . |
19,732 | public RangeInfo subListBorders ( int size ) { if ( inclusive == null ) throw new IllegalStateException ( "Should not call subListBorders on a non-inclusive aware IntRange" ) ; int tempFrom = from ; if ( tempFrom < 0 ) { tempFrom += size ; } int tempTo = to ; if ( tempTo < 0 ) { tempTo += size ; } if ( tempFrom > tempT... | A method for determining from and to information when using this IntRange to index an aggregate object of the specified size . Normally only used internally within Groovy but useful if adding range indexing support for your own aggregates . |
19,733 | protected void createSetterMethod ( ClassNode declaringClass , PropertyNode propertyNode , String setterName , Statement setterBlock ) { MethodNode setter = new MethodNode ( setterName , propertyNode . getModifiers ( ) , ClassHelper . VOID_TYPE , params ( param ( propertyNode . getType ( ) , "value" ) ) , ClassNode . E... | Creates a setter method with the given body . |
19,734 | public void applyToPrimaryClassNodes ( PrimaryClassNodeOperation body ) throws CompilationFailedException { Iterator classNodes = getPrimaryClassNodes ( body . needSortedInput ( ) ) . iterator ( ) ; while ( classNodes . hasNext ( ) ) { SourceUnit context = null ; try { ClassNode classNode = ( ClassNode ) classNodes . n... | A loop driver for applying operations to all primary ClassNodes in our AST . Automatically skips units that have already been processed through the current phase . |
19,735 | public static < T > T withStreams ( Socket socket , @ ClosureParams ( value = SimpleType . class , options = { "java.io.InputStream" , "java.io.OutputStream" } ) Closure < T > closure ) throws IOException { InputStream input = socket . getInputStream ( ) ; OutputStream output = socket . getOutputStream ( ) ; try { T re... | Passes the Socket s InputStream and OutputStream to the closure . The streams will be closed after the closure returns even if an exception is thrown . |
19,736 | public static < T > T withObjectStreams ( Socket socket , @ ClosureParams ( value = SimpleType . class , options = { "java.io.ObjectInputStream" , "java.io.ObjectOutputStream" } ) Closure < T > closure ) throws IOException { InputStream input = socket . getInputStream ( ) ; OutputStream output = socket . getOutputStrea... | Creates an InputObjectStream and an OutputObjectStream from a Socket and passes them to the closure . The streams will be closed after the closure returns even if an exception is thrown . |
19,737 | public MethodKey createCopy ( ) { int size = getParameterCount ( ) ; Class [ ] paramTypes = new Class [ size ] ; for ( int i = 0 ; i < size ; i ++ ) { paramTypes [ i ] = getParameterType ( i ) ; } return new DefaultMethodKey ( sender , name , paramTypes , isCallToSuper ) ; } | Creates an immutable copy that we can cache . |
19,738 | public static void doExtendTraits ( final ClassNode cNode , final SourceUnit unit , final CompilationUnit cu ) { if ( cNode . isInterface ( ) ) return ; boolean isItselfTrait = Traits . isTrait ( cNode ) ; SuperCallTraitTransformer superCallTransformer = new SuperCallTraitTransformer ( unit ) ; if ( isItselfTrait ) { c... | Given a class node if this class node implements a trait then generate all the appropriate code which delegates calls to the trait . It is safe to call this method on a class node which does not implement a trait . |
19,739 | public SyntaxException getSyntaxError ( int index ) { SyntaxException exception = null ; Message message = getError ( index ) ; if ( message != null && message instanceof SyntaxErrorMessage ) { exception = ( ( SyntaxErrorMessage ) message ) . getCause ( ) ; } return exception ; } | Convenience routine to return the specified error s underlying SyntaxException or null if it isn t one . |
19,740 | private void gobble ( Iterator iter ) { if ( eatTheRest ) { while ( iter . hasNext ( ) ) { tokens . add ( iter . next ( ) ) ; } } } | Adds the remaining tokens to the processed tokens list . |
19,741 | public static int allParametersAndArgumentsMatch ( Parameter [ ] params , ClassNode [ ] args ) { if ( params == null ) { params = Parameter . EMPTY_ARRAY ; } int dist = 0 ; if ( args . length < params . length ) return - 1 ; for ( int i = 0 ; i < params . length ; i ++ ) { ClassNode paramType = params [ i ] . getType (... | Checks that arguments and parameter types match . |
19,742 | static int excessArgumentsMatchesVargsParameter ( Parameter [ ] params , ClassNode [ ] args ) { int dist = 0 ; ClassNode vargsBase = params [ params . length - 1 ] . getType ( ) . getComponentType ( ) ; for ( int i = params . length ; i < args . length ; i ++ ) { if ( ! isAssignableTo ( args [ i ] , vargsBase ) ) retur... | Checks that excess arguments match the vararg signature parameter . |
19,743 | static int lastArgMatchesVarg ( Parameter [ ] params , ClassNode ... args ) { if ( ! isVargs ( params ) ) return - 1 ; ClassNode lastParamType = params [ params . length - 1 ] . getType ( ) ; ClassNode ptype = lastParamType . getComponentType ( ) ; ClassNode arg = args [ args . length - 1 ] ; if ( isNumberType ( ptype ... | Checks if the last argument matches the vararg type . |
19,744 | private static Parameter buildParameter ( final Map < String , GenericsType > genericFromReceiver , final Map < String , GenericsType > placeholdersFromContext , final Parameter methodParameter , final ClassNode paramType ) { if ( genericFromReceiver . isEmpty ( ) && ( placeholdersFromContext == null || placeholdersFro... | Given a parameter builds a new parameter for which the known generics placeholders are resolved . |
19,745 | public static boolean isClassClassNodeWrappingConcreteType ( ClassNode classNode ) { GenericsType [ ] genericsTypes = classNode . getGenericsTypes ( ) ; return ClassHelper . CLASS_Type . equals ( classNode ) && classNode . isUsingGenerics ( ) && genericsTypes != null && ! genericsTypes [ 0 ] . isPlaceholder ( ) && ! ge... | Returns true if the class node represents a the class node for the Class class and if the parametrized type is a neither a placeholder or a wildcard . For example the class node Class< ; Foo> ; where Foo is a class would return true but the class node for Class< ; ?> ; would return false . |
19,746 | public static < T > T splitEachLine ( InputStream stream , String regex , String charset , @ ClosureParams ( value = FromString . class , options = "List<String>" ) Closure < T > closure ) throws IOException { return splitEachLine ( new BufferedReader ( new InputStreamReader ( stream , charset ) ) , regex , closure ) ;... | Iterates through the given InputStream line by line using the specified encoding splitting each line using the given separator . The list of tokens for each line is then passed to the given closure . Finally the stream is closed . |
19,747 | public static void transformChar ( Reader self , Writer writer , @ ClosureParams ( value = SimpleType . class , options = "java.lang.String" ) Closure closure ) throws IOException { int c ; try { char [ ] chars = new char [ 1 ] ; while ( ( c = self . read ( ) ) != - 1 ) { chars [ 0 ] = ( char ) c ; writer . write ( ( S... | Transforms each character from this reader by passing it to the given closure . The Closure should return each transformed character which will be passed to the Writer . The reader and writer will be both be closed before this method returns . |
19,748 | public static < T , U extends Closeable > T withCloseable ( U self , @ ClosureParams ( value = FirstParam . class ) Closure < T > action ) throws IOException { try { T result = action . call ( self ) ; Closeable temp = self ; self = null ; temp . close ( ) ; return result ; } finally { DefaultGroovyMethodsSupport . clo... | Allows this closeable to be used within the closure ensuring that it is closed once the closure has been executed and before this method returns . |
19,749 | public Object getProperty ( Object object ) { return java . lang . reflect . Array . getLength ( object ) ; } | Get this property from the given object . |
19,750 | protected MethodVisitor makeDelegateCall ( final String name , final String desc , final String signature , final String [ ] exceptions , final int accessFlags ) { MethodVisitor mv = super . visitMethod ( accessFlags , name , desc , signature , exceptions ) ; mv . visitVarInsn ( ALOAD , 0 ) ; mv . visitFieldInsn ( GETF... | Generate a call to the delegate object . |
19,751 | public static Method getSAMMethod ( Class < ? > c ) { if ( ! Modifier . isAbstract ( c . getModifiers ( ) ) ) return null ; if ( c . isInterface ( ) ) { Method [ ] methods = c . getMethods ( ) ; Method res = null ; for ( Method mi : methods ) { if ( ! Modifier . isAbstract ( mi . getModifiers ( ) ) ) continue ; if ( mi... | returns the abstract method from a SAM type if it is a SAM type . |
19,752 | protected void generateMopCalls ( LinkedList < MethodNode > mopCalls , boolean useThis ) { for ( MethodNode method : mopCalls ) { String name = getMopMethodName ( method , useThis ) ; Parameter [ ] parameters = method . getParameters ( ) ; String methodDescriptor = BytecodeHelper . getMethodDescriptor ( method . getRet... | generates a Meta Object Protocol method that is used to call a non public method or to make a call to super . |
19,753 | public static ClassNode getWrapper ( ClassNode cn ) { cn = cn . redirect ( ) ; if ( ! isPrimitiveType ( cn ) ) return cn ; if ( cn == boolean_TYPE ) { return Boolean_TYPE ; } else if ( cn == byte_TYPE ) { return Byte_TYPE ; } else if ( cn == char_TYPE ) { return Character_TYPE ; } else if ( cn == short_TYPE ) { return ... | Creates a ClassNode containing the wrapper of a ClassNode of primitive type . Any ClassNode representing a primitive type should be created using the predefined types used in class . The method will check the parameter for known references of ClassNode representing a primitive type . If Reference is found then a ClassN... |
19,754 | public static MethodNode findSAM ( ClassNode type ) { if ( ! Modifier . isAbstract ( type . getModifiers ( ) ) ) return null ; if ( type . isInterface ( ) ) { List < MethodNode > methods = type . getMethods ( ) ; MethodNode found = null ; for ( MethodNode mi : methods ) { if ( ! Modifier . isAbstract ( mi . getModifier... | Returns the single abstract method of a class node if it is a SAM type or null otherwise . |
19,755 | public static int getPrecedence ( int type , boolean throwIfInvalid ) { switch ( type ) { case LEFT_PARENTHESIS : return 0 ; case EQUAL : case PLUS_EQUAL : case MINUS_EQUAL : case MULTIPLY_EQUAL : case DIVIDE_EQUAL : case INTDIV_EQUAL : case MOD_EQUAL : case POWER_EQUAL : case LOGICAL_OR_EQUAL : case LOGICAL_AND_EQUAL ... | Returns the precedence of the specified operator . Non - operator s will receive - 1 or a GroovyBugError depending on your preference . |
19,756 | public < T > T with ( Closure < T > closure ) { return DefaultGroovyMethods . with ( null , closure ) ; } | Allows the closure to be called for NullObject |
19,757 | private static boolean implementsMethod ( ClassNode classNode , String methodName , Class [ ] argTypes ) { List methods = classNode . getMethods ( ) ; if ( argTypes == null || argTypes . length == 0 ) { for ( Iterator i = methods . iterator ( ) ; i . hasNext ( ) ; ) { MethodNode mn = ( MethodNode ) i . next ( ) ; boole... | Tests whether the ClassNode implements the specified method name |
19,758 | public String getTypeDescriptor ( ) { if ( typeDescriptor == null ) { StringBuilder buf = new StringBuilder ( name . length ( ) + parameters . length * 10 ) ; buf . append ( returnType . getName ( ) ) ; buf . append ( ' ' ) ; buf . append ( name ) ; buf . append ( '(' ) ; for ( int i = 0 ; i < parameters . length ; i +... | The type descriptor for a method node is a string containing the name of the method its return type and its parameter types in a canonical form . For simplicity I m using the format of a Java declaration without parameter names . |
19,759 | public String getText ( ) { String retType = AstToTextHelper . getClassText ( returnType ) ; String exceptionTypes = AstToTextHelper . getThrowsClauseText ( exceptions ) ; String parms = AstToTextHelper . getParametersText ( parameters ) ; return AstToTextHelper . getModifiersText ( modifiers ) + " " + retType + " " + ... | Provides a nicely formatted string of the method definition . For simplicity generic types on some of the elements are not displayed . |
19,760 | public GroovyConstructorDoc [ ] constructors ( ) { Collections . sort ( constructors ) ; return constructors . toArray ( new GroovyConstructorDoc [ constructors . size ( ) ] ) ; } | returns a sorted array of constructors |
19,761 | public GroovyClassDoc [ ] innerClasses ( ) { Collections . sort ( nested ) ; return nested . toArray ( new GroovyClassDoc [ nested . size ( ) ] ) ; } | returns a sorted array of nested classes and interfaces |
19,762 | public GroovyFieldDoc [ ] fields ( ) { Collections . sort ( fields ) ; return fields . toArray ( new GroovyFieldDoc [ fields . size ( ) ] ) ; } | returns a sorted array of fields |
19,763 | public GroovyFieldDoc [ ] properties ( ) { Collections . sort ( properties ) ; return properties . toArray ( new GroovyFieldDoc [ properties . size ( ) ] ) ; } | returns a sorted array of properties |
19,764 | public GroovyFieldDoc [ ] enumConstants ( ) { Collections . sort ( enumConstants ) ; return enumConstants . toArray ( new GroovyFieldDoc [ enumConstants . size ( ) ] ) ; } | returns a sorted array of enum constants |
19,765 | public GroovyMethodDoc [ ] methods ( ) { Collections . sort ( methods ) ; return methods . toArray ( new GroovyMethodDoc [ methods . size ( ) ] ) ; } | returns a sorted array of methods |
19,766 | public void add ( Map < String , Object > map ) throws SQLException { if ( withinDataSetBatch ) { if ( batchData . size ( ) == 0 ) { batchKeys = map . keySet ( ) ; } else { if ( ! map . keySet ( ) . equals ( batchKeys ) ) { throw new IllegalArgumentException ( "Inconsistent keys found for batch add!" ) ; } } batchData ... | Adds the provided map of key - value pairs as a new row in the table represented by this DataSet . |
19,767 | public void each ( int offset , int maxRows , Closure closure ) throws SQLException { eachRow ( getSql ( ) , getParameters ( ) , offset , maxRows , closure ) ; } | Calls the provided closure for a page of rows from the table represented by this DataSet . A page is defined as starting at a 1 - based offset and containing a maximum number of rows . |
19,768 | private void wrapSetterMethod ( ClassNode classNode , boolean bindable , String propertyName ) { String getterName = "get" + MetaClassHelper . capitalize ( propertyName ) ; MethodNode setter = classNode . getSetterMethod ( "set" + MetaClassHelper . capitalize ( propertyName ) ) ; if ( setter != null ) { Statement code ... | Wrap an existing setter . |
19,769 | public static long directorySize ( File self ) throws IOException , IllegalArgumentException { final long [ ] size = { 0L } ; eachFileRecurse ( self , FileType . FILES , new Closure < Void > ( null ) { public void doCall ( Object [ ] args ) { size [ 0 ] += ( ( File ) args [ 0 ] ) . length ( ) ; } } ) ; return size [ 0 ... | Calculates directory size as total size of all its files recursively . |
19,770 | public static < T > T splitEachLine ( File self , String regex , @ ClosureParams ( value = SimpleType . class , options = "java.lang.String[]" ) Closure < T > closure ) throws IOException { return IOGroovyMethods . splitEachLine ( newReader ( self ) , regex , closure ) ; } | Iterates through this file line by line splitting each line using the given regex separator . For each line the given closure is called with a single parameter being the list of strings computed by splitting the line around matches of the given regular expression . Finally the resources used for processing the file are... |
19,771 | public static void write ( File file , String text , String charset ) throws IOException { Writer writer = null ; try { FileOutputStream out = new FileOutputStream ( file ) ; writeUTF16BomIfRequired ( charset , out ) ; writer = new OutputStreamWriter ( out , charset ) ; writer . write ( text ) ; writer . flush ( ) ; Wr... | Write the text to the File using the specified encoding . |
19,772 | public static void append ( File file , Object text ) throws IOException { Writer writer = null ; try { writer = new FileWriter ( file , true ) ; InvokerHelper . write ( writer , text ) ; writer . flush ( ) ; Writer temp = writer ; writer = null ; temp . close ( ) ; } finally { closeWithWarning ( writer ) ; } } | Append the text at the end of the File . |
19,773 | public static void append ( File file , Object text , String charset ) throws IOException { Writer writer = null ; try { FileOutputStream out = new FileOutputStream ( file , true ) ; if ( ! file . exists ( ) ) { writeUTF16BomIfRequired ( charset , out ) ; } writer = new OutputStreamWriter ( out , charset ) ; InvokerHel... | Append the text at the end of the File using a specified encoding . |
19,774 | public static void append ( File file , Writer writer , String charset ) throws IOException { appendBuffered ( file , writer , charset ) ; } | Append the text supplied by the Writer at the end of the File using a specified encoding . |
19,775 | private static void writeUtf16Bom ( OutputStream stream , boolean bigEndian ) throws IOException { if ( bigEndian ) { stream . write ( - 2 ) ; stream . write ( - 1 ) ; } else { stream . write ( - 1 ) ; stream . write ( - 2 ) ; } } | Write a Byte Order Mark at the beginning of the file |
19,776 | protected Class getClassCacheEntry ( String name ) { if ( name == null ) return null ; synchronized ( classCache ) { return classCache . get ( name ) ; } } | gets a class from the class cache . This cache contains only classes loaded through this class loader or an InnerLoader instance . If no class is stored for a specific name then the method should return null . |
19,777 | public MetaClassRegistryChangeEventListener [ ] getMetaClassRegistryChangeEventListeners ( ) { synchronized ( changeListenerList ) { ArrayList < MetaClassRegistryChangeEventListener > ret = new ArrayList < MetaClassRegistryChangeEventListener > ( changeListenerList . size ( ) + nonRemoveableChangeListenerList . size ( ... | Gets an array of of all registered ConstantMetaClassListener instances . |
19,778 | public static MetaClassRegistry getInstance ( int includeExtension ) { if ( includeExtension != DONT_LOAD_DEFAULT ) { if ( instanceInclude == null ) { instanceInclude = new MetaClassRegistryImpl ( ) ; } return instanceInclude ; } else { if ( instanceExclude == null ) { instanceExclude = new MetaClassRegistryImpl ( DONT... | Singleton of MetaClassRegistry . |
19,779 | public CSTNode get ( int index ) { CSTNode element = null ; if ( index < size ( ) ) { element = ( CSTNode ) elements . get ( index ) ; } return element ; } | Returns the specified element or null . |
19,780 | public CSTNode set ( int index , CSTNode element ) { if ( elements == null ) { throw new GroovyBugError ( "attempt to set() on a EMPTY Reduction" ) ; } if ( index == 0 && ! ( element instanceof Token ) ) { throw new GroovyBugError ( "attempt to set() a non-Token as root of a Reduction" ) ; } int count = elements . size... | Sets an element in at the specified index . |
19,781 | public void add ( T value ) { Element < T > element = new Element < T > ( bundle , value ) ; element . previous = tail ; if ( tail != null ) tail . next = element ; tail = element ; if ( head == null ) head = element ; } | adds a value to the list |
19,782 | public T [ ] toArray ( T [ ] tArray ) { List < T > array = new ArrayList < T > ( 100 ) ; for ( Iterator < T > it = iterator ( ) ; it . hasNext ( ) ; ) { T val = it . next ( ) ; if ( val != null ) array . add ( val ) ; } return array . toArray ( tArray ) ; } | Returns an array of non null elements from the source array . |
19,783 | public Value get ( Object key ) { if ( map == null && items . length < 20 ) { for ( Object item : items ) { MapItemValue miv = ( MapItemValue ) item ; if ( key . equals ( miv . name . toValue ( ) ) ) { return miv . value ; } } return null ; } else { if ( map == null ) buildIfNeededMap ( ) ; return map . get ( key ) ; }... | Get the items for the key . |
19,784 | public static < T > Iterator < T > unique ( Iterator < T > self ) { return toList ( ( Iterable < T > ) unique ( toList ( self ) ) ) . listIterator ( ) ; } | Returns an iterator equivalent to this iterator with all duplicated items removed by using the default comparator . The original iterator will become exhausted of elements after determining the unique values . A new iterator for the unique values will be returned . |
19,785 | public static int numberAwareCompareTo ( Comparable self , Comparable other ) { NumberAwareComparator < Comparable > numberAwareComparator = new NumberAwareComparator < Comparable > ( ) ; return numberAwareComparator . compare ( self , other ) ; } | Provides a method that compares two comparables using Groovy s default number aware comparator . |
19,786 | public static boolean any ( Object self , Closure closure ) { BooleanClosureWrapper bcw = new BooleanClosureWrapper ( closure ) ; for ( Iterator iter = InvokerHelper . asIterator ( self ) ; iter . hasNext ( ) ; ) { if ( bcw . call ( iter . next ( ) ) ) return true ; } return false ; } | Iterates over the contents of an object or collection and checks whether a predicate is valid for at least one element . |
19,787 | public static Object findResult ( Object self , Object defaultResult , Closure closure ) { Object result = findResult ( self , closure ) ; if ( result == null ) return defaultResult ; return result ; } | Treats the object as iterable iterating through the values it represents and returns the first non - null result obtained from calling the closure otherwise returns the defaultResult . |
19,788 | protected static < K , T > void groupAnswer ( final Map < K , List < T > > answer , T element , K value ) { if ( answer . containsKey ( value ) ) { answer . get ( value ) . add ( element ) ; } else { List < T > groupedElements = new ArrayList < T > ( ) ; groupedElements . add ( element ) ; answer . put ( value , groupe... | Groups the current element according to the value |
19,789 | public static < K , V > Map < K , V > asImmutable ( Map < ? extends K , ? extends V > self ) { return Collections . unmodifiableMap ( self ) ; } | A convenience method for creating an immutable map . |
19,790 | public static < K , V > SortedMap < K , V > asImmutable ( SortedMap < K , ? extends V > self ) { return Collections . unmodifiableSortedMap ( self ) ; } | A convenience method for creating an immutable sorted map . |
19,791 | public static < T > List < T > asImmutable ( List < ? extends T > self ) { return Collections . unmodifiableList ( self ) ; } | A convenience method for creating an immutable list |
19,792 | public static < T > Set < T > asImmutable ( Set < ? extends T > self ) { return Collections . unmodifiableSet ( self ) ; } | A convenience method for creating an immutable list . |
19,793 | public static < T > SortedSet < T > asImmutable ( SortedSet < T > self ) { return Collections . unmodifiableSortedSet ( self ) ; } | A convenience method for creating an immutable sorted set . |
19,794 | public static < T > T [ ] sort ( T [ ] self , Comparator < T > comparator ) { return sort ( self , true , comparator ) ; } | Sorts the given array into sorted order using the given comparator . |
19,795 | public static < T > boolean addAll ( Collection < T > self , Iterator < T > items ) { boolean changed = false ; while ( items . hasNext ( ) ) { T next = items . next ( ) ; if ( self . add ( next ) ) changed = true ; } return changed ; } | Adds all items from the iterator to the Collection . |
19,796 | public static < T > boolean addAll ( Collection < T > self , Iterable < T > items ) { boolean changed = false ; for ( T next : items ) { if ( self . add ( next ) ) changed = true ; } return changed ; } | Adds all items from the iterable to the Collection . |
19,797 | public static < K , V > Map < K , V > minus ( Map < K , V > self , Map removeMe ) { final Map < K , V > ansMap = createSimilarMap ( self ) ; ansMap . putAll ( self ) ; if ( removeMe != null && removeMe . size ( ) > 0 ) { for ( Map . Entry < K , V > e1 : self . entrySet ( ) ) { for ( Object e2 : removeMe . entrySet ( ) ... | Create a Map composed of the entries of the first map minus the entries of the given map . |
19,798 | public static int findLastIndexOf ( Object self , int startIndex , Closure closure ) { int result = - 1 ; int i = 0 ; BooleanClosureWrapper bcw = new BooleanClosureWrapper ( closure ) ; for ( Iterator iter = InvokerHelper . asIterator ( self ) ; iter . hasNext ( ) ; i ++ ) { Object value = iter . next ( ) ; if ( i < st... | Iterates over the elements of an iterable collection of items starting from a specified startIndex and returns the index of the last item that matches the condition specified in the closure . |
19,799 | public static List < Number > findIndexValues ( Object self , Closure closure ) { return findIndexValues ( self , 0 , closure ) ; } | Iterates over the elements of an iterable collection of items and returns the index values of the items that match the condition specified in the closure . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.