Skip to content

Commit

Permalink
WIP 7
Browse files Browse the repository at this point in the history
  • Loading branch information
dr0i committed May 2, 2024
1 parent 009b7cc commit df1d498
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import org.metafacture.framework.FluxCommand;
import org.metafacture.framework.ObjectReceiver;
import org.metafacture.framework.StreamPipe;
import org.metafacture.framework.Sender;
import org.metafacture.framework.StreamReceiver;
import org.metafacture.framework.annotations.Description;
import org.metafacture.framework.annotations.In;
Expand All @@ -35,23 +35,25 @@
@Out(String.class)
@Description("Encodes MARC21 records as MARCXML. Similar to encode-marcxml but safer especially when the 'leader' has to be computed.")
@FluxCommand("encode-marc21xml")
public class Marc21XmlEncoder extends MarcXmlEncoder implements StreamPipe<ObjectReceiver<String>> {
public class Marc21XmlEncoder extends MarcXmlEncoder implements Sender<ObjectReceiver<String>> {
private final Marc21Decoder marc21Decoder = new Marc21Decoder();
private final MarcXmlEncoder marcXmlEncoder= new MarcXmlEncoder();
// private final MarcXmlEncoder marcXmlEncoder= new MarcXmlEncoder();
private final Marc21Encoder marc21Encoder = new Marc21Encoder();

public Marc21XmlEncoder() {
marc21Decoder.setEmitLeaderAsWhole(true);

marc21Encoder.setReceiver(marc21Decoder);
marc21Decoder.setReceiver(marcXmlEncoder);
marc21Decoder.setReceiver(this);
this.getSe();
super.setReceiver(marc21Encoder);
}

@Override
public <R extends StreamReceiver> R setReceiver(final R receiver) {
marcXmlEncoder.setReceiver(receiver);
this.setReceiver(marc21Encoder);
return receiver;
public Sender<ObjectReceiver<String>> setReceiver(final ObjectReceiver<String> receiver) {
// marcXmlEncoder.setReceiver(receiver);
// super.setReceiver(receiver);
return this;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ public class MarcXmlEncoder extends DefaultStreamPipe<ObjectReceiver<String>> {
private static final String ROOT_OPEN = "<marc:collection xmlns:marc=\"http://www.loc.gov/MARC21/slim\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd\">";
private static final String ROOT_CLOSE = "</marc:collection>";

public <R extends StreamReceiver> R setReceiver(final R receiver) {
this.setReceiver(receiver);
return receiver;
}

private enum Tag {

collection(" xmlns%s=\"" + NAMESPACE + "\"%s"),
Expand Down

0 comments on commit df1d498

Please sign in to comment.