Package ch.grengine.source
Class DefaultTextSource
java.lang.Object
ch.grengine.source.BaseSource
ch.grengine.source.DefaultTextSource
- All Implemented Interfaces:
Source,TextSource
Text-based script source, default implementation of the
TextSource interface.
The source ID is "/groovy/script/Script<text-hash>" resp. "/groovy/script/<text-hash>/<desired-class-name>".
The text hash is calculated as follows:
- UTF-8 encode the script text to bytes
- calculate the MD5 hash
- convert the resulting bytes to a hex string
The method BaseSource.getLastModified() always returns 0.
- Since:
- 1.0
- Author:
- Alain Stalder, Made in Switzerland.
-
Field Summary
Fields inherited from class ch.grengine.source.BaseSource
id -
Constructor Summary
ConstructorsConstructorDescriptionDefaultTextSource(String text) constructor from script text.DefaultTextSource(String text, String desiredClassName) constructor from script text and desired class name. -
Method Summary
Methods inherited from class ch.grengine.source.BaseSource
equals, getId, getLastModified, hashCodeMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface ch.grengine.source.Source
equals, getId, getLastModified, hashCode
-
Constructor Details
-
DefaultTextSource
constructor from script text.If the script text does not explicitly declare a class, the name of the compiled script class will normally be "Script<text-hash>".
- Parameters:
text- script text- Throws:
NullPointerException- if text is null- Since:
- 1.0
-
DefaultTextSource
constructor from script text and desired class name.If the script text does not explicitly declare a class, the name of the compiled script class will normally be the given desired class name.
- Parameters:
text- script textdesiredClassName- desired class name- Throws:
NullPointerException- if text or desired class name is null- Since:
- 1.0
-
-
Method Details
-
toString
Description copied from interface:Sourcereturns a string suitable for logging.- Specified by:
toStringin interfaceSource- Overrides:
toStringin classBaseSource- Returns:
- a string suitable for logging
-
getText
Description copied from interface:TextSourcegets the script text.- Specified by:
getTextin interfaceTextSource- Returns:
- script text
-