Package helma.framework.core

# Class Prototype

java.lang.Object
helma.framework.core.Prototype

public final class Prototype extends Object
The Prototype class represents Script prototypes/type defined in a Helma application. This class manages a prototypes templates, functions and actions as well as optional information about the mapping of this type to a relational database table.

## Constructor Summary

Constructors
Constructor
Description
`Prototype(String name, Repository repository, Application app, Map typeProps)`
Creates a new Prototype object.

## Method Summary

Modifier and Type
Method
Description
`void`
`addRepository(Repository repository, boolean update)`
Adds an repository to the list of repositories
`void`
`checkForUpdates()`
Check a prototype for new or updated resources.
`Application`
`getApplication()`
Return the application this prototype is a part of
`Iterator`
`getCodeResources()`
Return an iterator over this prototype's code resoruces.
`DbMapping`
`getDbMapping()`
Get the DbMapping associated with this prototype
`String`
`getLowerCaseName()`
Return this prototype's name in lower case letters
`String`
`getName()`
Return this prototype's name
`Prototype`
`getParentPrototype()`
Get the parent prototype from which we inherit, or null if we are top of the line.
`Repository[]`
`getRepositories()`
Returns an array of repositories containing code for this prototype.
`Resource[]`
`getResources()`
Returns the list of resources in this prototype's repositories.
`Map`
`getScriptableSkinMap()`
Get a map containing this prototype's skins as strings
`Map`
`getScriptableSkinMap(Object[] skinpath)`
Get a map containing this prototype's skins as strings, overloaded by the skins found in the given skinpath.
`Skin`
`getSkin(Prototype proto, String skinname, String subskin, Object[] skinpath)`
Get a skin for this prototype.
`Iterator`
`getSkinResources()`
Return an iterator over this prototype's skin resoruces.
`ResourceProperties`
`getTypeProperties()`
Get the prototype's aggregated type.properties
`final boolean`
`isInstanceOf(String pname)`
Check if the given prototype is within this prototype's parent chain.
`long`
`lastCodeUpdate()`
Get the last time any script has been re-read for this prototype.
`void`
`markUpdated()`
Signal that some script in this prototype has been re-read from disk and needs to be re-compiled by the evaluators.
`final void`
`registerParents(Map handlers, Object obj)`
Register an object as handler for all our parent prototypes, but only if a handler by that prototype name isn't registered yet.
`void`
`setParentPrototype(Prototype parent)`
Set the parent prototype of this prototype, i.e.
`void`
`setTypeProperties(Map map)`
Set the custom type properties for this prototype and update the database mapping.
`String`
`toString()`
Return a string representing this prototype.

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

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

## Constructor Details

### Prototype

public Prototype(String name, Repository repository, Application app, Map typeProps)
Creates a new Prototype object.

Parameters:
  `name` - the prototype's name
  `repository` - the first prototype's repository
  `app` - the application this prototype is a part of
  `typeProps` - custom type mapping properties

## Method Details

### getApplication

public Application getApplication()
Return the application this prototype is a part of

### addRepository

public void addRepository(Repository repository, boolean update) throws IOException
Adds an repository to the list of repositories

Parameters:
  `repository` - repository to add
  `update` - indicates whether to immediately update the prototype with the new code
Throws:
  `IOException` - if reading/updating from the repository fails

### checkForUpdates

public void checkForUpdates()
Check a prototype for new or updated resources. After this has been called the code and skins collections of this prototype should be up-to-date and the lastCodeUpdate be set if there has been any changes.

### getResources

public Resource[] getResources()
Returns the list of resources in this prototype's repositories. Used by checkForUpdates() to see whether there is anything new.

### getRepositories

public Repository[] getRepositories()
Returns an array of repositories containing code for this prototype.

### setParentPrototype

public void setParentPrototype(Prototype parent)
Set the parent prototype of this prototype, i.e. the prototype this prototype inherits from.

### getParentPrototype

public Prototype getParentPrototype()
Get the parent prototype from which we inherit, or null if we are top of the line.

### isInstanceOf

public final boolean isInstanceOf(String pname)
Check if the given prototype is within this prototype's parent chain.

### registerParents

public final void registerParents(Map handlers, Object obj)
Register an object as handler for all our parent prototypes, but only if a handler by that prototype name isn't registered yet. This is used to implement direct over indirect prototype precedence and child over parent precedence.

### getDbMapping

public DbMapping getDbMapping()
Get the DbMapping associated with this prototype

### getSkin

public Skin getSkin(Prototype proto, String skinname, String subskin, Object[] skinpath) throws IOException
Get a skin for this prototype. This only works for skins residing in the prototype directory, not for skins files in other locations or database stored skins. If parentName and subName are defined, the skin may be a subskin of another skin.

Throws:
  `IOException`

### getName

public String getName()
Return this prototype's name

Returns:
  ...

### getLowerCaseName

public String getLowerCaseName()
Return this prototype's name in lower case letters

Returns:
  ...

### lastCodeUpdate

public long lastCodeUpdate()
Get the last time any script has been re-read for this prototype.

### markUpdated

public void markUpdated()
Signal that some script in this prototype has been re-read from disk and needs to be re-compiled by the evaluators.

### setTypeProperties

public void setTypeProperties(Map map)
Set the custom type properties for this prototype and update the database mapping.

Parameters:
  `map` - the custom type mapping properties.

### getTypeProperties

public ResourceProperties getTypeProperties()
Get the prototype's aggregated type.properties

Returns:
  type.properties

### getCodeResources

public Iterator getCodeResources()
Return an iterator over this prototype's code resoruces. Synchronized to not return a collection in a transient state where it is just being updated by the type manager.

Returns:
  an iterator of this prototype's code resources

### getSkinResources

public Iterator getSkinResources()
Return an iterator over this prototype's skin resoruces. Synchronized to not return a collection in a transient state where it is just being updated by the type manager.

Returns:
  an iterator over this prototype's skin resources

### toString

public String toString()
Return a string representing this prototype.

Overrides:
  `toString` in class `Object`

### getScriptableSkinMap

public Map getScriptableSkinMap()
Get a map containing this prototype's skins as strings

Returns:
  a scriptable skin map

### getScriptableSkinMap

public Map getScriptableSkinMap(Object[] skinpath)
Get a map containing this prototype's skins as strings, overloaded by the skins found in the given skinpath.

Returns:
  a scriptable skin map