public class GroovyCodeSource
extends Object
CodeSource wrapper class that allows specific security policies to be associated with a class compiled from groovy source.
| Constructor and description |
|---|
GroovyCodeSource(String script, String name, String codeBase)Creates a code source from script text with an explicit logical name and code base. |
GroovyCodeSource(Reader reader, String name, String codeBase)Construct a GroovyCodeSource for an inputStream of groovyCode that has an unknown provenance -- meaning it didn't come from a File or a URL (e.g. a String). |
GroovyCodeSource(File infile, String encoding)Creates a code source from a Groovy source file. |
GroovyCodeSource(File infile)
|
GroovyCodeSource(URI uri)Creates a code source from the Groovy source available at the supplied URI. |
GroovyCodeSource(URL url)Creates a code source from the Groovy source available at the supplied URL. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public boolean |
equals(Object o)Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.
|
|
public CodeSource |
getCodeSource()Returns the CodeSource associated with compiled script classes. |
|
public File |
getFile()Returns the backing file when this code source was created from a file. |
|
public String |
getName()Returns the logical name used for the script. |
|
public String |
getScriptText()Returns the Groovy source text. |
|
public URL |
getURL()Returns the backing URL when this code source was created from a URL. |
|
public int |
hashCode()Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by HashMap.
The general contract of
|
|
public boolean |
isCachable()Indicates whether classes compiled from this source may be cached. |
|
public void |
setCachable(boolean b)Controls whether classes compiled from this source may be cached by GroovyClassLoader. |
Creates a code source from script text with an explicit logical name and code base.
script - the Groovy source textname - the logical script namecodeBase - the code base used to create the backing CodeSourceConstruct a GroovyCodeSource for an inputStream of groovyCode that has an unknown provenance -- meaning it didn't come from a File or a URL (e.g. a String). The supplied codeBase will be used to construct a File URL that should match up with a java Policy entry that determines the grants to be associated with the class that will be built from the InputStream.
The permission groovy.security.GroovyCodeSourcePermission will be used to determine if the given codeBase may be specified. That is, the current Policy set must have a GroovyCodeSourcePermission that implies the codeBase, or an exception will be thrown. This is to prevent callers from hijacking existing codeBase policy entries unless explicitly authorized by the user.
Creates a code source from a Groovy source file.
infile - the source fileencoding - the character encoding used to read the file, or null for the default handlinginfile - the file to create a GroovyCodeSource for.Creates a code source from the Groovy source available at the supplied URI.
uri - the source URICreates a code source from the Groovy source available at the supplied URL.
url - the source URLIndicates whether some other object is "equal to" this one.
The equals method implements an equivalence relation
on non-null object references:
x, x.equals(x) should return
true.
x and y, x.equals(y)
should return true if and only if
y.equals(x) returns true.
x, y, and z, if
x.equals(y) returns true and
y.equals(z) returns true, then
x.equals(z) should return true.
x and y, multiple invocations of
x.equals(y) consistently return true
or consistently return false, provided no
information used in equals comparisons on the
objects is modified.
x,
x.equals(null) should return false.
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.
equals method for class Object implements
the most discriminating possible equivalence relation on objects;
that is, for any non-null reference values x and
y, this method returns true if and only
if x and y refer to the same object
(x == y has the value true).
In other words, under the reference equality equivalence
relation, each equivalence class only has a single element.hashCode method, which states
that equal objects must have equal hash codes.obj - the reference object with which to compare.true if this object is the same as the obj
argument; false otherwise.Returns the CodeSource associated with compiled script classes.
Returns the backing file when this code source was created from a file.
null if this source does not originate from a fileReturns the logical name used for the script.
Returns the Groovy source text.
Returns the backing URL when this code source was created from a URL.
null if this source does not originate from a URLReturns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by HashMap.
The general contract of hashCode is:
hashCode method
must consistently return the same integer, provided no information
used in equals comparisons on the object is modified.
This integer need not remain consistent from one execution of an
application to another execution of the same application.
hashCode method on each of the two objects must produce the
same integer result.
hashCode method on each of the two objects
must produce distinct integer results. However, the programmer
should be aware that producing distinct integer results for
unequal objects may improve the performance of hash tables.
hashCode method defined
by class Object returns distinct integers for distinct objects.Indicates whether classes compiled from this source may be cached.
true if the source is cacheableControls whether classes compiled from this source may be cached by GroovyClassLoader.
b - true to allow caching, false otherwiseCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.