Package de.hsh.graja.util.comment
Class Paragraph
java.lang.Object
de.hsh.graja.util.comment.Content
de.hsh.graja.util.comment.AbstractSequenceContent
de.hsh.graja.util.comment.Sequence
de.hsh.graja.util.comment.Paragraph
- All Implemented Interfaces:
ContentLogger
,Serializable
This content is rendered as a paragraph. A subsequent content will begin after a line break and
(depending on the renderer) after some vertical distance. A Paragraph
serves as a container for several Content
s that have Content.isInlineContent()
returning true
.
Usage example:
Sequence sq= new Sequence(); Paragraph para= new Paragraph(Inline.format(includeSpec, "Expected return value from '%s': %f. Observed: %f.", avgMethodName, expected, observed))); para.formatInlineItem(includeSpec, FontWeightAndStyle.smaller(), " Here comes some debug information ..."); sq.addItem(para);
- See Also:
-
Field Summary
Fields inherited from class de.hsh.graja.util.comment.Content
EXCLUSIVE, renderUuid
-
Constructor Summary
ConstructorsConstructorDescriptionCreate an empty paragraph.Paragraph
(IncludeSpec includeSpec, String firstInlineData) Create a paragraph with a first inline content with normal font style.Paragraph
(IncludeSpec includeSpec, String firstInlineData, FontWeightAndStyle fwas) Create a paragraph with a first inline content with given font style.Create a paragraph with a first inline content. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds an inline content or a line break to the paragraph.void
formatInlineItem
(IncludeSpec includeSpec, FontWeightAndStyle fwas, String format, Object... args) Add another inline content to the end of the paragraph.void
formatInlineItem
(IncludeSpec includeSpec, String format, Object... args) Add another inline content to the end of the paragraph.void
newLine
(IncludeSpec includeSpec) Add a line break.void
renderHtmlImpl
(StringBuilder sb, IncludeInfo includeInfo, RenderContext ctx, boolean useJavascript) appends all comments in the sequence one after the other without any visual marks between the individual items.void
renderPlainImpl
(StringBuilder sb, IncludeInfo includeInfo, RenderContext ctx) appends all comments in the sequence one after the other without any visual marks between the individual items.surroundParagraphIfNeededAndPossible
(Iterable<Content> comments) Finds successiveContent
items incomments
each returning {code true} fromand puts these together in one or more surrounding {@link Paragraph} items.
This method is for debugging purposes.Methods inherited from class de.hsh.graja.util.comment.Sequence
addItems, clear, equals, formatAsInlineNewlineSeq, getNestedContents, hashCode, size
Methods inherited from class de.hsh.graja.util.comment.AbstractSequenceContent
isInlineContent
Methods inherited from class de.hsh.graja.util.comment.Content
click, dehighlight, disableCallerStacktraceRecording, enableCallerStacktraceRecording, excludeGlobally, getIncludeSpec, getRenderUuid, getStackdump, hide, highlight, include, isCallerStacktraceRecordingEnabled, isHidden, isShowing, onClick, onClick, onHide, onHide, onLoad, onLoad, onShow, onShow, registerCallable, renderHtml, renderHtml, renderIdAttribute, renderJavascriptOncePerClass, renderOnClickAttribute, renderPlain, renderPlain, setGlobalIncludeInfo, setHref, setIncludeSpec, show, toString
-
Constructor Details
-
Paragraph
public Paragraph()Create an empty paragraph. -
Paragraph
Create a paragraph with a first inline content with normal font style.- Parameters:
includeSpec
- the include spec of the first inline contentfirstInlineData
- the text of the first inline content
-
Paragraph
Create a paragraph with a first inline content with given font style.- Parameters:
includeSpec
- the include Spec of the first inline contentfirstInlineData
- the text of the first inline contentfwas
- the font of the first inline content
-
Paragraph
Create a paragraph with a first inline content.- Parameters:
firstInline
- the first inline content
-
-
Method Details
-
addItem
Adds an inline content or a line break to the paragraph. If the item is globally excluded (seeAbstractSequenceContent#excludeGlobally(Content)
, then the item is not added and ignored.- Specified by:
addItem
in interfaceContentLogger
- Overrides:
addItem
in classSequence
- Parameters:
content
- content to be added. This must be an instance ofContent
returntrue
fromContent.isInlineContent()
. Otherwise an exception is thrown.- Throws:
IllegalArgumentException
- if the parameter is not an instance ofContent
returningtrue
fromContent.isInlineContent()
-
formatInlineItem
Add another inline content to the end of the paragraph.- Parameters:
includeSpec
- the include Spec of the additional inline contentformat
- a format string as defined byFormatter.format(String, Object...)
.args
- arguments as expected byFormatter.format(String, Object...)
.
-
formatInlineItem
public void formatInlineItem(IncludeSpec includeSpec, FontWeightAndStyle fwas, String format, Object... args) Add another inline content to the end of the paragraph.- Parameters:
includeSpec
- the include spec of the additional inline contentfwas
- a font specificationformat
- a format string as defined byFormatter.format(String, Object...)
.args
- arguments as expected byFormatter.format(String, Object...)
.
-
newLine
Add a line break.- Parameters:
includeSpec
- the include spec for the line break
-
toString
Description copied from class:Content
This method is for debugging purposes. -
renderHtmlImpl
public void renderHtmlImpl(StringBuilder sb, IncludeInfo includeInfo, RenderContext ctx, boolean useJavascript) Description copied from class:Sequence
appends all comments in the sequence one after the other without any visual marks between the individual items.- Overrides:
renderHtmlImpl
in classSequence
- Parameters:
sb
- HTML code resultincludeInfo
- controls, which content to be rendered.ctx
- render contextuseJavascript
- if true, the generated HTML code will contain Javascript- See Also:
-
Content#renderHtmlImpl(StringBuilder, IncludeInfo, RenderContext)
-
renderPlainImpl
Description copied from class:Sequence
appends all comments in the sequence one after the other without any visual marks between the individual items.- Overrides:
renderPlainImpl
in classSequence
- Parameters:
sb
- plain text resultincludeInfo
- controls, which content to be rendered.ctx
- render context (unused).- See Also:
-
surroundParagraphIfNeededAndPossible
Finds successiveContent
items incomments
each returning {code true} fromand puts these together in one or more surrounding {@link Paragraph} items.
- Parameters:
comments
-- Returns:
-