Package org.codehaus.groovy.tools.javac

# Class MemJavaFileObject

java.lang.Object
javax.tools.SimpleJavaFileObject
org.codehaus.groovy.tools.javac.MemJavaFileObject

All Implemented Interfaces:
  `FileObject`, `JavaFileObject`

public class MemJavaFileObject extends SimpleJavaFileObject
Represents a Java source file in memory to compile

Since:
  3.0.0

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from interface javax.tools.JavaFileObject

  `JavaFileObject.Kind`

- ## Field Summary

  ### Fields inherited from class javax.tools.SimpleJavaFileObject

  `kind, uri`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MemJavaFileObject(String className, String src)`
  Construct a MemJavaFileObject instance with given class name and source code
  `MemJavaFileObject(ClassNode classNode, String src)`
  Construct a MemJavaFileObject instance with given class node and source code

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `equals(Object o)`
  Compares this file object by its class name.
  `CharSequence`
  `getCharContent(boolean ignoreEncodingErrors)`
  Returns the in-memory source content.
  `int`
  `hashCode()`
  Returns the hash code derived from the class name.
  `String`
  `toString()`
  Returns a diagnostic string for this in-memory Java file object.

  ### Methods inherited from class javax.tools.SimpleJavaFileObject

  `delete, getAccessLevel, getKind, getLastModified, getName, getNestingKind, isNameCompatible, openInputStream, openOutputStream, openReader, openWriter, toUri`

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### MemJavaFileObject

    public MemJavaFileObject(ClassNode classNode, String src)
    Construct a MemJavaFileObject instance with given class node and source code
    Parameters:
      `classNode` - the class node
      `src` - the source code

  - ### MemJavaFileObject

    public MemJavaFileObject(String className, String src)
    Construct a MemJavaFileObject instance with given class name and source code
    Parameters:
      `className` - the class name
      `src` - the source code

- ## Method Details

  - ### getCharContent

    public CharSequence getCharContent(boolean ignoreEncodingErrors)
    Returns the in-memory source content.
    Specified by:
      `getCharContent` in interface `FileObject`
    Overrides:
      `getCharContent` in class `SimpleJavaFileObject`
    Parameters:
      `ignoreEncodingErrors` - ignored because the content is already a character sequence
    Returns:
      the source content

  - ### equals

    public boolean equals(Object o)
    Compares this file object by its class name.
    Overrides:
      `equals` in class `Object`
    Parameters:
      `o` - the object to compare against
    Returns:
      `true` if the other object represents the same class name

  - ### hashCode

    public int hashCode()
    Returns the hash code derived from the class name.
    Overrides:
      `hashCode` in class `Object`
    Returns:
      the hash code

  - ### toString

    public String toString()
    Returns a diagnostic string for this in-memory Java file object.
    Overrides:
      `toString` in class `SimpleJavaFileObject`
    Returns:
      a string representation of this file object