Skip to content

Commit 9f05dd6

Browse files
author
mgeipel
committed
readded StreamLiteralFormater
1 parent 37956e7 commit 9f05dd6

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright 2013 Deutsche Nationalbibliothek
3+
*
4+
* Licensed under the Apache License, Version 2.0 the "License";
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.culturegraph.mf.stream.converter;
18+
19+
import org.culturegraph.mf.framework.DefaultStreamPipe;
20+
import org.culturegraph.mf.framework.ObjectReceiver;
21+
import org.culturegraph.mf.framework.StreamReceiver;
22+
import org.culturegraph.mf.framework.annotations.Description;
23+
import org.culturegraph.mf.framework.annotations.In;
24+
import org.culturegraph.mf.framework.annotations.Out;
25+
26+
27+
/**
28+
*
29+
* @author Markus Michael Geipel
30+
*
31+
*/
32+
@Description("Formats litereals in a stream")
33+
@In(StreamReceiver.class)
34+
@Out(String.class)
35+
public final class StreamLiteralFormater extends DefaultStreamPipe<ObjectReceiver<String>>{
36+
private static final String DEFAULT_SEPARATOR = "\t";
37+
private String separator = DEFAULT_SEPARATOR;
38+
39+
public void setSeparator(final String separator) {
40+
this.separator = separator;
41+
}
42+
43+
44+
@Override
45+
public void literal(final String name, final String value) {
46+
if(name==null | name.isEmpty()){
47+
getReceiver().process(value);
48+
}else{
49+
getReceiver().process(name+ separator + value);
50+
}
51+
52+
}
53+
}
54+

0 commit comments

Comments
 (0)