Skip to content

Commit c46afb5

Browse files
committed
Add missing javadocs
DEVSIX-6349
1 parent fc4787c commit c46afb5

File tree

6 files changed

+86
-12
lines changed

6 files changed

+86
-12
lines changed

src/main/java/com/itextpdf/pdfcleanup/PdfCleanUpEventListener.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,19 @@ This file is part of the iText (R) project.
5555
import java.util.List;
5656
import java.util.Set;
5757

58+
/**
59+
* An event listener which handles cleanup related events.
60+
*/
5861
public class PdfCleanUpEventListener implements IEventListener {
5962
private static final String textDataExpected = "Text data expected.";
6063
private static final String imageDataExpected = "Image data expected.";
6164
private static final String pathDataExpected = "Path data expected.";
6265

6366
private List<IEventData> content = new ArrayList<>();
6467

68+
/**
69+
* {@inheritDoc}
70+
*/
6571
@Override
6672
public void eventOccurred(IEventData data, EventType type) {
6773
switch (type) {
@@ -134,6 +140,9 @@ PathRenderInfo getEncounteredPath() {
134140

135141
}
136142

143+
/**
144+
* {@inheritDoc}
145+
*/
137146
@Override
138147
public Set<EventType> getSupportedEvents() {
139148
return null;

src/main/java/com/itextpdf/pdfcleanup/PdfCleanUpProcessor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ This file is part of the iText (R) project.
106106
import org.slf4j.Logger;
107107
import org.slf4j.LoggerFactory;
108108

109+
/**
110+
* PDF content stream processor, which filters content to be cleaned up.
111+
*/
109112
public class PdfCleanUpProcessor extends PdfCanvasProcessor {
110113

111114
private static final Set<String> TEXT_SHOWING_OPERATORS = Collections.unmodifiableSet(new HashSet<String>(

src/main/java/com/itextpdf/pdfcleanup/PdfCleanUpTool.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,13 @@ public PdfCleanUpTool(PdfDocument pdfDocument, List<PdfCleanUpLocation> cleanUpL
183183
}
184184
}
185185

186+
/**
187+
* Adds a {@link PdfCleanUpLocation} to be cleaned up.
188+
*
189+
* @param cleanUpLocation a {@link PdfCleanUpLocation} to be cleaned up
190+
*
191+
* @return this {@link PdfCleanUpTool}
192+
*/
186193
public PdfCleanUpTool addCleanupLocation(PdfCleanUpLocation cleanUpLocation) {
187194
List<PdfCleanUpLocation> pgLocations = this.pdfCleanUpLocations.get(cleanUpLocation.getPage());
188195
if (pgLocations == null) {
@@ -362,7 +369,7 @@ private List<Rectangle> translateQuadPointsToRectangles(PdfArray quadPoints) {
362369
* Remove the redaction annotations.
363370
* This method is called after the annotations are processed.
364371
*
365-
* @throws IOException
372+
* @throws IOException signals that an I/O exception has occurred during redaction.
366373
*/
367374
private void removeRedactAnnots() throws IOException {
368375
for (PdfRedactAnnotation annotation : redactAnnotations.keySet()) {

src/main/java/com/itextpdf/pdfcleanup/autosweep/CompositeCleanupStrategy.java

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,33 @@ This file is part of the iText (R) project.
6262

6363

6464
/**
65-
* This class is a composite pattern for {@code ICleanupStrategy}
65+
* This class is a composite pattern for {@link ICleanupStrategy}.
6666
* It allows users to have multiple ICleanupStrategy implementations and bundle them as one.
6767
*/
6868
public class CompositeCleanupStrategy implements ICleanupStrategy {
6969

7070
private Map<Integer, Set<IPdfTextLocation>> locations = new HashMap<>();
7171
private List<ICleanupStrategy> strategies = new ArrayList<>();
7272

73+
/**
74+
* Creates a {@link CompositeCleanupStrategy composite pattern} for {@link ICleanupStrategy cleanup strategies}.
75+
*/
7376
public CompositeCleanupStrategy() {
7477
}
7578

76-
public void add(ICleanupStrategy ies) {
77-
strategies.add(ies);
79+
/**
80+
* Adds a {@link ICleanupStrategy cleanup strategy} to this {@link CompositeCleanupStrategy composite pattern}.
81+
*
82+
* @param strategy a {@link ICleanupStrategy cleanup strategy} to be added to this
83+
* {@link CompositeCleanupStrategy composite pattern}.
84+
*/
85+
public void add(ICleanupStrategy strategy) {
86+
strategies.add(strategy);
7887
}
7988

89+
/**
90+
* {@inheritDoc}
91+
*/
8092
@Override
8193
public Collection<IPdfTextLocation> getResultantLocations() {
8294
locations.clear();
@@ -104,10 +116,12 @@ public int compare(IPdfTextLocation l1, IPdfTextLocation l2) {
104116
}
105117
});
106118

107-
// return
108119
return rectangles;
109120
}
110121

122+
/**
123+
* {@inheritDoc}
124+
*/
111125
@Override
112126
public Color getRedactionColor(IPdfTextLocation location) {
113127
for (int i = 0; i < strategies.size(); i++) {
@@ -118,13 +132,19 @@ public Color getRedactionColor(IPdfTextLocation location) {
118132
return ColorConstants.BLACK;
119133
}
120134

135+
/**
136+
* {@inheritDoc}
137+
*/
121138
@Override
122139
public void eventOccurred(IEventData data, EventType type) {
123140
for (ILocationExtractionStrategy s : strategies) {
124141
s.eventOccurred(data, type);
125142
}
126143
}
127144

145+
/**
146+
* {@inheritDoc}
147+
*/
128148
@Override
129149
public Set<EventType> getSupportedEvents() {
130150
Set<EventType> evts = new HashSet<>();
@@ -136,13 +156,20 @@ public Set<EventType> getSupportedEvents() {
136156
return evts.isEmpty() ? null : evts;
137157
}
138158

139-
public ICleanupStrategy reset()
140-
{
141-
CompositeCleanupStrategy retval = new CompositeCleanupStrategy();
142-
for(ICleanupStrategy s : strategies)
143-
{
144-
retval.add(s.reset());
159+
/**
160+
* Returns a {@link ICleanupStrategy cleanup strategy} which represents
161+
* a reset {@link CompositeCleanupStrategy composite cleanup strategy}.
162+
*
163+
* <p>
164+
* Note that all the inner {@link ICleanupStrategy strategies} will be reset as well.
165+
*
166+
* @return a reset {@link CompositeCleanupStrategy composite strategy}
167+
*/
168+
public ICleanupStrategy reset() {
169+
CompositeCleanupStrategy resetCompositeStrategy = new CompositeCleanupStrategy();
170+
for(ICleanupStrategy s : strategies) {
171+
resetCompositeStrategy.add(s.reset());
145172
}
146-
return retval;
173+
return resetCompositeStrategy;
147174
}
148175
}

src/main/java/com/itextpdf/pdfcleanup/autosweep/RegexBasedCleanupStrategy.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,26 +57,51 @@ public class RegexBasedCleanupStrategy extends RegexBasedLocationExtractionStrat
5757
private Pattern pattern;
5858
private Color redactionColor = ColorConstants.BLACK;
5959

60+
/**
61+
* Creates an object of regular expression based cleanup strategy.
62+
*
63+
* @param regex regular expression on which cleanup strategy will be based
64+
*/
6065
public RegexBasedCleanupStrategy(String regex) {
6166
super(regex);
6267
this.pattern = Pattern.compile(regex);
6368
}
6469

70+
/**
71+
* Creates an object of regular expression based cleanup strategy.
72+
*
73+
* @param pattern {@link Pattern} pattern on which cleanup strategy will be based
74+
*/
6575
public RegexBasedCleanupStrategy(Pattern pattern) {
6676
super(pattern);
6777
this.pattern = pattern;
6878
}
6979

80+
/**
81+
* {@inheritDoc}
82+
*/
7083
@Override
7184
public Color getRedactionColor(IPdfTextLocation location) {
7285
return redactionColor;
7386
}
7487

88+
/**
89+
* Sets the color in which redaction is to take place.
90+
*
91+
* @param color the color in which redaction is to take place
92+
*
93+
* @return this {@link RegexBasedCleanupStrategy strategy}
94+
*/
7595
public RegexBasedCleanupStrategy setRedactionColor(Color color) {
7696
this.redactionColor = color;
7797
return this;
7898
}
7999

100+
/**
101+
* Returns an {@link ICleanupStrategy} object which is set to this regular pattern and redaction color.
102+
*
103+
* @return a reset {@link ICleanupStrategy cleanup strategy}
104+
*/
80105
public ICleanupStrategy reset() {
81106
return new RegexBasedCleanupStrategy(pattern).setRedactionColor(redactionColor);
82107
}

src/main/java/com/itextpdf/pdfcleanup/logs/CleanUpLogMessageConstant.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ This file is part of the iText (R) project.
2222
*/
2323
package com.itextpdf.pdfcleanup.logs;
2424

25+
/**
26+
* Class that bundles all the log message templates as constants.
27+
*/
2528
public class CleanUpLogMessageConstant {
2629

2730
/** The Constant CANNOT_OBTAIN_IMAGE_INFO_AFTER_FILTERING. */

0 commit comments

Comments
 (0)