Skip to content

Commit 5fdf003

Browse files
committed
Renamed SimpleXmlWriter to SimpleXmlEncoder
The SimpleXmlWriter/Encoder does not write xml but just encodes it. Hence, the class was renamed and moved from org.culturegraph.mf.stream.sink to org.culturegraph.mf.stream.converter.xml.
1 parent 0cbf6eb commit 5fdf003

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

src/main/java/org/culturegraph/mf/stream/converter/StreamToJDomDocument.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import org.culturegraph.mf.framework.annotations.Description;
2828
import org.culturegraph.mf.framework.annotations.In;
2929
import org.culturegraph.mf.framework.annotations.Out;
30-
import org.culturegraph.mf.stream.sink.SimpleXmlWriter;
30+
import org.culturegraph.mf.stream.converter.xml.SimpleXmlEncoder;
3131
import org.culturegraph.mf.util.ResourceUtil;
3232
import org.jdom.Document;
3333
import org.jdom.Element;
@@ -109,7 +109,7 @@ public void literal(final String name, final String value) {
109109
assert !isClosed();
110110
if (name.isEmpty()) {
111111
currentElement.addContent(value);
112-
} else if (name.startsWith(SimpleXmlWriter.ATTRIBUTE_MARKER)) {
112+
} else if (name.startsWith(SimpleXmlEncoder.ATTRIBUTE_MARKER)) {
113113
final String[] parts = NAMESPACE_DELIMITER.split(name);
114114
if (parts.length == 2) {
115115
currentElement.setAttribute(parts[1], value, getNamespace(parts[0].substring(1)));

src/main/java/org/culturegraph/mf/stream/sink/SimpleXmlWriter.java renamed to src/main/java/org/culturegraph/mf/stream/converter/xml/SimpleXmlEncoder.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.culturegraph.mf.stream.sink;
16+
package org.culturegraph.mf.stream.converter.xml;
1717

1818
import java.net.URL;
1919
import java.util.ArrayList;
@@ -35,15 +35,16 @@
3535

3636
/**
3737
*
38-
* writes a stream to XML
38+
* Encodes a stream as XML
3939
*
40-
* @author Markus Michael Geipel, Christoph Böhme
40+
* @author Markus Michael Geipel
41+
* @author Christoph Böhme
4142
*
4243
*/
43-
@Description("writes a stream to xml")
44+
@Description("Encodes a stream as xml")
4445
@In(StreamReceiver.class)
4546
@Out(String.class)
46-
public final class SimpleXmlWriter extends DefaultStreamPipe<ObjectReceiver<String>> {
47+
public final class SimpleXmlEncoder extends DefaultStreamPipe<ObjectReceiver<String>> {
4748

4849
public static final String ATTRIBUTE_MARKER = "~";
4950
public static final String NAMESPACES = "namespaces";
@@ -90,7 +91,7 @@ public void setNamespaceFile(final String file) {
9091
namespaces.put(entry.getKey().toString(), entry.getValue().toString());
9192
}
9293
}
93-
94+
9495
public void setNamespaceFile(final URL url) {
9596
final Properties properties = ResourceUtil.loadProperties(url);
9697
for (final Entry<Object, Object> entry : properties.entrySet()) {
@@ -274,7 +275,7 @@ public void setText(final String text) {
274275
public Element createChild(final String name) {
275276
final Element child = new Element(name, this);
276277
if (children == NO_CHILDREN) {
277-
children = new ArrayList<SimpleXmlWriter.Element>();
278+
children = new ArrayList<SimpleXmlEncoder.Element>();
278279
}
279280
children.add(child);
280281
return child;

src/main/resources/flux-commands.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ object-tee org.culturegraph.mf.stream.pipe.ObjectTee
7171
stream-tee org.culturegraph.mf.stream.pipe.StreamTee
7272
wait-for-inputs org.culturegraph.mf.stream.pipe.CloseSupressor
7373

74-
stream-to-xml org.culturegraph.mf.stream.sink.SimpleXmlWriter
74+
stream-to-xml org.culturegraph.mf.stream.converter.xml.SimpleXmlEncoder
7575
rdf-macros org.culturegraph.mf.stream.pipe.RdfMacroPipe
7676

7777
batch-log org.culturegraph.mf.stream.pipe.BatchLogger

src/test/java/org/culturegraph/mf/stream/sink/SimpleXmlWriterTest.java renamed to src/test/java/org/culturegraph/mf/stream/converter/xml/SimpleXmlEncoderTest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,23 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.culturegraph.mf.stream.sink;
16+
package org.culturegraph.mf.stream.converter.xml;
1717

1818

1919

2020
import org.culturegraph.mf.framework.DefaultObjectReceiver;
2121
import org.culturegraph.mf.framework.StreamReceiver;
22+
import org.culturegraph.mf.stream.converter.xml.SimpleXmlEncoder;
2223
import org.junit.Assert;
2324
import org.junit.Test;
2425

2526
/**
26-
* Tests {@link SimpleXmlWriter}.
27+
* Tests {@link SimpleXmlEncoder}.
2728
*
2829
* @author Markus Geipel
2930
*
3031
*/
31-
public final class SimpleXmlWriterTest {
32+
public final class SimpleXmlEncoderTest {
3233

3334

3435
private static final String TAG = "tag";
@@ -41,14 +42,14 @@ public final class SimpleXmlWriterTest {
4142
public void testShouldOnlyEscapeFiveChars() {
4243
final StringBuilder builder = new StringBuilder();
4344

44-
SimpleXmlWriter.writeEscaped(builder , "&<>'\" üäö");
45+
SimpleXmlEncoder.writeEscaped(builder , "&<>'\" üäö");
4546

4647
Assert.assertEquals("&amp;&lt;&gt;&apos;&quot; üäö", builder.toString());
4748
}
4849

4950
@Test
5051
public void testShouldHandleSeparateRoots(){
51-
final SimpleXmlWriter writer = new SimpleXmlWriter();
52+
final SimpleXmlEncoder writer = new SimpleXmlEncoder();
5253
writer.setRootTag("root");
5354
writer.setRecordTag("record");
5455
writer.setWriteXmlHeader(false);

0 commit comments

Comments
 (0)