Groovy Documentation

java.gate.yam
Class YamFile

java.lang.Object
  java.gate.yam.YamFile
All Implemented Interfaces:
Serializable

class YamFile

Main interface to the YAM language and its translation. Target languages:

author:
Hamish Cunningham


Nested Class Summary
enum YamFile.FileType

The various file types involved with YAM and their filename suffixes.

 
Field Summary
static Map currentGenerateCalls

Record of generation processes that are in progress.

boolean doIncludes

Should we process included files or not?

IOHandler ioHandler

IOHandler to pass to the parser.

org.springframework.core.io.FileSystemResource location

Location of the .yam.

static Logger log

Logger

Set outputTypes

What types of output to generate.

YamParseTree parseTree

The parse tree (and related state) created by {

 
Constructor Summary
YamFile(org.springframework.core.io.FileSystemResource location)

Construction.

YamFile(File locationFile)

Construction.

 
Method Summary
YamParseTree generate()

Translate to target languages.

void generateType(FileType type)

Trigger generation of the various output types.

static YamFile get(File location)

Static factory method for getting a YAM file.

static YamFile get(org.springframework.core.io.FileSystemResource location)

Static factory method for getting a YAM file.

String getCanonicalPath()

Get the canonical path of this file.

File getHtmlFile()

Get the File for HTML output.

String getHtmlPath()

Get the path for an HTML output file.

List getIncludes()

Get the list of includes from this YAM file to other local files, as a list of canonical paths of those files.

List getLinks()

Get the list of links from this YAM file to other local files, as a list of canonical paths of those files.

org.springframework.core.io.FileSystemResource getLocation()

Get the location of this file.

File getOutputFile(FileType type)

Create a file of a particular output type.

List getOutputLocations()

Get a List of those output file locations that are generated by this YamFile.

YamParseTree getParseTree()

Get the parse tree (and related state) created by {

static String getPluginPackageName()

Get the package name for YAM plugins.

String getVersion()

Get the language version number.

static YamFile needsGeneration(org.springframework.core.io.FileSystemResource location)

This method checks whether a dependent file (one that is generated from YAM) needs regeneration, and if so it returns a YamFile instance corresponding to the generated file.

static String printErrors(YamParseTree parseTree)

Print errors and warnings from parsing.

private void readObject(ObjectInputStream ois)

Allow serialization of the Spring FSR field.

void replaceInContext(String name)

Reset the location of this YamFile in the directory pointed to by the context path.

void setBibAnchorPrefix(String bibAnchorPrefix)

Set the prefix added to citation keys, when forming a reference to a bibiography file entry

void setBibPageUrl(org.springframework.core.io.UrlResource bibPageUrl)

Set the URL within which citation keys will be resolved.

void setContextPath(String contextPath)

Set the path in which to check for existence of relative links.

void setCreatePageUrl(String createPageUrl)

Set the URL which non-existent links will be pointed at (which presumably is the "create new page" URL for the parent wiki).

void setCreatePageUrl(org.springframework.core.io.UrlResource createPageUrl)

Set the URL which non-existent links will be pointed at (which presumably is the "create new page" URL for the parent wiki).

void setDoIncludes(boolean b)

Should we process included files or not?

String toString()

Return a String representing this YamFile: the String representation of the underlying File.

void translate(FileType outputType, Writer outputWriter, YamParseTree parseTree)

Construct an appropriate translator for the target language and run it.

YamFile valueOf(String name)

Returns the enum constant of this type with the specified name.

YamFile[] values()

Returns an array containing the constants of this enum type, in the order they are declared.

private void writeObject(ObjectOutputStream oos)

Allow serialization of the Spring FSR field.

 
Methods inherited from class Object
wait, wait, wait, hashCode, getClass, equals, toString, notify, notifyAll
 

Field Detail

currentGenerateCalls

static Map currentGenerateCalls
Record of generation processes that are in progress. Maps from canonical path of the YAM file to the file types that are being processed.


doIncludes

boolean doIncludes
Should we process included files or not?


ioHandler

IOHandler ioHandler
IOHandler to pass to the parser.


location

org.springframework.core.io.FileSystemResource location
Location of the .yam.


log

static Logger log
Logger


outputTypes

Set outputTypes
What types of output to generate.


parseTree

YamParseTree parseTree
The parse tree (and related state) created by #generate().


 
Constructor Detail

YamFile

public YamFile(org.springframework.core.io.FileSystemResource location)
Construction.


YamFile

public YamFile(File locationFile)
Construction.


 
Method Detail

generate

public YamParseTree generate()
Translate to target languages.
throws:
GateException if parsing or translation fails.
return:
the parse tree, or null if generation of any of our output types is currently underway in a different YamFile.


generateType

public void generateType(FileType type)
Trigger generation of the various output types.


get

public static YamFile get(File location)
Static factory method for getting a YAM file. Implemented via #get(FileSystemResource).


get

public static YamFile get(org.springframework.core.io.FileSystemResource location)
Static factory method for getting a YAM file. This method will create a YamFile for a particular location, or will return the YamFile dependency for a generated file (e.g. HTML). A null return value indicates that a dependent file was passed which is not generated from YAM.
param:
location a path that points to a YAM file or a file depending on a YAM file.
return:
either a YamFile instance or null.


getCanonicalPath

public String getCanonicalPath()
Get the canonical path of this file.


getHtmlFile

public File getHtmlFile()
Get the File for HTML output.


getHtmlPath

public String getHtmlPath()
Get the path for an HTML output file.


getIncludes

public List getIncludes()
Get the list of includes from this YAM file to other local files, as a list of canonical paths of those files. For files dependent on a YAM file, then the path of the YAM file will be returned. For files not dpendent on YAM files, the path of the file will be returned. Any includes that cannot be resolved from their local path are ignored.
return:
A list of the canonical paths of includes in this YAM file. Null if the parse tree has not been generated via a call to generate(). Null if the parent directory of this YamFile cannot be resolved. Empty if there are no includes.


getLinks

public List getLinks()
Get the list of links from this YAM file to other local files, as a list of canonical paths of those files. For files dependent on a YAM file, then the path of the YAM file will be returned. For files not dpendent on YAM files, the path of the file will be returned. Any links that cannot be resolved from their local path are ignored.
return:
A list of the canonical paths of links in this YAM file. Null if the parse tree has not been generated via a call to generate(). Null if the parent directory of this YamFile cannot be resolved. Empty if there are no links.


getLocation

public org.springframework.core.io.FileSystemResource getLocation()
Get the location of this file.


getOutputFile

public File getOutputFile(FileType type)
Create a file of a particular output type.


getOutputLocations

public List getOutputLocations()
Get a List of those output file locations that are generated by this YamFile.
throws:
GateException if there is an exception on the YamFile location.
return:
a List of locations as Strings.


getParseTree

public YamParseTree getParseTree()
Get the parse tree (and related state) created by #generate(). If generate hasn't been run this will be null.


getPluginPackageName

public static final String getPluginPackageName()
Get the package name for YAM plugins.


getVersion

public String getVersion()
Get the language version number. Version 1 was derived from Terrence Parr's TML language (thanks Ter! See the ANTLR site). Version 2 was the first version of YAM proper. Version 3 added various new facilities and was the basis for the first version of CLIE. Version 4 was a complete rewrite, for GATE version 4 and for use in CoW. Version 5 is intended to be stable and backwards-compatible with future versions.


needsGeneration

public static YamFile needsGeneration(org.springframework.core.io.FileSystemResource location)
This method checks whether a dependent file (one that is generated from YAM) needs regeneration, and if so it returns a YamFile instance corresponding to the generated file. If the file doesn't need regeneration or has not been generated from a YAM file the method returns null. A dependent file needs regeneration when
param:
location a file that may be generated from a YAM source file
return:
either the YAM file that needs generation or null
throws:
GateRuntimeException if we get an IO exception on the location file


printErrors

public static String printErrors(YamParseTree parseTree)
Print errors and warnings from parsing.


readObject

private void readObject(ObjectInputStream ois)
Allow serialization of the Spring FSR field.


replaceInContext

public void replaceInContext(String name)
Reset the location of this YamFile in the directory pointed to by the context path. I.e. the new location of the file will be contextPath + new file name. This method is useful for when a generate has been done out of place (e.g. in the CoW staging directory) but now dependency analysis needs to be done on the file as if it was in place (e.g. when saving an edit and checking in).
param:
name the file name of the


setBibAnchorPrefix

public void setBibAnchorPrefix(String bibAnchorPrefix)
Set the prefix added to citation keys, when forming a reference to a bibiography file entry
see:
#setBibPageUrl(UrlResource)
param:
bibAnchorPrefix The prefix added to citation keys.


setBibPageUrl

public void setBibPageUrl(org.springframework.core.io.UrlResource bibPageUrl)
Set the URL within which citation keys will be resolved. The URL will be for a bibliogrpahy. Citation keys reference a part of this URL, an individual bibliographic entry. Citation keys will form the final fragment of this URL, and will be prefixed, as defined by the #setBibAnchorPrefix(String) setBibAnchorPrefix method
param:
bibPageUrl the URL of the bibliogrpahy.


setContextPath

public void setContextPath(String contextPath)
Set the path in which to check for existence of relative links.
param:
contextPath the path to search in.


setCreatePageUrl

public void setCreatePageUrl(String createPageUrl)
Set the URL which non-existent links will be pointed at (which presumably is the "create new page" URL for the parent wiki).
param:
createPageUrl the link to point to.


setCreatePageUrl

public void setCreatePageUrl(org.springframework.core.io.UrlResource createPageUrl)
Set the URL which non-existent links will be pointed at (which presumably is the "create new page" URL for the parent wiki).
param:
createPageUrl the link to point to.


setDoIncludes

public void setDoIncludes(boolean b)
Should we process included files or not?


toString

public String toString()
Return a String representing this YamFile: the String representation of the underlying File.
return:
A String representing this YamFile


translate

public void translate(FileType outputType, Writer outputWriter, YamParseTree parseTree)
Construct an appropriate translator for the target language and run it.


valueOf

YamFile valueOf(String name)
Returns the enum constant of this type with the specified name.


values

YamFile[] values()
Returns an array containing the constants of this enum type, in the order they are declared.


writeObject

private void writeObject(ObjectOutputStream oos)
Allow serialization of the Spring FSR field.


 

Groovy Documentation