org.rythmengine.extension
Interface ICodeType

All Known Implementing Classes:
ICodeType.DefImpl

public interface ICodeType

Specify a language (e.g. JavaScript) or a format (e.g. csv). The information could be used by Rythm to support natural template feature and smart escape feature


Nested Class Summary
static class ICodeType.DefImpl
           
 
Method Summary
 Set<ICodeType> allowedExternalTypes()
          Return a set of other types that could embed this type impl.
 boolean allowInternalTypeBlock()
          Return true if this file type impl allow another type be embedded inside.
 String blockEnd()
          Return a regex string indicate an end of a type block
 String blockStart()
          Some type could be embedded into another.
 String commentEnd()
          Return comment end.
 String commentStart()
          Return comment start.
 Escape escape()
          Return escape scheme
 ICodeType getParent()
          Return parent type or null if there is no parent set on it
 String newInstanceStr()
          Return a string that could be write into the target java source code to create an instance of this type
 String resourceNameSuffix()
          Return recommended resource name suffix, e.g.
 void setParent(ICodeType parent)
          Set the parent type to the embedded type
 

Method Detail

commentStart

String commentStart()
Return comment start. E.g. for HTML, it should be <!--

Returns:
comment start

commentEnd

String commentEnd()
Return comment end. For HTML it should be -->

Returns:
comment end

escape

Escape escape()
Return escape scheme

Returns:
escape

blockStart

String blockStart()
Some type could be embedded into another. E.g. JS and CSS could be embedded into HTML. This method returns a regex string the direct the start of the embedded type.

Note the regex string must support group and the group 1 must be the captured block start. For example, JS block start is <script> or <script type="..."...>, then the blockStart method of JS type should be (\<\s*script\s*.*?\<).*

Returns:
block start

blockEnd

String blockEnd()
Return a regex string indicate an end of a type block

Returns:
block end
See Also:
for regex requirement

allowInternalTypeBlock

boolean allowInternalTypeBlock()
Return true if this file type impl allow another type be embedded inside. e.g. HTML should return true for this method because it allows JS and CSS be embedded inside

Returns:
true if this type allows embedded type

allowedExternalTypes

Set<ICodeType> allowedExternalTypes()
Return a set of other types that could embed this type impl. For example, JS should return a Set contains an HTML impl. If no other type is allowed to embed this type, then an empty set shall be returned

Returns:
true if this type allows external type

setParent

void setParent(ICodeType parent)
Set the parent type to the embedded type

Parameters:
parent -

getParent

ICodeType getParent()
Return parent type or null if there is no parent set on it

Returns:
parent type

newInstanceStr

String newInstanceStr()
Return a string that could be write into the target java source code to create an instance of this type

Returns:
the java code

resourceNameSuffix

String resourceNameSuffix()
Return recommended resource name suffix, e.g. ".html" etc

Returns:
proposed resource name suffix


Copyright © 2013. All Rights Reserved.