Skip to content

Commit b600d81

Browse files
committed
metafacture-strings/ (main): Fix Checkstyle violations.
1 parent 000f06c commit b600d81

17 files changed

+81
-58
lines changed

metafacture-strings/src/main/java/org/metafacture/strings/LineRecorder.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ public final class LineRecorder implements ObjectPipe<String, ObjectReceiver<Str
4141
private String recordMarkerRegexp = "^\\s*$";
4242
private StringBuilder record = new StringBuilder(SB_CAPACITY);
4343
private ObjectReceiver<String> receiver;
44-
private boolean isClosed = false;
44+
private boolean isClosed;
45+
46+
public LineRecorder() {
47+
}
4548

4649
public void setRecordMarkerRegexp(final String regexp) {
4750
recordMarkerRegexp = regexp;
@@ -53,8 +56,10 @@ public void process(final String line) {
5356
if (line.matches(recordMarkerRegexp)) {
5457
getReceiver().process(record.toString());
5558
record = new StringBuilder(SB_CAPACITY);
56-
} else
59+
}
60+
else {
5761
record.append(line + "\n");
62+
}
5863
}
5964

6065
private boolean isClosed() {
@@ -73,17 +78,17 @@ public void closeStream() {
7378
}
7479

7580
@Override
76-
public <R extends ObjectReceiver<String>> R setReceiver(R receiver) {
77-
this.receiver = receiver;
78-
return receiver;
81+
public <R extends ObjectReceiver<String>> R setReceiver(final R newReceiver) {
82+
receiver = newReceiver;
83+
return newReceiver;
7984
}
8085

8186
/**
8287
* Returns a reference to the downstream module.
8388
*
8489
* @return reference to the downstream module
8590
*/
86-
protected final ObjectReceiver<String> getReceiver() {
91+
protected ObjectReceiver<String> getReceiver() {
8792
return receiver;
8893
}
8994

metafacture-strings/src/main/java/org/metafacture/strings/LineSplitter.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.metafacture.strings;
1716

18-
import java.util.regex.Pattern;
17+
package org.metafacture.strings;
1918

2019
import org.metafacture.framework.FluxCommand;
2120
import org.metafacture.framework.ObjectReceiver;
@@ -24,6 +23,8 @@
2423
import org.metafacture.framework.annotations.Out;
2524
import org.metafacture.framework.helpers.DefaultObjectPipe;
2625

26+
import java.util.regex.Pattern;
27+
2728
/**
2829
* Splits a string at new lines and sends each line to the receiver.
2930
*
@@ -34,12 +35,13 @@
3435
@In(String.class)
3536
@Out(String.class)
3637
@FluxCommand("split-lines")
37-
public final class LineSplitter
38-
extends DefaultObjectPipe<String, ObjectReceiver<String>> {
38+
public final class LineSplitter extends DefaultObjectPipe<String, ObjectReceiver<String>> {
3939

4040
private static final char NEWLINE = '\n';
41-
private static final Pattern LINE_PATTERN = Pattern.compile(
42-
String.valueOf(NEWLINE), Pattern.LITERAL);
41+
private static final Pattern LINE_PATTERN = Pattern.compile(String.valueOf(NEWLINE), Pattern.LITERAL);
42+
43+
public LineSplitter() {
44+
}
4345

4446
@Override
4547
public void process(final String lines) {

metafacture-strings/src/main/java/org/metafacture/strings/RegexDecoder.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,8 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.metafacture.strings;
1716

18-
import java.util.ArrayList;
19-
import java.util.List;
20-
import java.util.regex.Matcher;
21-
import java.util.regex.Pattern;
17+
package org.metafacture.strings;
2218

2319
import org.metafacture.framework.FluxCommand;
2420
import org.metafacture.framework.StreamReceiver;
@@ -27,6 +23,10 @@
2723
import org.metafacture.framework.annotations.Out;
2824
import org.metafacture.framework.helpers.DefaultObjectPipe;
2925

26+
import java.util.ArrayList;
27+
import java.util.List;
28+
import java.util.regex.Matcher;
29+
import java.util.regex.Pattern;
3030

3131
/**
3232
* Decodes a string based on a regular expression using named capture groups.

metafacture-strings/src/main/java/org/metafacture/strings/StreamUnicodeNormalizer.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.metafacture.strings;
1716

18-
import java.text.Normalizer;
17+
package org.metafacture.strings;
1918

2019
import org.metafacture.framework.FluxCommand;
2120
import org.metafacture.framework.StreamReceiver;
@@ -24,6 +23,8 @@
2423
import org.metafacture.framework.annotations.Out;
2524
import org.metafacture.framework.helpers.DefaultStreamPipe;
2625

26+
import java.text.Normalizer;
27+
2728
/**
2829
* Normalises Unicode characters in record identifiers, entity and literal
2930
* names and literal values. Unicode normalisation converts between precomposed
@@ -42,21 +43,22 @@
4243
@In(StreamReceiver.class)
4344
@Out(StreamReceiver.class)
4445
@FluxCommand("normalize-unicode-stream")
45-
public final class StreamUnicodeNormalizer
46-
extends DefaultStreamPipe<StreamReceiver> {
46+
public final class StreamUnicodeNormalizer extends DefaultStreamPipe<StreamReceiver> {
4747

4848
/**
4949
* The default value for {@link #setNormalizationForm(Normalizer.Form)}.
5050
*/
51-
public static final Normalizer.Form DEFAULT_NORMALIZATION_FORM =
52-
Normalizer.Form.NFC;
51+
public static final Normalizer.Form DEFAULT_NORMALIZATION_FORM = Normalizer.Form.NFC;
5352

5453
private boolean normalizeIds;
5554
private boolean normalizeKeys;
5655
private boolean normalizeValues = true;
5756

5857
private Normalizer.Form normalizationForm = DEFAULT_NORMALIZATION_FORM;
5958

59+
public StreamUnicodeNormalizer() {
60+
}
61+
6062
/**
6163
* Controls whether to normalise record identifiers. By default record
6264
* identifiers are not normalised.
@@ -161,10 +163,8 @@ public void endEntity() {
161163

162164
@Override
163165
public void literal(final String name, final String value) {
164-
final String normalizedName =
165-
normalizeKeys ? normalize(name) : name;
166-
final String normalizedValue=
167-
normalizeValues ? normalize(value) : value;
166+
final String normalizedName = normalizeKeys ? normalize(name) : name;
167+
final String normalizedValue = normalizeValues ? normalize(value) : value;
168168

169169
getReceiver().literal(normalizedName, normalizedValue);
170170
}

metafacture-strings/src/main/java/org/metafacture/strings/StringConcatenator.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.metafacture.strings;
1718

1819
import org.metafacture.framework.ObjectReceiver;
@@ -28,10 +29,12 @@ public final class StringConcatenator implements ObjectReceiver<String> {
2829
private StringBuilder builder = new StringBuilder();
2930
private String separator = "";
3031

32+
public StringConcatenator() {
33+
}
34+
3135
@Override
3236
public void resetStream() {
3337
reset();
34-
3538
}
3639

3740
public void setSeparator(final String separator) {
@@ -41,21 +44,19 @@ public void setSeparator(final String separator) {
4144
@Override
4245
public void closeStream() {
4346
// nothing to do
44-
4547
}
4648

4749
@Override
4850
public void process(final String obj) {
4951
builder.append(separator);
5052
builder.append(obj);
51-
5253
}
5354

54-
public void reset(){
55+
public void reset() {
5556
builder = new StringBuilder();
5657
}
5758

58-
public String getString(){
59+
public String getString() {
5960
return builder.toString();
6061
}
6162

metafacture-strings/src/main/java/org/metafacture/strings/StringDecoder.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.metafacture.strings;
1716

18-
import java.util.regex.Matcher;
19-
import java.util.regex.Pattern;
17+
package org.metafacture.strings;
2018

2119
import org.metafacture.framework.FluxCommand;
2220
import org.metafacture.framework.ObjectReceiver;
@@ -25,6 +23,9 @@
2523
import org.metafacture.framework.annotations.Out;
2624
import org.metafacture.framework.helpers.DefaultObjectPipe;
2725

26+
import java.util.regex.Matcher;
27+
import java.util.regex.Pattern;
28+
2829
/**
2930
* Splits a {@link String} into several {@link String}s, either by extracting
3031
* parts that match a regexp or by splitting by a regexp.
@@ -65,10 +66,11 @@ public void process(final String obj) {
6566

6667
final ObjectReceiver<String> receiver = getReceiver();
6768
if (mode == Mode.SPLIT) {
68-
for (String part : pattern.split(obj)) {
69+
for (final String part : pattern.split(obj)) {
6970
receiver.process(part);
7071
}
71-
} else {
72+
}
73+
else {
7274
final Matcher matcher = pattern.matcher(obj);
7375
while (matcher.find()) {
7476
receiver.process(matcher.group());

metafacture-strings/src/main/java/org/metafacture/strings/StringFilter.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.metafacture.strings;
1716

18-
import java.util.regex.Matcher;
19-
import java.util.regex.Pattern;
17+
package org.metafacture.strings;
2018

2119
import org.metafacture.framework.FluxCommand;
2220
import org.metafacture.framework.ObjectReceiver;
@@ -25,6 +23,8 @@
2523
import org.metafacture.framework.annotations.Out;
2624
import org.metafacture.framework.helpers.DefaultObjectPipe;
2725

26+
import java.util.regex.Matcher;
27+
import java.util.regex.Pattern;
2828

2929
/**
3030
* Only forwards records which match (or do not match) a regular expression
@@ -41,7 +41,7 @@ public final class StringFilter extends
4141
DefaultObjectPipe<String, ObjectReceiver<String>> {
4242

4343
private final Matcher matcher;
44-
private boolean passMatches=true;
44+
private boolean passMatches = true;
4545

4646
public StringFilter(final String pattern) {
4747
this.matcher = Pattern.compile(pattern).matcher("");
@@ -62,7 +62,7 @@ public void setPassMatches(final boolean passMatches) {
6262
@Override
6363
public void process(final String obj) {
6464
assert !isClosed();
65-
assert null!=obj;
65+
assert null != obj;
6666
matcher.reset(obj);
6767
if (matcher.find() == passMatches) {
6868
getReceiver().process(obj);

metafacture-strings/src/main/java/org/metafacture/strings/StringMatcher.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.metafacture.strings;
1716

18-
import java.util.regex.Matcher;
19-
import java.util.regex.Pattern;
17+
package org.metafacture.strings;
2018

2119
import org.metafacture.framework.FluxCommand;
2220
import org.metafacture.framework.ObjectReceiver;
@@ -25,6 +23,8 @@
2523
import org.metafacture.framework.annotations.Out;
2624
import org.metafacture.framework.helpers.DefaultObjectPipe;
2725

26+
import java.util.regex.Matcher;
27+
import java.util.regex.Pattern;
2828

2929
/**
3030
* Matches the incoming strings against a regular expression and replaces
@@ -36,12 +36,14 @@
3636
@In(String.class)
3737
@Out(String.class)
3838
@FluxCommand("match")
39-
public final class StringMatcher extends
40-
DefaultObjectPipe<String, ObjectReceiver<String>> {
39+
public final class StringMatcher extends DefaultObjectPipe<String, ObjectReceiver<String>> {
4140

4241
private Matcher matcher;
4342
private String replacement;
4443

44+
public StringMatcher() {
45+
}
46+
4547
public String getPattern() {
4648
return matcher.pattern().pattern();
4749
}
@@ -61,7 +63,7 @@ public void setReplacement(final String replacement) {
6163
@Override
6264
public void process(final String obj) {
6365
assert !isClosed();
64-
assert null!=obj;
66+
assert null != obj;
6567
matcher.reset(obj);
6668
getReceiver().process(matcher.replaceAll(replacement));
6769
}

metafacture-strings/src/main/java/org/metafacture/strings/StringReader.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.metafacture.strings;
1716

18-
import java.io.Reader;
17+
package org.metafacture.strings;
1918

2019
import org.metafacture.framework.FluxCommand;
2120
import org.metafacture.framework.ObjectReceiver;
@@ -24,6 +23,7 @@
2423
import org.metafacture.framework.annotations.Out;
2524
import org.metafacture.framework.helpers.DefaultObjectPipe;
2625

26+
import java.io.Reader;
2727

2828
/**
2929
* Creates a reader for the supplied string and sends it to the receiver.
@@ -35,8 +35,10 @@
3535
@In(String.class)
3636
@Out(java.io.Reader.class)
3737
@FluxCommand("read-string")
38-
public final class StringReader
39-
extends DefaultObjectPipe<String, ObjectReceiver<Reader>> {
38+
public final class StringReader extends DefaultObjectPipe<String, ObjectReceiver<Reader>> {
39+
40+
public StringReader() {
41+
}
4042

4143
@Override
4244
public void process(final String str) {

0 commit comments

Comments
 (0)