Package de.hsh.graja.util.comment
Class Content
java.lang.Object
de.hsh.graja.util.comment.Content
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
AbstractElementContent
,AbstractSequenceContent
Something that can be rendered to a presentable medium.
We think of Content as an interface abstracting any class that
holds data that can be transformed to HTML.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final MutualExclusiveObject<String>
protected Function<RenderContext,
String> -
Constructor Summary
ConstructorsConstructorDescriptionContent
(String idPrefix, IncludeSpec includeSpec) Create a new content instance. -
Method Summary
Modifier and TypeMethodDescriptionclick()
static void
Disables the stacktrace recording mechanism that allows to trace a comments origin within the graja codebasestatic void
Enables the stacktrace recording mechanism that allows to trace a comments origin within the graja codebaseboolean
Two Content are equal, when theirgetIncludeSpec()
are equal.boolean
Only relevant for the regression testing mechanism.int
hashCode()
hide()
boolean
include
(IncludeInfo info) static boolean
isHidden()
abstract boolean
Register an action that will be rendered in the 'onClick' attribute of this content.Register actions that will be rendered in the 'onClick' attribute of this content.Register an action that will be rendered byhide()
.Register actions that will be rendered byhide()
.Register an action that will be rendered at the top level besides this content's HTML markup.Register actions that will be rendered at the top level besides this content's HTML markup.Register an action that will be rendered byshow()
.Register actions that will be rendered byshow()
.<T extends Action>
CallableAction<T>registerCallable
(T delegate, String functionPrefix) Places a javascript snippet besides this content defining a function of the givenfunctionName
.void
renderHtml
(StringBuilder appender, IncludeInfo includeInfo, RenderContext ctx, boolean useJavascript) render content to HTML.void
renderHtml
(StringBuilder appender, IncludeInfo includeInfo, String namespace, boolean useJavascript) render content to HTML.protected abstract void
renderHtmlImpl
(StringBuilder appender, IncludeInfo includeInfo, RenderContext ctx, boolean useJavascript) render content to HTML.protected void
renderIdAttribute
(StringBuilder appender, RenderContext ctx) static void
renderJavascriptOncePerClass
(StringBuilder appender, RenderContext ctx) This method writes javascript code toappender
.protected void
renderOnClickAttribute
(StringBuilder appender, RenderContext ctx, boolean useJavascript) void
renderPlain
(StringBuilder appender, IncludeInfo includeInfo, RenderContext ctx) render content to plain text.void
renderPlain
(StringBuilder appender, IncludeInfo includeInfo, String namespace) render content to plain text.abstract void
renderPlainImpl
(StringBuilder appender, IncludeInfo includeInfo, RenderContext ctx) render content to plain text.static void
This method configures the html content classes to exclude all content not included byinfo
.void
void
setIncludeSpec
(IncludeSpec spec) show()
toString()
This method is for debugging purposes.
-
Field Details
-
renderUuid
-
EXCLUSIVE
-
-
Constructor Details
-
Content
Create a new content instance. For every render context this method sets a new uuid with the given prefix. Hyphens in the uuid are eliminated, so the uuid can be used as an javascript identifier.- Parameters:
prefix
- an optional id prefixincludeSpec
- an optional include spec
-
-
Method Details
-
setGlobalIncludeInfo
This method configures the html content classes to exclude all content not included byinfo
. With this setting we can speed up document generation without many debug content that is only used in developement situations.- Parameters:
info
- include info
-
excludeGlobally
public boolean excludeGlobally()- Returns:
- true, if this content is excluded by the value set via
setGlobalIncludeInfo(IncludeInfo)
.
-
getRenderUuid
- Returns:
- the uuid for the given context, or null.
-
renderJavascriptOncePerClass
This method writes javascript code toappender
. Subclasses can also implement an own version of this method. The javascript content will be rendered only once when callingContent#renderHtml(StringBuilder, IncludeInfo, RenderContext, Boolean)
with a RenderContext parameter being null.- Parameters:
appender
-ctx
-
-
getIncludeSpec
- Returns:
- the specification object of this content's include behaviour
-
setIncludeSpec
- Parameters:
new
- include spec
-
include
- Parameters:
info
- inclusion info- Returns:
- true, if this content is to be included
-
getNestedContents
- Returns:
- the set of contents nested in this content. Nested contents can be list items in a List, elements in a Sequence, elements in a Grid, elements in a Paragraph, and so on. If this is a leaf content, the returned set is empty.
-
isInlineContent
public abstract boolean isInlineContent()- Returns:
- true, if this content can be used as a child content of a
Paragraph
.
-
equals
Two Content are equal, when theirgetIncludeSpec()
are equal. -
hashCode
public int hashCode() -
toString
This method is for debugging purposes.- Parameters:
prefix
- If the output has multiple lines,prefix
specifies the indentation of the subsequent lines.- Returns:
- a string representation of the content and it's internal structure.
-
toString
-
renderHtml
public void renderHtml(StringBuilder appender, IncludeInfo includeInfo, String namespace, boolean useJavascript) render content to HTML.- Parameters:
appender
- HTML code resultincludeInfo
- controls, which content to be rendered.namespace
- the namespace of the rendered HTML. If null, a random namespace string will be generated.useJavascript
- if true, the generated HTML code will contain Javascript
-
renderHtml
public void renderHtml(StringBuilder appender, IncludeInfo includeInfo, RenderContext ctx, boolean useJavascript) render content to HTML.- Parameters:
appender
- HTML code resultincludeInfo
- controls, which content to be rendered.ctx
- render context. If null, a new render context will be instantiated automatically.useJavascript
- if true, the generated HTML code will contain Javascript
-
renderHtmlImpl
protected abstract void renderHtmlImpl(StringBuilder appender, IncludeInfo includeInfo, RenderContext ctx, boolean useJavascript) render content to HTML. This method is meant to be overriden by subclasses.- Parameters:
appender
- HTML code resultincludeInfo
- controls, which content to be rendered.ctx
- render contextuseJavascript
- if true, the generated HTML code will contain Javascript
-
renderPlainImpl
public abstract void renderPlainImpl(StringBuilder appender, IncludeInfo includeInfo, RenderContext ctx) render content to plain text. This method is meant to be overriden by subclasses.- Parameters:
appender
- plain text resultincludeInfo
- controls, which content to be rendered.ctx
- render context (unused).
-
renderPlain
render content to plain text.- Parameters:
appender
- plain text resultincludeInfo
- controls, which content to be rendered.namespace
- unused
-
renderPlain
render content to plain text.- Parameters:
appender
- plain text resultincludeInfo
- controls, which content to be rendered.ctx
- render context (unused).
-
setHref
-
click
-
hide
- Returns:
- an object that can be used to render a javascript snippet that will hide this content and that will render all actions registered with onHide.
-
show
- Returns:
- an object that can be used to render a javascript snippet that will show this content and that will render all actions registered with onShow.
-
isHidden
- Returns:
- an object that can be used to render a javascript snippet that represents a boolean expression being true if this content is currently hidden.
-
isShowing
- Returns:
- an object that can be used to render a javascript snippet that represents a boolean expression being true if this content is currently visible.
-
highlight
- Returns:
- an object that can be used to render a javascript snippet that highlights content
-
dehighlight
- Returns:
- an object that can be used to render a javascript snippet that dehighlights content
-
onClick
Register an action that will be rendered in the 'onClick' attribute of this content. -
onClick
Register actions that will be rendered in the 'onClick' attribute of this content. -
onHide
Register an action that will be rendered byhide()
. -
onHide
Register actions that will be rendered byhide()
. -
onShow
Register an action that will be rendered byshow()
. -
onShow
Register actions that will be rendered byshow()
. -
onLoad
Register an action that will be rendered at the top level besides this content's HTML markup. This action will be executed when the browser loads the document. -
onLoad
Register actions that will be rendered at the top level besides this content's HTML markup. These actions will be executed when the browser loads the document. -
registerCallable
Places a javascript snippet besides this content defining a function of the givenfunctionName
. The function is implemented by calling the givendelegate
.- Parameters:
delegate
-functionName
-- Returns:
-
renderOnClickAttribute
protected void renderOnClickAttribute(StringBuilder appender, RenderContext ctx, boolean useJavascript) -
renderIdAttribute
-
enableCallerStacktraceRecording
public static void enableCallerStacktraceRecording()Enables the stacktrace recording mechanism that allows to trace a comments origin within the graja codebase -
isCallerStacktraceRecordingEnabled
public static boolean isCallerStacktraceRecordingEnabled()- Returns:
- true, if stacktrace recording is enabled, which is only the case when regression test behavior recording is enabled
-
disableCallerStacktraceRecording
public static void disableCallerStacktraceRecording()Disables the stacktrace recording mechanism that allows to trace a comments origin within the graja codebase -
getStackdump
Only relevant for the regression testing mechanism.Generates a filtered stackdump consisting out of
StackTraceElement
s without the first two irrelevant stackframes.- Returns:
- filtered stackdump
- Throws:
UnsupportedOperationException
- if no recording has been created
-