1
1
/*
2
- * Copyright 2013, 2014 Deutsche Nationalbibliothek
2
+ * Copyright 2013, 2021 Deutsche Nationalbibliothek and others
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 the "License";
5
5
* you may not use this file except in compliance with the License.
25
25
* Outputs a record containing the input object as literal.
26
26
*
27
27
* @param <T> input object type
28
- * @author Christoph Böhme
28
+ * @author Christoph Böhme, Fabian Steeg
29
29
*/
30
30
@ Description ("Outputs a record containing the input object as literal" )
31
31
@ Out (StreamReceiver .class )
@@ -34,22 +34,40 @@ public final class ObjectToLiteral<T> extends
34
34
DefaultObjectPipe <T , StreamReceiver > {
35
35
36
36
public static final String DEFAULT_LITERAL_NAME = "obj" ;
37
+ public static final String DEFAULT_RECORD_ID = "" ;
37
38
38
- private String literalName = DEFAULT_LITERAL_NAME ;
39
+ private String literalName ;
40
+ private String recordId ;
41
+ private int recordCount ;
42
+
43
+ public ObjectToLiteral () {
44
+ super ();
45
+ setLiteralName (DEFAULT_LITERAL_NAME );
46
+ setRecordId (DEFAULT_RECORD_ID );
47
+ recordCount =0 ;
48
+ }
39
49
40
50
public void setLiteralName (final String literalName ) {
41
51
this .literalName = literalName ;
42
52
}
43
53
54
+ public void setRecordId (final String recordId ) {
55
+ this .recordId = recordId ;
56
+ }
57
+
44
58
public String getLiteralName () {
45
59
return literalName ;
46
60
}
47
61
62
+ public String getRecordId () {
63
+ return recordId ;
64
+ }
65
+
48
66
@ Override
49
67
public void process (final T obj ) {
50
68
assert obj !=null ;
51
69
assert !isClosed ();
52
- getReceiver ().startRecord ("" );
70
+ getReceiver ().startRecord (String . format ( recordId , ++ recordCount ) );
53
71
getReceiver ().literal (literalName , obj .toString ());
54
72
getReceiver ().endRecord ();
55
73
}
0 commit comments