Overview | Package | Class | Deprecated | Index | Help
| Groovy Documentation
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## groovy.lang
[Java] Class GroovyCodeSource

    java.lang.Object
      groovy.lang.GroovyCodeSource

    public class GroovyCodeSource
    extends java.lang.Object

CodeSource wrapper class that allows specific security policies to be associated with a class compiled from groovy source.

Authors:
  Steve Goetze
  Guillaume Laforge
  Merlyn Albery-Speyer

Constructor Summary
`GroovyCodeSource(java.lang.String script, java.lang.String name, java.lang.String codeBase)`
`GroovyCodeSource(java.io.Reader reader, java.lang.String name, java.lang.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.
`GroovyCodeSource(java.io.File infile, java.lang.String encoding)`
`GroovyCodeSource(java.io.File infile)` @param infile the file to create a GroovyCodeSource for.
`GroovyCodeSource(java.net.URL url)`

Method Summary
`java.io.File` | `getFile()`
`java.lang.String` | `getName()`
`java.lang.String` | `getScriptText()`
`boolean` | `isCachable()`
`void` | `setCachable(boolean b)`

Methods inherited from class java.lang.Object
java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()

Constructor Detail

### GroovyCodeSource

    public GroovyCodeSource(java.lang.String script, java.lang.String name, java.lang.String codeBase)

### GroovyCodeSource

    public GroovyCodeSource(java.io.Reader reader, java.lang.String name, java.lang.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). 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.

### GroovyCodeSource

    public GroovyCodeSource(java.io.File infile, java.lang.String encoding)

### GroovyCodeSource

    public GroovyCodeSource(java.io.File infile)

  throws:
    IOException if an issue arises opening and reading the file.
  Parameters:
    `infile` - the file to create a GroovyCodeSource for.

### GroovyCodeSource

    public GroovyCodeSource(java.net.URL url)

Method Detail

### getFile

    public java.io.File getFile()

### getName

    public java.lang.String getName()

### getScriptText

    public java.lang.String getScriptText()

### isCachable

    public boolean isCachable()

### setCachable

    public void setCachable(boolean b)

Groovy Documentation