idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
6,600 | public void refreshInheritedMethods ( Set modifiedSuperExpandos ) { for ( Iterator i = modifiedSuperExpandos . iterator ( ) ; i . hasNext ( ) ; ) { ExpandoMetaClass superExpando = ( ExpandoMetaClass ) i . next ( ) ; if ( superExpando != this ) { refreshInheritedMethods ( superExpando ) ; } } } | Called from ExpandoMetaClassCreationHandle in the registry if it exists to set up inheritance handling |
6,601 | public Object invokeMethod ( Class sender , Object object , String methodName , Object [ ] originalArguments , boolean isCallToSuper , boolean fromInsideClass ) { if ( invokeMethodMethod != null ) { MetaClassHelper . unwrap ( originalArguments ) ; return invokeMethodMethod . invoke ( object , new Object [ ] { methodNam... | Overrides default implementation just in case invokeMethod has been overridden by ExpandoMetaClass |
6,602 | public Object invokeStaticMethod ( Object object , String methodName , Object [ ] arguments ) { if ( invokeStaticMethodMethod != null ) { MetaClassHelper . unwrap ( arguments ) ; return invokeStaticMethodMethod . invoke ( object , new Object [ ] { methodName , arguments } ) ; } return super . invokeStaticMethod ( objec... | Overrides default implementation just in case a static invoke method has been set on ExpandoMetaClass |
6,603 | public void setProperty ( Class sender , Object object , String name , Object newValue , boolean useSuper , boolean fromInsideClass ) { if ( setPropertyMethod != null && ! name . equals ( META_CLASS_PROPERTY ) && getJavaClass ( ) . isInstance ( object ) ) { setPropertyMethod . invoke ( object , new Object [ ] { name , ... | Overrides default implementation just in case setProperty method has been overridden by ExpandoMetaClass |
6,604 | public MetaProperty getMetaProperty ( String name ) { MetaProperty mp = this . expandoProperties . get ( name ) ; if ( mp != null ) return mp ; return super . getMetaProperty ( name ) ; } | Looks up an existing MetaProperty by name |
6,605 | private static boolean isPropertyName ( String name ) { return ( ( name . length ( ) > 0 ) && Character . isUpperCase ( name . charAt ( 0 ) ) ) || ( ( name . length ( ) > 1 ) && Character . isUpperCase ( name . charAt ( 1 ) ) ) ; } | Determine if this method name suffix is a legitimate bean property name . Either the first or second letter must be upperCase for that to be true . |
6,606 | private boolean isGetter ( String name , CachedClass [ ] args ) { if ( name == null || name . length ( ) == 0 || args == null ) return false ; if ( args . length != 0 ) return false ; if ( name . startsWith ( "get" ) ) { name = name . substring ( 3 ) ; return isPropertyName ( name ) ; } else if ( name . startsWith ( "i... | Returns true if the name of the method specified and the number of arguments make it a javabean property |
6,607 | private String getPropertyForGetter ( String getterName ) { if ( getterName == null || getterName . length ( ) == 0 ) return null ; if ( getterName . startsWith ( "get" ) ) { String prop = getterName . substring ( 3 ) ; return MetaClassHelper . convertPropertyName ( prop ) ; } else if ( getterName . startsWith ( "is" )... | Returns a property name equivalent for the given getter name or null if it is not a getter |
6,608 | public String getPropertyForSetter ( String setterName ) { if ( setterName == null || setterName . length ( ) == 0 ) return null ; if ( setterName . startsWith ( "set" ) ) { String prop = setterName . substring ( 3 ) ; return MetaClassHelper . convertPropertyName ( prop ) ; } return null ; } | Returns a property name equivalent for the given setter name or null if it is not a getter |
6,609 | public static String getText ( int type ) { String text = "" ; if ( TEXTS . containsKey ( type ) ) { text = TEXTS . get ( type ) ; } return text ; } | Returns the text for the specified type . Returns if the text isn t found . |
6,610 | private static void addTranslation ( String text , int type ) { TEXTS . put ( type , text ) ; LOOKUP . put ( text , type ) ; } | Adds a element to the TEXTS and LOOKUP . |
6,611 | private static void addKeyword ( String text , int type ) { KEYWORDS . add ( text ) ; addTranslation ( text , type ) ; } | Adds a element to the KEYWORDS TEXTS and LOOKUP . |
6,612 | private static void addDescription ( int type , String description ) { if ( description . startsWith ( "<" ) && description . endsWith ( ">" ) ) { DESCRIPTIONS . put ( type , description ) ; } else { DESCRIPTIONS . put ( type , '"' + description + '"' ) ; } } | Adds a description to the set . |
6,613 | public String text ( ) { final StringBuilder sb = new StringBuilder ( ) ; for ( Object child : this . children ) { if ( child instanceof Node ) { sb . append ( ( ( Node ) child ) . text ( ) ) ; } else { sb . append ( child ) ; } } return sb . toString ( ) ; } | Returns a string containing the text of the children of this Node . |
6,614 | public Iterator childNodes ( ) { return new Iterator ( ) { private final Iterator iter = Node . this . children . iterator ( ) ; private Object nextElementNodes = getNextElementNodes ( ) ; public boolean hasNext ( ) { return this . nextElementNodes != null ; } public Object next ( ) { try { return this . nextElementNod... | Returns an iterator over the child nodes of this Node . |
6,615 | public Object getAt ( int index ) throws SQLException { index = normalizeIndex ( index ) ; return getResultSet ( ) . getObject ( index ) ; } | Supports integer based subscript operators for accessing at numbered columns starting at zero . Negative indices are supported they will count from the last column backwards . |
6,616 | public void putAt ( int index , Object newValue ) throws SQLException { index = normalizeIndex ( index ) ; getResultSet ( ) . updateObject ( index , newValue ) ; } | Supports integer based subscript operators for updating the values of numbered columns starting at zero . Negative indices are supported they will count from the last column backwards . |
6,617 | public void add ( Map values ) throws SQLException { getResultSet ( ) . moveToInsertRow ( ) ; for ( Iterator iter = values . entrySet ( ) . iterator ( ) ; iter . hasNext ( ) ; ) { Map . Entry entry = ( Map . Entry ) iter . next ( ) ; getResultSet ( ) . updateObject ( entry . getKey ( ) . toString ( ) , entry . getValue... | Adds a new row to the result set |
6,618 | protected int normalizeIndex ( int index ) throws SQLException { if ( index < 0 ) { int columnCount = getResultSet ( ) . getMetaData ( ) . getColumnCount ( ) ; do { index += columnCount ; } while ( index < 0 ) ; } return index + 1 ; } | Takes a zero based index and convert it into an SQL based 1 based index . A negative index will count backwards from the last column . |
6,619 | private void postProcessClassDocs ( ) { for ( GroovyClassDoc groovyClassDoc : classDocs . values ( ) ) { SimpleGroovyClassDoc classDoc = ( SimpleGroovyClassDoc ) groovyClassDoc ; if ( classDoc . isClass ( ) ) { GroovyConstructorDoc [ ] constructors = classDoc . constructors ( ) ; if ( constructors != null && constructo... | Step through ClassDocs and tie up loose ends |
6,620 | private boolean processModifiers ( GroovySourceAST t , SimpleGroovyAbstractableElementDoc memberOrClass ) { GroovySourceAST modifiers = t . childOfType ( MODIFIERS ) ; boolean hasNonPublicVisibility = false ; boolean hasPublicVisibility = false ; if ( modifiers != null ) { AST currentModifier = modifiers . getFirstChil... | return true if a property is found |
6,621 | private String getJavaDocCommentsBeforeNode ( GroovySourceAST t ) { String result = "" ; LineColumn thisLineCol = new LineColumn ( t . getLine ( ) , t . getColumn ( ) ) ; String text = sourceBuffer . getSnippet ( lastLineCol , thisLineCol ) ; if ( text != null ) { Matcher m = PREV_JAVADOC_COMMENT_PATTERN . matcher ( te... | todo - If no comment before node then get comment from same node on parent class - ouch! |
6,622 | public static byte [ ] decodeHex ( final String value ) { if ( value . length ( ) % 2 != 0 ) { throw new NumberFormatException ( "odd number of characters in hex string" ) ; } byte [ ] bytes = new byte [ value . length ( ) / 2 ] ; for ( int i = 0 ; i < value . length ( ) ; i += 2 ) { bytes [ i / 2 ] = ( byte ) Integer ... | Decodes a hex string to a byte array . The hex string can contain either upper case or lower case letters . |
6,623 | public static String digest ( CharSequence self , String algorithm ) throws NoSuchAlgorithmException { final String text = self . toString ( ) ; return digest ( text . getBytes ( StandardCharsets . UTF_8 ) , algorithm ) ; } | digest the CharSequence instance |
6,624 | public static String digest ( byte [ ] self , String algorithm ) throws NoSuchAlgorithmException { MessageDigest md = MessageDigest . getInstance ( algorithm ) ; md . update ( ByteBuffer . wrap ( self ) ) ; return encodeHex ( md . digest ( ) ) . toString ( ) ; } | digest the byte array |
6,625 | public void compile ( File file ) throws CompilationFailedException { CompilationUnit unit = new CompilationUnit ( configuration ) ; unit . addSource ( file ) ; unit . compile ( ) ; } | Compiles a single File . |
6,626 | public void compile ( File [ ] files ) throws CompilationFailedException { CompilationUnit unit = new CompilationUnit ( configuration ) ; unit . addSources ( files ) ; unit . compile ( ) ; } | Compiles a series of Files . |
6,627 | public void compile ( String [ ] files ) throws CompilationFailedException { CompilationUnit unit = new CompilationUnit ( configuration ) ; unit . addSources ( files ) ; unit . compile ( ) ; } | Compiles a series of Files from file names . |
6,628 | public void compile ( String name , String code ) throws CompilationFailedException { CompilationUnit unit = new CompilationUnit ( configuration ) ; unit . addSource ( new SourceUnit ( name , code , configuration , unit . getClassLoader ( ) , unit . getErrorCollector ( ) ) ) ; unit . compile ( ) ; } | Compiles a string of code . |
6,629 | public String [ ] getClassProps ( ) { String [ ] result = new String [ CLASS_OTHER_IDX + 1 ] ; Package pack = getClassUnderInspection ( ) . getPackage ( ) ; result [ CLASS_PACKAGE_IDX ] = "package " + ( ( pack == null ) ? NOT_APPLICABLE : pack . getName ( ) ) ; String modifiers = Modifier . toString ( getClassUnderInsp... | Get the Class Properties of the object under inspection . |
6,630 | public Object [ ] getMethods ( ) { Method [ ] methods = getClassUnderInspection ( ) . getMethods ( ) ; Constructor [ ] ctors = getClassUnderInspection ( ) . getConstructors ( ) ; Object [ ] result = new Object [ methods . length + ctors . length ] ; int resultIndex = 0 ; for ( ; resultIndex < methods . length ; resultI... | Get info about usual Java instance and class Methods as well as Constructors . |
6,631 | public Object [ ] getMetaMethods ( ) { MetaClass metaClass = InvokerHelper . getMetaClass ( objectUnderInspection ) ; List metaMethods = metaClass . getMetaMethods ( ) ; Object [ ] result = new Object [ metaMethods . size ( ) ] ; int i = 0 ; for ( Iterator iter = metaMethods . iterator ( ) ; iter . hasNext ( ) ; i ++ )... | Get info about instance and class Methods that are dynamically added through Groovy . |
6,632 | public Object [ ] getPublicFields ( ) { Field [ ] fields = getClassUnderInspection ( ) . getFields ( ) ; Object [ ] result = new Object [ fields . length ] ; for ( int i = 0 ; i < fields . length ; i ++ ) { Field field = fields [ i ] ; result [ i ] = fieldInfo ( field ) ; } return result ; } | Get info about usual Java public fields incl . constants . |
6,633 | public static BinaryExpression newAssignmentExpression ( Variable variable , Expression rhs ) { VariableExpression lhs = new VariableExpression ( variable ) ; Token operator = Token . newPlaceholder ( Types . ASSIGN ) ; return new BinaryExpression ( lhs , operator , rhs ) ; } | Creates an assignment expression in which the specified expression is written into the specified variable name . |
6,634 | public static BinaryExpression newInitializationExpression ( String variable , ClassNode type , Expression rhs ) { VariableExpression lhs = new VariableExpression ( variable ) ; if ( type != null ) { lhs . setType ( type ) ; } Token operator = Token . newPlaceholder ( Types . ASSIGN ) ; return new BinaryExpression ( lh... | Creates variable initialization expression in which the specified expression is written into the specified variable name . |
6,635 | protected static MethodHandle makeFallBack ( MutableCallSite mc , Class < ? > sender , String name , int callID , MethodType type , boolean safeNavigation , boolean thisCall , boolean spreadCall ) { MethodHandle mh = MethodHandles . insertArguments ( SELECT_METHOD , 0 , mc , sender , name , callID , safeNavigation , th... | Makes a fallback method for an invalidated method selection |
6,636 | public static Object selectMethod ( MutableCallSite callSite , Class sender , String methodName , int callID , Boolean safeNavigation , Boolean thisCall , Boolean spreadCall , Object dummyReceiver , Object [ ] arguments ) throws Throwable { Selector selector = Selector . getSelector ( callSite , sender , methodName , c... | Core method for indy method selection using runtime types . |
6,637 | private void addDelegateFields ( ) { visitField ( ACC_PRIVATE + ACC_FINAL , CLOSURES_MAP_FIELD , "Ljava/util/Map;" , null , null ) ; if ( generateDelegateField ) { visitField ( ACC_PRIVATE + ACC_FINAL , DELEGATE_OBJECT_FIELD , BytecodeHelper . getTypeDescription ( delegateClass ) , null , null ) ; } } | Creates delegate fields for every closure defined in the map . |
6,638 | @ SuppressWarnings ( "unchecked" ) public static Closure ensureClosure ( Object o ) { if ( o == null ) throw new UnsupportedOperationException ( ) ; if ( o instanceof Closure ) return ( Closure ) o ; return new ReturnValueWrappingClosure ( o ) ; } | Ensures that the provided object is wrapped into a closure if it s not a closure . Do not trust IDEs this method is used in bytecode . |
6,639 | public static String convertYamlToJson ( Reader yamlReader ) { try ( Reader reader = yamlReader ) { Object yaml = new ObjectMapper ( new YAMLFactory ( ) ) . readValue ( reader , Object . class ) ; return new ObjectMapper ( ) . writeValueAsString ( yaml ) ; } catch ( IOException e ) { throw new YamlRuntimeException ( e ... | Convert yaml to json |
6,640 | public static String convertJsonToYaml ( Reader jsonReader ) { try ( Reader reader = jsonReader ) { JsonNode json = new ObjectMapper ( ) . readTree ( reader ) ; return new YAMLMapper ( ) . writeValueAsString ( json ) ; } catch ( IOException e ) { throw new YamlRuntimeException ( e ) ; } } | Convert json to yaml |
6,641 | private MethodNode chooseMethodRefMethodCandidate ( Expression methodRef , List < MethodNode > candidates ) { if ( 1 == candidates . size ( ) ) return candidates . get ( 0 ) ; return candidates . stream ( ) . map ( e -> Tuple . tuple ( e , matchingScore ( e , methodRef ) ) ) . min ( ( t1 , t2 ) -> Integer . compare ( t... | Choose the best method node for method reference . |
6,642 | private void printEscaped ( String s , boolean isAttributeValue ) { for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char c = s . charAt ( i ) ; switch ( c ) { case '<' : out . print ( "<" ) ; break ; case '>' : out . print ( ">" ) ; break ; case '&' : out . print ( "&" ) ; break ; case '\'' : if ( isAttribute... | we could always escape if we wanted to . |
6,643 | public void clear ( ) { if ( stateStack . size ( ) > 1 ) { int size = stateStack . size ( ) - 1 ; throw new GroovyBugError ( "the compile stack contains " + size + " more push instruction" + ( size == 1 ? "" : "s" ) + " than pops." ) ; } if ( lhsStack . size ( ) > 1 ) { int size = lhsStack . size ( ) - 1 ; throw new Gr... | Clears the state of the class . This method should be called after a MethodNode is visited . Note that a call to init will fail if clear is not called before |
6,644 | public void pushVariableScope ( VariableScope el ) { pushState ( ) ; scope = el ; superBlockNamedLabels = new HashMap ( superBlockNamedLabels ) ; superBlockNamedLabels . putAll ( currentBlockNamedLabels ) ; currentBlockNamedLabels = new HashMap ( ) ; } | Causes the state - stack to add an element and sets the given scope as new current variable scope . Creates a element for the state stack so pop has to be called later |
6,645 | public void pushLoop ( List < String > labelNames ) { pushState ( ) ; continueLabel = new Label ( ) ; breakLabel = new Label ( ) ; if ( labelNames != null ) { for ( String labelName : labelNames ) { initLoopLabels ( labelName ) ; } } } | Should be called when descending into a loop that does not define a scope . Creates a element for the state stack so pop has to be called later |
6,646 | public BytecodeVariable defineVariable ( Variable v , boolean initFromStack ) { return defineVariable ( v , v . getOriginType ( ) , initFromStack ) ; } | Defines a new Variable using an AST variable . |
6,647 | private void makeNextVariableID ( ClassNode type , boolean useReferenceDirectly ) { currentVariableIndex = nextVariableIndex ; if ( ( type == ClassHelper . long_TYPE || type == ClassHelper . double_TYPE ) && ! useReferenceDirectly ) { nextVariableIndex ++ ; } nextVariableIndex ++ ; } | Calculates the index of the next free register stores it and sets the current variable index to the old value |
6,648 | public Label getLabel ( String name ) { if ( name == null ) return null ; Label l = ( Label ) superBlockNamedLabels . get ( name ) ; if ( l == null ) l = createLocalLabel ( name ) ; return l ; } | Returns the label for the given name |
6,649 | public Label createLocalLabel ( String name ) { Label l = ( Label ) currentBlockNamedLabels . get ( name ) ; if ( l == null ) { l = new Label ( ) ; currentBlockNamedLabels . put ( name , l ) ; } return l ; } | creates a new named label |
6,650 | public static < T > T use ( Class categoryClass , Closure < T > closure ) { return THREAD_INFO . getInfo ( ) . use ( categoryClass , closure ) ; } | Create a scope based on given categoryClass and invoke closure within that scope . |
6,651 | public static < T > T use ( List < Class > categoryClasses , Closure < T > closure ) { return THREAD_INFO . getInfo ( ) . use ( categoryClasses , closure ) ; } | Create a scope based on given categoryClasses and invoke closure within that scope . |
6,652 | public static CategoryMethodList getCategoryMethods ( String name ) { final ThreadCategoryInfo categoryInfo = THREAD_INFO . getInfoNullable ( ) ; return categoryInfo == null ? null : categoryInfo . getCategoryMethods ( name ) ; } | This method is used to pull all the new methods out of the local thread context with a particular name . |
6,653 | public void addErrorAndContinue ( Message message ) { if ( this . errors == null ) { this . errors = new LinkedList ( ) ; } this . errors . add ( message ) ; } | Adds an error to the message set but does not cause a failure . The message is not required to have a source line and column specified but it is best practice to try and include that information . |
6,654 | public void addError ( Message message ) throws CompilationFailedException { addErrorAndContinue ( message ) ; if ( errors != null && this . errors . size ( ) >= configuration . getTolerance ( ) ) { failIfErrors ( ) ; } } | Adds a non - fatal error to the message set which may cause a failure if the error threshold is exceeded . The message is not required to have a source line and column specified but it is best practice to try and include that information . |
6,655 | public void addError ( Message message , boolean fatal ) throws CompilationFailedException { if ( fatal ) { addFatalError ( message ) ; } else { addError ( message ) ; } } | Adds an optionally - fatal error to the message set . The message is not required to have a source line and column specified but it is best practice to try and include that information . |
6,656 | public WarningMessage getWarning ( int index ) { if ( index < getWarningCount ( ) ) { return ( WarningMessage ) this . warnings . get ( index ) ; } return null ; } | Returns the specified warning message or null . |
6,657 | public Message getError ( int index ) { if ( index < getErrorCount ( ) ) { return ( Message ) this . errors . get ( index ) ; } return null ; } | Returns the specified error message or null . |
6,658 | public Exception getException ( int index ) { Exception exception = null ; Message message = getError ( index ) ; if ( message != null ) { if ( message instanceof ExceptionMessage ) { exception = ( ( ExceptionMessage ) message ) . getCause ( ) ; } else if ( message instanceof SyntaxErrorMessage ) { exception = ( ( Synt... | Convenience routine to return the specified error s underlying Exception or null if it isn t one . |
6,659 | public void addWarning ( WarningMessage message ) { if ( message . isRelevant ( configuration . getWarningLevel ( ) ) ) { if ( this . warnings == null ) { this . warnings = new LinkedList ( ) ; } this . warnings . add ( message ) ; } } | Adds a WarningMessage to the message set . |
6,660 | public void write ( PrintWriter writer , Janitor janitor ) { write ( writer , janitor , warnings , "warning" ) ; write ( writer , janitor , errors , "error" ) ; } | Writes error messages to the specified PrintWriter . |
6,661 | public ClassNode getClassNode ( final String name ) { final ClassNode [ ] result = new ClassNode [ ] { null } ; PrimaryClassNodeOperation handler = new PrimaryClassNodeOperation ( ) { public void call ( SourceUnit source , GeneratorContext context , ClassNode classNode ) { if ( classNode . getName ( ) . equals ( name )... | Convenience routine to get the named ClassNode . |
6,662 | public SourceUnit addSource ( String name , InputStream stream ) { ReaderSource source = new InputStreamReaderSource ( stream , configuration ) ; return addSource ( new SourceUnit ( name , source , configuration , classLoader , getErrorCollector ( ) ) ) ; } | Adds a InputStream source to the unit . |
6,663 | public SourceUnit addSource ( SourceUnit source ) { String name = source . getName ( ) ; source . setClassLoader ( this . classLoader ) ; for ( SourceUnit su : queuedSources ) { if ( name . equals ( su . getName ( ) ) ) return su ; } queuedSources . add ( source ) ; return source ; } | Adds a SourceUnit to the unit . |
6,664 | public Iterator < SourceUnit > iterator ( ) { return new Iterator < SourceUnit > ( ) { Iterator < String > nameIterator = names . iterator ( ) ; public boolean hasNext ( ) { return nameIterator . hasNext ( ) ; } public SourceUnit next ( ) { String name = nameIterator . next ( ) ; return sources . get ( name ) ; } publi... | Returns an iterator on the unit s SourceUnits . |
6,665 | public void compile ( int throughPhase ) throws CompilationFailedException { gotoPhase ( Phases . INITIALIZATION ) ; throughPhase = Math . min ( throughPhase , Phases . ALL ) ; while ( throughPhase >= phase && phase <= Phases . ALL ) { if ( phase == Phases . SEMANTIC_ANALYSIS ) { doPhaseOperation ( resolve ) ; if ( deq... | Compiles the compilation unit from sources . |
6,666 | public void applyToSourceUnits ( SourceUnitOperation body ) throws CompilationFailedException { for ( String name : names ) { SourceUnit source = sources . get ( name ) ; if ( ( source . phase < phase ) || ( source . phase == phase && ! source . phaseComplete ) ) { try { body . call ( source ) ; } catch ( CompilationFa... | A loop driver for applying operations to all SourceUnits . Automatically skips units that have already been processed through the current phase . |
6,667 | public List < MethodNode > handleMissingMethod ( ClassNode receiver , String name , ArgumentListExpression argumentList , ClassNode [ ] argumentTypes , MethodCall call ) { return Collections . emptyList ( ) ; } | This method is called by the type checker when a method call cannot be resolved . Extensions may override this method to handle missing methods and prevent the type checker from throwing an error . |
6,668 | public ClassNode lookupClassNodeFor ( String type ) { for ( ClassNode cn : typeCheckingVisitor . getSourceUnit ( ) . getAST ( ) . getClasses ( ) ) { if ( cn . getName ( ) . equals ( type ) ) return cn ; } return null ; } | Lookup a ClassNode by its name from the source unit |
6,669 | public ClassNode buildMapType ( ClassNode keyType , ClassNode valueType ) { return parameterizedType ( ClassHelper . MAP_TYPE , keyType , valueType ) ; } | Builds a parametrized class node representing the Map< ; keyType valueType> ; type . |
6,670 | public boolean isStaticMethodCallOnClass ( MethodCall call , ClassNode receiver ) { ClassNode staticReceiver = extractStaticReceiver ( call ) ; return staticReceiver != null && staticReceiver . equals ( receiver ) ; } | Given a method call checks if it s a static method call and if it is tells if the receiver matches the one supplied as an argument . |
6,671 | private MultiLineRun getMultiLineRun ( int offset ) { MultiLineRun ml = null ; if ( offset > 0 ) { Integer os = offset ; SortedSet set = mlTextRunSet . headSet ( os ) ; if ( ! set . isEmpty ( ) ) { ml = ( MultiLineRun ) set . last ( ) ; ml = ml . end ( ) >= offset ? ml : null ; } } return ml ; } | given an offset return the mlr it resides in |
6,672 | protected void parseDocument ( int offset , int length ) throws BadLocationException { styledDocument . getText ( 0 , styledDocument . getLength ( ) , segment ) ; buffer = CharBuffer . wrap ( segment . array ) . asReadOnlyBuffer ( ) ; if ( ! lexer . isInitialized ( ) ) { lexer . initialize ( ) ; offset = 0 ; length = s... | Parse the Document to update the character styles given an initial start position . Called by the filter after it has updated the text . |
6,673 | public void remove ( DocumentFilter . FilterBypass fb , int offset , int length ) throws BadLocationException { if ( offset == 0 && length != fb . getDocument ( ) . getLength ( ) ) { fb . replace ( 0 , length , "\n" , lexer . defaultStyle ) ; parseDocument ( offset , 2 ) ; fb . remove ( offset , 1 ) ; } else { fb . rem... | Remove a string from the document and then parse it if the parser has been set . |
6,674 | public static TimeDuration minus ( final Date lhs , final Date rhs ) { long milliseconds = lhs . getTime ( ) - rhs . getTime ( ) ; long days = milliseconds / ( 24 * 60 * 60 * 1000 ) ; milliseconds -= days * 24 * 60 * 60 * 1000 ; int hours = ( int ) ( milliseconds / ( 60 * 60 * 1000 ) ) ; milliseconds -= hours * 60 * 60... | Subtract one date from the other . |
6,675 | public Object parse ( Reader reader ) { return jsonSlurper . parse ( new StringReader ( YamlConverter . convertYamlToJson ( reader ) ) ) ; } | Parse the content of the specified reader into a tree of Nodes . |
6,676 | public static void main ( String [ ] urls ) throws Exception { GroovyScriptEngine gse = new GroovyScriptEngine ( urls ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String line ; while ( true ) { System . out . print ( "groovy> " ) ; if ( ( line = br . readLine ( ) ) == null || l... | Simple testing harness for the GSE . Enter script roots as arguments and then input script names to run them . |
6,677 | public Class loadScriptByName ( String scriptName ) throws ResourceException , ScriptException { URLConnection conn = rc . getResourceConnection ( scriptName ) ; String path = conn . getURL ( ) . toExternalForm ( ) ; ScriptCacheEntry entry = scriptCache . get ( path ) ; Class clazz = null ; if ( entry != null ) clazz =... | Get the class of the scriptName in question so that you can instantiate Groovy objects with caching and reloading . |
6,678 | public String run ( String scriptName , String argument ) throws ResourceException , ScriptException { Binding binding = new Binding ( ) ; binding . setVariable ( "arg" , argument ) ; Object result = run ( scriptName , binding ) ; return result == null ? "" : result . toString ( ) ; } | Run a script identified by name with a single argument . |
6,679 | public Object run ( String scriptName , Binding binding ) throws ResourceException , ScriptException { return createScript ( scriptName , binding ) . run ( ) ; } | Run a script identified by name with a given binding . |
6,680 | public Script createScript ( String scriptName , Binding binding ) throws ResourceException , ScriptException { return InvokerHelper . createScript ( loadScriptByName ( scriptName ) , binding ) ; } | Creates a Script with a given scriptName and binding . |
6,681 | public void setConfig ( CompilerConfiguration config ) { if ( config == null ) throw new NullPointerException ( "configuration cannot be null" ) ; this . config = config ; this . groovyLoader = initGroovyLoader ( ) ; } | sets a compiler configuration |
6,682 | public Closure < V > trampoline ( final Object ... args ) { return new TrampolineClosure < V > ( original . curry ( args ) ) ; } | Builds a trampolined variant of the current closure . |
6,683 | public boolean contains ( Object value ) { if ( value == null ) { return false ; } final Iterator it = new StepIterator ( this , stepSize ) ; while ( it . hasNext ( ) ) { if ( compareEqual ( value , it . next ( ) ) ) { return true ; } } return false ; } | iterates over all values and returns true if one value matches . Also see containsWithinBounds . |
6,684 | @ SuppressWarnings ( "unchecked" ) private Comparable increment ( Object value , Number step ) { return ( Comparable ) plus ( ( Number ) value , step ) ; } | Increments by given step |
6,685 | @ SuppressWarnings ( "unchecked" ) private Comparable decrement ( Object value , Number step ) { return ( Comparable ) minus ( ( Number ) value , step ) ; } | Decrements by given step |
6,686 | public Collection < String > listAttributeNames ( ) { List < String > list = new ArrayList < String > ( ) ; try { MBeanAttributeInfo [ ] attrs = beanInfo . getAttributes ( ) ; for ( MBeanAttributeInfo attr : attrs ) { list . add ( attr . getName ( ) ) ; } } catch ( Exception e ) { throwException ( "Could not list attri... | List of the names of each of the attributes on the MBean |
6,687 | public List < String > listAttributeValues ( ) { List < String > list = new ArrayList < String > ( ) ; Collection < String > names = listAttributeNames ( ) ; for ( String name : names ) { try { Object val = this . getProperty ( name ) ; if ( val != null ) { list . add ( name + " : " + val . toString ( ) ) ; } } catch (... | The values of each of the attributes on the MBean |
6,688 | public Collection < String > listAttributeDescriptions ( ) { List < String > list = new ArrayList < String > ( ) ; try { MBeanAttributeInfo [ ] attrs = beanInfo . getAttributes ( ) ; for ( MBeanAttributeInfo attr : attrs ) { list . add ( describeAttribute ( attr ) ) ; } } catch ( Exception e ) { throwException ( "Could... | List of string representations of all of the attributes on the MBean . |
6,689 | public Collection < String > listOperationNames ( ) { List < String > list = new ArrayList < String > ( ) ; try { MBeanOperationInfo [ ] operations = beanInfo . getOperations ( ) ; for ( MBeanOperationInfo operation : operations ) { list . add ( operation . getName ( ) ) ; } } catch ( Exception e ) { throwException ( "... | Names of all the operations available on the MBean . |
6,690 | public Collection < String > listOperationDescriptions ( ) { List < String > list = new ArrayList < String > ( ) ; try { MBeanOperationInfo [ ] operations = beanInfo . getOperations ( ) ; for ( MBeanOperationInfo operation : operations ) { list . add ( describeOperation ( operation ) ) ; } } catch ( Exception e ) { thr... | Description of all of the operations available on the MBean . |
6,691 | public List < String > describeOperation ( String operationName ) { List < String > list = new ArrayList < String > ( ) ; try { MBeanOperationInfo [ ] operations = beanInfo . getOperations ( ) ; for ( MBeanOperationInfo operation : operations ) { if ( operation . getName ( ) . equals ( operationName ) ) { list . add ( ... | Get the description of the specified operation . This returns a Collection since operations can be overloaded and one operationName can have multiple forms . |
6,692 | protected String describeOperation ( MBeanOperationInfo operation ) { StringBuilder buf = new StringBuilder ( ) ; buf . append ( operation . getReturnType ( ) ) . append ( " " ) . append ( operation . getName ( ) ) . append ( "(" ) ; MBeanParameterInfo [ ] params = operation . getSignature ( ) ; for ( int j = 0 ; j < p... | Description of the operation . |
6,693 | public boolean contains ( Object value ) { final Iterator < Comparable > iter = new StepIterator ( this , 1 ) ; if ( value == null ) { return false ; } while ( iter . hasNext ( ) ) { if ( DefaultTypeTransformation . compareEqual ( value , iter . next ( ) ) ) return true ; } return false ; } | Iterates over all values and returns true if one value matches . |
6,694 | private static Comparable normaliseStringType ( final Comparable operand ) { if ( operand instanceof Character ) { return ( int ) ( Character ) operand ; } if ( operand instanceof String ) { final String string = ( String ) operand ; if ( string . length ( ) == 1 ) { return ( int ) string . charAt ( 0 ) ; } return stri... | if operand is a Character or a String with one character return that character s int value . |
6,695 | public static String prettyPrint ( String jsonPayload ) { int indentSize = 0 ; final CharBuf output = CharBuf . create ( ( int ) ( jsonPayload . length ( ) * 1.2 ) ) ; JsonLexer lexer = new JsonLexer ( new StringReader ( jsonPayload ) ) ; Map < Integer , char [ ] > indentCache = new HashMap < Integer , char [ ] > ( ) ;... | Pretty print a JSON payload . |
6,696 | private static char [ ] getIndent ( int indentSize , Map < Integer , char [ ] > indentCache ) { char [ ] indent = indentCache . get ( indentSize ) ; if ( indent == null ) { indent = new char [ indentSize ] ; Arrays . fill ( indent , SPACE ) ; indentCache . put ( indentSize , indent ) ; } return indent ; } | Creates new indent if it not exists in the indent cache . |
6,697 | public int size ( ) { Map < String , GroovyRunner > map = getMap ( ) ; readLock . lock ( ) ; try { return map . size ( ) ; } finally { readLock . unlock ( ) ; } } | Returns the number of registered runners . |
6,698 | public GroovyRunner get ( Object key ) { if ( key == null ) { return null ; } Map < String , GroovyRunner > map = getMap ( ) ; readLock . lock ( ) ; try { return map . get ( key ) ; } finally { readLock . unlock ( ) ; } } | Returns the registered runner for the specified key . |
6,699 | public GroovyRunner put ( String key , GroovyRunner runner ) { if ( key == null || runner == null ) { return null ; } Map < String , GroovyRunner > map = getMap ( ) ; writeLock . lock ( ) ; try { cachedValues = null ; return map . put ( key , runner ) ; } finally { writeLock . unlock ( ) ; } } | Registers a runner with the specified key . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.