org.millscript.millscript.loaders
Class Loader

java.lang.Object
  extended by org.millscript.millscript.loaders.Loader
All Implemented Interfaces:
org.millscript.commons.alert.AlertOrigin
Direct Known Subclasses:
BindingsLoader, ValueLoader

public abstract class Loader
extends java.lang.Object
implements org.millscript.commons.alert.AlertOrigin

This is the base class of all loaders in MillScript. A loader is responsible for compiling the contents of a file into a MillScript structure. e.g. a text file is compiled to a string, while a template is compiled into a function wrapping some recursive XML.


Field Summary
protected  org.millscript.commons.vfs.VEntry entry
          The source we want to compile from
protected  Package pack
          The package we want to compile the source file into
protected  java.lang.String symbol
          The symbol we want bound after compiling the source file
 
Constructor Summary
Loader()
           
 
Method Summary
 Loader getInstance()
          Returns a new instance of this loader, to be used as appropriate.
 int getLineNumber()
           
 java.lang.String getOrigin()
           
 java.lang.String getSymbol()
          Returns the symbol this loader will compile.
abstract  void loadBindings()
          Causes this loader to load it's bindings.
abstract  java.lang.Object loadValue()
          Causes this loader to load it's value.
 Loader newLoader(Package p, java.lang.String sym, org.millscript.commons.vfs.VEntry e)
          Returns a new loader to load the specified source file into the specified package, binding a value to the specified symbol.
 void setContext(java.lang.String s, int n)
           
 void setLineNumber(int n)
           
 Loader setLoader(Package p, java.lang.String sym, org.millscript.commons.vfs.VEntry e)
          Sets the package this loader will import into, the symbol for the loaded resource and the virtual filesystem entry for the data to compile.
 void setOrigin(java.lang.String o)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pack

protected Package pack
The package we want to compile the source file into


entry

protected org.millscript.commons.vfs.VEntry entry
The source we want to compile from


symbol

protected java.lang.String symbol
The symbol we want bound after compiling the source file

Constructor Detail

Loader

public Loader()
Method Detail

setLoader

public Loader setLoader(Package p,
                        java.lang.String sym,
                        org.millscript.commons.vfs.VEntry e)
Sets the package this loader will import into, the symbol for the loaded resource and the virtual filesystem entry for the data to compile.

Parameters:
p - the package to compile into
sym - the symbol for the compiled resource
e - the entry of the data to compile
Returns:
this Loader

getInstance

public Loader getInstance()
Returns a new instance of this loader, to be used as appropriate.

Returns:
a new instance of this loader.

getLineNumber

public int getLineNumber()
Specified by:
getLineNumber in interface org.millscript.commons.alert.AlertOrigin
See Also:
AlertOrigin.getLineNumber()

getOrigin

public java.lang.String getOrigin()
Specified by:
getOrigin in interface org.millscript.commons.alert.AlertOrigin
See Also:
AlertOrigin.getOrigin()

getSymbol

public java.lang.String getSymbol()
Returns the symbol this loader will compile.

Returns:
a String holding the symbol for the resource

loadValue

public abstract java.lang.Object loadValue()
                                    throws java.io.IOException
Causes this loader to load it's value.

Returns:
the object that was loaded
Throws:
java.io.IOException - if something goes wrong reading from the source

loadBindings

public abstract void loadBindings()
                           throws java.io.IOException
Causes this loader to load it's bindings. This will usually trigger the loader to load it's value, then compile it into the package.

Throws:
java.io.IOException - if something goes wrong reading from the source

newLoader

public Loader newLoader(Package p,
                        java.lang.String sym,
                        org.millscript.commons.vfs.VEntry e)
Returns a new loader to load the specified source file into the specified package, binding a value to the specified symbol.

Parameters:
p - the package to load values into
sym - the symbol that must be bound after loading
e - the entry of the data to compile
Returns:
a Loader to compile the source file

setContext

public void setContext(java.lang.String s,
                       int n)
Specified by:
setContext in interface org.millscript.commons.alert.AlertOrigin
See Also:
AlertOrigin.setContext(java.lang.String, int)

setLineNumber

public void setLineNumber(int n)
Specified by:
setLineNumber in interface org.millscript.commons.alert.AlertOrigin
See Also:
AlertOrigin.setLineNumber(int)

setOrigin

public void setOrigin(java.lang.String o)
Specified by:
setOrigin in interface org.millscript.commons.alert.AlertOrigin
See Also:
AlertOrigin.setOrigin(java.lang.String)


Copyright © 2001-2007 Open World Ltd. All Rights Reserved.