- All Known Implementing Classes:
PowerpointParagraph
public interface Paragraph
The Paragraph interface represents a paragraph in a text document.
It provides methods for replacing a placeholder within the paragraph and retrieving the paragraph as a string.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Applies the specified consumer function to the paragraph content.asString()
Returns the paragraph as a string.default boolean
Deprecated, for removal: This API element is subject to removal in a future version.was used by the core to deal with multiline paragraphsOptional
<org.docx4j.wml.Comments.Comment> org.docx4j.wml.P
getP()
Deprecated, for removal: This API element is subject to removal in a future version.As of version 2.6, due to its direct exposure of the docx4j API.<T> Optional
<T> Retrieves the parent of the current paragraph that matches the specified class type.processorContext
(Placeholder placeholder) Creates a processor context for the given placeholder within this paragraph.void
remove()
Removes the paragraph from the document.void
Replaces specified contiguous elements within the paragraph with new elements.void
replace
(Placeholder placeholder, Object replacement) Replaces a placeholder in the given paragraph with the specified replacement.default void
replaceAll
(Placeholder placeholder, org.docx4j.wml.R replacement) Deprecated, for removal: This API element is subject to removal in a future version.was used by the core to deal with multiline paragraphs, users should fallback toreplace(Placeholder, Object)
only
-
Method Details
-
processorContext
Creates a processor context for the given placeholder within this paragraph.- Parameters:
placeholder
- The placeholder to create a context for.- Returns:
- The processor context for the specified placeholder.
-
replace
Replaces specified contiguous elements within the paragraph with new elements.- Parameters:
toRemove
- The list of elements to be removed from the paragraph.toAdd
- The list of elements to be added to the paragraph.
-
remove
void remove()Removes the paragraph from the document. This method is intended to be used when a paragraph needs to be deleted. -
getP
Deprecated, for removal: This API element is subject to removal in a future version.As of version 2.6, due to its direct exposure of the docx4j API. It is scheduled for removal in the future.Retrieves the paragraph associated with this object. TODO replace with API not exposing the docx4j API directly- Returns:
- the paragraph object
-
replaceAll
@Deprecated(since="2.4", forRemoval=true) default void replaceAll(Placeholder placeholder, org.docx4j.wml.R replacement) Deprecated, for removal: This API element is subject to removal in a future version.was used by the core to deal with multiline paragraphs, users should fallback toreplace(Placeholder, Object)
onlyReplaces all occurrences of a placeholder with a specified replacement value within a paragraph.- Parameters:
placeholder
- The placeholder to be replaced.replacement
- The replacement value for the placeholder.
-
contains
Deprecated, for removal: This API element is subject to removal in a future version.was used by the core to deal with multiline paragraphsReturns true if the given expression is found within the paragraph, otherwise returns false.- Parameters:
expression
- The string to search for within the paragraph.- Returns:
- true if the given expression is found within the paragraph, otherwise false.
-
replace
Replaces a placeholder in the given paragraph with the specified replacement.- Parameters:
placeholder
- The placeholder to be replaced.replacement
- The replacement for the placeholder.
-
asString
String asString()Returns the paragraph as a string.- Returns:
- the paragraph as a string
-
apply
Applies the specified consumer function to the paragraph content.- Parameters:
pConsumer
- The consumer function to apply to the paragraph content.
-
parent
Retrieves the parent of the current paragraph that matches the specified class type.- Type Parameters:
T
- The type of the parent element to be returned.- Parameters:
aClass
- The class type to match for the parent element.- Returns:
- An
Optional
containing the matched parent element if found, otherwise an emptyOptional
.
-
getComment
Optional<org.docx4j.wml.Comments.Comment> getComment()
-