Skip to content

Commit 0cd5d86

Browse files
committed
metafacture-jdom/ (main): Fix Checkstyle violations.
1 parent 52c9559 commit 0cd5d86

File tree

2 files changed

+33
-28
lines changed

2 files changed

+33
-28
lines changed

metafacture-jdom/src/main/java/org/metafacture/jdom/JDomDocumentToStream.java

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

18-
import org.jdom2.Document;
19-
import org.jdom2.JDOMException;
20-
import org.jdom2.output.SAXOutputter;
2119
import org.metafacture.framework.FluxCommand;
2220
import org.metafacture.framework.ObjectPipe;
2321
import org.metafacture.framework.StreamReceiver;
2422
import org.metafacture.framework.XmlPipe;
2523
import org.metafacture.framework.annotations.In;
2624
import org.metafacture.framework.annotations.Out;
2725

26+
import org.jdom2.Document;
27+
import org.jdom2.JDOMException;
28+
import org.jdom2.output.SAXOutputter;
29+
2830
/**
2931
* Converts a {@link Document} to a stream.
3032
*
@@ -46,10 +48,11 @@ public JDomDocumentToStream(final XmlPipe<StreamReceiver> xmlPipe) {
4648

4749
@Override
4850
public void process(final Document document) {
49-
assert null!=document;
51+
assert null != document;
5052
try {
5153
saxOutputer.output(document);
52-
} catch (JDOMException e) {
54+
}
55+
catch (final JDOMException e) {
5356
throw new IllegalArgumentException("Invalid JDOM document", e);
5457
}
5558
}

metafacture-jdom/src/main/java/org/metafacture/jdom/StreamToJDomDocument.java

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

18-
import java.io.IOException;
19-
import java.util.HashMap;
20-
import java.util.Map;
21-
import java.util.Map.Entry;
22-
import java.util.Properties;
23-
import java.util.regex.Pattern;
17+
package org.metafacture.jdom;
2418

25-
import org.jdom2.Document;
26-
import org.jdom2.Element;
27-
import org.jdom2.Namespace;
2819
import org.metafacture.commons.ResourceUtil;
2920
import org.metafacture.framework.FluxCommand;
3021
import org.metafacture.framework.MetafactureException;
@@ -35,6 +26,17 @@
3526
import org.metafacture.framework.annotations.Out;
3627
import org.metafacture.framework.helpers.DefaultStreamPipe;
3728

29+
import org.jdom2.Document;
30+
import org.jdom2.Element;
31+
import org.jdom2.Namespace;
32+
33+
import java.io.IOException;
34+
import java.util.HashMap;
35+
import java.util.Map.Entry;
36+
import java.util.Map;
37+
import java.util.Properties;
38+
import java.util.regex.Pattern;
39+
3840
/**
3941
* Converts a stream into a {@link Document}.
4042
*
@@ -54,34 +56,33 @@ public final class StreamToJDomDocument
5456
private Document document;
5557
private Element currentElement;
5658
private final String rootTagName;
57-
private final Map<String, Namespace> namespaces = new HashMap<String,Namespace>();
59+
private final Map<String, Namespace> namespaces = new HashMap<String, Namespace>();
5860

5961
public StreamToJDomDocument(final String rootTagName, final String namespaceProperties) {
6062
this.rootTagName = rootTagName;
6163
namespaces.put(XML, Namespace.getNamespace(XML, "http://www.w3.org/XML/1998/namespace"));
6264
final Properties properties;
6365
try {
6466
properties = ResourceUtil.loadProperties(namespaceProperties);
65-
} catch (IOException e) {
67+
}
68+
catch (final IOException e) {
6669
throw new MetafactureException("Cannot load namespaces list", e);
6770
}
68-
for (Entry<Object, Object> entry : properties.entrySet()) {
71+
for (final Entry<Object, Object> entry : properties.entrySet()) {
6972
namespaces.put(entry.getKey().toString(), Namespace.getNamespace(entry.getKey().toString(), entry.getValue().toString()));
7073
}
7174
}
7275

73-
7476
@Override
7577
public void startRecord(final String identifier) {
7678
assert !isClosed();
7779
currentElement = createElement(rootTagName);
78-
for (Namespace namespace : namespaces.values()) {
80+
for (final Namespace namespace : namespaces.values()) {
7981
currentElement.addNamespaceDeclaration(namespace);
8082
}
8183
document = new Document(currentElement);
8284
}
8385

84-
8586
@Override
8687
public void startEntity(final String name) {
8788
assert !isClosed();
@@ -98,36 +99,37 @@ private Element createElement(final String name) {
9899
return new Element(name);
99100
}
100101

101-
private Namespace getNamespace(final String name){
102+
private Namespace getNamespace(final String name) {
102103
final Namespace namespace = namespaces.get(name);
103-
if(namespace==null){
104+
if (namespace == null) {
104105
throw new IllegalArgumentException("Namespace " + name + " not registered");
105106
}
106107
return namespace;
107108
}
108109

109-
110110
@Override
111111
public void endEntity() {
112112
assert !isClosed();
113113
currentElement = currentElement.getParentElement();
114114
}
115115

116-
117116
@Override
118117
public void literal(final String name, final String value) {
119118
assert !isClosed();
120119
if (name.isEmpty()) {
121120
currentElement.addContent(value);
122-
} else if (name.startsWith(ATTRIBUTE_MARKER)) {
121+
}
122+
else if (name.startsWith(ATTRIBUTE_MARKER)) {
123123
final String[] parts = NAMESPACE_DELIMITER.split(name);
124124
if (parts.length == 2) {
125125
currentElement.setAttribute(parts[1], value, getNamespace(parts[0].substring(1)));
126-
} else{
126+
}
127+
else {
127128
currentElement.setAttribute(name.substring(1), value);
128129
}
129130

130-
} else {
131+
}
132+
else {
131133
final Element temp = createElement(name);
132134
currentElement.addContent(temp);
133135
temp.setText(value);

0 commit comments

Comments
 (0)