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
public class Paragraph extends Sequence
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
ParagraphContent
serves as a container for severalInlineContent
s orNewlineContent
s.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:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class de.hsh.graja.util.comment.Content
EXCLUSIVE, renderUuid
-
-
Constructor Summary
Constructors Constructor Description Paragraph()
Create 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.Paragraph(Inline firstInline)
Create a paragraph with a first inline content.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addItem(Content content)
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.String
toString(String prefix)
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.Content
click, disableCallerStacktraceRecording, enableCallerStacktraceRecording, excludeGlobally, getIncludeSpec, getRenderUuid, getStackdump, hide, 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 Detail
-
Paragraph
public Paragraph()
Create an empty paragraph.
-
Paragraph
public Paragraph(IncludeSpec includeSpec, String firstInlineData)
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
public Paragraph(IncludeSpec includeSpec, String firstInlineData, FontWeightAndStyle fwas)
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
public Paragraph(Inline firstInline)
Create a paragraph with a first inline content.- Parameters:
firstInline
- the first inline content
-
-
Method Detail
-
addItem
public void addItem(Content content)
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 ofInline
orNewline
. Otherwise an exception is thrown.- Throws:
IllegalArgumentException
- if the parameter is not an instance ofInline
orNewline
-
formatInlineItem
public void formatInlineItem(IncludeSpec includeSpec, String format, Object... args)
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
public void newLine(IncludeSpec includeSpec)
Add a line break.- Parameters:
includeSpec
- the include spec for the line break
-
toString
public String toString(String prefix)
Description copied from class:Content
This method is for debugging purposes.- Overrides:
toString
in classContent
- 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.
- See Also:
Content.toString(java.lang.String)
-
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
public void renderPlainImpl(StringBuilder sb, IncludeInfo includeInfo, RenderContext ctx)
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:
Content.renderPlainImpl(StringBuilder, IncludeInfo, RenderContext)
-
-