idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
6,500
public List rows ( int offset , int maxRows ) throws SQLException { return rows ( getSql ( ) , getParameters ( ) , offset , maxRows ) ; }
Returns a page of the rows from the table a DataSet represents . A page is defined as starting at a 1 - based offset and containing a maximum number of rows .
6,501
public Object firstRow ( ) throws SQLException { List rows = rows ( ) ; if ( rows . isEmpty ( ) ) return null ; return ( rows . get ( 0 ) ) ; }
Returns the first row from a DataSet s underlying table
6,502
protected void addError ( String message , ASTNode node , SourceUnit source ) { source . getErrorCollector ( ) . addErrorAndContinue ( new SyntaxErrorMessage ( new SyntaxException ( message , node . getLineNumber ( ) , node . getColumnNumber ( ) , node . getLastLineNumber ( ) , node . getLastColumnNumber ( ) ) , source...
Adds a new syntax error to the source unit and then continues .
6,503
private static ClassNode getSerializeClass ( ClassNode alias ) { List < AnnotationNode > annotations = alias . getAnnotations ( ClassHelper . make ( AnnotationCollector . class ) ) ; if ( ! annotations . isEmpty ( ) ) { AnnotationNode annotationNode = annotations . get ( 0 ) ; Expression member = annotationNode . getMe...
2 . 5 . 3 and above gets from annotation attribute otherwise self
6,504
protected List < AnnotationNode > getTargetAnnotationList ( AnnotationNode collector , AnnotationNode aliasAnnotationUsage , SourceUnit source ) { List < AnnotationNode > stored = getStoredTargetList ( aliasAnnotationUsage , source ) ; List < AnnotationNode > targetList = getTargetListFromValue ( collector , aliasAnnot...
Returns a list of AnnotationNodes for the value attribute of the given AnnotationNode .
6,505
public List < AnnotationNode > visit ( AnnotationNode collector , AnnotationNode aliasAnnotationUsage , AnnotatedNode aliasAnnotated , SourceUnit source ) { List < AnnotationNode > ret = getTargetAnnotationList ( collector , aliasAnnotationUsage , source ) ; Set < String > unusedNames = new HashSet < String > ( aliasAn...
Implementation method of the alias annotation processor . This method will get the list of annotations we aliased from the collector and adds it to aliasAnnotationUsage . The method will also map all members from aliasAnnotationUsage to the aliased nodes . Should a member stay unmapped we will ad an error . Further pro...
6,506
public String namespaceURI ( ) { if ( namespacePrefix == null || namespacePrefix . isEmpty ( ) ) return "" ; String uri = namespaceTagHints . get ( namespacePrefix ) ; return uri == null ? "" : uri ; }
Returns the URI of the namespace of this Attribute .
6,507
public static < K , V > EntryWeigher < K , V > asEntryWeigher ( final Weigher < ? super V > weigher ) { return ( weigher == singleton ( ) ) ? Weighers . < K , V > entrySingleton ( ) : new EntryWeigherView < K , V > ( weigher ) ; }
A entry weigher backed by the specified weigher . The weight of the value determines the weight of the entry .
6,508
public static void addReturnIfNeeded ( MethodNode node ) { ReturnAdder adder = new ReturnAdder ( ) ; adder . visitMethod ( node ) ; }
Adds return statements in method code whenever an implicit return is detected .
6,509
public synchronized void touch ( final Object key , final Object value ) { remove ( key ) ; put ( key , value ) ; }
The touch method can be used to renew an element and move it to the from of the LRU queue .
6,510
public synchronized Object get ( final Object key ) { final Object value = remove ( key ) ; if ( value != null ) put ( key , value ) ; return value ; }
Makes sure the retrieved object is moved to the head of the LRU list
6,511
public static Class getCallingClass ( int matchLevel , Collection < String > extraIgnoredPackages ) { Class [ ] classContext = HELPER . getClassContext ( ) ; int depth = 0 ; try { Class c ; Class sc ; do { do { c = classContext [ depth ++ ] ; if ( c != null ) { sc = c . getSuperclass ( ) ; } else { sc = null ; } } whil...
Get the called that is matchLevel stack frames before the call ignoring MOP frames and desired exclude packages .
6,512
public boolean isOneOf ( int [ ] types ) { int meaning = getMeaning ( ) ; for ( int i = 0 ; i < types . length ; i ++ ) { if ( Types . ofType ( meaning , types [ i ] ) ) { return true ; } } return false ; }
Returns true if the node s meaning matches any of the specified types .
6,513
public int getMeaningAs ( int [ ] types ) { for ( int i = 0 ; i < types . length ; i ++ ) { if ( isA ( types [ i ] ) ) { return types [ i ] ; } } return Types . UNKNOWN ; }
Returns the first matching meaning of the specified types . Returns Types . UNKNOWN if there are no matches .
6,514
boolean matches ( int type , int child1 , int child2 ) { return matches ( type , child1 ) && get ( 2 , true ) . isA ( child2 ) ; }
Returns true if the node and it s first and second child match the specified types . Missing nodes are Token . NULL .
6,515
public Token getRoot ( boolean safe ) { Token root = getRoot ( ) ; if ( root == null && safe ) { root = Token . NULL ; } return root ; }
Returns the root of the node the Token that indicates it s type . Returns a Token . NULL if safe and the actual root is null .
6,516
public void addChildrenOf ( CSTNode of ) { for ( int i = 1 ; i < of . size ( ) ; i ++ ) { add ( of . get ( i ) ) ; } }
Adds all children of the specified node to this one . Not all nodes support this operation!
6,517
public Closure < V > ncurry ( int n , final Object argument ) { return ncurry ( n , new Object [ ] { argument } ) ; }
Support for Closure currying at a given index .
6,518
@ SuppressWarnings ( "unchecked" ) public Closure < V > dehydrate ( ) { Closure < V > result = ( Closure < V > ) this . clone ( ) ; result . delegate = null ; result . owner = null ; result . thisObject = null ; return result ; }
Returns a copy of this closure where the owner delegate and thisObject fields are null allowing proper serialization when one of them is not serializable .
6,519
public Object beforeInvoke ( Object object , String methodName , Object [ ] arguments ) { if ( ! calls . containsKey ( methodName ) ) calls . put ( methodName , new LinkedList ( ) ) ; ( ( List ) calls . get ( methodName ) ) . add ( System . currentTimeMillis ( ) ) ; return null ; }
This code is executed before the method is called .
6,520
public Object afterInvoke ( Object object , String methodName , Object [ ] arguments , Object result ) { ( ( List ) calls . get ( methodName ) ) . add ( System . currentTimeMillis ( ) ) ; return result ; }
This code is executed after the method is called .
6,521
protected static Class getWrapperClass ( Class c ) { if ( c == Integer . TYPE ) { c = Integer . class ; } else if ( c == Byte . TYPE ) { c = Byte . class ; } else if ( c == Long . TYPE ) { c = Long . class ; } else if ( c == Double . TYPE ) { c = Double . class ; } else if ( c == Float . TYPE ) { c = Float . class ; } ...
Get wrapper class for a given class . If the class is for a primitive number type then the wrapper class will be returned . If it is no primitive number type we return the class itself .
6,522
protected static boolean argumentClassIsParameterClass ( Class argumentClass , Class parameterClass ) { if ( argumentClass == parameterClass ) return true ; if ( getWrapperClass ( parameterClass ) == argumentClass ) return true ; return false ; }
Realizes an unsharp equal for the class . In general we return true if the provided arguments are the same . But we will also return true if our argument class is a wrapper for the parameter class . For example the parameter is an int and the argument class is a wrapper .
6,523
protected static MethodType replaceWithMoreSpecificType ( Object [ ] args , MethodType callSiteType ) { for ( int i = 0 ; i < args . length ; i ++ ) { if ( args [ i ] == null ) continue ; if ( callSiteType . parameterType ( i ) . isPrimitive ( ) ) continue ; Class argClass = args [ i ] . getClass ( ) ; callSiteType = c...
Replaces the types in the callSiteType parameter if more specific types given through the arguments . This is in general the case unless the argument is null .
6,524
public void setPackagenames ( String packages ) { StringTokenizer tok = new StringTokenizer ( packages , "," ) ; while ( tok . hasMoreTokens ( ) ) { String packageName = tok . nextToken ( ) ; packageNames . add ( packageName ) ; } }
Set the package names to be processed .
6,525
public static final double random ( double max ) { last = ( last * IA + IC ) % IM ; return max * last / IM ; }
pseudo - random number generator
6,526
private JsonToken readingConstant ( JsonTokenType type , JsonToken token ) { try { int numCharsToRead = ( ( String ) type . getValidator ( ) ) . length ( ) ; char [ ] chars = new char [ numCharsToRead ] ; reader . read ( chars ) ; String stringRead = new String ( chars ) ; if ( stringRead . equals ( type . getValidator...
When a constant token type is expected check that the expected constant is read and update the content of the token accordingly .
6,527
public int skipWhitespace ( ) { try { int readChar = 20 ; char c = SPACE ; while ( Character . isWhitespace ( c ) ) { reader . mark ( 1 ) ; readChar = reader . read ( ) ; c = ( char ) readChar ; } reader . reset ( ) ; return readChar ; } catch ( IOException ioe ) { throw new JsonException ( "An IO exception occurred wh...
Skips all the whitespace characters and moves the cursor to the next non - space character .
6,528
private static VariableExpression getTarget ( VariableExpression ve ) { if ( ve . getAccessedVariable ( ) == null || ve . getAccessedVariable ( ) == ve || ( ! ( ve . getAccessedVariable ( ) instanceof VariableExpression ) ) ) return ve ; return getTarget ( ( VariableExpression ) ve . getAccessedVariable ( ) ) ; }
The inferred type in case of a variable expression can be set on the accessed variable so we take it instead of the facade one .
6,529
public String getLine ( int lineNumber , Janitor janitor ) { if ( lineSource != null && number > lineNumber ) { cleanup ( ) ; } if ( lineSource == null ) { try { lineSource = new BufferedReader ( getReader ( ) ) ; } catch ( Exception e ) { } number = 0 ; } if ( lineSource != null ) { while ( number < lineNumber ) { try...
Returns a line from the source or null if unavailable . If you supply a Janitor resources will be cached .
6,530
public Object getAt ( int index ) { try { if ( index < 0 ) index += result . size ( ) ; Iterator it = result . values ( ) . iterator ( ) ; int i = 0 ; Object obj = null ; while ( ( obj == null ) && ( it . hasNext ( ) ) ) { if ( i == index ) obj = it . next ( ) ; else it . next ( ) ; i ++ ; } return obj ; } catch ( Exce...
Retrieve the value of the property by its index . A negative index will count backwards from the last column .
6,531
@ SuppressWarnings ( "unchecked" ) public Object put ( Object key , Object value ) { Object orig = remove ( key ) ; result . put ( key , value ) ; return orig ; }
Associates the specified value with the specified property name in this result .
6,532
public static < T > T withObjectOutputStream ( Path self , @ ClosureParams ( value = SimpleType . class , options = "java.io.ObjectOutputStream" ) Closure < T > closure ) throws IOException { return IOGroovyMethods . withStream ( newObjectOutputStream ( self ) , closure ) ; }
Create a new ObjectOutputStream for this path and then pass it to the closure . This method ensures the stream is closed after the closure returns .
6,533
public static ObjectInputStream newObjectInputStream ( Path self , final ClassLoader classLoader ) throws IOException { return IOGroovyMethods . newObjectInputStream ( Files . newInputStream ( self ) , classLoader ) ; }
Create an object input stream for this path using the given class loader .
6,534
public static < T > T withObjectInputStream ( Path self , ClassLoader classLoader , @ ClosureParams ( value = SimpleType . class , options = "java.io.ObjectInputStream" ) Closure < T > closure ) throws IOException { return IOGroovyMethods . withStream ( newObjectInputStream ( self , classLoader ) , closure ) ; }
Create a new ObjectInputStream for this file associated with the given class loader and pass it to the closure . This method ensures the stream is closed after the closure returns .
6,535
public static String getText ( Path self , String charset ) throws IOException { return IOGroovyMethods . getText ( newReader ( self , charset ) ) ; }
Read the content of the Path using the specified encoding and return it as a String .
6,536
public static void setBytes ( Path self , byte [ ] bytes ) throws IOException { IOGroovyMethods . setBytes ( Files . newOutputStream ( self ) , bytes ) ; }
Write the bytes from the byte array to the Path .
6,537
public static Path leftShift ( Path self , byte [ ] bytes ) throws IOException { append ( self , bytes ) ; return self ; }
Write bytes to a Path .
6,538
public static void write ( Path self , String text , String charset ) throws IOException { write ( self , text , charset , false ) ; }
Write the text to the Path without writing a BOM using the specified encoding .
6,539
public static void append ( Path self , Object text ) throws IOException { append ( self , text , Charset . defaultCharset ( ) . name ( ) , false ) ; }
Append the text at the end of the Path without writing a BOM .
6,540
public static void append ( Path self , Object text , String charset ) throws IOException { append ( self , text , charset , false ) ; }
Append the text at the end of the Path without writing a BOM using a specified encoding .
6,541
public static void eachDir ( Path self , @ ClosureParams ( value = SimpleType . class , options = "java.nio.file.Path" ) Closure closure ) throws IOException { eachFile ( self , FileType . DIRECTORIES , closure ) ; }
Invokes the closure for each subdirectory in this directory ignoring regular files .
6,542
public static boolean renameTo ( final Path self , URI newPathName ) { try { Files . move ( self , Paths . get ( newPathName ) ) ; return true ; } catch ( IOException e ) { return false ; } }
Renames a file .
6,543
public static BufferedWriter newWriter ( Path self ) throws IOException { return Files . newBufferedWriter ( self , Charset . defaultCharset ( ) ) ; }
Create a buffered writer for this file .
6,544
public static BufferedWriter newWriter ( Path self , String charset , boolean append ) throws IOException { return newWriter ( self , charset , append , false ) ; }
Helper method to create a buffered writer for a file without writing a BOM .
6,545
public static < T > T withWriter ( Path self , String charset , @ ClosureParams ( value = SimpleType . class , options = "java.io.Writer" ) Closure < T > closure ) throws IOException { return withWriter ( self , charset , false , closure ) ; }
Creates a new BufferedWriter for this file passes it to the closure and ensures the stream is flushed and closed after the closure returns . The writer will use the given charset encoding but will not write a BOM .
6,546
public static < T > T withWriterAppend ( Path self , @ ClosureParams ( value = SimpleType . class , options = "java.io.Writer" ) Closure < T > closure ) throws IOException { return withWriterAppend ( self , Charset . defaultCharset ( ) . name ( ) , closure ) ; }
Create a new BufferedWriter for this file in append mode . The writer is passed to the closure and is closed after the closure returns . The writer will not write a BOM .
6,547
public static PrintWriter newPrintWriter ( Path self , String charset ) throws IOException { return new GroovyPrintWriter ( newWriter ( self , charset ) ) ; }
Create a new PrintWriter for this file using specified charset .
6,548
public static void eachByte ( Path self , int bufferLen , @ ClosureParams ( value = FromString . class , options = "byte[],Integer" ) Closure closure ) throws IOException { BufferedInputStream is = newInputStream ( self ) ; IOGroovyMethods . eachByte ( is , bufferLen , closure ) ; }
Traverse through the bytes of this Path bufferLen bytes at a time .
6,549
public int compareTo ( Object that ) { if ( that instanceof GroovyDoc ) { return name . compareTo ( ( ( GroovyDoc ) that ) . name ( ) ) ; } else { throw new ClassCastException ( String . format ( "Cannot compare object of type %s." , that . getClass ( ) ) ) ; } }
Methods from Comparable
6,550
public static void setProperties ( Object object , Map map ) { MetaClass mc = getMetaClass ( object ) ; for ( Object o : map . entrySet ( ) ) { Map . Entry entry = ( Map . Entry ) o ; String key = entry . getKey ( ) . toString ( ) ; Object value = entry . getValue ( ) ; setPropertySafe ( object , mc , key , value ) ; }...
Sets the properties on the given object
6,551
public static void write ( Writer out , Object object ) throws IOException { if ( object instanceof String ) { out . write ( ( String ) object ) ; } else if ( object instanceof Object [ ] ) { out . write ( toArrayString ( ( Object [ ] ) object ) ) ; } else if ( object instanceof Map ) { out . write ( toMapString ( ( Ma...
Writes an object to a Writer using Groovy s default representation for the object .
6,552
public static void append ( Appendable out , Object object ) throws IOException { if ( object instanceof String ) { out . append ( ( String ) object ) ; } else if ( object instanceof Object [ ] ) { out . append ( toArrayString ( ( Object [ ] ) object ) ) ; } else if ( object instanceof Map ) { out . append ( toMapStrin...
Appends an object to an Appendable using Groovy s default representation for the object .
6,553
public void setSrcdir ( Path srcDir ) { if ( src == null ) { src = srcDir ; } else { src . append ( srcDir ) ; } }
Set the source directories to find the source Java files .
6,554
public void setSourcepath ( Path sourcepath ) { if ( compileSourcepath == null ) { compileSourcepath = sourcepath ; } else { compileSourcepath . append ( sourcepath ) ; } }
Set the sourcepath to be used for this compilation .
6,555
public synchronized void updatePath ( PropertyChangeListener listener , Object newObject , Set updateSet ) { if ( currentObject != newObject ) { removeListeners ( ) ; } if ( ( children != null ) && ( children . length > 0 ) ) { try { Object newValue = null ; if ( newObject != null ) { updateSet . add ( newObject ) ; ne...
Called when we detect a change somewhere down our path . First check to see if our object is changing . If so remove our old listener Next update the reference object the children have and recurse Finally add listeners if we have a different object
6,556
public void addAllListeners ( PropertyChangeListener listener , Object newObject , Set updateSet ) { addListeners ( listener , newObject , updateSet ) ; if ( ( children != null ) && ( children . length > 0 ) ) { try { Object newValue = null ; if ( newObject != null ) { updateSet . add ( newObject ) ; newValue = extract...
Adds all the listeners to the objects in the bind path . This assumes that we are not added as listeners to any of them hence it is not idempotent .
6,557
public void addListeners ( PropertyChangeListener listener , Object newObject , Set updateSet ) { removeListeners ( ) ; if ( newObject != null ) { TriggerBinding syntheticTrigger = getSyntheticTriggerBinding ( newObject ) ; MetaClass mc = InvokerHelper . getMetaClass ( newObject ) ; if ( syntheticTrigger != null ) { Pr...
Add listeners to a specific object . Updates the bould flags and update set
6,558
public void removeListeners ( ) { if ( globalListener != null ) { try { InvokerHelper . invokeMethod ( currentObject , "removePropertyChangeListener" , globalListener ) ; } catch ( Exception e ) { } globalListener = null ; } if ( localListener != null ) { try { InvokerHelper . invokeMethod ( currentObject , "removeProp...
Remove listeners believing that our bould flags are accurate and it removes only as declared .
6,559
private boolean tryMacroMethod ( MethodCallExpression call , ExtensionMethodNode macroMethod , Object [ ] macroArguments ) { Expression result = ( Expression ) InvokerHelper . invokeStaticMethod ( macroMethod . getExtensionMethodNode ( ) . getDeclaringClass ( ) . getTypeClass ( ) , macroMethod . getName ( ) , macroArgu...
Attempts to call given macroMethod
6,560
public void setProperty ( final Object object , Object newValue ) { AccessPermissionChecker . checkAccessPermission ( field ) ; final Object goalValue = DefaultTypeTransformation . castToType ( newValue , field . getType ( ) ) ; if ( isFinal ( ) ) { throw new GroovyRuntimeException ( "Cannot set the property '" + name ...
Sets the property on the given object to the new value
6,561
public static void putAt ( StringBuilder self , IntRange range , Object value ) { RangeInfo info = subListBorders ( self . length ( ) , range ) ; self . replace ( info . from , info . to , value . toString ( ) ) ; }
Support the range subscript operator for StringBuilder . Index values are treated as characters within the builder .
6,562
public Node parse ( File file ) throws IOException , SAXException { InputSource input = new InputSource ( new FileInputStream ( file ) ) ; input . setSystemId ( "file://" + file . getAbsolutePath ( ) ) ; getXMLReader ( ) . parse ( input ) ; return parent ; }
Parses the content of the given file as XML turning it into a tree of Nodes .
6,563
public Node parse ( InputSource input ) throws IOException , SAXException { getXMLReader ( ) . parse ( input ) ; return parent ; }
Parse the content of the specified input source into a tree of Nodes .
6,564
public Node parse ( String uri ) throws IOException , SAXException { InputSource is = new InputSource ( uri ) ; getXMLReader ( ) . parse ( is ) ; return parent ; }
Parse the content of the specified URI into a tree of Nodes .
6,565
protected Object getElementName ( String namespaceURI , String localName , String qName ) { String name = localName ; String prefix = "" ; if ( ( name == null ) || ( name . length ( ) < 1 ) ) { name = qName ; } if ( namespaceURI == null || namespaceURI . length ( ) <= 0 ) { return name ; } if ( qName != null && qName ....
Return a name given the namespaceURI localName and qName .
6,566
public static ClassNode pickGenericType ( ClassNode type , int gtIndex ) { final GenericsType [ ] genericsTypes = type . getGenericsTypes ( ) ; if ( genericsTypes == null || genericsTypes . length < gtIndex ) { return ClassHelper . OBJECT_TYPE ; } return genericsTypes [ gtIndex ] . getType ( ) ; }
A helper method which will extract the n - th generic type from a class node .
6,567
public static ClassNode pickGenericType ( MethodNode node , int parameterIndex , int gtIndex ) { final Parameter [ ] parameters = node . getParameters ( ) ; final ClassNode type = parameters [ parameterIndex ] . getOriginType ( ) ; return pickGenericType ( type , gtIndex ) ; }
A helper method which will extract the n - th generic type from the n - th parameter of a method node .
6,568
protected ClassNode findClassNode ( final SourceUnit sourceUnit , final CompilationUnit compilationUnit , final String className ) { if ( className . endsWith ( "[]" ) ) { return findClassNode ( sourceUnit , compilationUnit , className . substring ( 0 , className . length ( ) - 2 ) ) . makeArray ( ) ; } ClassNode cn = ...
Finds a class node given a string representing the type . Performs a lookup in the compilation unit to check if it is done in the same source unit .
6,569
public static String render ( String text , ValueRecorder recorder ) { return new AssertionRenderer ( text , recorder ) . render ( ) ; }
Creates a string representation of an assertion and its recorded values .
6,570
public static Object setBeanProperties ( MetaClass mc , Object bean , Map properties ) { for ( Iterator iter = properties . entrySet ( ) . iterator ( ) ; iter . hasNext ( ) ; ) { Map . Entry entry = ( Map . Entry ) iter . next ( ) ; String key = entry . getKey ( ) . toString ( ) ; Object value = entry . getValue ( ) ; ...
This method is called by he handle to realize the bean constructor with property map .
6,571
public static boolean isSameMetaClass ( MetaClass mc , Object receiver ) { return receiver instanceof GroovyObject && mc == ( ( GroovyObject ) receiver ) . getMetaClass ( ) ; }
called by handle
6,572
public static boolean sameClass ( Class c , Object o ) { if ( o == null ) return false ; return o . getClass ( ) == c ; }
Guard to check if the provided Object has the same class as the provided Class . This method will return false if the Object is null .
6,573
public static Thread start ( Thread self , Closure closure ) { return createThread ( null , false , closure ) ; }
Start a Thread with the given closure as a Runnable instance .
6,574
public static Thread start ( Thread self , String name , Closure closure ) { return createThread ( name , false , closure ) ; }
Start a Thread with a given name and the given closure as a Runnable instance .
6,575
public static Thread startDaemon ( Thread self , Closure closure ) { return createThread ( null , true , closure ) ; }
Start a daemon Thread with the given closure as a Runnable instance .
6,576
public static Thread startDaemon ( Thread self , String name , Closure closure ) { return createThread ( name , true , closure ) ; }
Start a daemon Thread with a given name and the given closure as a Runnable instance .
6,577
private static void createSuperForwarder ( ClassNode targetNode , MethodNode forwarder , final Map < String , ClassNode > genericsSpec ) { List < ClassNode > interfaces = new ArrayList < ClassNode > ( Traits . collectAllInterfacesReverseOrder ( targetNode , new LinkedHashSet < ClassNode > ( ) ) ) ; String name = forwar...
Creates if necessary a super forwarder method for stackable traits .
6,578
public void visitConstantExpression ( ConstantExpression expression ) { final String constantName = expression . getConstantName ( ) ; if ( controller . isStaticConstructor ( ) || constantName == null ) { controller . getOperandStack ( ) . pushConstant ( expression ) ; } else { controller . getMethodVisitor ( ) . visit...
Generate byte code for constants
6,579
public void visitBooleanExpression ( BooleanExpression expression ) { controller . getCompileStack ( ) . pushBooleanExpression ( ) ; int mark = controller . getOperandStack ( ) . getStackLength ( ) ; Expression inner = expression . getExpression ( ) ; inner . visit ( this ) ; controller . getOperandStack ( ) . castToBo...
return a primitive boolean value of the BooleanExpression .
6,580
public void visitClassExpression ( ClassExpression expression ) { ClassNode type = expression . getType ( ) ; MethodVisitor mv = controller . getMethodVisitor ( ) ; if ( BytecodeHelper . isClassLiteralPossible ( type ) || BytecodeHelper . isSameCompilationUnit ( controller . getClassNode ( ) , type ) ) { if ( controlle...
load class object on stack
6,581
private void visitAnnotationAttributes ( AnnotationNode an , AnnotationVisitor av ) { Map < String , Object > constantAttrs = new HashMap < String , Object > ( ) ; Map < String , PropertyExpression > enumAttrs = new HashMap < String , PropertyExpression > ( ) ; Map < String , Object > atAttrs = new HashMap < String , O...
Generate the annotation attributes .
6,582
private ListExpression determineClasses ( Expression expr , boolean searchSourceUnit ) { ListExpression list = new ListExpression ( ) ; if ( expr instanceof ClassExpression ) { list . addExpression ( expr ) ; } else if ( expr instanceof VariableExpression && searchSourceUnit ) { VariableExpression ve = ( VariableExpres...
allow non - strict mode in scripts because parsing not complete at that point
6,583
public static String methodDescriptorWithoutReturnType ( MethodNode mNode ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( mNode . getName ( ) ) . append ( ':' ) ; for ( Parameter p : mNode . getParameters ( ) ) { sb . append ( ClassNodeUtils . formatTypeName ( p . getType ( ) ) ) . append ( ',' ) ; } retur...
Return the method node s descriptor including its name and parameter types without generics .
6,584
public static String methodDescriptor ( MethodNode mNode ) { StringBuilder sb = new StringBuilder ( mNode . getName ( ) . length ( ) + mNode . getParameters ( ) . length * 10 ) ; sb . append ( mNode . getReturnType ( ) . getName ( ) ) ; sb . append ( ' ' ) ; sb . append ( mNode . getName ( ) ) ; sb . append ( '(' ) ; f...
Return the method node s descriptor which includes its return type name and parameter types without generics .
6,585
public static String getPropertyName ( MethodNode mNode ) { String name = mNode . getName ( ) ; if ( name . startsWith ( "set" ) || name . startsWith ( "get" ) || name . startsWith ( "is" ) ) { String pname = decapitalize ( name . substring ( name . startsWith ( "is" ) ? 2 : 3 ) ) ; if ( ! pname . isEmpty ( ) ) { if ( ...
For a method node potentially representing a property returns the name of the property .
6,586
public static boolean isIntCategory ( ClassNode type ) { return type == byte_TYPE || type == char_TYPE || type == int_TYPE || type == short_TYPE ; }
It is of an int category if the provided type is a byte char short int .
6,587
public static ClassNode lowestUpperBound ( List < ClassNode > nodes ) { if ( nodes . size ( ) == 1 ) return nodes . get ( 0 ) ; return lowestUpperBound ( nodes . get ( 0 ) , lowestUpperBound ( nodes . subList ( 1 , nodes . size ( ) ) ) ) ; }
Given a list of class nodes returns the first common supertype . For example Double and Float would return Number while Set and String would return Object .
6,588
public static ClassNode lowestUpperBound ( ClassNode a , ClassNode b ) { ClassNode lub = lowestUpperBound ( a , b , null , null ) ; if ( lub == null || ! lub . isUsingGenerics ( ) ) return lub ; if ( lub instanceof LowestUpperBoundClassNode ) { ClassNode superClass = lub . getSuperClass ( ) ; ClassNode psc = superClass...
Given two class nodes returns the first common supertype or the class itself if there are equal . For example Double and Float would return Number while Set and String would return Object .
6,589
private static ClassNode parameterizeLowestUpperBound ( final ClassNode lub , final ClassNode a , final ClassNode b , final ClassNode fallback ) { if ( ! lub . isUsingGenerics ( ) ) return lub ; ClassNode holderForA = findGenericsTypeHolderForClass ( a , lub ) ; ClassNode holderForB = findGenericsTypeHolderForClass ( b...
Given a lowest upper bound computed without generic type information but which requires to be parameterized and the two implementing classnodes which are parameterized with potentially two different types returns a parameterized lowest upper bound .
6,590
private static List < ClassNode > keepLowestCommonInterfaces ( List < ClassNode > fromA , List < ClassNode > fromB ) { if ( fromA == null || fromB == null ) return EMPTY_CLASSNODE_LIST ; Set < ClassNode > common = new HashSet < ClassNode > ( fromA ) ; common . retainAll ( fromB ) ; List < ClassNode > result = new Array...
Given the list of interfaces implemented by two class nodes returns the list of the most specific common implemented interfaces .
6,591
private static ClassNode buildTypeWithInterfaces ( ClassNode baseType1 , ClassNode baseType2 , Collection < ClassNode > interfaces ) { boolean noInterface = interfaces . isEmpty ( ) ; if ( noInterface ) { if ( baseType1 . equals ( baseType2 ) ) return baseType1 ; if ( baseType1 . isDerivedFrom ( baseType2 ) ) return ba...
Given two class nodes supposedly at the upper common level returns a class node which is able to represent their lowest upper bound .
6,592
private static boolean areEqualWithGenerics ( ClassNode a , ClassNode b ) { if ( a == null ) return b == null ; if ( ! a . equals ( b ) ) return false ; if ( a . isUsingGenerics ( ) && ! b . isUsingGenerics ( ) ) return false ; GenericsType [ ] gta = a . getGenericsTypes ( ) ; GenericsType [ ] gtb = b . getGenericsType...
Compares two class nodes but including their generics types .
6,593
public Object parse ( char [ ] chars ) { if ( chars == null ) { throw new IllegalArgumentException ( "chars must not be null" ) ; } Object content ; content = createParser ( ) . parse ( chars ) ; return content ; }
Parse a JSON data structure from content from a char array .
6,594
public void addPropertyChangeListener ( PropertyChangeListener listener ) { if ( propertyChangeSupport == null ) { propertyChangeSupport = new PropertyChangeSupport ( this ) ; } propertyChangeSupport . addPropertyChangeListener ( listener ) ; }
Add a PropertyChangeListener to the listener list .
6,595
public static Number parseInteger ( AST reportNode , String text ) { text = text . replace ( "_" , "" ) ; char c = ' ' ; int length = text . length ( ) ; boolean negative = false ; if ( ( c = text . charAt ( 0 ) ) == '-' || c == '+' ) { negative = ( c == '-' ) ; text = text . substring ( 1 , length ) ; length -= 1 ; } ...
Builds a Number from the given integer descriptor . Creates the narrowest type possible or a specific type if specified .
6,596
public static Number parseDecimal ( String text ) { text = text . replace ( "_" , "" ) ; int length = text . length ( ) ; char type = 'x' ; if ( isNumericTypeSpecifier ( text . charAt ( length - 1 ) , true ) ) { type = Character . toLowerCase ( text . charAt ( length - 1 ) ) ; text = text . substring ( 0 , length - 1 )...
Builds a Number from the given decimal descriptor . Uses BigDecimal unless Double or Float is requested .
6,597
public void registerBeanProperty ( final String property , final Object newValue ) { performOperationOnMetaClass ( new Callable ( ) { public void call ( ) { Class type = newValue == null ? Object . class : newValue . getClass ( ) ; MetaBeanProperty mbp = newValue instanceof MetaBeanProperty ? ( MetaBeanProperty ) newVa...
Registers a new bean property
6,598
public void registerInstanceMethod ( final MetaMethod metaMethod ) { final boolean inited = this . initCalled ; performOperationOnMetaClass ( new Callable ( ) { public void call ( ) { String methodName = metaMethod . getName ( ) ; checkIfGroovyObjectMethod ( metaMethod ) ; MethodKey key = new DefaultCachedMethodKey ( t...
Registers a new instance method for the given method name and closure on this MetaClass
6,599
protected void registerStaticMethod ( final String name , final Closure callable , final Class [ ] paramTypes ) { performOperationOnMetaClass ( new Callable ( ) { public void call ( ) { String methodName ; if ( name . equals ( METHOD_MISSING ) ) methodName = STATIC_METHOD_MISSING ; else if ( name . equals ( PROPERTY_MI...
Registers a new static method for the given method name and closure on this MetaClass