@@ -83,6 +84,7 @@ public Marc21Encoder() { builder = new RecordBuilder(Marc21Constants.MARC21_FORMAT); builder.setCharset(Marc21Constants.MARC21_CHARSET); } + /** * Controls whether the record identifier field ("001") is * generated from the record id in the start-record event. If id field @@ -117,8 +119,8 @@ public void startRecord(final String identifier) { private void initLeader() { builder.setRecordStatus(' '); - builder.setImplCodes(new char[]{ ' ', ' ', ' ', ' ' }); - builder.setSystemChars(new char[]{ ' ', ' ', ' ' }); + builder.setImplCodes(new char[]{' ', ' ', ' ', ' '}); + builder.setSystemChars(new char[]{' ', ' ', ' '}); builder.setReservedChar(Marc21Constants.RESERVED_CHAR); } @@ -136,7 +138,8 @@ public void startEntity(final String name) { } if (Marc21EventNames.LEADER_ENTITY.equals(name)) { state = State.IN_LEADER_ENTITY; - } else { + } + else { startField(name); state = State.IN_FIELD_ENTITY; } @@ -153,7 +156,6 @@ private void startField(final String name) { builder.startDataField(tag, indicators); } - @Override public void endEntity() { if (state.equals(State.IN_FIELD_ENTITY)) { @@ -229,18 +231,17 @@ private void requireValidCode(final char code, final char[] validCodes) { return; } } - throw new FormatException("invalid code '" + code + "'; allowed codes are: " - + Arrays.toString(validCodes)); + throw new FormatException("invalid code '" + code + "'; allowed codes are: " + Arrays.toString(validCodes)); } private void processTopLevelLiteral(final String name, final String value) { - if (Marc21EventNames.MARCXML_TYPE_LITERAL.equals(name)) { - // MarcXmlHandler may output `type` literals. The - // information in these literals is not included in - // marc21 records. Therefore, we need to ignore - // these literals here. + if (Marc21EventNames.MARCXML_TYPE_LITERAL.equals(name)) { + // MarcXmlHandler may output `type` literals. The + // information in these literals is not included in + // marc21 records. Therefore, we need to ignore + // these literals here. return; - } + } builder.appendReferenceField(name.toCharArray(), value); } diff --git a/metafacture-biblio/src/main/java/org/metafacture/biblio/marc21/Marc21EventNames.java b/metafacture-biblio/src/main/java/org/metafacture/biblio/marc21/Marc21EventNames.java index 1b0e6e1aa..fa842b137 100644 --- a/metafacture-biblio/src/main/java/org/metafacture/biblio/marc21/Marc21EventNames.java +++ b/metafacture-biblio/src/main/java/org/metafacture/biblio/marc21/Marc21EventNames.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.metafacture.biblio.marc21; /** @@ -22,127 +23,127 @@ */ public final class Marc21EventNames { - /** - * Name of the literal event which contains the value of the - * type attribute of the record element. - */ - public static final String MARCXML_TYPE_LITERAL = "type"; + /** + * Name of the literal event which contains the value of the + * type attribute of the record element. + */ + public static final String MARCXML_TYPE_LITERAL = "type"; - /** - * Name of the entity event which contains the bibliographic - * information in the record leader. - * - * @see MARC 21 - * Standard: Record Leader - */ - public static final String LEADER_ENTITY = "leader"; + /** + * Name of the entity event which contains the bibliographic + * information in the record leader. + * + * @see MARC 21 + * Standard: Record Leader + */ + public static final String LEADER_ENTITY = "leader"; - /** - * Name of the literal event emitted for the record status field. - *
- * The name of the literal is "{@value #RECORD_STATUS_LITERAL}". - *
- * The record status is specified at position 5 in the record leader. - * - * @see MARC 21 - * Standard: Record Leader - */ - public static final String RECORD_STATUS_LITERAL = "status"; + /** + * Name of the literal event emitted for the record status field. + *
+ * The name of the literal is "{@value #RECORD_STATUS_LITERAL}". + *
+ * The record status is specified at position 5 in the record leader. + * + * @see MARC 21 + * Standard: Record Leader + */ + public static final String RECORD_STATUS_LITERAL = "status"; - /** - * Name of the literal event emitted for the bibliographic level - * field. - *
- * The name of the literal is - * "{@value #BIBLIOGRAPHIC_LEVEL_LITERAL}". - *
- * The bibliographic level is specified at position 7 in the record leader. - * - * @see MARC 21 - * Standard: Record Leader - */ - public static final String BIBLIOGRAPHIC_LEVEL_LITERAL = "bibliographicLevel"; + /** + * Name of the literal event emitted for the bibliographic level + * field. + *
+ * The name of the literal is + * "{@value #BIBLIOGRAPHIC_LEVEL_LITERAL}". + *
+ * The bibliographic level is specified at position 7 in the record leader. + * + * @see MARC 21 + * Standard: Record Leader + */ + public static final String BIBLIOGRAPHIC_LEVEL_LITERAL = "bibliographicLevel"; - /** - * Name of the literal event emitted for the type of control field. - *
- * The name of the literal is "{@value #TYPE_OF_CONTROL_LITERAL}". - *
- * The type of control is specified at position 8 in the record leader. - * - * @see MARC 21 - * Standard: Record Leader - */ - public static final String TYPE_OF_CONTROL_LITERAL = "typeOfControl"; + /** + * Name of the literal event emitted for the type of control field. + *
+ * The name of the literal is "{@value #TYPE_OF_CONTROL_LITERAL}". + *
+ * The type of control is specified at position 8 in the record leader. + * + * @see MARC 21 + * Standard: Record Leader + */ + public static final String TYPE_OF_CONTROL_LITERAL = "typeOfControl"; - /** - * Name of the literal event emitted for the character coding scheme - * field. - *
- * The name of the literal is "{@value #CHARACTER_CODING_LITERAL}". - *
- * The character coding scheme is specified at position 9 in the record - * leader. - * - * @see MARC 21 - * Standard: Record Leader - */ - public static final String CHARACTER_CODING_LITERAL = "characterCodingScheme"; + /** + * Name of the literal event emitted for the character coding scheme + * field. + *
+ * The name of the literal is "{@value #CHARACTER_CODING_LITERAL}". + *
+ * The character coding scheme is specified at position 9 in the record + * leader. + * + * @see MARC 21 + * Standard: Record Leader + */ + public static final String CHARACTER_CODING_LITERAL = "characterCodingScheme"; - /** - * Name of the literal event emitted for the encoding level field. - *
- * The name of the literal is "{@value #ENCODING_LEVEL_LITERAL}". - *
- * The encoding level is specified at position 17 in the record leader. - * - * @see MARC 21 - * Standard: Record Leader - */ - public static final String ENCODING_LEVEL_LITERAL = "encodingLevel"; + /** + * Name of the literal event emitted for the encoding level field. + *
+ * The name of the literal is "{@value #ENCODING_LEVEL_LITERAL}". + *
+ * The encoding level is specified at position 17 in the record leader. + * + * @see MARC 21 + * Standard: Record Leader + */ + public static final String ENCODING_LEVEL_LITERAL = "encodingLevel"; - /** - * Name of the literal event emitted for the descriptive cataloging - * form field. - *
- * The name of the literal is "{@value #CATALOGING_FORM_LITERAL}". - *
- * The descriptive cataloging form is specified at position 18 in the record - * leader. - * - * @see MARC 21 - * Standard: Record Leader - */ - public static final String CATALOGING_FORM_LITERAL = "catalogingForm"; + /** + * Name of the literal event emitted for the descriptive cataloging + * form field. + *
+ * The name of the literal is "{@value #CATALOGING_FORM_LITERAL}". + *
+ * The descriptive cataloging form is specified at position 18 in the record + * leader. + * + * @see MARC 21 + * Standard: Record Leader + */ + public static final String CATALOGING_FORM_LITERAL = "catalogingForm"; - /** - * Name of the literal event emitted for the multipart resource - * record level field. - *
- * The name of the literal is "{@value #MULTIPART_LEVEL_LITERAL}". - *
- * The multipart resource record level is specified at position 19 in the - * record leader. - * - * @see MARC 21 - * Standard: Record Leader - */ - public static final String MULTIPART_LEVEL_LITERAL = "multipartLevel"; + /** + * Name of the literal event emitted for the multipart resource + * record level field. + *
+ * The name of the literal is "{@value #MULTIPART_LEVEL_LITERAL}". + *
+ * The multipart resource record level is specified at position 19 in the + * record leader. + * + * @see MARC 21 + * Standard: Record Leader + */ + public static final String MULTIPART_LEVEL_LITERAL = "multipartLevel"; - /** - * Name of the literal event emitted for the type of record field. - *
- * The name of the literal is "{@value #RECORD_TYPE_LITERAL}". - *
- * The type of record is specified at position 6 in the record leader. - * - * @see MARC 21 - * Standard: Record Leader - */ - public static final String RECORD_TYPE_LITERAL = "type"; + /** + * Name of the literal event emitted for the type of record field. + *
+ * The name of the literal is "{@value #RECORD_TYPE_LITERAL}". + *
+ * The type of record is specified at position 6 in the record leader.
+ *
+ * @see MARC 21
+ * Standard: Record Leader
+ */
+ public static final String RECORD_TYPE_LITERAL = "type";
- private Marc21EventNames() {
- throw new AssertionError("class should not be instantiated");
- }
+ private Marc21EventNames() {
+ throw new AssertionError("class should not be instantiated");
+ }
}
diff --git a/metafacture-biblio/src/main/java/org/metafacture/biblio/marc21/MarcXmlEncoder.java b/metafacture-biblio/src/main/java/org/metafacture/biblio/marc21/MarcXmlEncoder.java
index 84b4d8aa6..43df44e5f 100644
--- a/metafacture-biblio/src/main/java/org/metafacture/biblio/marc21/MarcXmlEncoder.java
+++ b/metafacture-biblio/src/main/java/org/metafacture/biblio/marc21/MarcXmlEncoder.java
@@ -15,8 +15,6 @@
package org.metafacture.biblio.marc21;
-import java.util.Collections;
-
import org.metafacture.commons.XmlUtil;
import org.metafacture.framework.FluxCommand;
import org.metafacture.framework.MetafactureException;
@@ -27,6 +25,8 @@
import org.metafacture.framework.annotations.Out;
import org.metafacture.framework.helpers.DefaultStreamPipe;
+import java.util.Collections;
+
/**
* Encodes a stream into MARCXML.
*
@@ -62,6 +62,15 @@ public final class MarcXmlEncoder extends DefaultStreamPipe
@@ -103,8 +104,7 @@
@Out(StreamReceiver.class)
@Description("Groups multiscript fields in entities")
@FluxCommand("remodel-pica-multiscript")
-public final class PicaMultiscriptRemodeler extends
- DefaultStreamPipe {
this.depth = depth;
}
- ACNode addNext(final char key){
+ ACNode addNext(final char key) {
return addNext(key, null);
}
- ACNode addNext(final char key, final P value){
- final ACNode next = new ACNode (value, depth+1);
+ ACNode addNext(final char key, final P currentValue) {
+ final ACNode next = new ACNode (currentValue, depth + 1);
links.put(key, next);
return next;
}
@@ -52,14 +52,18 @@ void setValue(final P value) {
this.value = value;
}
- P getValue(){
+ P getValue() {
return value;
}
- ACNode getNext(final char key){
+ ACNode getNext(final char key) {
return links.get(key);
}
+ Collection getFailure() {
return failure;
}
@@ -72,10 +76,6 @@ int getDepth() {
return depth;
}
- Collection get(final String key) {
diff --git a/metafacture-commons/src/main/java/org/metafacture/commons/tries/SimpleTrie.java b/metafacture-commons/src/main/java/org/metafacture/commons/tries/SimpleTrie.java
index a35f50e44..40f0f422f 100644
--- a/metafacture-commons/src/main/java/org/metafacture/commons/tries/SimpleTrie.java
+++ b/metafacture-commons/src/main/java/org/metafacture/commons/tries/SimpleTrie.java
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.metafacture.commons.tries;
/**
@@ -24,32 +25,36 @@
public final class SimpleTrie {
private final Node root = new Node<>(null);
- public void put(final String key, final P value){
+ public SimpleTrie() {
+ }
+
+ public void put(final String key, final P value) {
Node node = root;
Node next;
final int length = key.length();
- for (int i = 0; i < length-1; ++i) {
+ for (int i = 0; i < length - 1; ++i) {
next = node.getNext(key.charAt(i));
- if(next==null){
+ if (next == null) {
next = node.addNext(key.charAt(i));
}
node = next;
}
- next = node.getNext(key.charAt(length-1));
- if(next==null){
- next = node.addNext(key.charAt(length-1), value);
- }else{
+ next = node.getNext(key.charAt(length - 1));
+ if (next == null) {
+ next = node.addNext(key.charAt(length - 1), value);
+ }
+ else {
throw new IllegalStateException("Value '" + value + "' already in trie");
}
}
- public P get(final String key){
+ public P get(final String key) {
Node node = root;
final int length = key.length();
for (int i = 0; i < length; ++i) {
node = node.getNext(key.charAt(i));
- if(node==null){
+ if (node == null) {
return null;
}
}
@@ -65,25 +70,25 @@ private static final class Node {
private final P value;
private final CharMap addNext(final char key){
+ public Node addNext(final char key) {
return addNext(key, null);
}
- public Node addNext(final char key, final P value){
- final Node next = new Node (value);
+ public Node addNext(final char key, final P currentValue) {
+ final Node next = new Node (currentValue);
links.put(key, next);
return next;
}
- public P getValue(){
+ public P getValue() {
return value;
}
- public Node getNext(final char key){
+ public Node getNext(final char key) {
return links.get(key);
}
}
diff --git a/metafacture-commons/src/main/java/org/metafacture/commons/tries/WildcardTrie.java b/metafacture-commons/src/main/java/org/metafacture/commons/tries/WildcardTrie.java
index 14f13ba8b..1bada6d34 100644
--- a/metafacture-commons/src/main/java/org/metafacture/commons/tries/WildcardTrie.java
+++ b/metafacture-commons/src/main/java/org/metafacture/commons/tries/WildcardTrie.java
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.metafacture.commons.tries;
import java.util.ArrayList;
@@ -41,6 +42,9 @@ public final class WildcardTrie {
private Set {
public void put(final String keys, final P value) {
if (keys.contains(OR_STRING)) {
final String[] keysSplit = OR_PATTERN.split(keys);
- for (String string : keysSplit) {
+ for (final String string : keysSplit) {
simplyPut(string, value);
}
- } else {
+ }
+ else {
simplyPut(keys, value);
}
}
@@ -76,13 +81,11 @@ private void simplyPut(final String key, final P value) {
}
public List get(final String key) {
-
nodes.add(root);
final int length = key.length();
for (int i = 0; i < length; ++i) {
- for (Node node : nodes) {
- Node temp;
- temp = node.getNext(key.charAt(i));
+ for (final Node node : nodes) {
+ Node temp = node.getNext(key.charAt(i));
if (temp != null) {
nextNodes.add(temp);
}
@@ -108,8 +111,12 @@ public List get(final String key) {
nextNodes = temp;
}
+ return matches();
+ }
+
+ private List matches() {
List matches = Collections.emptyList();
- for (Node node : nodes) {
+ for (final Node node : nodes) {
final Set values = node.getValues();
if (!values.isEmpty()) {
if (matches == Collections.emptyList()) {
diff --git a/metafacture-commons/src/main/java/org/metafacture/commons/types/ListMap.java b/metafacture-commons/src/main/java/org/metafacture/commons/types/ListMap.java
index 186bee82a..2b0ec6859 100644
--- a/metafacture-commons/src/main/java/org/metafacture/commons/types/ListMap.java
+++ b/metafacture-commons/src/main/java/org/metafacture/commons/types/ListMap.java
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.metafacture.commons.types;
import java.util.ArrayList;
@@ -39,12 +40,10 @@ public class ListMap