diff --git a/build.gradle b/build.gradle index 7e3d1e00c..bc11914d8 100644 --- a/build.gradle +++ b/build.gradle @@ -58,6 +58,7 @@ subprojects { apply plugin: 'checkstyle' check.dependsOn(editorconfigCheck) + check.dependsOn(javadoc) sourceCompatibility = 1.8 targetCompatibility = 1.8 @@ -81,6 +82,12 @@ subprojects { group 'build' } + javadoc { + options { + addBooleanOption 'Xwerror', true + } + } + artifacts { archives sourceJar archives javadocJar diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml index a5415c3d6..a68d6fd5a 100644 --- a/config/checkstyle/checkstyle.xml +++ b/config/checkstyle/checkstyle.xml @@ -68,6 +68,7 @@ + @@ -81,6 +82,7 @@ + @@ -97,6 +99,7 @@ + diff --git a/metafacture-biblio/src/main/java/org/metafacture/biblio/AlephMabXmlHandler.java b/metafacture-biblio/src/main/java/org/metafacture/biblio/AlephMabXmlHandler.java index 3904ed3a6..1a54a80e2 100644 --- a/metafacture-biblio/src/main/java/org/metafacture/biblio/AlephMabXmlHandler.java +++ b/metafacture-biblio/src/main/java/org/metafacture/biblio/AlephMabXmlHandler.java @@ -50,6 +50,9 @@ public final class AlephMabXmlHandler extends DefaultXmlPipe { private String currentTag = ""; private StringBuilder builder = new StringBuilder(); + /** + * Creates instance of {@link AlephMabXmlHandler}. + */ public AlephMabXmlHandler() { } diff --git a/metafacture-biblio/src/main/java/org/metafacture/biblio/AseqDecoder.java b/metafacture-biblio/src/main/java/org/metafacture/biblio/AseqDecoder.java index 9c5d37977..bb6e70c4a 100644 --- a/metafacture-biblio/src/main/java/org/metafacture/biblio/AseqDecoder.java +++ b/metafacture-biblio/src/main/java/org/metafacture/biblio/AseqDecoder.java @@ -42,6 +42,9 @@ public final class AseqDecoder extends DefaultObjectPipe private static final int RECORD_IDENTIFIER_BEGIN = 0; private static final int RECORD_IDENTIFIER_END = 9; + /** + * Creates an instance of {@link AseqDecoder}. + */ public AseqDecoder() { } diff --git a/metafacture-biblio/src/main/java/org/metafacture/biblio/ComarcXmlHandler.java b/metafacture-biblio/src/main/java/org/metafacture/biblio/ComarcXmlHandler.java index 625300a8d..2833064f1 100644 --- a/metafacture-biblio/src/main/java/org/metafacture/biblio/ComarcXmlHandler.java +++ b/metafacture-biblio/src/main/java/org/metafacture/biblio/ComarcXmlHandler.java @@ -63,6 +63,9 @@ public class ComarcXmlHandler extends DefaultXmlPipe { private String currentTag = ""; private StringBuilder builder = new StringBuilder(); + /** + * Creates an instance of {@link ComarcXmlHandler}. + */ public ComarcXmlHandler() { } diff --git a/metafacture-biblio/src/main/java/org/metafacture/biblio/MabDecoder.java b/metafacture-biblio/src/main/java/org/metafacture/biblio/MabDecoder.java index 4804199b8..6cdbf1e56 100644 --- a/metafacture-biblio/src/main/java/org/metafacture/biblio/MabDecoder.java +++ b/metafacture-biblio/src/main/java/org/metafacture/biblio/MabDecoder.java @@ -57,6 +57,9 @@ public final class MabDecoder extends DefaultObjectPipe private static final String ID_TAG = "001 "; private static final int TAG_LENGTH = 4; + /** + * Creates an instance of {@link MabDecoder}. + */ public MabDecoder() { } diff --git a/metafacture-biblio/src/main/java/org/metafacture/biblio/iso2709/FieldHandler.java b/metafacture-biblio/src/main/java/org/metafacture/biblio/iso2709/FieldHandler.java index 35c82f2ee..785aa9bfa 100644 --- a/metafacture-biblio/src/main/java/org/metafacture/biblio/iso2709/FieldHandler.java +++ b/metafacture-biblio/src/main/java/org/metafacture/biblio/iso2709/FieldHandler.java @@ -24,14 +24,42 @@ */ public interface FieldHandler { + /** + * Reference a field. + * + * @param tag the tag + * @param implDefinedPart the impl defined part + * @param value the value + */ void referenceField(char[] tag, char[] implDefinedPart, String value); + /** + * Starts a data field. + * + * @param tag the tag + * @param implDefinedPart the impl defined part + * @param indicators the indicators + */ void startDataField(char[] tag, char[] implDefinedPart, char[] indicators); + /** + * Ends the data field. + */ void endDataField(); + /** + * Sets the impl defined part. + * + * @param implDefinedPart he impl defined part + */ void additionalImplDefinedPart(char[] implDefinedPart); + /** + * Sets the identifier to a value. + * + * @param identifier the identifier + * @param value the value + */ void data(char[] identifier, String value); } diff --git a/metafacture-biblio/src/main/java/org/metafacture/biblio/iso2709/Label.java b/metafacture-biblio/src/main/java/org/metafacture/biblio/iso2709/Label.java index 51de1fd2b..6068eee5b 100644 --- a/metafacture-biblio/src/main/java/org/metafacture/biblio/iso2709/Label.java +++ b/metafacture-biblio/src/main/java/org/metafacture/biblio/iso2709/Label.java @@ -17,7 +17,7 @@ package org.metafacture.biblio.iso2709; /** - * Provides read access to the record label of a ISO 2709:2008 formatted + * Provides read access to the record label of an ISO 2709:2008 formatted * record. The record label consists of the first 24 octets of the record. *

* Use {@link LabelBuilder} if write access to the label is required. diff --git a/metafacture-biblio/src/main/java/org/metafacture/biblio/iso2709/Record.java b/metafacture-biblio/src/main/java/org/metafacture/biblio/iso2709/Record.java index c72b5b4e4..2fcb8241f 100644 --- a/metafacture-biblio/src/main/java/org/metafacture/biblio/iso2709/Record.java +++ b/metafacture-biblio/src/main/java/org/metafacture/biblio/iso2709/Record.java @@ -91,22 +91,47 @@ private int findRecordIdFieldStart() { return RECORD_ID_MISSING; } + /** + * Gets the record format of the Label. + * + * @return the record format of the Label + */ public RecordFormat getRecordFormat() { return label.getRecordFormat(); } + /** + * Gets the record status of the Label. + * + * @return the record status of the Label + */ public char getRecordStatus() { return label.getRecordStatus(); } + /** + * Gets the impl codes. + * + * @return the impl codes + */ public char[] getImplCodes() { return label.getImplCodes(); } + /** + * Gets the systems chars of the Label. + * + * @return the system chars + */ public char[] getSystemChars() { return label.getSystemChars(); } + /** + * Gets the reserved char of the Label. + * + * @return the reserved char + */ public char getReservedChar() { return label.getReservedChar(); } diff --git a/metafacture-biblio/src/main/java/org/metafacture/biblio/iso2709/RecordBuilder.java b/metafacture-biblio/src/main/java/org/metafacture/biblio/iso2709/RecordBuilder.java index 5c47701c9..22d13b260 100644 --- a/metafacture-biblio/src/main/java/org/metafacture/biblio/iso2709/RecordBuilder.java +++ b/metafacture-biblio/src/main/java/org/metafacture/biblio/iso2709/RecordBuilder.java @@ -56,6 +56,12 @@ public final class RecordBuilder { private AppendState appendState; private int fieldStart; + /** + * Initializes the RecordBuilder based on a RecordFormat. + * + * @param recordFormat RecordFormat as base to configure the RecordBuilder + * @see RecordFormat + */ public RecordBuilder(final RecordFormat recordFormat) { Require.notNull(recordFormat); label = new LabelBuilder(recordFormat); @@ -82,19 +88,45 @@ private char[] arrayOfNSpaceChars(final int count) { return chars; } + /** + * Sets the charset of the FieldsBuilder. + * + * @param charset Charset used by the FieldsBuilder + * @see FieldsBuilder + * @see Charset + */ public void setCharset(final Charset charset) { fields.setCharset(Require.notNull(charset)); } + /** + * Gets the Charset of the FieldsBuilder. + * + * @return the Charset + */ public Charset getCharset() { return fields.getCharset(); } + /** + * Sets the record status of the LabelBuilder. + * + * @param recordStatus 7 bit char record status + * @see Iso2709Constants#RECORD_STATUS_POS + * @see LabelBuilder + */ public void setRecordStatus(final char recordStatus) { require7BitAscii(recordStatus); label.setRecordStatus(recordStatus); } + /** + * Sets the impl codes in the LabelBuilder. + * + * @param implCodes char array of 7 bit impl codes + * @see Iso2709Constants + * @see LabelBuilder + */ public void setImplCodes(final char[] implCodes) { Require.notNull(implCodes); Require.that(implCodes.length == Iso2709Constants.IMPL_CODES_LENGTH); @@ -102,12 +134,27 @@ public void setImplCodes(final char[] implCodes) { label.setImplCodes(implCodes); } + /** + * Sets an impl code at a given position in the LabelBuilder. + * + * @param index index of the 7 bit impl code + * @param implCode char of a 7 bit impl code + * @see Iso2709Constants + * @see LabelBuilder + */ public void setImplCode(final int index, final char implCode) { Require.that(0 <= index && index < Iso2709Constants.IMPL_CODES_LENGTH); require7BitAscii(implCode); label.setImplCode(index, implCode); } + /** + * Sets the system chars in the LabelBuilder. + * + * @param systemChars 7-bit char array to be set as system chars + * @see Iso2709Constants + * @see LabelBuilder + */ public void setSystemChars(final char[] systemChars) { Require.notNull(systemChars); Require.that(systemChars.length == Iso2709Constants.SYSTEM_CHARS_LENGTH); @@ -115,21 +162,47 @@ public void setSystemChars(final char[] systemChars) { label.setSystemChars(systemChars); } + /** + * Sets a system char at the given position in the LabelBuilder. + * + * @param systemChar 7-bit char to be set as the system char + * @param index position of the system char + * @see Iso2709Constants + * @see LabelBuilder + */ public void setSystemChar(final int index, final char systemChar) { Require.that(0 <= index && index < Iso2709Constants.SYSTEM_CHARS_LENGTH); require7BitAscii(systemChar); label.setSystemChar(index, systemChar); } + /** + * Sets a reserved char in the LabelBuilder. + * + * @param reservedChar 7-bit char to be set as reserved char + * @see Iso2709Constants + * @see LabelBuilder + */ public void setReservedChar(final char reservedChar) { require7BitAscii(reservedChar); label.setReservedChar(reservedChar); } + /** + * Appends an identifier field. + * + * @param value String that is appended as an identfier field + */ public void appendIdentifierField(final String value) { appendIdentifierField(defaultImplDefinedPart, value); } + /** + * Appends an identifier field in dependency of the current impl defined part. + * + * @param currentImplDefinedPart char array of the current impl defined part + * @param value String that is appended as an identfier field + */ public void appendIdentifierField(final char[] currentImplDefinedPart, final String value) { requireNotInDataField(); requireNotAppendingReferenceFields(); @@ -140,10 +213,25 @@ public void appendIdentifierField(final char[] currentImplDefinedPart, final Str appendReferenceField(ID_FIELD_TAG, currentImplDefinedPart, value); } + /** + * Appends a reference field in dependency of the current tag and of the default + * impl defined part. + * + * @param currentTag char array of the current tag + * @param value String that is appended as a reference field + */ public void appendReferenceField(final char[] currentTag, final String value) { appendReferenceField(currentTag, defaultImplDefinedPart, value); } + /** + * Appends a reference field in dependency of the current tag and of the + * current impl defined part. + * + * @param currentTag char array of the current tag + * @param currentImplDefinedPart char array of the current impl defined part + * @param value String that is appended as a reference field + */ public void appendReferenceField(final char[] currentTag, final char[] currentImplDefinedPart, final String value) { requireNotInDataField(); requireNotAppendingDataFields(); @@ -173,14 +261,34 @@ private void checkValidReferenceFieldTag(final char[] currentTag) { } } + /** + * Starts a data field in dependency of the current tag and default indicators. + * + * @param currentTag char array of the current tag + */ public void startDataField(final char[] currentTag) { startDataField(currentTag, defaultIndicators); } + /** + * Starts a data field in dependency of the current tag, indicators and of the + * default impl defined part. + * + * @param currentTag char array of the current tag + * @param indicators char array of the current indicators + */ public void startDataField(final char[] currentTag, final char[] indicators) { startDataField(currentTag, indicators, defaultImplDefinedPart); } + /** + * Starts a data field in dependency of the current tag, indicators and of the + * current impl defined part. + * + * @param currentTag char array of the current tag + * @param indicators char array of the current indicators + * @param currentImplDefinedPart char array of the current impl defined part + */ public void startDataField(final char[] currentTag, final char[] indicators, final char[] currentImplDefinedPart) { requireNotInDataField(); Require.notNull(currentTag); @@ -208,6 +316,9 @@ private void copyArray(final char[] source, final char[] destination) { System.arraycopy(source, 0, destination, 0, destination.length); } + /** + * Ends a data field. + */ public void endDataField() { requireInDataField(); final int fieldEnd = fields.endField(); @@ -221,12 +332,23 @@ public void endDataField() { } } + /** + * Appends a subfield. + * + * @param value String of the subfield to be appended + */ public void appendSubfield(final String value) { requireInDataField(); Require.notNull(value); fields.appendSubfield(defaultIdentifier, value); } + /** + * Appends a subfield in dependency of an identifier. + * + * @param identifier char array of an identifier + * @param value String of the subfield to be appended + */ public void appendSubfield(final char[] identifier, final String value) { requireInDataField(); Require.notNull(identifier); @@ -236,6 +358,11 @@ public void appendSubfield(final char[] identifier, final String value) { fields.appendSubfield(identifier, value); } + /** + * Builds the record. + * + * @return byte array of the record + */ public byte[] build() { requireNotInDataField(); final int baseAddress = Iso2709Constants.RECORD_LABEL_LENGTH + directory.length(); @@ -286,6 +413,10 @@ private void require7BitAscii(final char charCode) { Require.that(charCode != Iso646Constants.INFORMATION_SEPARATOR_3); } + /** + * Resets the label, directory and the fields. Sets the "append state" to "id + * field". + */ public void reset() { label.reset(); directory.reset(); diff --git a/metafacture-biblio/src/main/java/org/metafacture/biblio/iso2709/RecordFormat.java b/metafacture-biblio/src/main/java/org/metafacture/biblio/iso2709/RecordFormat.java index 0fe9756cf..c302666df 100644 --- a/metafacture-biblio/src/main/java/org/metafacture/biblio/iso2709/RecordFormat.java +++ b/metafacture-biblio/src/main/java/org/metafacture/biblio/iso2709/RecordFormat.java @@ -51,6 +51,15 @@ public final class RecordFormat { private final int fieldStartLength; private final int implDefinedPartLength; + /** + * Initializes the RecordFormat. + * + * @param indicatorLength the length of the indicator + * @param identifierLength the length of the identifier + * @param fieldLengthLength the length of the field length + * @param fieldStartLength the length of the field start + * @param implDefinedPartLength the length of the defined part + */ public RecordFormat(final int indicatorLength, final int identifierLength, final int fieldLengthLength, final int fieldStartLength, final int implDefinedPartLength) { @@ -61,6 +70,11 @@ public RecordFormat(final int indicatorLength, final int identifierLength, this.implDefinedPartLength = implDefinedPartLength; } + /** + * Initializes a RecordFormat defined by a RecordFormat. + * + * @param source the RecordFormat + */ public RecordFormat(final RecordFormat source) { Require.notNull(source); @@ -71,10 +85,21 @@ public RecordFormat(final RecordFormat source) { implDefinedPartLength = source.implDefinedPartLength; } + /** + * Returns a new default Builder. + * + * @return Builder + */ public static Builder create() { return new Builder(); } + /** + * Returns a new Builder created from a RecordFormat. + * + * @param source the RecordFormat + * @return Builder + */ public static Builder createFrom(final RecordFormat source) { return create() .withIndicatorLength(source.indicatorLength) @@ -84,22 +109,47 @@ public static Builder createFrom(final RecordFormat source) { .withImplDefinedPartLength(source.implDefinedPartLength); } + /** + * Gets the length of the indicator. + * + * @return the length of the indicator + */ public int getIndicatorLength() { return indicatorLength; } + /** + * Gets the length of the identifier. + * + * @return the length of the identifier + */ public int getIdentifierLength() { return identifierLength; } + /** + * Gets the length of the field length. + * + * @return the length of the field length + */ public int getFieldLengthLength() { return fieldLengthLength; } + /** + * Gets the length of the field start. + * + * @return length of the field start + */ public int getFieldStartLength() { return fieldStartLength; } + /** + * Gets the the length of the defined part. + * + * @return the length of the defined part + */ public int getImplDefinedPartLength() { return implDefinedPartLength; } @@ -149,6 +199,12 @@ public static class Builder { Builder() { } + /** + * Returns a new Builder with defined indicator length. + * + * @param currentIndicatorLength the length of the indicator + * @return Builder + */ public Builder withIndicatorLength(final int currentIndicatorLength) { Require.notNegative(currentIndicatorLength); Require.that(currentIndicatorLength < RADIX); @@ -156,6 +212,12 @@ public Builder withIndicatorLength(final int currentIndicatorLength) { return this; } + /** + * Returns a new Builder with defined identifier length. + * + * @param currentIdentifierLength the length of the identifier + * @return Builder + */ public Builder withIdentifierLength(final int currentIdentifierLength) { Require.notNegative(currentIdentifierLength); Require.that(currentIdentifierLength < RADIX); @@ -163,6 +225,12 @@ public Builder withIdentifierLength(final int currentIdentifierLength) { return this; } + /** + * Returns a new Builder with defined field length length. + * + * @param currentFieldLengthLength the length of the field length + * @return Builder + */ public Builder withFieldLengthLength(final int currentFieldLengthLength) { Require.that(currentFieldLengthLength > 0); Require.that(currentFieldLengthLength < RADIX); @@ -170,6 +238,12 @@ public Builder withFieldLengthLength(final int currentFieldLengthLength) { return this; } + /** + * Returns a new Builder with defined field start length. + * + * @param currentFieldStartLength the length of the field start + * @return Builder + */ public Builder withFieldStartLength(final int currentFieldStartLength) { Require.that(currentFieldStartLength > 0); Require.that(currentFieldStartLength < RADIX); @@ -177,6 +251,12 @@ public Builder withFieldStartLength(final int currentFieldStartLength) { return this; } + /** + * Returns a new Builder with defined part length. + * + * @param currentImplDefinedPartLength the length of the defined part + * @return Builder + */ public Builder withImplDefinedPartLength(final int currentImplDefinedPartLength) { Require.notNegative(currentImplDefinedPartLength); Require.that(currentImplDefinedPartLength < RADIX); @@ -184,6 +264,11 @@ public Builder withImplDefinedPartLength(final int currentImplDefinedPartLength) return this; } + /** + * Returns a new RecordFormat. + * + * @return RecordFormat + */ public RecordFormat build() { return new RecordFormat(indicatorLength, identifierLength, fieldLengthLength, fieldStartLength, implDefinedPartLength); diff --git a/metafacture-biblio/src/main/java/org/metafacture/biblio/marc21/Marc21Decoder.java b/metafacture-biblio/src/main/java/org/metafacture/biblio/marc21/Marc21Decoder.java index 29080313c..401cdd3ce 100644 --- a/metafacture-biblio/src/main/java/org/metafacture/biblio/marc21/Marc21Decoder.java +++ b/metafacture-biblio/src/main/java/org/metafacture/biblio/marc21/Marc21Decoder.java @@ -41,8 +41,9 @@ *

  • data fields. * * This decoder only supports MARC 21 records with UTF-8 encoding. Other - * character coding schemes are not supported. A {@link FormatException} is - * thrown if a record with an unsupported coding scheme is encountered. + * character coding schemes are not supported. A + * {@link org.metafacture.framework.FormatException} is thrown if a record + * with an unsupported coding scheme is encountered. *

    * The bibliographic information in the record leader is *

      @@ -56,18 +57,18 @@ *
    • multipart resource record level. *
    * This information is emitted as an entity named - * "{@value Marc21EventNames#LEADER_ENTITY}". It is emitted directly - * after the start-record event. The entity contains the following - * literals: + * {@value org.metafacture.biblio.marc21.Marc21EventNames#LEADER_ENTITY}. It is + * emitted directly after the start-record event. The entity contains + * the following literals: *
      - *
    1. {@value Marc21EventNames#RECORD_STATUS_LITERAL} - *
    2. {@value Marc21EventNames#RECORD_TYPE_LITERAL} - *
    3. {@value Marc21EventNames#BIBLIOGRAPHIC_LEVEL_LITERAL} - *
    4. {@value Marc21EventNames#TYPE_OF_CONTROL_LITERAL} - *
    5. {@value Marc21EventNames#CHARACTER_CODING_LITERAL} - *
    6. {@value Marc21EventNames#ENCODING_LEVEL_LITERAL} - *
    7. {@value Marc21EventNames#CATALOGING_FORM_LITERAL} - *
    8. {@value Marc21EventNames#MULTIPART_LEVEL_LITERAL} + *
    9. {@value org.metafacture.biblio.marc21.Marc21EventNames#RECORD_STATUS_LITERAL} + *
    10. {@value org.metafacture.biblio.marc21.Marc21EventNames#RECORD_TYPE_LITERAL} + *
    11. {@value org.metafacture.biblio.marc21.Marc21EventNames#BIBLIOGRAPHIC_LEVEL_LITERAL} + *
    12. {@value org.metafacture.biblio.marc21.Marc21EventNames#TYPE_OF_CONTROL_LITERAL} + *
    13. {@value org.metafacture.biblio.marc21.Marc21EventNames#CHARACTER_CODING_LITERAL} + *
    14. {@value org.metafacture.biblio.marc21.Marc21EventNames#ENCODING_LEVEL_LITERAL} + *
    15. {@value org.metafacture.biblio.marc21.Marc21EventNames#CATALOGING_FORM_LITERAL} + *
    16. {@value org.metafacture.biblio.marc21.Marc21EventNames#MULTIPART_LEVEL_LITERAL} *
    * The literals are emitted in the order in which they are listed here. The * values of these literals are the characters at the corresponding @@ -75,9 +76,9 @@ * MARC 21 * Standard: Record Leader for a description of the allowed values). The * literal values are always only single characters. As this decoder only - * supports MARC 21 records with UTF-8 encoding, the value of the literal - * "{@value Marc21EventNames#CHARACTER_CODING_LITERAL}" will - * always be "a". + * supports MARC 21 records with UTF-8 encoding, the value of the literal + * {@value org.metafacture.biblio.marc21.Marc21EventNames#CHARACTER_CODING_LITERAL} + * will always be "a". *

    * For example, given a record with the leader *

    @@ -86,15 +87,15 @@
      * the following event stream will be emitted:
      * 
      * start-record "1"
    - * start-entity "{@value Marc21EventNames#LEADER_ENTITY}"
    - * literal "{@value Marc21EventNames#RECORD_STATUS_LITERAL}": n
    - * literal "{@value Marc21EventNames#RECORD_TYPE_LITERAL}": o
    - * literal "{@value Marc21EventNames#BIBLIOGRAPHIC_LEVEL_LITERAL}": a
    - * literal "{@value Marc21EventNames#TYPE_OF_CONTROL_LITERAL}": " "
    - * literal "{@value Marc21EventNames#CHARACTER_CODING_LITERAL}": a
    - * literal "{@value Marc21EventNames#ENCODING_LEVEL_LITERAL}": z
    - * literal "{@value Marc21EventNames#CATALOGING_FORM_LITERAL}": u
    - * literal "{@value Marc21EventNames#MULTIPART_LEVEL_LITERAL}": " "
    + * start-entity {@value org.metafacture.biblio.marc21.Marc21EventNames#LEADER_ENTITY}
    + * literal {@value org.metafacture.biblio.marc21.Marc21EventNames#RECORD_STATUS_LITERAL}: n
    + * literal {@value org.metafacture.biblio.marc21.Marc21EventNames#RECORD_TYPE_LITERAL}: o
    + * literal {@value org.metafacture.biblio.marc21.Marc21EventNames#BIBLIOGRAPHIC_LEVEL_LITERAL}: a
    + * literal {@value org.metafacture.biblio.marc21.Marc21EventNames#TYPE_OF_CONTROL_LITERAL}: " "
    + * literal {@value org.metafacture.biblio.marc21.Marc21EventNames#CHARACTER_CODING_LITERAL}: a
    + * literal {@value org.metafacture.biblio.marc21.Marc21EventNames#ENCODING_LEVEL_LITERAL}: z
    + * literal {@value org.metafacture.biblio.marc21.Marc21EventNames#CATALOGING_FORM_LITERAL}: u
    + * literal {@value org.metafacture.biblio.marc21.Marc21EventNames#MULTIPART_LEVEL_LITERAL}: " "
      * end-entity
      * …
      * 
    @@ -124,7 +125,8 @@ * If the decoder receives an empty input string it is ignored and no stream * events are emitted. *

    - * If an error occurs during decoding, a {@link FormatException} is thrown. + * If an error occurs during decoding, a + * {@link org.metafacture.framework.FormatException} is thrown. * * @author Christoph Böhme * @see "ISO 2709:2008 Standard" @@ -137,33 +139,45 @@ @FluxCommand("decode-marc21") public final class Marc21Decoder extends DefaultObjectPipe { + public static final boolean EMIT_LEADER_AS_WHOLE = false; + public static final boolean IGNORE_MISSING_ID = false; + private final FieldHandler fieldHandler = new Marc21Handler(); - private boolean ignoreMissingId; - private boolean emitLeaderAsWhole; + private boolean ignoreMissingId = IGNORE_MISSING_ID; + private boolean emitLeaderAsWhole = EMIT_LEADER_AS_WHOLE; + /** + * Creates an instance of {@link Marc21Decoder}. + */ public Marc21Decoder() { } /** - * Controls whether the decoder aborts processing if a record has no - * identifier. A {@link MissingIdException} is thrown in these cases. - * If this parameter is set to true then the identifier emitted with the - * start-record event of records without field "001" will - * be an empty string. + * Controls whether the decoder aborts processing if a record has no identifier. + * A {@link MissingIdException} is thrown in these cases. If this parameter is + * set to true then the identifier emitted with the start-record event of + * records without field "001" will be an empty string. *

    - * The default value of {@code ignoreMissingId} is false. + * Default value: {@value #IGNORE_MISSING_ID} *

    * This parameter can be changed anytime during processing. The new value * becomes effective with the next record being processed. * - * @param ignoreMissingId - * true if missing identifiers should be silently ignored. + * @param ignoreMissingId true if missing identifiers should be silently + * ignored. */ public void setIgnoreMissingId(final boolean ignoreMissingId) { this.ignoreMissingId = ignoreMissingId; } + /** + * Gets the flag to decide whether to abort the processing of a record if it has + * no identifier. + * + * @return true if a missing identifier shouldn't abort processing, otherwise + * false + */ public boolean getIgnoreMissingId() { return ignoreMissingId; } @@ -172,16 +186,22 @@ public boolean getIgnoreMissingId() { * Controls whether the Record Leader should be emitted as a whole instead of * extracting the bibliographic information in the record leader. * - * @see MARC 21 - * Standard: Record Leader + * Default value: {@value #EMIT_LEADER_AS_WHOLE} * - * @param emitLeaderAsWhole - * true if the leader should be emitted as a whole. + * @see MARC 21 + * Standard: Record Leader + * @param emitLeaderAsWhole true if the leader should be emitted as a whole. */ public void setEmitLeaderAsWhole(final boolean emitLeaderAsWhole) { this.emitLeaderAsWhole = emitLeaderAsWhole; } + /** + * Gets the flag to decide whether the Record Leader is emitted as whole instead + * of extracting the bibliographic information in the record leader. + * + * @return true if the Record Leader is emitted as whole, otherwise false + */ public boolean getEmitLeaderAsWhole() { return emitLeaderAsWhole; } diff --git a/metafacture-biblio/src/main/java/org/metafacture/biblio/marc21/Marc21Encoder.java b/metafacture-biblio/src/main/java/org/metafacture/biblio/marc21/Marc21Encoder.java index 5bf3643fc..04f330ec4 100644 --- a/metafacture-biblio/src/main/java/org/metafacture/biblio/marc21/Marc21Encoder.java +++ b/metafacture-biblio/src/main/java/org/metafacture/biblio/marc21/Marc21Encoder.java @@ -80,6 +80,9 @@ public final class Marc21Encoder extends private boolean generateIdField; + /** + * Initializes the encoder with MARC 21 constants and charset. + */ public Marc21Encoder() { builder = new RecordBuilder(Marc21Constants.MARC21_FORMAT); builder.setCharset(Marc21Constants.MARC21_CHARSET); @@ -103,6 +106,11 @@ public void setGenerateIdField(final boolean generateIdField) { this.generateIdField = generateIdField; } + /** + * Gets the flag to decide whether the ID field is generated. + * + * @return true if the record ID is generated, otherwise false + */ public boolean getGenerateIdField() { return generateIdField; } 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 fa842b137..38f148d53 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 @@ -41,7 +41,7 @@ public final class Marc21EventNames { /** * Name of the literal event emitted for the record status field. *

    - * The name of the literal is "{@value #RECORD_STATUS_LITERAL}". + * The name of the literal is {@value #RECORD_STATUS_LITERAL}. *

    * The record status is specified at position 5 in the record leader. * @@ -54,8 +54,7 @@ public final class Marc21EventNames { * Name of the literal event emitted for the bibliographic level * field. *

    - * The name of the literal is - * "{@value #BIBLIOGRAPHIC_LEVEL_LITERAL}". + * The name of the literal is {@value #BIBLIOGRAPHIC_LEVEL_LITERAL}. *

    * The bibliographic level is specified at position 7 in the record leader. * @@ -67,7 +66,7 @@ public final class Marc21EventNames { /** * Name of the literal event emitted for the type of control field. *

    - * The name of the literal is "{@value #TYPE_OF_CONTROL_LITERAL}". + * The name of the literal is {@value #TYPE_OF_CONTROL_LITERAL}. *

    * The type of control is specified at position 8 in the record leader. * @@ -80,7 +79,7 @@ public final class Marc21EventNames { * Name of the literal event emitted for the character coding scheme * field. *

    - * The name of the literal is "{@value #CHARACTER_CODING_LITERAL}". + * The name of the literal is {@value #CHARACTER_CODING_LITERAL}. *

    * The character coding scheme is specified at position 9 in the record * leader. @@ -93,7 +92,7 @@ public final class Marc21EventNames { /** * Name of the literal event emitted for the encoding level field. *

    - * The name of the literal is "{@value #ENCODING_LEVEL_LITERAL}". + * The name of the literal is {@value #ENCODING_LEVEL_LITERAL}. *

    * The encoding level is specified at position 17 in the record leader. * @@ -106,7 +105,7 @@ public final class Marc21EventNames { * Name of the literal event emitted for the descriptive cataloging * form field. *

    - * The name of the literal is "{@value #CATALOGING_FORM_LITERAL}". + * The name of the literal is {@value #CATALOGING_FORM_LITERAL}. *

    * The descriptive cataloging form is specified at position 18 in the record * leader. @@ -120,7 +119,7 @@ public final class Marc21EventNames { * Name of the literal event emitted for the multipart resource * record level field. *

    - * The name of the literal is "{@value #MULTIPART_LEVEL_LITERAL}". + * The name of the literal is {@value #MULTIPART_LEVEL_LITERAL}. *

    * The multipart resource record level is specified at position 19 in the * record leader. @@ -133,7 +132,7 @@ public final class Marc21EventNames { /** * Name of the literal event emitted for the type of record field. *

    - * The name of the literal is "{@value #RECORD_TYPE_LITERAL}". + * The name of the literal is {@value #RECORD_TYPE_LITERAL}. *

    * The type of record is specified at position 6 in the record leader. * 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 9a1e6e9f6..0b8202ec0 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 @@ -42,6 +42,15 @@ @FluxCommand("encode-marcxml") public final class MarcXmlEncoder extends DefaultStreamPipe> { + public static final String NAMESPACE_NAME = "marc"; + public static final String XML_ENCODING = "UTF-8"; + public static final String XML_VERSION = "1.0"; + public static final boolean PRETTY_PRINTED = true; + public static final boolean OMIT_XML_DECLARATION = false; + + private static final String ROOT_OPEN = ""; + private static final String ROOT_CLOSE = ""; + private enum Tag { collection(" xmlns%s=\"" + NAMESPACE + "\"%s"), @@ -73,7 +82,6 @@ public String close(final Object[] args) { } private static final String NAMESPACE = "http://www.loc.gov/MARC21/slim"; - private static final String NAMESPACE_NAME = "marc"; private static final String NAMESPACE_PREFIX = NAMESPACE_NAME + ":"; private static final String NAMESPACE_SUFFIX = ":" + NAMESPACE_NAME; @@ -96,60 +104,80 @@ public String close(final Object[] args) { private static final int TAG_BEGIN = 0; private static final int TAG_END = 3; - private final StringBuilder builder; + private final StringBuilder builder = new StringBuilder(); - private boolean atStreamStart; + private boolean atStreamStart = true; - private boolean omitXmlDeclaration; - private String xmlVersion; - private String xmlEncoding; + private boolean omitXmlDeclaration = OMIT_XML_DECLARATION; + private String xmlVersion = XML_VERSION; + private String xmlEncoding = XML_ENCODING; - private boolean emitNamespace; - private Object[] namespacePrefix; + private String currentEntity = ""; + + private boolean emitNamespace = true; + private Object[] namespacePrefix = new Object[]{emitNamespace ? NAMESPACE_PREFIX : EMPTY}; - private String currentEntity; private int indentationLevel; + private boolean formatted = PRETTY_PRINTED; private int recordAttributeOffset; - private boolean formatted; + /** + * Creates an instance of {@link MarcXmlEncoder}. + */ public MarcXmlEncoder() { - this.builder = new StringBuilder(); - this.atStreamStart = true; - - this.omitXmlDeclaration = false; - this.xmlVersion = "1.0"; - this.xmlEncoding = "UTF-8"; - - this.currentEntity = ""; - - this.indentationLevel = 0; - this.formatted = true; - - setEmitNamespace(true); } + /** + * Sets the flag to decide whether to emit the {@value #NAMESPACE_NAME} + * namespace + * + * @param emitNamespace true if the namespace is emitted, otherwise false + */ public void setEmitNamespace(final boolean emitNamespace) { this.emitNamespace = emitNamespace; namespacePrefix = new Object[]{emitNamespace ? NAMESPACE_PREFIX : EMPTY}; } + /** + * Sets the flag to decide whether to omit the XML declaration. + * + * Default value: {@value #OMIT_XML_DECLARATION} + * + * @param currentOmitXmlDeclaration true if the XML declaration is omitted, otherwise + * false + */ public void omitXmlDeclaration(final boolean currentOmitXmlDeclaration) { omitXmlDeclaration = currentOmitXmlDeclaration; } + /** + * Sets the XML version. + * + * Default value: {@value #XML_VERSION} + * + * @param xmlVersion the XML version + */ public void setXmlVersion(final String xmlVersion) { this.xmlVersion = xmlVersion; } + /** + * Sets the XML encoding. + * + * Default value: {@value #XML_ENCODING} + * + * @param xmlEncoding the XML encoding + */ public void setXmlEncoding(final String xmlEncoding) { this.xmlEncoding = xmlEncoding; } /** - * Formats the resulting xml, by indentation. + * Formats the resulting xml by indentation. Aka "pretty printing". * - * @param formatted - * True, if formatting is activated. + * Default value: {@value #PRETTY_PRINTED} + * + * @param formatted true if formatting is activated, otherwise false */ public void setFormatted(final boolean formatted) { this.formatted = formatted; @@ -278,12 +306,20 @@ private void writeFooter() { writeTag(Tag.collection::close); } - /** Writes a unescaped sequence */ + /** + * Writes an unescaped sequence. + * + * @param str the unescaped sequence to be written + */ private void writeRaw(final String str) { builder.append(str); } - /** Writes a escaped sequence */ + /** + * Writes an escaped sequence. + * + * @param str the unescaped sequence to be written + */ private void writeEscaped(final String str) { builder.append(XmlUtil.escape(str, false)); } diff --git a/metafacture-biblio/src/main/java/org/metafacture/biblio/marc21/MarcXmlHandler.java b/metafacture-biblio/src/main/java/org/metafacture/biblio/marc21/MarcXmlHandler.java index 98d7d082e..a79ecce6d 100644 --- a/metafacture-biblio/src/main/java/org/metafacture/biblio/marc21/MarcXmlHandler.java +++ b/metafacture-biblio/src/main/java/org/metafacture/biblio/marc21/MarcXmlHandler.java @@ -38,11 +38,12 @@ @FluxCommand("handle-marcxml") public final class MarcXmlHandler extends DefaultXmlPipe { + public static final String NAMESPACE = "http://www.loc.gov/MARC21/slim"; + private static final String SUBFIELD = "subfield"; private static final String DATAFIELD = "datafield"; private static final String CONTROLFIELD = "controlfield"; private static final String RECORD = "record"; - private static final String NAMESPACE = "http://www.loc.gov/MARC21/slim"; private static final String LEADER = "leader"; private static final String TYPE = "type"; @@ -51,9 +52,19 @@ public final class MarcXmlHandler extends DefaultXmlPipe { private String namespace = NAMESPACE; private StringBuilder builder = new StringBuilder(); + /** + * Creates an instance of {@link MarcXmlHandler}. + */ public MarcXmlHandler() { } + /** + * Sets the namespace. + * + * Default value: {@value #NAMESPACE} + * + * @param namespace the namespace + */ public void setNamespace(final String namespace) { this.namespace = namespace; } @@ -62,10 +73,23 @@ private boolean checkNamespace(final String uri) { return namespace == null || namespace.equals(uri); } + /** + * Sets the attribute marker. + * + * Default value: + * {@value org.metafacture.framework.helpers.DefaultXmlPipe#DEFAULT_ATTRIBUTE_MARKER} + * + * @param attributeMarker the attribute marker + */ public void setAttributeMarker(final String attributeMarker) { this.attributeMarker = attributeMarker; } + /** + * Gets the attribute marker. + * + * @return the attribute marker + */ public String getAttributeMarker() { return attributeMarker; } diff --git a/metafacture-biblio/src/main/java/org/metafacture/biblio/pica/PicaDecoder.java b/metafacture-biblio/src/main/java/org/metafacture/biblio/pica/PicaDecoder.java index a94af6020..1b3c7cae2 100644 --- a/metafacture-biblio/src/main/java/org/metafacture/biblio/pica/PicaDecoder.java +++ b/metafacture-biblio/src/main/java/org/metafacture/biblio/pica/PicaDecoder.java @@ -108,14 +108,14 @@ * is removed). This can be changed by setting * {@link #setTrimFieldNames(boolean)} to false. *

    - * The record id emitted with the start-record event is extracted from + * The record ID emitted with the start-record event is extracted from * one of the following non-normalized pica+ fields: *

      *
    • 003@ $0 *
    • 107F $0 *
    • 203@ $0 (this field may have an optional occurrence marker) *
    - * The value of the first matching field is used as the record id. The $0 + * The value of the first matching field is used as the record ID. The $0 * subfield must be the first subfield in the field. If * {@link #setIgnoreMissingIdn(boolean)} is false and no matching field is not * found in the record a {@link MissingIdException} is thrown otherwise the @@ -168,10 +168,20 @@ public final class PicaDecoder extends DefaultObjectPipe private boolean ignoreMissingIdn; private boolean isNormalized; + /** + * Creates an instance of {@link PicaDecoder}. Sets the input to read as + * normalized pica+. + */ public PicaDecoder() { this(true); } + /** + * Creates an instance of {@link PicaDecoder}. Sets the input to read as + * normalized or non-normalized pica+. + * + * @param normalized true if input is read as normalized pica+, otherwiese false + */ public PicaDecoder(final boolean normalized) { setNormalizedSerialization(normalized); } @@ -197,7 +207,7 @@ public void setNormalizedSerialization(final boolean normalized) { } /** - * Controls whether records having no record id are reported as faulty. By + * Controls whether records having no record ID are reported as faulty. By * default such records are reported by the {@code PicaDecoder} by throwing * a {@link MissingIdException}. *

    @@ -206,7 +216,7 @@ public void setNormalizedSerialization(final boolean normalized) { *

    * Default value: {@code false} * - * @param ignoreMissingIdn if true, missing record ids do not trigger a + * @param ignoreMissingIdn if true, missing record IDs do not trigger a * {@link MissingIdException} but an empty string is * used as record identifier instead. */ @@ -214,12 +224,17 @@ public void setIgnoreMissingIdn(final boolean ignoreMissingIdn) { this.ignoreMissingIdn = ignoreMissingIdn; } + /** + * Gets the flag to decide whether records without a record ID are processed. + * + * @return true if the ID of a record can be absent, otherwise false + */ public boolean getIgnoreMissingIdn() { return ignoreMissingIdn; } /** - * Controls whether decomposed unicode characters in field values are + * Controls whether decomposed Unicode characters in field values are * normalised to their precomposed version. By default no normalisation is * applied. The normalisation is only applied to values not to field or * subfield names. @@ -229,13 +244,18 @@ public boolean getIgnoreMissingIdn() { *

    * Default value: {@code false} * - * @param normalizeUTF8 if true, decomposed unicode characters in values are + * @param normalizeUTF8 if true, decomposed Unicode characters in values are * normalised to their precomposed version. */ public void setNormalizeUTF8(final boolean normalizeUTF8) { parserContext.setNormalizeUTF8(normalizeUTF8); } + /** + * Gets the flag to decide whether the record is UTF-8 normalized. + * + * @return true if the record is UTF-8 normalized, otherwise false + */ public boolean getNormalizeUTF8() { return parserContext.getNormalizeUTF8(); } @@ -255,6 +275,11 @@ public void setSkipEmptyFields(final boolean skipEmptyFields) { parserContext.setSkipEmptyFields(skipEmptyFields); } + /** + * Gets the flag to decide whether to skip empty fields. + * + * @return true if empty fields are ignored, otherwise false + */ public boolean getSkipEmptyFields() { return parserContext.getSkipEmptyFields(); } @@ -274,6 +299,11 @@ public void setTrimFieldNames(final boolean trimFieldNames) { parserContext.setTrimFieldNames(trimFieldNames); } + /** + * Gets the flag to decide whether the field names are trimmed. + * + * @return true if the field names are trimmed, otherwise false + */ public boolean getTrimFieldNames() { return parserContext.getTrimFieldNames(); } diff --git a/metafacture-biblio/src/main/java/org/metafacture/biblio/pica/PicaEncoder.java b/metafacture-biblio/src/main/java/org/metafacture/biblio/pica/PicaEncoder.java index ffba87888..b1e069251 100644 --- a/metafacture-biblio/src/main/java/org/metafacture/biblio/pica/PicaEncoder.java +++ b/metafacture-biblio/src/main/java/org/metafacture/biblio/pica/PicaEncoder.java @@ -54,6 +54,8 @@ @FluxCommand("encode-pica") public final class PicaEncoder extends DefaultStreamPipe> { + public static final boolean IGNORE_RECORD_ID = false; + private static final String FIELD_DELIMITER = "\u001e"; private static final String SUB_DELIMITER = "\u001f"; private static final String FIELD_IDN_INTERN = "003@"; @@ -62,12 +64,15 @@ public final class PicaEncoder extends DefaultStreamPipe> private static StringBuilder builder = new StringBuilder(); //Result of the encoding process - private boolean entityOpen; //Flag to inform whether an entity is opened. - private boolean idnControlSubField; //Flag to inform whether it is the 003@ field. - private boolean ignoreRecordId; //Flag to decide whether the record Id is checked. + private boolean entityOpen; // Flag to inform whether an entity is opened. + private boolean idnControlSubField; // Flag to inform whether it is the 003@ field. + private boolean ignoreRecordId = IGNORE_RECORD_ID; // Flag to decide whether the record ID is checked. private String id; + /** + * Creates an instance of {@link PicaEncoder}. + */ public PicaEncoder() { } @@ -81,10 +86,23 @@ public void startRecord(final String recordId) { this.entityOpen = false; } + /** + * Sets the flag to decide whether the record ID is checked. + * + * Default value: {@value #IGNORE_RECORD_ID} + * + * @param ignoreRecordId true if the record ID should be ignored, otherwise + * false + */ public void setIgnoreRecordId(final boolean ignoreRecordId) { this.ignoreRecordId = ignoreRecordId; } + /** + * Gets the flag to decide whether the record ID is checked. + * + * @return true if the record ID is ignored, otherwise false + */ public boolean getIgnoreRecordId() { return this.ignoreRecordId; } @@ -118,11 +136,11 @@ public void literal(final String name, final String value) { } final String valueNew = Normalizer.normalize(value, Form.NFD); if (idnControlSubField) { - // it is a 003@ field, the same record id delivered with record should follow + // it is a 003@ field, the same record ID delivered with record should follow if (!this.id.equals(value)) { throw new MissingIdException(value); } - idnControlSubField = false; //only one record Id will be checked. + idnControlSubField = false; //only one record ID will be checked. } builder.append(SUB_DELIMITER); builder.append(name); diff --git a/metafacture-biblio/src/main/java/org/metafacture/biblio/pica/PicaMultiscriptRemodeler.java b/metafacture-biblio/src/main/java/org/metafacture/biblio/pica/PicaMultiscriptRemodeler.java index 5b8780c18..3551105f0 100644 --- a/metafacture-biblio/src/main/java/org/metafacture/biblio/pica/PicaMultiscriptRemodeler.java +++ b/metafacture-biblio/src/main/java/org/metafacture/biblio/pica/PicaMultiscriptRemodeler.java @@ -124,6 +124,9 @@ public final class PicaMultiscriptRemodeler extends DefaultStreamPipe bufferedFields = new TreeMap(); + /** + * Creates an instance of {@link PicaMultiscriptRemodeler}. + */ public PicaMultiscriptRemodeler() { } diff --git a/metafacture-biblio/src/main/java/org/metafacture/biblio/pica/PicaXmlHandler.java b/metafacture-biblio/src/main/java/org/metafacture/biblio/pica/PicaXmlHandler.java index f943250c3..4435aa4fa 100644 --- a/metafacture-biblio/src/main/java/org/metafacture/biblio/pica/PicaXmlHandler.java +++ b/metafacture-biblio/src/main/java/org/metafacture/biblio/pica/PicaXmlHandler.java @@ -50,6 +50,9 @@ public final class PicaXmlHandler extends DefaultXmlPipe { private String currentTag = ""; private StringBuilder builder = new StringBuilder(); + /** + * Creates an instance of {@link PicaXmlHandler}. + */ public PicaXmlHandler() { } diff --git a/metafacture-commons/src/main/java/org/metafacture/commons/ResourceUtil.java b/metafacture-commons/src/main/java/org/metafacture/commons/ResourceUtil.java index a6d0fca39..d803f0470 100644 --- a/metafacture-commons/src/main/java/org/metafacture/commons/ResourceUtil.java +++ b/metafacture-commons/src/main/java/org/metafacture/commons/ResourceUtil.java @@ -47,12 +47,12 @@ private ResourceUtil() { } /** - * First attempts to open open {@code name} as a file. On fail attempts to - * open resource with name {@code name}. On fail attempts to open {@code name} - * as a URL. + * First attempts to open a file with the provided name. On fail attempts to + * open a resource identified by the name. On fail attempts to open a URL + * identified by the name. * - * @param name name of the file or resource to open - * @return an input stream for reading the opened file or resource + * @param name name of the file, resource or the URL to open + * @return an input stream for reading the opened file, resource or URL * @throws FileNotFoundException if all attempts fail */ public static InputStream getStream(final String name) @@ -83,6 +83,13 @@ public static InputStream getStream(final String name) } + /** + * Gets an InputStream of a File. + * + * @param file the File. + * @return the InputStream + * @throws FileNotFoundException if the File couldn't be found + */ public static InputStream getStream(final File file) throws FileNotFoundException { return new FileInputStream(file); @@ -98,20 +105,53 @@ private static void throwFileNotFoundException(final String name, throw e; } + /** + * Gets a Reader. First attempts to open a file. On fail attempts to open the + * resource with name. On fail attempts to open name as a URL. + * + * @param name the name of the resource + * @return the Reader + * @throws FileNotFoundException if the File couldn't be found + */ public static Reader getReader(final String name) throws FileNotFoundException { return new InputStreamReader(getStream(name)); } + /** + * Gets a Reader from a File. + * + * @param file the File + * @return the Reader + * @throws FileNotFoundException if the File couldn't be found + */ public static Reader getReader(final File file) throws FileNotFoundException { return new InputStreamReader(getStream(file)); } + /** + * Gets a Reader. First attempts to open a file. On fail attempts to open the + * resource with name. On fail attempts to open name as a URL. Uses the given + * {@link java.nio.charset.Charset charset} as encoding. + * + * @param name the name of the resource + * @param encoding the Charset + * @return the Reader + * @throws IOException if an I/O error occurs + */ public static Reader getReader(final String name, final String encoding) throws IOException { return new InputStreamReader(getStream(name), encoding); } + /** + * Gets a Reader from a File using {@link java.nio.charset.Charset charset}. + * + * @param file the File + * @param encoding the Charset + * @return the Reader + * @throws IOException if an I/O error occurs + */ public static Reader getReader(final File file, final String encoding) throws IOException { return new InputStreamReader(getStream(file), encoding); @@ -139,15 +179,38 @@ public static URL getUrl(final String name) throws MalformedURLException { return resourceUrl != null ? resourceUrl : new URL(name); } + /** + * Gets an URL of a File. + * + * @param file the File + * @return the URL + * @throws MalformedURLException if malformed URL has occurred + */ public static URL getUrl(final File file) throws MalformedURLException { return file.toURI().toURL(); } + /** + * Creates Properties based upon a location. First attempts to open a file. On + * fail attempts to open the resource with name. On fail attempts to open name + * as a URL. + * + * @param location the location of the resource + * @return the Properties + * @throws IOException if an I/O error occurs + */ public static Properties loadProperties(final String location) throws IOException { return loadProperties(getStream(location)); } + /** + * Loads properties from an InputStream. + * + * @param stream properties as InputStream + * @return the Properties + * @throws IOException if an I/O error occurs + */ public static Properties loadProperties(final InputStream stream) throws IOException { final Properties properties; @@ -156,10 +219,24 @@ public static Properties loadProperties(final InputStream stream) return properties; } + /** + * Loads properties from a URL. + * + * @param url properties as URL + * @return the Properties + * @throws IOException if an I/O error occurs + */ public static Properties loadProperties(final URL url) throws IOException { return loadProperties(url.openStream()); } + /** + * Loads a text file. + * + * @param location the filename + * @return the content of the file + * @throws IOException if an I/O error occurs + */ public static String loadTextFile(final String location) throws IOException { final StringBuilder builder = new StringBuilder(); final BufferedReader reader = new BufferedReader(getReader(location)); @@ -173,6 +250,14 @@ public static String loadTextFile(final String location) throws IOException { return builder.toString(); } + /** + * * Loads a text file. + * + * @param location the filename + * @param list a List of Strings to append the lines of the file to + * @return the List of Strings with the lines of the file appended + * @throws IOException if an I/O error occurs + */ public static List loadTextFile(final String location, final List list) throws IOException { final BufferedReader reader = new BufferedReader(getReader(location)); @@ -186,6 +271,14 @@ public static List loadTextFile(final String location, return list; } + /** + * Reads an InputStream with the given Charset. + * + * @param inputStream the InputStream + * @param encoding the Charset + * @return a String of the content of the InputStream + * @throws IOException if an I/O error occurs + */ public static String readAll(final InputStream inputStream, final Charset encoding) throws IOException { try (Reader reader = new InputStreamReader(inputStream, encoding)) { @@ -193,6 +286,13 @@ public static String readAll(final InputStream inputStream, final Charset encodi } } + /** + * Reads a Reader. + * + * @param reader the Reader + * @return a String of the content of the Reader + * @throws IOException if an I/O error occurs + */ public static String readAll(final Reader reader) throws IOException { final StringBuilder loadedText = new StringBuilder(); try (Reader bufferedReader = new BufferedReader(reader)) { diff --git a/metafacture-commons/src/main/java/org/metafacture/commons/StringUtil.java b/metafacture-commons/src/main/java/org/metafacture/commons/StringUtil.java index 2d703bc10..ce9c7f89c 100644 --- a/metafacture-commons/src/main/java/org/metafacture/commons/StringUtil.java +++ b/metafacture-commons/src/main/java/org/metafacture/commons/StringUtil.java @@ -27,13 +27,21 @@ */ public final class StringUtil { - private static final String DEFAULT_VARSTART = "${"; - private static final String DEFAULT_VAREND = "}"; + public static final String DEFAULT_VARSTART = "${"; + public static final String DEFAULT_VAREND = "}"; private StringUtil() { // no instances allowed } + /** + * Returns a fallback of an object if the object is null. + * + * @param the type of the object + * @param value the object + * @param fallbackValue the default object + * @return an object + */ public static O fallback(final O value, final O fallbackValue) { if (value == null) { return fallbackValue; @@ -41,20 +49,64 @@ public static O fallback(final O value, final O fallbackValue) { return value; } + /** + * Formats a String. If a String has a variable it will be replaced based on a + * Map. The start and the end of indicating this variable must be defined. + * {@value #DEFAULT_VARSTART} indicates the start of a variable and + * {@value #DEFAULT_VAREND} the end of the variable . Unassigned variables are + * ignored. + * + * @param format the String to be formatted + * @param variables a Map of variable names and their values + * @return the formatted String + */ public static String format(final String format, final Map variables) { return format(format, DEFAULT_VARSTART, DEFAULT_VAREND, true, variables); } + /** + * Formats a String. If a String has a variable it will be replaced based on a + * Map. The start and the end of indicating this variable must be defined. + * Unassigned variables are ignored. + * + * @param format the String to be formatted + * @param varStartIndicator a String indicating the start of a variable + * @param varEndIndicator a String indicating the end of a variable + * @param variables a Map of variable names and their values + * @return the formatted String + */ public static String format(final String format, final String varStartIndicator, final String varEndIndicator, final Map variables) { return format(format, varStartIndicator, varEndIndicator, true, variables); } + /** + * Formats a String. If a String has a variable it will be replaced based on a + * Map. The start and the end of indicating this variable must be defined. + * {@value #DEFAULT_VARSTART} indicates the start of a variable and + * {@value #DEFAULT_VAREND} the end of the variable . + * + * @param format the String to be formatted + * @param ignoreMissingVars boolean if an unassigned variable should be ignored + * @param variables a Map of variable names and their values + * @return the formatted String + */ public static String format(final String format, final boolean ignoreMissingVars, final Map variables) { return format(format, DEFAULT_VARSTART, DEFAULT_VAREND, ignoreMissingVars, variables); } + /** + * Formats a String. If a String has a variable it will be replaced based on a + * Map. The start and the end of indicating this variable must be defined. + * + * @param format the String to be formatted + * @param varStartIndicator a String indicating the start of a variable + * @param varEndIndicator a String indicating the end of a variable + * @param ignoreMissingVars boolean if an unassigned variable should be ignored + * @param variables a Map of variable names and their values + * @return the formatted String + */ public static String format(final String format, final String varStartIndicator, final String varEndIndicator, final boolean ignoreMissingVars, final Map variables) { if (format.indexOf(varStartIndicator) < 0) { // shortcut if there is diff --git a/metafacture-commons/src/main/java/org/metafacture/commons/TimeUtil.java b/metafacture-commons/src/main/java/org/metafacture/commons/TimeUtil.java index df04cfd55..55b274543 100644 --- a/metafacture-commons/src/main/java/org/metafacture/commons/TimeUtil.java +++ b/metafacture-commons/src/main/java/org/metafacture/commons/TimeUtil.java @@ -39,6 +39,12 @@ private TimeUtil() { // No instances allowed } + /** + * Formats a duration to human readable abbrevations. + * + * @param duration a long value of the duration + * @return a human readable format of the duration + */ public static String formatDuration(final long duration) { long major = duration; long minor = 0; diff --git a/metafacture-commons/src/main/java/org/metafacture/commons/XmlUtil.java b/metafacture-commons/src/main/java/org/metafacture/commons/XmlUtil.java index daa6f9ba2..c56d41757 100644 --- a/metafacture-commons/src/main/java/org/metafacture/commons/XmlUtil.java +++ b/metafacture-commons/src/main/java/org/metafacture/commons/XmlUtil.java @@ -45,10 +45,23 @@ private XmlUtil() { // No instances allowed } + /** + * Converts a Node to a String. + * + * @param node the Node + * @return the String represantation of the Node + */ public static String nodeToString(final Node node) { return nodeToString(node, false); } + /** + * Converts a Node to a String, with or without an XML declaration + * + * @param node the Node + * @param omitXMLDecl boolean if an XML declaration is omitted or not + * @return a String representation of the Node + */ public static String nodeToString(final Node node, final boolean omitXMLDecl) { final StringWriter writer = new StringWriter(); @@ -79,6 +92,12 @@ public static String nodeToString(final Node node, return writer.toString(); } + /** + * Converts a NodeList to a String. + * + * @param nodes the NodeList + * @return a String representation of the NodeList + */ public static String nodeListToString(final NodeList nodes) { final StringBuilder builder = new StringBuilder(); @@ -89,6 +108,12 @@ public static String nodeListToString(final NodeList nodes) { return builder.toString(); } + /** + * Checks if a String is an XML MIME type. + * + * @param mimeType the MIME type + * @return boolean if a String is an XML MIME type + */ public static boolean isXmlMimeType(final String mimeType) { if (mimeType == null) { return false; @@ -98,10 +123,24 @@ public static boolean isXmlMimeType(final String mimeType) { mimeType.endsWith(XML_BASE_MIME_TYPE); } + /** + * Escapes an unescaped String. + * + * @param unescaped the unescaped String + * @return the escaped String + */ public static String escape(final String unescaped) { return escape(unescaped, true); } + /** + * Escapes XML special characters. May also escape non-ASCII characters (aka + * Unicode). + * + * @param unescaped the String to be unescaped + * @param escapeUnicode boolean if Unicode should be also escaped + * @return the escaped String + */ public static String escape(final String unescaped, final boolean escapeUnicode) { return unescaped.codePoints() .mapToObj(value -> escapeCodePoint(value, escapeUnicode)) diff --git a/metafacture-commons/src/main/java/org/metafacture/commons/reflection/ConfigurableClass.java b/metafacture-commons/src/main/java/org/metafacture/commons/reflection/ConfigurableClass.java index 2fdb4d59d..c3d8f7121 100644 --- a/metafacture-commons/src/main/java/org/metafacture/commons/reflection/ConfigurableClass.java +++ b/metafacture-commons/src/main/java/org/metafacture/commons/reflection/ConfigurableClass.java @@ -46,14 +46,30 @@ public final class ConfigurableClass { private Map settersCache; + /** + * + * Creates an instance of {@link ConfigurableClass} defined by a Class. + * + * @param plainClass the plain class of object type T + */ public ConfigurableClass(final Class plainClass) { this.plainClass = plainClass; } + /** + * Gets the plain class of the ConfigurableClass. + * + * @return the Class + */ public Class getPlainClass() { return plainClass; } + /** + * Gets all public "set" methods of this class. + * + * @return the Map of the setter methods of this class + */ public Map getSetters() { if (settersCache == null) { initSettersCache(); @@ -82,6 +98,11 @@ private boolean isSetter(final Method method) { return false; } + /** + * Gets the parameter types of the setter methods. + * + * @return a Map of the setter method names and their types + */ public Map> getSetterTypes() { final Map> setterTypes = new HashMap<>(); for (final Map.Entry method : getSetters().entrySet()) { @@ -91,10 +112,23 @@ public Map> getSetterTypes() { return setterTypes; } + /** + * Creates an empty instance of the class. + * + * @return a new instance + */ public T newInstance() { return newInstance(Collections.emptyMap()); } + /** + * Creates an instance of the class using the first constructor that matches the + * varargs argument of the methods. + * + * @param setterValues the Map of setter values + * @param constructorArgs the Object of args of the constructor + * @return the new instance + */ public T newInstance(final Map setterValues, final Object... constructorArgs) { try { final Constructor constructor = findConstructor(constructorArgs); diff --git a/metafacture-commons/src/main/java/org/metafacture/commons/reflection/ObjectFactory.java b/metafacture-commons/src/main/java/org/metafacture/commons/reflection/ObjectFactory.java index 239d963ec..57e84f391 100644 --- a/metafacture-commons/src/main/java/org/metafacture/commons/reflection/ObjectFactory.java +++ b/metafacture-commons/src/main/java/org/metafacture/commons/reflection/ObjectFactory.java @@ -37,9 +37,18 @@ public class ObjectFactory { private final Map> classes = new HashMap<>(); + /** + * Creates an instance of {@link ObjectFactory}. + */ public ObjectFactory() { } + /** + * Loads classes from a map. + * + * @param classMap the map of classes + * @param baseType the object type of the classes + */ public final void loadClassesFromMap(final Map classMap, final Class baseType) { final ClassLoader loader = ReflectionUtil.getContextClassLoader(); for (final Entry entry : classMap.entrySet()) { @@ -49,18 +58,45 @@ public final void loadClassesFromMap(final Map classMap, final Class ba } } + /** + * Registers a Class as a ConfigurableClass. + * + * @param key the key associcated with the Class + * @param objectClass the Class + */ public final void registerClass(final String key, final Class objectClass) { registerClass(key, new ConfigurableClass<>(objectClass)); } + /** + * Registers a ConfigurableClass. + * + * @param key the key associcated with the ConfigurableClass + * @param objectClass the ConfigurableClass + */ public final void registerClass(final String key, final ConfigurableClass objectClass) { classes.put(key, objectClass); } + /** + * Returns a new instance of a ConfigurableClass with no setters. + * + * @param key the name of the class + * @param constructorArgs the args of the constructor + * @return a new instance + */ public final T newInstance(final String key, final Object... constructorArgs) { return newInstance(key, Collections.emptyMap(), constructorArgs); } + /** + * Returns a new instance of a ConfigurableClass. + * + * @param key the name of the class + * @param values the Map of Strings of the setters + * @param constructorArgs the args of the constructor + * @return a new instance + */ public final T newInstance(final String key, final Map values, final Object... constructorArgs) { if (!classes.containsKey(key)) { throw new NoSuchElementException("no registered class for: " + key); @@ -69,14 +105,31 @@ public final T newInstance(final String key, final Map values, f return instanceClass.newInstance(values, constructorArgs); } + /** + * Checks wether a ConfigurableClass is asscociated with a key. + * + * @param key the key + * @return true if the key is associcated with a ConfigurableClass + */ public final boolean containsKey(final String key) { return classes.containsKey(key); } + /** + * Gets the key set of all {ConfigurableClass}es. + * + * @return all keys that identify the {ConfigurableClass}es + */ public final Set keySet() { return Collections.unmodifiableSet(classes.keySet()); } + /** + * Gets a ConfigurableClass. + * + * @param key the key that identifies the ConfigurableClass + * @return the ConfigurableClass + */ public final ConfigurableClass get(final String key) { return classes.get(key); } diff --git a/metafacture-commons/src/main/java/org/metafacture/commons/reflection/ReflectionUtil.java b/metafacture-commons/src/main/java/org/metafacture/commons/reflection/ReflectionUtil.java index e381ea0b4..0b09336c5 100644 --- a/metafacture-commons/src/main/java/org/metafacture/commons/reflection/ReflectionUtil.java +++ b/metafacture-commons/src/main/java/org/metafacture/commons/reflection/ReflectionUtil.java @@ -28,6 +28,10 @@ private ReflectionUtil() { throw new AssertionError("No instances allowed"); } + /** + * @return the context ClassLoader for this thread, or null indicating the + * system class loader (or, failing that, the bootstrap class loader) + */ public static ClassLoader getContextClassLoader() { final ClassLoader loader = Thread.currentThread().getContextClassLoader(); if (loader == null) { @@ -36,10 +40,27 @@ public static ClassLoader getContextClassLoader() { return loader; } + /** + * Loads a Class. + * + * @param the object type + * @param className the name of the class + * @param baseType the object type of the class to be wrapped + * @return the ConfigurableClass + */ public static ConfigurableClass loadClass(final String className, final Class baseType) { return loadClass(getContextClassLoader(), className, baseType); } + /** + * Wraps a Class in a ConfigurableClass. + * + * @param the object type of the ConfigurableClass + * @param loader the ClassLoader + * @param className the name of the class + * @param baseType the object type of the class to be wrapped + * @return the ConfigurableClass + */ public static ConfigurableClass loadClass(final ClassLoader loader, final String className, final Class baseType) { final Class clazz; try { diff --git a/metafacture-commons/src/main/java/org/metafacture/commons/tries/SetMatcher.java b/metafacture-commons/src/main/java/org/metafacture/commons/tries/SetMatcher.java index eaa706977..e77e16ff9 100644 --- a/metafacture-commons/src/main/java/org/metafacture/commons/tries/SetMatcher.java +++ b/metafacture-commons/src/main/java/org/metafacture/commons/tries/SetMatcher.java @@ -33,9 +33,18 @@ public final class SetMatcher { private final ACNode root = new ACNode<>(null, 0); private boolean isPrepared; + /** + * Creates an instance of {@link SetMatcher}. + */ public SetMatcher() { } + /** + * Adds a value for a key. + * + * @param key the key + * @param value the value + */ public void put(final String key, final T value) { if (isPrepared) { throw new IllegalStateException("keys cannot be added during matching."); @@ -63,6 +72,12 @@ else if (next.getValue() == null) { } } + /** + * Gets the List of Matches of a text. + * + * @param text the text + * @return List of Matches + */ public List> match(final String text) { if (!isPrepared) { prepare(); @@ -135,10 +150,10 @@ private void prepare() { } /** - * Prints dot description of the automaton to out for visualization in - * GraphViz. Used for debugging and education. + * Prints dot description of the automaton to the PrintStream for + * visualization in GraphViz. Used for debugging and education. * - * @param out the stream t which the description is written + * @param out the stream to which the description is written */ public void printAutomaton(final PrintStream out) { out.println("digraph ahocorasick {"); @@ -173,20 +188,42 @@ public static final class Match { private final int start; private final int length; + /** + * Constructs a Match. + * + * @param value the value + * @param start the position + * @param length the length + */ public Match(final T value, final int start, final int length) { this.value = value; this.start = start; this.length = length; } + /** + * Gets the value. + * + * @return the value + */ public T getValue() { return value; } + /** + * Gets the start position. + * + * @return the start position + */ public int getStart() { return start; } + /** + * Gets the length. + * + * @return the length + */ public int getLength() { return length; } diff --git a/metafacture-commons/src/main/java/org/metafacture/commons/tries/SetReplacer.java b/metafacture-commons/src/main/java/org/metafacture/commons/tries/SetReplacer.java index fbb2eae38..17530c3f4 100644 --- a/metafacture-commons/src/main/java/org/metafacture/commons/tries/SetReplacer.java +++ b/metafacture-commons/src/main/java/org/metafacture/commons/tries/SetReplacer.java @@ -25,29 +25,50 @@ import java.util.Map; /** - * @author Markus Michael Geipel + * Replaces Strings by other Strings. * + * @author Markus Michael Geipel */ public final class SetReplacer { private final SetMatcher matcher = new SetMatcher(); + /** + * Creates an instance of {@link SetReplacer}. + */ public SetReplacer() { } - public void addReplacement(final String key, final String with) { - matcher.put(key, with); + /** + * Adds a replacement of a String by another String. + * + * @param toReplace String to replace + * @param replacement String of replacement + */ + public void addReplacement(final String toReplace, final String replacement) { + matcher.put(toReplace, replacement); } + /** + * Adds replacements given as a Map of Strings. + * + * @param replacements the Map of Strings to be replaced + */ public void addReplacements(final Map replacements) { for (final Entry entry : replacements.entrySet()) { addReplacement(entry.getKey(), entry.getValue()); } } + /** + * Replaces the Strings defined with {@link #addReplacement(String, String)} in + * the text. + * + * @param text the text + * @return the text with the replacements + */ public String replaceIn(final String text) { final List> matches = matcher.match(text); final StringBuilder builder = new StringBuilder(); - int lastCut = 0; Collections.sort(matches, new Comparator>() { @@ -56,25 +77,17 @@ public int compare(final Match o1, final Match o2) { final int delta = o1.getStart() - o2.getStart(); return delta < 0 ? -1 : delta > 0 ? 1 : o1.getLength() > o2.getLength() ? -1 : 1; } - }); for (final SetMatcher.Match match : matches) { - if (match.getStart() < lastCut) { continue; } - - // System.out.println(match.getStart() + " "+ match.getValue() +" "+ - // match.getLength()); - builder.append(text.substring(lastCut, match.getStart())); builder.append(match.getValue()); - lastCut = match.getStart() + match.getLength(); } builder.append(text.substring(lastCut, text.length())); - return builder.toString(); } diff --git a/metafacture-commons/src/main/java/org/metafacture/commons/tries/SimpleRegexTrie.java b/metafacture-commons/src/main/java/org/metafacture/commons/tries/SimpleRegexTrie.java index c871f6d11..8514c3f9b 100644 --- a/metafacture-commons/src/main/java/org/metafacture/commons/tries/SimpleRegexTrie.java +++ b/metafacture-commons/src/main/java/org/metafacture/commons/tries/SimpleRegexTrie.java @@ -33,10 +33,12 @@ public class SimpleRegexTrie

    { // matches: `lit-[A]`, `lit-[AB]`, does not match: `a[].1`, `a[].1.b[].1` public static final String SIMPLE_CHARACTER_CLASS = ".*\\[[^\\[\\]]+\\].*"; - private final WildcardTrie

    trie; + private final WildcardTrie

    trie = new WildcardTrie

    (); + /** + * Creates an instance of {@link SimpleRegexTrie}. + */ public SimpleRegexTrie() { - trie = new WildcardTrie

    (); } /** @@ -62,6 +64,13 @@ public void put(final String keys, final P value) { } } + /** + * Gets the List of values identified by a key. + * + * @see WildcardTrie + * @param key the key + * @return the List of the key if the key exists, otherwise an empty List + */ public List

    get(final String key) { return trie.get(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 40f0f422f..9494b11ed 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 @@ -25,11 +25,19 @@ public final class SimpleTrie

    { private final Node

    root = new Node<>(null); + /** + * Creates an instance of {@link SimpleTrie}. + */ public SimpleTrie() { } + /** + * Adds a value for the key. + * + * @param key the name of the key + * @param value the value + */ public void put(final String key, final P value) { - Node

    node = root; Node

    next; final int length = key.length(); @@ -49,6 +57,12 @@ public void put(final String key, final P value) { } } + /** + * Gets the value of a key. + * + * @param key the name of the key + * @return the value + */ public P get(final String key) { Node

    node = root; final int length = key.length(); 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 1bada6d34..7efb6edac 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 @@ -32,6 +32,7 @@ * @author Pascal Christoph */ public final class WildcardTrie

    { + public static final char STAR_WILDCARD = '*'; public static final char Q_WILDCARD = '?'; public static final String OR_STRING = "|"; @@ -42,15 +43,18 @@ public final class WildcardTrie

    { private Set> nodes = new HashSet>(); private Set> nextNodes = new HashSet>(); + /** + * Creates an instance of {@link WildcardTrie}. + */ public WildcardTrie() { } /** - * Inserts keys into the try. Use '|' to concatenate. Use '*' (0,inf) and - * '?' (1,1) to express wildcards. + * Inserts keys into the trie. Use '|' to concatenate. Use '*' (0,inf) and '?' + * (1,1) to express wildcards. * - * @param keys pattern of keys to register - * @param value value to associate with the key pattern. + * @param keys pattern of keys to register + * @param value value to associate with the key pattern */ public void put(final String keys, final P value) { if (keys.contains(OR_STRING)) { @@ -65,7 +69,6 @@ public void put(final String keys, final P value) { } private void simplyPut(final String key, final P value) { - final int length = key.length(); Node

    node = root; @@ -80,6 +83,12 @@ private void simplyPut(final String key, final P value) { node.addValue(value); } + /** + * Gets the List of values identified by a key. + * + * @param key the key + * @return the List of + */ public List

    get(final String key) { nodes.add(root); final int length = key.length(); @@ -168,4 +177,5 @@ public Node getNext(final char key) { return links.get(key); } } + } 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 2b0ec6859..9f464980f 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 @@ -29,20 +29,26 @@ * * @author Markus Michael Geipel * - * @param - * key - * @param - * value + * @param key + * @param value */ public class ListMap implements Map> { private String identifier; private final Map> map; + /** + * Creates an empty instance of an empty ListMap. + */ public ListMap() { map = new HashMap>(); } + /** + * Creates an instance of a ListMap with the given Map. + * + * @param map the Map + */ public ListMap(final Map> map) { this.map = map; } @@ -57,10 +63,21 @@ public final void clear() { identifier = null; } + /** + * Removes a key from the map. + * + * @param key the key + * @return the List of values or null if the map didn't contain the key + */ public final List removeKey(final K key) { return map.remove(key); } + /** + * Clears all values of a key in the map. + * + * @param key the key of the map + */ public final void clearKey(final K key) { final List values = map.get(key); if (values != null) { @@ -68,6 +85,9 @@ public final void clearKey(final K key) { } } + /** + * Clears all values of all keys in the map. + */ public final void clearAllKeys() { for (final Entry> entry: map.entrySet()) { entry.getValue().clear(); @@ -84,14 +104,18 @@ public final Set keySet() { return map.keySet(); } + /** + * Adds a value to the List of values of the key in the map. + * + * @param name the key + * @param value the value + */ public final void add(final K name, final V value) { - List values = map.get(name); if (values == null) { values = new ArrayList(); map.put(name, values); } - values.add(value); } @@ -104,10 +128,22 @@ public final List get(final Object name) { return values; } + /** + * Checks is a key exists in ListMap. + * + * @param name the name of the key + * @return true if the key exists, otherwise false + */ public final boolean existsKey(final K name) { return getFirst(name) != null; } + /** + * Gets the first element of the List of values of the key in the map or null. + * + * @param name the key + * @return first element of the values of the key or null + */ public final V getFirst(final K name) { final List values = map.get(name); if (values == null || values.isEmpty()) { @@ -121,10 +157,20 @@ public final String toString() { return map.toString(); } + /** + * Sets the ID of the ListMap. + * + * @param newIdentifier the ID of the ListMap + */ public final void setId(final String newIdentifier) { identifier = newIdentifier; } + /** + * Gets the ID of the ListMap. + * + * @return the ID of the ListMap + */ public final String getId() { return identifier; } @@ -159,7 +205,12 @@ public final List remove(final Object key) { return map.remove(key); } - //@Override + /** + * Adds a List of values to a key in the map. + * + * @param name the key + * @param addValues the List of values + */ public final void putAll(final K name, final Collection addValues) { List values = map.get(name); if (values == null) { @@ -179,4 +230,5 @@ public final void putAll(final Map> putMap) { public final Collection> values() { return map.values(); } + } diff --git a/metafacture-commons/src/main/java/org/metafacture/commons/types/NamedValue.java b/metafacture-commons/src/main/java/org/metafacture/commons/types/NamedValue.java index f1c310945..f308e85c0 100644 --- a/metafacture-commons/src/main/java/org/metafacture/commons/types/NamedValue.java +++ b/metafacture-commons/src/main/java/org/metafacture/commons/types/NamedValue.java @@ -17,7 +17,7 @@ package org.metafacture.commons.types; /** - * Stores an immutable name-value-pair. The hash code is + * Stores an immutable name-value pair. The hash code is * precomputed during instantiation. * * @author Markus Michael Geipel @@ -30,6 +30,12 @@ public final class NamedValue implements Comparable { private final String value; private final int preCompHashCode; + /** + * Constructs an immutable name-value pair by computing a hash code. + * + * @param name the name of the pair + * @param value the value of the pair + */ public NamedValue(final String name, final String value) { this.name = name; this.value = value; diff --git a/metafacture-commons/src/main/java/org/metafacture/commons/types/ScopedHashMap.java b/metafacture-commons/src/main/java/org/metafacture/commons/types/ScopedHashMap.java index a7031c65e..d22d2c603 100644 --- a/metafacture-commons/src/main/java/org/metafacture/commons/types/ScopedHashMap.java +++ b/metafacture-commons/src/main/java/org/metafacture/commons/types/ScopedHashMap.java @@ -32,10 +32,18 @@ public final class ScopedHashMap extends HashMap { // checkstyle-dis private static final long serialVersionUID = -7184066609960144713L; private final ScopedHashMap outerScope; + /** + * Creates an instance of {@link ScopedHashMap} and sets the outer scope. + * + * @param outerScope outer scope + */ public ScopedHashMap(final ScopedHashMap outerScope) { this.outerScope = outerScope; } + /** + * Creates an empty instance of {@link ScopedHashMap}. + */ public ScopedHashMap() { outerScope = null; } @@ -65,6 +73,11 @@ public V get(final Object key) { return ret; } + /** + * Gets the outer scope. + * + * @return the outer scope + */ public ScopedHashMap getOuterScope() { return outerScope; } diff --git a/metafacture-csv/src/main/java/org/metafacture/csv/CsvDecoder.java b/metafacture-csv/src/main/java/org/metafacture/csv/CsvDecoder.java index 39de4d4f9..06bd6a690 100644 --- a/metafacture-csv/src/main/java/org/metafacture/csv/CsvDecoder.java +++ b/metafacture-csv/src/main/java/org/metafacture/csv/CsvDecoder.java @@ -30,26 +30,28 @@ import java.util.List; /** - * Decodes lines of CSV files. First line is interpreted as header. + * Decodes lines of CSV files. First line may be interpreted as header. * * @author Markus Michael Geipel * @author Fabian Steeg (fsteeg) * */ -@Description("Decodes lines of CSV files. First line is interpreted as header.") +@Description("Decodes lines of CSV files. First line may be interpreted as header.") @In(String.class) @Out(StreamReceiver.class) @FluxCommand("decode-csv") public final class CsvDecoder extends DefaultObjectPipe { - private static final char DEFAULT_SEP = ','; - private char separator; + public static final char DEFAULT_SEP = ','; + private char separator = DEFAULT_SEP; private String[] header = new String[0]; private int count; private boolean hasHeader; /** + * Creates an instance of {@link CsvDecoder} with a given separator. + * * @param separator to split lines */ public CsvDecoder(final String separator) { @@ -57,14 +59,19 @@ public CsvDecoder(final String separator) { } /** + * Creates an instance of {@link CsvDecoder} with a given separator. + * * @param separator to split lines */ public CsvDecoder(final char separator) { this.separator = separator; } + /** + * Creates an instance of {@link CsvDecoder}. The default separator is + * {@value #DEFAULT_SEP}. + */ public CsvDecoder() { - this.separator = DEFAULT_SEP; } @Override @@ -115,10 +122,21 @@ private String[] parseCsv(final String string) { return parts; } + /** + * Flags if the CSV has a header or comes without a header. + * + * @param hasHeader true if the CSV has a header, otherwise false + */ public void setHasHeader(final boolean hasHeader) { this.hasHeader = hasHeader; } + /** + * Sets the separator. + * + * @param separator the separator as a String. The first character is used as + * the separator. + */ public void setSeparator(final String separator) { this.separator = separator.charAt(0); } diff --git a/metafacture-elasticsearch/src/main/java/org/metafacture/elasticsearch/JsonToElasticsearchBulk.java b/metafacture-elasticsearch/src/main/java/org/metafacture/elasticsearch/JsonToElasticsearchBulk.java index 804e762eb..3dca1f339 100644 --- a/metafacture-elasticsearch/src/main/java/org/metafacture/elasticsearch/JsonToElasticsearchBulk.java +++ b/metafacture-elasticsearch/src/main/java/org/metafacture/elasticsearch/JsonToElasticsearchBulk.java @@ -46,20 +46,21 @@ public class JsonToElasticsearchBulk extends DefaultObjectPipe> { private ObjectMapper mapper = new ObjectMapper(); - private String[] idPath; + private String[] idPath = new String[] {}; private String type; private String index; + /** + * Creates an instance of {@link JsonToElasticsearchBulk}. + */ public JsonToElasticsearchBulk() { - this.idPath = new String[]{}; - this.type = null; - this.index = null; } /** - * As an id is not required it can be omitted. + * Creates an instance of {@link JsonToElasticsearchBulk}. As an id is not + * required it can be omitted. * - * @param type The Elasticsearch index type + * @param type The Elasticsearch index type * @param index The Elasticsearch index name */ public JsonToElasticsearchBulk(final String type, final String index) { @@ -67,9 +68,12 @@ public JsonToElasticsearchBulk(final String type, final String index) { } /** - * @param idPath The key path of the JSON value to be used as the ID for the record - * @param type The Elasticsearch index type - * @param index The Elasticsearch index name + * Creates an instance of {@link JsonToElasticsearchBulk}. + * + * @param idPath the key path of the JSON value to be used as the ID for the + * record + * @param type the Elasticsearch index type + * @param index the Elasticsearch index name */ public JsonToElasticsearchBulk(final String[] idPath, final String type, final String index) { this.idPath = idPath; @@ -78,32 +82,53 @@ public JsonToElasticsearchBulk(final String[] idPath, final String type, final S } /** - * @param idKey The key of the JSON value to be used as the ID for the record - * @param type The Elasticsearch index type - * @param index The Elasticsearch index name + * Creates an instance of {@link JsonToElasticsearchBulk}. + * + * @param idKey the key of the JSON value to be used as the ID for the record + * @param type the Elasticsearch index type + * @param index the Elasticsearch index name */ public JsonToElasticsearchBulk(final String idKey, final String type, final String index) { this(new String[]{idKey}, type, index); } /** - * @param idKey The key of the JSON value to be used as the ID for the record - * @param type The Elasticsearch index type - * @param index The Elasticsearch index name - * @param entitySeparator The separator between entity names in idKey + * + * Creates an instance of {@link JsonToElasticsearchBulk}. + * + * @param idKey the key of the JSON value to be used as the ID for the + * record + * @param type the Elasticsearch index type + * @param index the Elasticsearch index name + * @param entitySeparator the separator between entity names in idKey */ public JsonToElasticsearchBulk(final String idKey, final String type, final String index, final String entitySeparator) { this(idKey.split(Pattern.quote(entitySeparator)), type, index); } + /** + * Sets the key path of the JSON value to be used as the ID for the record. + * + * @param idKey the key path of the JSON value + */ public void setIdKey(final String idKey) { this.idPath = new String[]{idKey}; } + /** + * Sets the name of the type of the index. + * + * @param type the name of the type of the index. + */ public void setType(final String type) { this.type = type; } + /** + * Sets the name of the index. + * + * @param index the name of the index + */ public void setIndex(final String index) { this.index = index; } diff --git a/metafacture-files/src/main/java/org/metafacture/files/DirReader.java b/metafacture-files/src/main/java/org/metafacture/files/DirReader.java index 952e0cd9b..068b6bd41 100644 --- a/metafacture-files/src/main/java/org/metafacture/files/DirReader.java +++ b/metafacture-files/src/main/java/org/metafacture/files/DirReader.java @@ -43,13 +43,27 @@ public final class DirReader extends DefaultObjectPipe private final int numCloses; private int count; + /** + * Creates an instance of {@link CloseSuppressor} with a number defining the + * number of events to block before closing the stream. + * + * @param numCloses the number of events to block before closing the stream. The + * String is parsed to an integer. + */ public CloseSuppressor(final String numCloses) { this(Integer.parseInt(numCloses)); } + /** + * Creates an instance of {@link CloseSuppressor} with a number defining the + * number of events to block before closing the stream. + * + * @param numCloses the number of events to block before closing the stream + */ public CloseSuppressor(final int numCloses) { this.numCloses = numCloses; } diff --git a/metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/ObjectBatchResetter.java b/metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/ObjectBatchResetter.java index 70137a785..8a5efdd78 100644 --- a/metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/ObjectBatchResetter.java +++ b/metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/ObjectBatchResetter.java @@ -42,16 +42,19 @@ public class ObjectBatchResetter extends DefaultObjectPipereset-stream event is triggered. *

    - * The default value is {@value DEFAULT_BATCH_SIZE}. + * The default value is {@value #DEFAULT_BATCH_SIZE}. *

    - * This parameter can be changed anytime during processing. If the new value - * is less than the number of received objects a reset-stream event is + * This parameter can be changed anytime during processing. If the new value is + * less than the number of received objects a reset-stream event is * emitted when the next object is received. * * @param batchSize number of objects before a reset-stream event is @@ -61,6 +64,11 @@ public void setBatchSize(final int batchSize) { this.batchSize = batchSize; } + /** + * Gets the size of the batch. + * + * @return the size of the batch + */ public int getBatchSize() { return batchSize; } diff --git a/metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/ObjectExceptionCatcher.java b/metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/ObjectExceptionCatcher.java index 3b440b445..9bf50f748 100644 --- a/metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/ObjectExceptionCatcher.java +++ b/metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/ObjectExceptionCatcher.java @@ -53,26 +53,57 @@ public final class ObjectExceptionCatcher extends private String logPrefix; private boolean logStackTrace; + /** + * Creates an instance of {@link ObjectExceptionCatcher} without a log message + * prefix. + */ public ObjectExceptionCatcher() { this(""); } + /** + * Creates an instance of {@link ObjectExceptionCatcher} with a given prefix of + * the log messages. + * + * @param logPrefix the prefix of the log messages + */ public ObjectExceptionCatcher(final String logPrefix) { this.logPrefix = logPrefix; } + /** + * Sets the log prefix. + * + * @param logPrefix the log message prefix + */ public void setLogPrefix(final String logPrefix) { this.logPrefix = logPrefix; } + /** + * Gets the log messages prefix. + * + * @return the log message prefix + */ public String getLogPrefix() { return logPrefix; } + /** + * Sets the log messages to stack trace level. + * + * @param logStackTrace true if the log messages should be set to stack trace + * level. + */ public void setLogStackTrace(final boolean logStackTrace) { this.logStackTrace = logStackTrace; } + /** + * Checks wether the log messages should be in stack trace level. + * + * @return true if the log messages are in stack trace level + */ public boolean isLogStackTrace() { return logStackTrace; } diff --git a/metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/ObjectPipeDecoupler.java b/metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/ObjectPipeDecoupler.java index 38f275ca0..b801d7097 100644 --- a/metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/ObjectPipeDecoupler.java +++ b/metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/ObjectPipeDecoupler.java @@ -51,18 +51,37 @@ public final class ObjectPipeDecoupler implements ObjectPipe receiver; private boolean debug; + /** + * Creates an instance of {@link ObjectPipeDecoupler} by setting a default + * capacity of {@value #DEFAULT_CAPACITY}. + */ public ObjectPipeDecoupler() { queue = new LinkedBlockingQueue<>(DEFAULT_CAPACITY); } + /** + * Creates an instance of {@link ObjectPipeDecoupler} by setting a capacity. + * + * @param capacity the capacity + */ public ObjectPipeDecoupler(final int capacity) { queue = new LinkedBlockingQueue<>(capacity); } + /** + * Creates an instance of {@link ObjectPipeDecoupler} by setting a capacity. + * + * @param capacity the capacity as String. Will be parsed as integer. + */ public ObjectPipeDecoupler(final String capacity) { queue = new LinkedBlockingQueue<>(Integer.parseInt(capacity)); } + /** + * Sets the log messages to be more verbose. + * + * @param debug true if the log messages should be more verbose + */ public void setDebug(final boolean debug) { this.debug = debug; } diff --git a/metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/ObjectThreader.java b/metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/ObjectThreader.java index 63aacc3ea..e4aa872d6 100644 --- a/metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/ObjectThreader.java +++ b/metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/ObjectThreader.java @@ -51,6 +51,9 @@ public class ObjectThreader implements Tee>, ObjectPipe> receivers = new ArrayList>(); private int objectNumber; + /** + * Creates an instance of {@link ObjectThreader}. + */ public ObjectThreader() { } diff --git a/metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/StreamBatchResetter.java b/metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/StreamBatchResetter.java index d6def5222..dcad1b38b 100644 --- a/metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/StreamBatchResetter.java +++ b/metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/StreamBatchResetter.java @@ -41,21 +41,44 @@ public final class StreamBatchResetter extends ForwardingStreamPipe { private long recordCount; private long batchCount; + /** + * Creates an instance of {@link StreamBatchResetter}. + */ public StreamBatchResetter() { } + /** + * Sets the size of the batch. + * + * @param batchSize the size of the batch + */ public void setBatchSize(final int batchSize) { this.batchSize = batchSize; } + /** + * Gets the size of the batch. + * + * @return the size of the batch + */ public long getBatchSize() { return batchSize; } + /** + * Gets the batch count. + * + * @return the number of counted batches. + */ public long getBatchCount() { return batchCount; } + /** + * Gets the record count. + * + * @return the number of counted records + */ public long getRecordCount() { return recordCount; } diff --git a/metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/StreamBuffer.java b/metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/StreamBuffer.java index 0f1940d63..94732aa30 100644 --- a/metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/StreamBuffer.java +++ b/metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/StreamBuffer.java @@ -42,9 +42,17 @@ private enum MessageType { private final List typeBuffer = new ArrayList(); private final List valueBuffer = new ArrayList(); + /** + * Creates an instance of {@link StreamBuffer}. + */ public StreamBuffer() { } + /** + * Checks wether there are messages stored. + * + * @return true if messages are empty, otherwise false + */ public boolean isEmpty() { return typeBuffer.isEmpty(); } @@ -80,6 +88,9 @@ public void replay() { } } + /** + * Clears the buffer. + */ public void clear() { typeBuffer.clear(); valueBuffer.clear(); diff --git a/metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/StreamDeferrer.java b/metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/StreamDeferrer.java index f9ce9d702..b03888670 100644 --- a/metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/StreamDeferrer.java +++ b/metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/StreamDeferrer.java @@ -45,6 +45,9 @@ public class StreamDeferrer extends DefaultStreamPipe { private final StreamBuffer buffer = new StreamBuffer(); + /** + * Creates an instance of {@link StreamDeferrer}. + */ public StreamDeferrer() { } diff --git a/metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/StreamExceptionCatcher.java b/metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/StreamExceptionCatcher.java index e0fe7aaad..20c7b684d 100644 --- a/metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/StreamExceptionCatcher.java +++ b/metafacture-flowcontrol/src/main/java/org/metafacture/flowcontrol/StreamExceptionCatcher.java @@ -44,10 +44,19 @@ public final class StreamExceptionCatcher extends private final String logPrefix; + /** + * Creates an instance of {@link StreamExceptionCatcher}. + */ public StreamExceptionCatcher() { this(""); } + /** + * Creates an instance of {@link StreamExceptionCatcher} setting a prefix for + * the logs messages. + * + * @param logPrefix the prefix of the log messages + */ public StreamExceptionCatcher(final String logPrefix) { this.logPrefix = logPrefix; } diff --git a/metafacture-flux/src/main/java/org/metafacture/flux/FluxCompiler.java b/metafacture-flux/src/main/java/org/metafacture/flux/FluxCompiler.java index 0805ddec3..2dd718b78 100644 --- a/metafacture-flux/src/main/java/org/metafacture/flux/FluxCompiler.java +++ b/metafacture-flux/src/main/java/org/metafacture/flux/FluxCompiler.java @@ -40,6 +40,16 @@ private FluxCompiler() { // no instances } + /** + * Compiles the flux to a flow. + * + * @see FluxProgramm + * @param flux the flux + * @param vars the variables of the flux + * @return the flow + * @throws RecognitionException if an ANTLR exception occurs + * @throws IOException if an I/O error occurs + */ public static FluxProgramm compile(final InputStream flux, final Map vars) throws RecognitionException, IOException { return compileFlow(compileAst(flux), vars); } diff --git a/metafacture-flux/src/main/java/org/metafacture/flux/FluxParseException.java b/metafacture-flux/src/main/java/org/metafacture/flux/FluxParseException.java index ee1e331e6..576d31711 100644 --- a/metafacture-flux/src/main/java/org/metafacture/flux/FluxParseException.java +++ b/metafacture-flux/src/main/java/org/metafacture/flux/FluxParseException.java @@ -26,10 +26,22 @@ public final class FluxParseException extends MetafactureException { private static final long serialVersionUID = -5728526458760884738L; + /** + * Creates an instance of {@link FluxParseException} by a given message and the + * cause of the exception. + * + * @param message the message + * @param cause the cause + */ public FluxParseException(final String message, final Throwable cause) { super(message, cause); } + /** + * Creates an instance of {@link FluxParseException} by a given message. + * + * @param message the message + */ public FluxParseException(final String message) { super(message); } diff --git a/metafacture-flux/src/main/java/org/metafacture/flux/HelpPrinter.java b/metafacture-flux/src/main/java/org/metafacture/flux/HelpPrinter.java index fc173cf5e..8ed027aba 100644 --- a/metafacture-flux/src/main/java/org/metafacture/flux/HelpPrinter.java +++ b/metafacture-flux/src/main/java/org/metafacture/flux/HelpPrinter.java @@ -37,7 +37,7 @@ import java.util.Map; /** - * prints Flux help for a given {@link ObjectFactory} + * Prints Flux help for a given {@link ObjectFactory} * * @author Markus Michael Geipel */ @@ -46,6 +46,13 @@ private HelpPrinter() { // no instances } + /** + * Prints Flux help for a given ObjectFactory. Excerpts setters and their + * arguments, {@code @in} annotations and {@code @out} annotations. + * + * @param factory the ObjectFactory + * @param out the PrintStream to print to + */ public static void print(final ObjectFactory factory, final PrintStream out) { out.println("Welcome to Metafacture"); diff --git a/metafacture-flux/src/main/java/org/metafacture/flux/parser/FluxProgramm.java b/metafacture-flux/src/main/java/org/metafacture/flux/parser/FluxProgramm.java index 0b1d162ca..6c3aa98ad 100644 --- a/metafacture-flux/src/main/java/org/metafacture/flux/parser/FluxProgramm.java +++ b/metafacture-flux/src/main/java/org/metafacture/flux/parser/FluxProgramm.java @@ -64,6 +64,9 @@ public final class FluxProgramm { private final Map wormholeNameMapping = new HashMap(); private final Map wormholeInFlowMapping = new Hashtable(); + /** + * Creates an instance of {@link FluxProgramm}. + */ public FluxProgramm() { } @@ -157,6 +160,9 @@ protected void compile() { } } + /** + * Starts all flows. + */ public void start() { for (final Flow flow : initialFlows) { flow.start(); @@ -169,6 +175,11 @@ public void start() { } } + /** + * Prints the help to the given PrintStream. + * + * @param out the PrintStream to orint to + */ public static void printHelp(final PrintStream out) { HelpPrinter.print(COMMAND_FACTORY, out); } diff --git a/metafacture-flux/src/main/java/org/metafacture/flux/parser/StringSender.java b/metafacture-flux/src/main/java/org/metafacture/flux/parser/StringSender.java index 095f8b830..90260f38a 100644 --- a/metafacture-flux/src/main/java/org/metafacture/flux/parser/StringSender.java +++ b/metafacture-flux/src/main/java/org/metafacture/flux/parser/StringSender.java @@ -28,6 +28,11 @@ public final class StringSender extends DefaultObjectPipe extends DefaultObjectPipe vars = new HashMap(); + private final Map vars = new HashMap<>(); private final String template; + /** + * Creates an instance of {@link ObjectTemplate} with a given template. + * + * @param template the template + */ public ObjectTemplate(final String template) { this.template = template; } diff --git a/metafacture-formatting/src/main/java/org/metafacture/formatting/PreambleEpilogueAdder.java b/metafacture-formatting/src/main/java/org/metafacture/formatting/PreambleEpilogueAdder.java index 369d43312..c740e9edf 100644 --- a/metafacture-formatting/src/main/java/org/metafacture/formatting/PreambleEpilogueAdder.java +++ b/metafacture-formatting/src/main/java/org/metafacture/formatting/PreambleEpilogueAdder.java @@ -46,6 +46,9 @@ public final class PreambleEpilogueAdder extends DefaultObjectPipe -1; } diff --git a/metafacture-formeta/src/main/java/org/metafacture/formeta/FormetaDecoder.java b/metafacture-formeta/src/main/java/org/metafacture/formeta/FormetaDecoder.java index 5e74f080a..315cd52cb 100644 --- a/metafacture-formeta/src/main/java/org/metafacture/formeta/FormetaDecoder.java +++ b/metafacture-formeta/src/main/java/org/metafacture/formeta/FormetaDecoder.java @@ -42,6 +42,9 @@ public final class FormetaDecoder extends private final FormetaParser parser = new FormetaParser(); private final Emitter emitter = new FullRecordEmitter(); + /** + * Creates an instance of {@link FormetaDecoder}. + */ public FormetaDecoder() { parser.setEmitter(emitter); } diff --git a/metafacture-formeta/src/main/java/org/metafacture/formeta/FormetaEncoder.java b/metafacture-formeta/src/main/java/org/metafacture/formeta/FormetaEncoder.java index e9f65ee6e..440686f50 100644 --- a/metafacture-formeta/src/main/java/org/metafacture/formeta/FormetaEncoder.java +++ b/metafacture-formeta/src/main/java/org/metafacture/formeta/FormetaEncoder.java @@ -41,13 +41,26 @@ public final class FormetaEncoder extends DefaultStreamPipe value(); } diff --git a/metafacture-framework/src/main/java/org/metafacture/framework/annotations/Out.java b/metafacture-framework/src/main/java/org/metafacture/framework/annotations/Out.java index ee9b62723..d9eecc70f 100644 --- a/metafacture-framework/src/main/java/org/metafacture/framework/annotations/Out.java +++ b/metafacture-framework/src/main/java/org/metafacture/framework/annotations/Out.java @@ -22,14 +22,19 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; - /** + * Metadata for pipe elements. + * * @author Markus Michael Geipel - * Metadata for pipe elements */ @Documented @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) public @interface Out { + /** + * Returns the class produced as output when using this class in a pipe. + * + * @return the Class + */ Class value(); } diff --git a/metafacture-framework/src/main/java/org/metafacture/framework/helpers/DefaultLifeCycle.java b/metafacture-framework/src/main/java/org/metafacture/framework/helpers/DefaultLifeCycle.java index 4e7e8dc09..fc28a2206 100644 --- a/metafacture-framework/src/main/java/org/metafacture/framework/helpers/DefaultLifeCycle.java +++ b/metafacture-framework/src/main/java/org/metafacture/framework/helpers/DefaultLifeCycle.java @@ -27,6 +27,9 @@ */ public class DefaultLifeCycle implements LifeCycle { + /** + * Creates an instance of {@link DefaultLifeCycle}. + */ public DefaultLifeCycle() { } diff --git a/metafacture-framework/src/main/java/org/metafacture/framework/helpers/DefaultObjectPipe.java b/metafacture-framework/src/main/java/org/metafacture/framework/helpers/DefaultObjectPipe.java index 866bb103c..d12cebeb3 100644 --- a/metafacture-framework/src/main/java/org/metafacture/framework/helpers/DefaultObjectPipe.java +++ b/metafacture-framework/src/main/java/org/metafacture/framework/helpers/DefaultObjectPipe.java @@ -31,6 +31,9 @@ */ public class DefaultObjectPipe extends DefaultSender implements ObjectPipe { + /** + * Creates an instance of {@link DefaultObjectPipe}. + */ public DefaultObjectPipe() { } diff --git a/metafacture-framework/src/main/java/org/metafacture/framework/helpers/DefaultObjectReceiver.java b/metafacture-framework/src/main/java/org/metafacture/framework/helpers/DefaultObjectReceiver.java index 6c9999b77..dd23ae754 100644 --- a/metafacture-framework/src/main/java/org/metafacture/framework/helpers/DefaultObjectReceiver.java +++ b/metafacture-framework/src/main/java/org/metafacture/framework/helpers/DefaultObjectReceiver.java @@ -34,6 +34,9 @@ */ public class DefaultObjectReceiver extends DefaultLifeCycle implements ObjectReceiver { + /** + * Creates an instance of {@link DefaultObjectReceiver}. + */ public DefaultObjectReceiver() { } diff --git a/metafacture-framework/src/main/java/org/metafacture/framework/helpers/DefaultSender.java b/metafacture-framework/src/main/java/org/metafacture/framework/helpers/DefaultSender.java index a785fa213..e2dd4c27b 100644 --- a/metafacture-framework/src/main/java/org/metafacture/framework/helpers/DefaultSender.java +++ b/metafacture-framework/src/main/java/org/metafacture/framework/helpers/DefaultSender.java @@ -39,9 +39,17 @@ public class DefaultSender implements Sender { private T receiver; private boolean isClosed; + /** + * Creates an instance of {@link DefaultSender}. + */ public DefaultSender() { } + /** + * Checks wether the DefaultSender is closed. + * + * @return true if the DefaultSender is closed + */ public final boolean isClosed() { return isClosed; } diff --git a/metafacture-framework/src/main/java/org/metafacture/framework/helpers/DefaultStreamPipe.java b/metafacture-framework/src/main/java/org/metafacture/framework/helpers/DefaultStreamPipe.java index ac31632f6..913bc4ea2 100644 --- a/metafacture-framework/src/main/java/org/metafacture/framework/helpers/DefaultStreamPipe.java +++ b/metafacture-framework/src/main/java/org/metafacture/framework/helpers/DefaultStreamPipe.java @@ -29,7 +29,9 @@ * @see ForwardingStreamPipe */ public class DefaultStreamPipe extends DefaultSender implements StreamPipe { - + /** + * Creates an instance of {@link DefaultStreamPipe}. + */ public DefaultStreamPipe() { } diff --git a/metafacture-framework/src/main/java/org/metafacture/framework/helpers/DefaultStreamReceiver.java b/metafacture-framework/src/main/java/org/metafacture/framework/helpers/DefaultStreamReceiver.java index 88781c78b..fa4bf651b 100644 --- a/metafacture-framework/src/main/java/org/metafacture/framework/helpers/DefaultStreamReceiver.java +++ b/metafacture-framework/src/main/java/org/metafacture/framework/helpers/DefaultStreamReceiver.java @@ -31,7 +31,9 @@ * */ public class DefaultStreamReceiver extends DefaultLifeCycle implements StreamReceiver { - + /** + * Creates an instance of {@link DefaultStreamReceiver}. + */ public DefaultStreamReceiver() { } diff --git a/metafacture-framework/src/main/java/org/metafacture/framework/helpers/DefaultTee.java b/metafacture-framework/src/main/java/org/metafacture/framework/helpers/DefaultTee.java index 6d73fe074..d7ee4843e 100644 --- a/metafacture-framework/src/main/java/org/metafacture/framework/helpers/DefaultTee.java +++ b/metafacture-framework/src/main/java/org/metafacture/framework/helpers/DefaultTee.java @@ -34,6 +34,9 @@ public class DefaultTee implements Tee { private final List receivers = new ArrayList(); + /** + * Creates an instance of {@link DefaultTee}. + */ public DefaultTee() { } diff --git a/metafacture-framework/src/main/java/org/metafacture/framework/helpers/DefaultXmlPipe.java b/metafacture-framework/src/main/java/org/metafacture/framework/helpers/DefaultXmlPipe.java index a429fd094..894fea7fa 100644 --- a/metafacture-framework/src/main/java/org/metafacture/framework/helpers/DefaultXmlPipe.java +++ b/metafacture-framework/src/main/java/org/metafacture/framework/helpers/DefaultXmlPipe.java @@ -43,6 +43,9 @@ public class DefaultXmlPipe extends DefaultSender impleme public static final String DEFAULT_ROOT_TAG = "records"; public static final String DEFAULT_VALUE_TAG = "value"; + /** + * Creates an instance of {@link DefaultXmlPipe}. + */ public DefaultXmlPipe() { } diff --git a/metafacture-framework/src/main/java/org/metafacture/framework/helpers/DefaultXmlReceiver.java b/metafacture-framework/src/main/java/org/metafacture/framework/helpers/DefaultXmlReceiver.java index 07bb1c0a6..00b1f3bf7 100644 --- a/metafacture-framework/src/main/java/org/metafacture/framework/helpers/DefaultXmlReceiver.java +++ b/metafacture-framework/src/main/java/org/metafacture/framework/helpers/DefaultXmlReceiver.java @@ -40,6 +40,9 @@ */ public class DefaultXmlReceiver extends DefaultLifeCycle implements XmlReceiver { + /** + * Creates an instance of {@link DefaultXmlReceiver}. + */ public DefaultXmlReceiver() { } diff --git a/metafacture-framework/src/main/java/org/metafacture/framework/helpers/ForwardingStreamPipe.java b/metafacture-framework/src/main/java/org/metafacture/framework/helpers/ForwardingStreamPipe.java index 2bffeb8c3..3e38ed59a 100644 --- a/metafacture-framework/src/main/java/org/metafacture/framework/helpers/ForwardingStreamPipe.java +++ b/metafacture-framework/src/main/java/org/metafacture/framework/helpers/ForwardingStreamPipe.java @@ -29,6 +29,9 @@ */ public class ForwardingStreamPipe extends DefaultStreamPipe { + /** + * Creates an instance of {@link ForwardingStreamPipe}. + */ public ForwardingStreamPipe() { } diff --git a/metafacture-framework/src/main/java/org/metafacture/framework/objects/Triple.java b/metafacture-framework/src/main/java/org/metafacture/framework/objects/Triple.java index f793d3cf3..e6edd8205 100644 --- a/metafacture-framework/src/main/java/org/metafacture/framework/objects/Triple.java +++ b/metafacture-framework/src/main/java/org/metafacture/framework/objects/Triple.java @@ -35,11 +35,26 @@ public final class Triple implements Comparable { private final int preCompHashCode; + /** + * Creates an instance of {@link Triple}. + * + * @param subject the subject + * @param predicate the predicate + * @param object the object + */ public Triple(final String subject, final String predicate, final String object) { this(subject, predicate, object, ObjectType.STRING); } + /** + * Constructs a Triple. + * + * @param subject the subject + * @param predicate the predicate + * @param object the object + * @param objectType the ObjectType + */ public Triple(final String subject, final String predicate, final String object, final ObjectType objectType) { this.subject = subject; @@ -53,22 +68,49 @@ private int computeHashCode() { return Objects.hash(subject, predicate, object, objectType); } + /** + * Gets the subject. + * + * @return the subject + */ public String getSubject() { return subject; } + /** + * Gets the predicate + * + * @return the predicate + */ public String getPredicate() { return predicate; } + /** + * Gets the object. + * + * @return the object + */ public String getObject() { return object; } + /** + * Gets the object type. + * + * @return the {@link ObjectType} + */ public ObjectType getObjectType() { return objectType; } + /** + * Reads an ObjectInputStream as Triple and returns it. + * + * @param in the ObjectInputStream + * @return the Triple + * @throws IOException if an I/O error occurs + */ public static Triple read(final ObjectInputStream in) throws IOException { try { return new Triple(in.readUTF(), in.readUTF(), in.readUTF(), @@ -79,6 +121,12 @@ public static Triple read(final ObjectInputStream in) throws IOException { } } + /** + * Writes the Triple to an ObjectOutputStream. + * + * @param out the ObjectOutputStream. + * @throws IOException if an I/O error occurs + */ public void write(final ObjectOutputStream out) throws IOException { out.writeUTF(subject); out.writeUTF(predicate); diff --git a/metafacture-html/src/main/java/org/metafacture/html/HtmlDecoder.java b/metafacture-html/src/main/java/org/metafacture/html/HtmlDecoder.java index 26ae792d5..eeb1e4397 100644 --- a/metafacture-html/src/main/java/org/metafacture/html/HtmlDecoder.java +++ b/metafacture-html/src/main/java/org/metafacture/html/HtmlDecoder.java @@ -68,6 +68,9 @@ public class HtmlDecoder extends DefaultObjectPipe { private Map attrValsAsSubfields; + /** + * Creates an instance of {@link HtmlDecoder}. + */ public HtmlDecoder() { setAttrValsAsSubfields(DEFAULT_ATTR_VALS_AS_SUBFIELDS); } @@ -123,6 +126,12 @@ private boolean handleAttributeValuesAsSubfields(final StreamReceiver receiver, return false; } + /** + * Sets attribute values as subfields. If the value(s) start with an `&` they + * are appended to {@link #DEFAULT_ATTR_VALS_AS_SUBFIELDS}. + * + * @param mapString the attributes to be added as subfields + */ public void setAttrValsAsSubfields(final String mapString) { this.attrValsAsSubfields = new HashMap(); final String input = mapString.startsWith("&") ? DEFAULT_ATTR_VALS_AS_SUBFIELDS + mapString : mapString; diff --git a/metafacture-io/src/main/java/org/metafacture/io/ByteStreamFileWriter.java b/metafacture-io/src/main/java/org/metafacture/io/ByteStreamFileWriter.java index 6032d860c..ff49334bd 100644 --- a/metafacture-io/src/main/java/org/metafacture/io/ByteStreamFileWriter.java +++ b/metafacture-io/src/main/java/org/metafacture/io/ByteStreamFileWriter.java @@ -27,6 +27,9 @@ public class ByteStreamFileWriter extends DefaultObjectReceiver { private OutputStream outputStream; + /** + * Creates an instance of {@link ByteStreamFileWriter}. + */ public ByteStreamFileWriter() { } diff --git a/metafacture-io/src/main/java/org/metafacture/io/CloseFailed.java b/metafacture-io/src/main/java/org/metafacture/io/CloseFailed.java index 53c60c42a..1a27a62ee 100644 --- a/metafacture-io/src/main/java/org/metafacture/io/CloseFailed.java +++ b/metafacture-io/src/main/java/org/metafacture/io/CloseFailed.java @@ -2,14 +2,30 @@ public class CloseFailed extends IoFailed { + /** + * Creates an instance of {@link CloseFailed} by a given message. + * + * @param message the message + */ public CloseFailed(final String message) { super(message); } + /** + * Creates an instance of {@link CloseFailed} by a given cause. + * + * @param cause the {@link Throwable} + */ public CloseFailed(final Throwable cause) { super(cause); } + /** + * Creates an instance of {@link CloseFailed} by a given message and a cause. + * + * @param message the message + * @param cause the {@link Throwable} + */ public CloseFailed(final String message, final Throwable cause) { super(message, cause); } diff --git a/metafacture-io/src/main/java/org/metafacture/io/FileCompression.java b/metafacture-io/src/main/java/org/metafacture/io/FileCompression.java index 116fc3367..9f5cfa956 100644 --- a/metafacture-io/src/main/java/org/metafacture/io/FileCompression.java +++ b/metafacture-io/src/main/java/org/metafacture/io/FileCompression.java @@ -202,10 +202,31 @@ public InputStream createDecompressor(final InputStream readFrom, final boolean private static final int BUFFER_SIZE = 8 * 1024 * 1024; + /** + * Creates a compressor. + * + * @param writeTo the {@link OutputStream} to write to + * @param fileName the filename + * @return the {@link OutputStream} + */ public abstract OutputStream createCompressor(OutputStream writeTo, String fileName); + /** + * Creates a decompressor. + * + * @param readFrom {the @link InputStream} to read from. + * @param decompressConcatenated true if decompress concatenated, otherwise + * false + * @return the {@link InputStream} + */ public abstract InputStream createDecompressor(InputStream readFrom, boolean decompressConcatenated); + /** + * Creates a decompressor. + * + * @param readFrom {the @link InputStream} to read from. + * @return the {@link InputStream} + */ public InputStream createDecompressor(final InputStream readFrom) { return createDecompressor(readFrom, DEFAULT_DECOMPRESS_CONCATENATED); } diff --git a/metafacture-io/src/main/java/org/metafacture/io/FileOpener.java b/metafacture-io/src/main/java/org/metafacture/io/FileOpener.java index 55abf99b4..b4104b119 100644 --- a/metafacture-io/src/main/java/org/metafacture/io/FileOpener.java +++ b/metafacture-io/src/main/java/org/metafacture/io/FileOpener.java @@ -48,6 +48,9 @@ public final class FileOpener extends DefaultObjectPipe receiver) { final BufferedReader lineReader = new BufferedReader(reader, BUFFER_SIZE); try { diff --git a/metafacture-io/src/main/java/org/metafacture/io/ObjectFileWriter.java b/metafacture-io/src/main/java/org/metafacture/io/ObjectFileWriter.java index fd487f0d1..bcbf90fb3 100644 --- a/metafacture-io/src/main/java/org/metafacture/io/ObjectFileWriter.java +++ b/metafacture-io/src/main/java/org/metafacture/io/ObjectFileWriter.java @@ -52,6 +52,11 @@ public final class ObjectFileWriter extends AbstractObjectWriter { private String encoding = "UTF-8"; private FileCompression compression = FileCompression.AUTO; + /** + * Sets the destination of a file to write objects to. + * + * @param path the path to be written to + */ public ObjectFileWriter(final String path) { this.path = path; startNewFile(); diff --git a/metafacture-io/src/main/java/org/metafacture/io/ObjectJavaIoWriter.java b/metafacture-io/src/main/java/org/metafacture/io/ObjectJavaIoWriter.java index fd431ca73..08659fd04 100644 --- a/metafacture-io/src/main/java/org/metafacture/io/ObjectJavaIoWriter.java +++ b/metafacture-io/src/main/java/org/metafacture/io/ObjectJavaIoWriter.java @@ -23,8 +23,7 @@ import java.io.Writer; /** - * @param - * object type + * @param object type * * @author Christoph Böhme, Markus Geipel * @deprecated Use {@link ObjectWriter} or {@link ObjectFileWriter} instead. @@ -36,11 +35,21 @@ public final class ObjectJavaIoWriter implements ObjectReceiver { private boolean closed; private final IoWriterFactory writerFactory; + /** + * Deprecated. + * + * @param writer the Writer + */ public ObjectJavaIoWriter(final Writer writer) { this.writer = writer; writerFactory = null; } + /** + * Deprecated. + * + * @param writerFactory the IoWriterFactory + */ public ObjectJavaIoWriter(final IoWriterFactory writerFactory) { this.writerFactory = writerFactory; this.writer = writerFactory.createWriter(); diff --git a/metafacture-io/src/main/java/org/metafacture/io/ObjectStdoutWriter.java b/metafacture-io/src/main/java/org/metafacture/io/ObjectStdoutWriter.java index b7824cd76..5394b26a7 100644 --- a/metafacture-io/src/main/java/org/metafacture/io/ObjectStdoutWriter.java +++ b/metafacture-io/src/main/java/org/metafacture/io/ObjectStdoutWriter.java @@ -39,6 +39,9 @@ public final class ObjectStdoutWriter extends AbstractObjectWriter { private boolean firstObject = true; private boolean closed; + /** + * Creates an instance of {@link ObjectStdoutWriter}. + */ public ObjectStdoutWriter() { } diff --git a/metafacture-io/src/main/java/org/metafacture/io/ObjectWriter.java b/metafacture-io/src/main/java/org/metafacture/io/ObjectWriter.java index 279c36832..6ce1c4436 100644 --- a/metafacture-io/src/main/java/org/metafacture/io/ObjectWriter.java +++ b/metafacture-io/src/main/java/org/metafacture/io/ObjectWriter.java @@ -40,11 +40,20 @@ @FluxCommand("write") public final class ObjectWriter implements ConfigurableObjectWriter { - private static final String STDOUT = "stdout"; + public static final String STDOUT = "stdout"; + private static final List ARGUMENTS = Collections.unmodifiableList(Arrays.asList(STDOUT, "PATH")); private final ConfigurableObjectWriter objectWriter; + /** + * Sets the destination to write objects to. If the destination is set to + * {@value #STDOUT} the object is written to the standard output. Otherwise + * it's written to a file of that name. + * + * @param destination the path to be written to or standard out if it's + * {@value #STDOUT} + */ public ObjectWriter(final String destination) { if (STDOUT.equals(destination)) { objectWriter = new ObjectStdoutWriter(); @@ -54,6 +63,11 @@ public ObjectWriter(final String destination) { } } + /** + * Returns the available arguments. + * + * @return arguments + */ @ReturnsAvailableArguments public static Collection getArguments() { return ARGUMENTS; diff --git a/metafacture-io/src/main/java/org/metafacture/io/OpenFailed.java b/metafacture-io/src/main/java/org/metafacture/io/OpenFailed.java index 58e47ae2c..fd0be1032 100644 --- a/metafacture-io/src/main/java/org/metafacture/io/OpenFailed.java +++ b/metafacture-io/src/main/java/org/metafacture/io/OpenFailed.java @@ -2,14 +2,30 @@ public class OpenFailed extends IoFailed { + /** + * Creates an instance of {@link OpenFailed} by a given message. + * + * @param message the message + */ public OpenFailed(final String message) { super(message); } + /** + * Creates an instance of {@link OpenFailed} by a given cause. + * + * @param cause the {@link Throwable} + */ public OpenFailed(final Throwable cause) { super(cause); } + /** + * Creates an instance of {@link OpenFailed} by a given message and a cause. + * + * @param message the message + * @param cause the {@link Throwable} + */ public OpenFailed(final String message, final Throwable cause) { super(message, cause); } diff --git a/metafacture-io/src/main/java/org/metafacture/io/RecordReader.java b/metafacture-io/src/main/java/org/metafacture/io/RecordReader.java index 2ddbdb56a..cbde07f82 100644 --- a/metafacture-io/src/main/java/org/metafacture/io/RecordReader.java +++ b/metafacture-io/src/main/java/org/metafacture/io/RecordReader.java @@ -53,9 +53,17 @@ public final class RecordReader extends DefaultObjectPipe= 1) { this.separator = separator.charAt(0); @@ -65,18 +73,38 @@ public void setSeparator(final String separator) { } } + /** + * Sets the separator. + * + * @param separator the separator + */ public void setSeparator(final char separator) { this.separator = separator; } + /** + * Gets the separator + * + * @return the separator + */ public char getSeparator() { return separator; } + /** + * Flags to skip empty records. + * + * @param skipEmptyRecords true if empty records should be skipped + */ public void setSkipEmptyRecords(final boolean skipEmptyRecords) { this.skipEmptyRecords = skipEmptyRecords; } + /** + * Checks wether to skip empty records. + * + * @return true if empty records should be skipped + */ public boolean getSkipEmptyRecords() { return skipEmptyRecords; } diff --git a/metafacture-io/src/main/java/org/metafacture/io/ResourceOpener.java b/metafacture-io/src/main/java/org/metafacture/io/ResourceOpener.java index 410d8ff38..4a2084eff 100644 --- a/metafacture-io/src/main/java/org/metafacture/io/ResourceOpener.java +++ b/metafacture-io/src/main/java/org/metafacture/io/ResourceOpener.java @@ -42,6 +42,9 @@ public final class ResourceOpener extends DefaultObjectPipe> { + /** + * Creates an instance of {@link StdInOpener}. + */ public StdInOpener() { } diff --git a/metafacture-io/src/main/java/org/metafacture/io/TarReader.java b/metafacture-io/src/main/java/org/metafacture/io/TarReader.java index d3e3e9c49..07d7ccb4e 100644 --- a/metafacture-io/src/main/java/org/metafacture/io/TarReader.java +++ b/metafacture-io/src/main/java/org/metafacture/io/TarReader.java @@ -47,6 +47,9 @@ @FluxCommand("open-tar") public class TarReader extends DefaultObjectPipe> { + /** + * Creates an instance of {@link TarReader}. + */ public TarReader() { } diff --git a/metafacture-io/src/main/java/org/metafacture/io/WriteFailed.java b/metafacture-io/src/main/java/org/metafacture/io/WriteFailed.java index 606de11ae..0bffa780d 100644 --- a/metafacture-io/src/main/java/org/metafacture/io/WriteFailed.java +++ b/metafacture-io/src/main/java/org/metafacture/io/WriteFailed.java @@ -2,14 +2,30 @@ public class WriteFailed extends IoFailed { + /** + * Creates an instance of {@link WriteFailed} by given message. + * + * @param message the message + */ public WriteFailed(final String message) { super(message); } + /** + * Creates an instance of {@link WriteFailed} by given cause. + * + * @param cause the {@link Throwable} + */ public WriteFailed(final Throwable cause) { super(cause); } + /** + * Creates an instance of {@link WriteFailed} by given message and cause. + * + * @param message the message + * @param cause the {@link Throwable} + */ public WriteFailed(final String message, final Throwable cause) { super(message, cause); } diff --git a/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/Collector.java b/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/Collector.java index df463fe32..69dc770ae 100644 --- a/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/Collector.java +++ b/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/Collector.java @@ -27,9 +27,19 @@ * */ public interface Collector { - + /** + * + * Gets the Collection. + * + * @return the Collection of collected data + */ Collection getCollection(); + /** + * Sets collection. + * + * @param collection the collection + */ void setCollection(Collection collection); } diff --git a/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/EventList.java b/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/EventList.java index 72e250617..96ace4fc9 100644 --- a/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/EventList.java +++ b/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/EventList.java @@ -34,13 +34,26 @@ public final class EventList implements StreamReceiver { private boolean closed; + /** + * Creates an instance of {@link EventList}. + */ public EventList() { } + /** + * Get events. + * + * @return the List of {@link Event} + */ public List getEvents() { return Collections.unmodifiableList(events); } + /** + * Check wether EventList is closed. + * + * @return true if EventList is closed. + */ public boolean isClosed() { return closed; } @@ -118,14 +131,29 @@ public enum Type { this.value = value; } + /** + * Gets the type. + * + * @return the type + */ public Type getType() { return type; } + /** + * Gets the name. + * + * @return the name + */ public String getName() { return name; } + /** + * Gets the value. + * + * @return the value + */ public String getValue() { return value; } diff --git a/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/MapToStream.java b/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/MapToStream.java index a53936486..4d6f62557 100644 --- a/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/MapToStream.java +++ b/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/MapToStream.java @@ -31,7 +31,7 @@ * event is emitted. *

    * If the map contains an entry whose key value matches the one set as - * {@link #setIdKey(Object)}, this entry's value is used as the record id. + * {@link #setIdKey(Object)}, this entry's value is used as the record ID. *

    * The keys and values in the map can be of any type. They will be converted to * strings using their {@link Object#toString()} method. Neither key nor value @@ -64,24 +64,33 @@ public final class MapToStream extends DefaultObjectPipe, StreamReceiv private Object idKey = StandardEventNames.ID; + /** + * Creates an instance of {@link MapToStream}. + */ public MapToStream() { } /** - * Sets the key of the map entry that is used for the record id. + * Sets the key of the map entry that is used for the record ID. *

    - * The default id key is "{@value StandardEventNames#ID}". + * The default ID key is + * {@value org.metafacture.framework.StandardEventNames#ID}. *

    * This parameter can be changed anytime during processing. The new value * becomes effective with the next record being processed. * - * @param idKey the id key. The object passed here is used in a call to + * @param idKey the ID key. The object passed here is used in a call to * {@link Map#get(Object)} to get the identifier value. */ public void setIdKey(final Object idKey) { this.idKey = idKey; } + /** + * Gets the ID. + * + * @return the ID + */ public Object getIdKey() { return idKey; } diff --git a/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/NamedValueList.java b/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/NamedValueList.java index d2dc101b4..c7a81d334 100644 --- a/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/NamedValueList.java +++ b/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/NamedValueList.java @@ -34,14 +34,20 @@ public final class NamedValueList extends DefaultStreamReceiver implements List, Collector> { private Collection> collection; - private List list; + private List list = new ArrayList<>(); + /** + * Creates an instance of {@link NamedValueList}. + */ public NamedValueList() { - list = new ArrayList(); } + /** + * Constructs a NamedValueList with a given Collection. + * + * @param collection the Collection + */ public NamedValueList(final Collection> collection) { - list = new ArrayList(); this.collection = collection; } diff --git a/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/NamedValueSet.java b/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/NamedValueSet.java index 0630172ea..b89bf564c 100644 --- a/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/NamedValueSet.java +++ b/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/NamedValueSet.java @@ -33,12 +33,12 @@ public final class NamedValueSet extends DefaultStreamReceiver implements Set, Collector> { private Collection> collection; - private Set set; + private Set set = new HashSet<>(); + /** + * Creates an instance of {@link NamedValueSet}. + */ public NamedValueSet() { - set = new HashSet<>(); - this.collection = null; - } /** @@ -48,7 +48,6 @@ public NamedValueSet() { * @param collection is filled with the received results. */ public NamedValueSet(final Collection> collection) { - set = new HashSet<>(); this.collection = collection; } diff --git a/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/ObjectCollector.java b/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/ObjectCollector.java index a432afd8d..6b3764d0e 100644 --- a/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/ObjectCollector.java +++ b/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/ObjectCollector.java @@ -36,14 +36,27 @@ public final class ObjectCollector implements ObjectReceiver { private boolean closed; + /** + * Creates an instance of {@link ObjectCollector}. + */ public ObjectCollector() { this(-1); } + /** + * Creates an instance of {@link ObjectCollector} by a given capacity. + * + * @param maxCapacity the maximal capacity + */ public ObjectCollector(final int maxCapacity) { this.maxCapacity = maxCapacity; } + /** + * Check wether ObjectCollector is closed. + * + * @return true if ObjectCollector is closed. + */ public boolean isClosed() { return closed; } diff --git a/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/SingleValue.java b/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/SingleValue.java index bb94b3d03..4d0c46d13 100644 --- a/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/SingleValue.java +++ b/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/SingleValue.java @@ -21,7 +21,7 @@ import java.util.Collection; /** - * just records the value of the last received literal. + * Just records the value of the last received literal. * @author Markus Michael Geipel * */ @@ -31,14 +31,26 @@ public final class SingleValue extends DefaultStreamReceiver implements Collecto private String value = ""; private Collection collection; + /** + * Creates an instance of {@link SingleValue}. + */ public SingleValue() { - collection = null; } + /** + * Creates an instance of {@link SingleValue} by a given Collection. + * + * @param collection the Collection + */ public SingleValue(final Collection collection) { this.collection = collection; } + /** + * Check wether SingleValue is closed. + * + * @return true if SingleValue is closed. + */ public boolean isClosed() { return closed; } diff --git a/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/StringListMap.java b/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/StringListMap.java index 39f78f34c..2e075f8bd 100644 --- a/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/StringListMap.java +++ b/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/StringListMap.java @@ -36,13 +36,26 @@ public final class StringListMap extends DefaultStreamReceiver implements Collec private Collection> collection; private ListMap listMap = new ListMap(); + /** + * Creates an instance of {@link StringListMap}. + */ public StringListMap() { } + /** + * Creates an instance of {@link StringListMap} by a given Collection. + * + * @param collection the Collection + */ public StringListMap(final Collection> collection) { this.collection = collection; } + /** + * Checks if StringListMap is closed. + * + * @return true if it is closed + */ public boolean isClosed() { return closed; } @@ -52,14 +65,27 @@ public void clear() { listMap.clear(); } + /** + * Removes a key in the map. + * + * @param key the key + */ public void removeKey(final String key) { listMap.removeKey(key); } + /** + * Clears a key in the map. + * + * @param key the key + */ public void clearKey(final String key) { listMap.clearKey(key); } + /** + * Clears all keys in the map. + */ public void clearAllKeys() { listMap.clearAllKeys(); } @@ -74,10 +100,22 @@ public Set keySet() { return listMap.keySet(); } + /** + * Adds a value to the List of values of the key in the map. + * + * @param name the key + * @param value the value + */ public void add(final String name, final String value) { listMap.add(name, value); } + /** + * Adds a List of values to a key in the map + * + * @param name the key + * @param addValues the {@link Collection} of values + */ public void putAll(final String name, final Collection addValues) { listMap.putAll(name, addValues); } @@ -97,10 +135,23 @@ public List get(final Object name) { return listMap.get(name); } + /** + * Checks wether a key exists. + * + * @param name the key + * @return true if the key exists, otherwise false + */ public boolean existsKey(final String name) { return listMap.existsKey(name); } + /** + * Gets the first element of the List of values of the key in the map or null + * + * @param name the name + * @return the first element of the List of values of the key in the map or + * null. + */ public String getFirst(final String name) { return listMap.getFirst(name); } @@ -110,10 +161,20 @@ public String toString() { return listMap.toString(); } + /** + * Sets the ID. + * + * @param identifier the ID + */ public void setId(final String identifier) { listMap.setId(identifier); } + /** + * Gets the ID. + * + * @return the ID + */ public String getId() { return listMap.getId(); } diff --git a/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/StringListMapToStream.java b/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/StringListMapToStream.java index a9ccf95b0..e776e5001 100644 --- a/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/StringListMapToStream.java +++ b/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/StringListMapToStream.java @@ -37,6 +37,9 @@ @FluxCommand("string-list-map-to-stream") public final class StringListMapToStream extends DefaultObjectPipe, StreamReceiver> { + /** + * Creates an instance of {@link StringListMapToStream}. + */ public StringListMapToStream() { } @@ -46,6 +49,12 @@ public void process(final ListMap listMap) { process(listMap, getReceiver()); } + /** + * Reads a {@link ListMap} and sends it to a {@link StreamReceiver}. + * + * @param listMap the ListMap to be read + * @param receiver the StreamReceiver to send to + */ public static void process(final ListMap listMap, final StreamReceiver receiver) { receiver.startRecord(listMap.getId()); for (final Entry> entry: listMap.entrySet()) { diff --git a/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/StringMap.java b/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/StringMap.java index fd7113ede..5223551e3 100644 --- a/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/StringMap.java +++ b/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/StringMap.java @@ -33,15 +33,20 @@ public final class StringMap extends DefaultStreamReceiver implements Map> collection; - private Map map; + private Map map = new HashMap<>(); + /** + * Creates an instance of {@link StringMap}. + */ public StringMap() { - map = new HashMap(); - collection = null; } + /** + * Constructs a StringMap with a given Collection. + * + * @param collection the Collection + */ public StringMap(final Collection> collection) { - map = new HashMap(); this.collection = collection; } @@ -56,6 +61,11 @@ protected void setMap(final Map map) { this.map = map; } + /** + * Checks if the StringMap is closed. + * + * @return true if StringMap is closed. + */ public boolean isClosed() { return closed; } diff --git a/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/ValueSet.java b/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/ValueSet.java index b079a7e08..6b39b2f85 100644 --- a/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/ValueSet.java +++ b/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/ValueSet.java @@ -31,13 +31,13 @@ */ public final class ValueSet extends DefaultStreamReceiver implements Set, Collector> { - private Collection> collection; + private Collection> collection = new HashSet<>(); private Set set; + /** + * Creates an instance of {@link ValueSet}. + */ public ValueSet() { - set = new HashSet<>(); - this.collection = null; - } /** @@ -47,7 +47,6 @@ public ValueSet() { * @param collection is filled with the received results. */ public ValueSet(final Collection> collection) { - set = new HashSet<>(); this.collection = collection; } diff --git a/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/pojo/MetafactureSource.java b/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/pojo/MetafactureSource.java index 6b5280924..0b3c271eb 100644 --- a/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/pojo/MetafactureSource.java +++ b/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/pojo/MetafactureSource.java @@ -27,7 +27,11 @@ * */ public interface MetafactureSource { - + /** + * Sends received events to this stream. + * + * @param streamReceiver the {@link StreamReceiver} + */ void sendToStream(StreamReceiver streamReceiver); } diff --git a/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/pojo/PojoDecoder.java b/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/pojo/PojoDecoder.java index 1a473dfe9..71a594962 100644 --- a/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/pojo/PojoDecoder.java +++ b/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/pojo/PojoDecoder.java @@ -80,6 +80,9 @@ public class PojoDecoder extends DefaultObjectPipe { private final TypeDecoderFactory typeDecoderFactory = new TypeDecoderFactory(); + /** + * Creates an instance of {@link PojoDecoder}. + */ public PojoDecoder() { } diff --git a/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/pojo/PojoEncoder.java b/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/pojo/PojoEncoder.java index 6f72ba333..b7396da2f 100644 --- a/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/pojo/PojoEncoder.java +++ b/metafacture-javaintegration/src/main/java/org/metafacture/javaintegration/pojo/PojoEncoder.java @@ -54,6 +54,11 @@ public class PojoEncoder extends DefaultStreamPipe> { private final Deque typeEncoderStack = new ArrayDeque<>(); private final Class pojoClass; + /** + * Creates an instance of {@link PojoEncoder} by a given Class. + * + * @param pojoClass the Class + */ public PojoEncoder(final Class pojoClass) { this.pojoClass = pojoClass; } diff --git a/metafacture-jdom/src/main/java/org/metafacture/jdom/JDomDocumentToStream.java b/metafacture-jdom/src/main/java/org/metafacture/jdom/JDomDocumentToStream.java index dc9309078..e0bf9399e 100644 --- a/metafacture-jdom/src/main/java/org/metafacture/jdom/JDomDocumentToStream.java +++ b/metafacture-jdom/src/main/java/org/metafacture/jdom/JDomDocumentToStream.java @@ -41,6 +41,11 @@ public final class JDomDocumentToStream private final SAXOutputter saxOutputer; private final XmlPipe xmlPipe; + /** + * Contructs a JDomDocumentToStream with a given XmlPipe. + * + * @param xmlPipe the XmlPipe of type StreamReceiver + */ public JDomDocumentToStream(final XmlPipe xmlPipe) { this.xmlPipe = xmlPipe; saxOutputer = new SAXOutputter(xmlPipe); diff --git a/metafacture-jdom/src/main/java/org/metafacture/jdom/StreamToJDomDocument.java b/metafacture-jdom/src/main/java/org/metafacture/jdom/StreamToJDomDocument.java index b1cc3101a..d9ed9d541 100644 --- a/metafacture-jdom/src/main/java/org/metafacture/jdom/StreamToJDomDocument.java +++ b/metafacture-jdom/src/main/java/org/metafacture/jdom/StreamToJDomDocument.java @@ -58,6 +58,13 @@ public final class StreamToJDomDocument private final String rootTagName; private final Map namespaces = new HashMap(); + /** + * Constructs a StreamToJDomDocument initialized with a given root tag name and + * a location of a file with named properties. + * + * @param rootTagName the root tag name + * @param namespaceProperties the location of the file of the named properties + */ public StreamToJDomDocument(final String rootTagName, final String namespaceProperties) { this.rootTagName = rootTagName; namespaces.put(XML, Namespace.getNamespace(XML, "http://www.w3.org/XML/1998/namespace")); diff --git a/metafacture-json/src/main/java/org/metafacture/json/JsonDecoder.java b/metafacture-json/src/main/java/org/metafacture/json/JsonDecoder.java index 410fe7bd0..934a39938 100644 --- a/metafacture-json/src/main/java/org/metafacture/json/JsonDecoder.java +++ b/metafacture-json/src/main/java/org/metafacture/json/JsonDecoder.java @@ -60,70 +60,130 @@ public final class JsonDecoder extends DefaultObjectPipe private final JsonFactory jsonFactory = new JsonFactory(); private JsonParser jsonParser; - private String arrayMarker; - private String arrayName; - private String recordId; - private int recordCount; + private String arrayMarker = DEFAULT_ARRAY_MARKER; + private String arrayName = DEFAULT_ARRAY_NAME; + private String recordId = DEFAULT_RECORD_ID; + private String recordPath = DEFAULT_ROOT_PATH; - private String recordPath; + private int recordCount; + /** + * Creates an instance of {@link JsonDecoder}. + */ public JsonDecoder() { - setArrayMarker(DEFAULT_ARRAY_MARKER); - setArrayName(DEFAULT_ARRAY_NAME); - setRecordId(DEFAULT_RECORD_ID); - setRecordPath(DEFAULT_ROOT_PATH); - - resetRecordCount(); } + /** + * Flags wether to allow comments. + * + * @param allowComments true if comments should be allowed + */ public void setAllowComments(final boolean allowComments) { jsonFactory.configure(JsonParser.Feature.ALLOW_COMMENTS, allowComments); } + /** + * Checks if comments are allowed. + * + * @return true if comments are allowed + */ public boolean getAllowComments() { return jsonFactory.isEnabled(JsonParser.Feature.ALLOW_COMMENTS); } + /** + * Sets the array marker. + * + * @param arrayMarker the array marker + */ public void setArrayMarker(final String arrayMarker) { this.arrayMarker = arrayMarker; } + /** + * Gets the array marker. + * + * @return the array marker + */ public String getArrayMarker() { return arrayMarker; } + /** + * Sets the name of the array. + * + * @param arrayName the name of the array + */ public void setArrayName(final String arrayName) { this.arrayName = arrayName; } + /** + * Gets the name of the array. + * + * @return the name of the array + */ public String getArrayName() { return arrayName; } + /** + * Sets the ID of the record. + * + * @param recordId the ID of the record + */ public void setRecordId(final String recordId) { this.recordId = recordId; } + /** + * Gets the ID of the record. + * + * @return the ID of the record + */ public String getRecordId() { return recordId; } + /** + * Sets the record count. + * + * @param recordCount the record count + */ public void setRecordCount(final int recordCount) { this.recordCount = recordCount; } + /** + * Gets the record count. + * + * @return the record count + */ public int getRecordCount() { return recordCount; } + /** + * Sets the record path. + * + * @param recordPath the record path + */ public void setRecordPath(final String recordPath) { this.recordPath = recordPath; } + /** + * Gets the record path. + * + * @return the record path + */ public String getRecordPath() { return recordPath; } + /** + * Resets the record count. + */ public void resetRecordCount() { setRecordCount(0); } diff --git a/metafacture-json/src/main/java/org/metafacture/json/JsonEncoder.java b/metafacture-json/src/main/java/org/metafacture/json/JsonEncoder.java index d0527fa18..919fdd3f0 100644 --- a/metafacture-json/src/main/java/org/metafacture/json/JsonEncoder.java +++ b/metafacture-json/src/main/java/org/metafacture/json/JsonEncoder.java @@ -62,6 +62,10 @@ public final class JsonEncoder extends DefaultStreamPipe> private String arrayMarker = ARRAY_MARKER; + /** + * Constructs a JsonEncoder if no IOException occurs. The root value + * separator of the JsonGenerator is set to null. + */ public JsonEncoder() { try { jsonGenerator = new JsonFactory().createGenerator(writer); @@ -72,18 +76,38 @@ public JsonEncoder() { } } + /** + * Sets the array marker. + * + * @param arrayMarker the array marker + */ public void setArrayMarker(final String arrayMarker) { this.arrayMarker = arrayMarker; } + /** + * Gets the array marker. + * + * @return the array marker + */ public String getArrayMarker() { return arrayMarker; } + /** + * Flags wether to use pretty printing. + * + * @param prettyPrinting true if pretty printing should be used + */ public void setPrettyPrinting(final boolean prettyPrinting) { jsonGenerator.setPrettyPrinter(prettyPrinting ? new DefaultPrettyPrinter((SerializableString) null) : null); } + /** + * Checks if the {@link JsonGenerator} has a pretty printer. + * + * @return true if {@link JsonGenerator} has a pretty printer. + */ public boolean getPrettyPrinting() { return jsonGenerator.getPrettyPrinter() != null; } diff --git a/metafacture-linkeddata/src/main/java/org/metafacture/linkeddata/BeaconReader.java b/metafacture-linkeddata/src/main/java/org/metafacture/linkeddata/BeaconReader.java index 9a9ce94ae..50464b24b 100644 --- a/metafacture-linkeddata/src/main/java/org/metafacture/linkeddata/BeaconReader.java +++ b/metafacture-linkeddata/src/main/java/org/metafacture/linkeddata/BeaconReader.java @@ -43,6 +43,7 @@ @Out(StreamReceiver.class) @FluxCommand("read-beacon") public final class BeaconReader extends DefaultObjectPipe { + public static final String DEFAULT_RELATION = "seeAlso"; private static final int MB = 1024 * 1024; private static final int BUFFER_SIZE = MB * 2; @@ -51,27 +52,40 @@ public final class BeaconReader extends DefaultObjectPipe } } + /** + * Creates an instance of {@link OreAggregationAdder}. + */ public OreAggregationAdder() { } diff --git a/metafacture-linkeddata/src/main/java/org/metafacture/linkeddata/RdfMacroPipe.java b/metafacture-linkeddata/src/main/java/org/metafacture/linkeddata/RdfMacroPipe.java index 0f947bfe8..870a26847 100644 --- a/metafacture-linkeddata/src/main/java/org/metafacture/linkeddata/RdfMacroPipe.java +++ b/metafacture-linkeddata/src/main/java/org/metafacture/linkeddata/RdfMacroPipe.java @@ -42,9 +42,17 @@ public final class RdfMacroPipe extends DefaultStreamPipe { public static final String XML_LANG = "~xml:lang"; private String autoAddedSubject = ""; + /** + * Creates an instance of {@link RdfMacroPipe}. + */ public RdfMacroPipe() { } + /** + * Flas wether to auto add the subject. + * + * @param autoAddedSubject true if subject shoudl be auto added + */ public void setAutoAddedSubject(final String autoAddedSubject) { this.autoAddedSubject = autoAddedSubject; } diff --git a/metafacture-mangling/src/main/java/org/metafacture/mangling/DuplicateObjectFilter.java b/metafacture-mangling/src/main/java/org/metafacture/mangling/DuplicateObjectFilter.java index d8f40b58a..9c11585df 100644 --- a/metafacture-mangling/src/main/java/org/metafacture/mangling/DuplicateObjectFilter.java +++ b/metafacture-mangling/src/main/java/org/metafacture/mangling/DuplicateObjectFilter.java @@ -39,6 +39,9 @@ public final class DuplicateObjectFilter extends DefaultObjectPipeThe separator must not be changed while processing a stream. * diff --git a/metafacture-mangling/src/main/java/org/metafacture/mangling/LiteralToObject.java b/metafacture-mangling/src/main/java/org/metafacture/mangling/LiteralToObject.java index 44f53b35a..059f0a53b 100644 --- a/metafacture-mangling/src/main/java/org/metafacture/mangling/LiteralToObject.java +++ b/metafacture-mangling/src/main/java/org/metafacture/mangling/LiteralToObject.java @@ -50,6 +50,9 @@ public final class LiteralToObject extends DefaultStreamPipe extends public static final String DEFAULT_LITERAL_NAME = "obj"; public static final String DEFAULT_RECORD_ID = ""; - private String literalName; - private String recordId; + private String literalName = DEFAULT_LITERAL_NAME; + private String recordId = DEFAULT_RECORD_ID; private int recordCount; + /** + * Creates an instance of {@link ObjectToLiteral}. + */ public ObjectToLiteral() { - setLiteralName(DEFAULT_LITERAL_NAME); - setRecordId(DEFAULT_RECORD_ID); - recordCount = 0; } + /** + * Sets the literal name. + * + * @param literalName the literal name + */ public void setLiteralName(final String literalName) { this.literalName = literalName; } + /** + * Sets the record ID. + * + * @param recordId the record ID + */ public void setRecordId(final String recordId) { this.recordId = recordId; } + /** + * Gets the literal name. + * + * @return the literal name + */ public String getLiteralName() { return literalName; } + /** + * Gets the record ID. + * + * @return the record ID + */ public String getRecordId() { return recordId; } diff --git a/metafacture-mangling/src/main/java/org/metafacture/mangling/RecordIdChanger.java b/metafacture-mangling/src/main/java/org/metafacture/mangling/RecordIdChanger.java index 6513784f7..43212622c 100644 --- a/metafacture-mangling/src/main/java/org/metafacture/mangling/RecordIdChanger.java +++ b/metafacture-mangling/src/main/java/org/metafacture/mangling/RecordIdChanger.java @@ -26,13 +26,13 @@ import org.metafacture.framework.helpers.DefaultStreamPipe; /** - * Replaces the record id with the value of a literal from the record. The name + * Replaces the record ID with the value of a literal from the record. The name * of the literal can be configured using {@link #setIdLiteral(String)}. *

    * If a record contains multiple matching literals, the value of the last - * literal is used as id. + * literal is used as ID. *

    - * This module can optionally remove records which do not have an id literal + * This module can optionally remove records which do not have an ID literal * from the stream. This is configured through the * {@link #setKeepRecordsWithoutIdLiteral(boolean)} parameter. *

    @@ -57,14 +57,14 @@ * end-record * }

    * - * By default, the id literals are removed from the record. This can be changed + * By default, the ID literals are removed from the record. This can be changed * through {@link #setKeepIdLiteral(boolean)}. * * @author Markus Michael Geipel * @author Christoph Böhme * */ -@Description("By default changes the record id to the value of the '_id' literal (if present). Use the contructor to choose another literal as id source.") +@Description("By default changes the record ID to the value of the '_id' literal (if present). Use the contructor to choose another literal as ID source.") @In(StreamReceiver.class) @Out(StreamReceiver.class) @FluxCommand("change-id") @@ -79,19 +79,23 @@ public final class RecordIdChanger extends DefaultStreamPipe { private boolean keepRecordsWithoutIdLiteral = true; private boolean keepIdLiteral; + /** + * Creates an instance of {@link RecordIdChanger}. + */ public RecordIdChanger() { } /** - * Sets the name of the literal that contains the new record id. This must be + * Sets the name of the literal that contains the new record ID. This must be * a qualified literal name including the entities in which the literal is * contained. *

    - * For instance, the id literal “metadata.id” matches only + * For instance, the ID literal “metadata.id” matches only * literals named “id” which are part of an entity named * “metadata”. *

    - * The default value is “{@value StandardEventNames#ID}”. + * The default value is + * {@value org.metafacture.framework.StandardEventNames#ID}. *

    * This parameter must only be changed between records otherwise the * behaviour of the module is undefined. @@ -102,20 +106,25 @@ public void setIdLiteral(final String idLiteral) { this.idLiteral = idLiteral; } + /** + * Gets the ID literal. + * + * @return the ID literal. + */ public String getIdLiteral() { return idLiteral; } /** - * Controls whether records without an id literal are kept in the stream or + * Controls whether records without an ID literal are kept in the stream or * removed from the stream. *

    - * By default records without an id literal are kept in the stream. + * By default records without an ID literal are kept in the stream. *

    * This parameter may be changed at any time it becomes effective with the * next end-record event. * - * @param keepRecordsWithoutIdLiteral true to keep records without id + * @param keepRecordsWithoutIdLiteral true to keep records without ID * literal, false to remove them */ public void setKeepRecordsWithoutIdLiteral( @@ -123,27 +132,37 @@ public void setKeepRecordsWithoutIdLiteral( this.keepRecordsWithoutIdLiteral = keepRecordsWithoutIdLiteral; } + /** + * Checks wether to keep records without ID literal. + * + * @return true if records without ID literal should be kept + */ public boolean getKeepRecordsWithoutIdLiteral() { return keepRecordsWithoutIdLiteral; } /** - * Controls whether the id literal is kept in the record after changing the - * record id. If a record contains multiple id literals, all of them are + * Controls whether the ID literal is kept in the record after changing the + * record ID. If a record contains multiple ID literals, all of them are * removed. *

    - * By default the id literal is removed from the stream. + * By default the ID literal is removed from the stream. *

    * This parameter must only be changed between records otherwise the * behaviour of the module is undefined. * - * @param keepIdLiteral true to keep id literals in records, false to + * @param keepIdLiteral true to keep ID literals in records, false to * remove them */ public void setKeepIdLiteral(final boolean keepIdLiteral) { this.keepIdLiteral = keepIdLiteral; } + /** + * Checks wether the ID literal should be kept. + * + * @return true if the ID literal should be kept + */ public boolean getKeepIdLiteral() { return keepIdLiteral; } diff --git a/metafacture-mangling/src/main/java/org/metafacture/mangling/RecordPathFilter.java b/metafacture-mangling/src/main/java/org/metafacture/mangling/RecordPathFilter.java index bba0e6210..44b017b60 100644 --- a/metafacture-mangling/src/main/java/org/metafacture/mangling/RecordPathFilter.java +++ b/metafacture-mangling/src/main/java/org/metafacture/mangling/RecordPathFilter.java @@ -38,43 +38,78 @@ public final class RecordPathFilter extends DefaultStreamPipe { private final EntityPathTracker entityPathTracker = new EntityPathTracker(); - private String path; - private String recordIdFormat; + private String path = ROOT_PATH; + private String recordIdFormat = DEFAULT_RECORD_ID_FORMAT; private String recordIdentifier; private boolean inMatch; private boolean recordStarted; private int recordCount; + /** + * Creates an instance of {@link RecordPathFilter}. + */ public RecordPathFilter() { - this(ROOT_PATH); } + /** + * Constructs a RecordPathFilter with a given path. + * + * @param path the name of the path + */ public RecordPathFilter(final String path) { - resetRecord(); setPath(path); - setRecordIdFormat(DEFAULT_RECORD_ID_FORMAT); } + /** + * Sets the entity separator. + * + * @param entitySeparator the entity separator + */ public void setEntitySeparator(final String entitySeparator) { entityPathTracker.setEntitySeparator(entitySeparator); } + /** + * Get the entity separator. + * + * @return the entity separator + */ public String getEntitySeparator() { return entityPathTracker.getEntitySeparator(); } + /** + * Sets the path. + * + * @param path the path + */ public void setPath(final String path) { this.path = path; } + /** + * Gets the path. + * + * @return the path + */ public String getPath() { return path; } + /** + * Sets the record ID format. + * + * @param recordIdFormat the record ID format + */ public void setRecordIdFormat(final String recordIdFormat) { this.recordIdFormat = recordIdFormat; } + /** + * Gets the record ID format. + * + * @return the record ID format + */ public String getRecordIdFormat() { return recordIdFormat; } diff --git a/metafacture-mangling/src/main/java/org/metafacture/mangling/RecordToEntity.java b/metafacture-mangling/src/main/java/org/metafacture/mangling/RecordToEntity.java index fac5938df..b1c0e18e0 100644 --- a/metafacture-mangling/src/main/java/org/metafacture/mangling/RecordToEntity.java +++ b/metafacture-mangling/src/main/java/org/metafacture/mangling/RecordToEntity.java @@ -48,16 +48,24 @@ public class RecordToEntity extends ForwardingStreamPipe { private String entityName = DEFAULT_ENTITY_NAME; private String idLiteralName; + /** + * Creates an instance of {@link RecordToEntity}. + */ public RecordToEntity() { } + /** + * Gets the entity name. + * + * @return the entity name + */ public String getEntityName() { return entityName; } /** * Sets the name of the entity which replaces the record. The default name is - * "{@value DEFAULT_ENTITY_NAME}". + * {@value DEFAULT_ENTITY_NAME}. * *

    The entity name may be changed while processing an event stream. It * becomes effective with the next record. diff --git a/metafacture-mangling/src/main/java/org/metafacture/mangling/StreamEventDiscarder.java b/metafacture-mangling/src/main/java/org/metafacture/mangling/StreamEventDiscarder.java index f94f88589..0500bb5ce 100644 --- a/metafacture-mangling/src/main/java/org/metafacture/mangling/StreamEventDiscarder.java +++ b/metafacture-mangling/src/main/java/org/metafacture/mangling/StreamEventDiscarder.java @@ -49,6 +49,9 @@ public class StreamEventDiscarder implements StreamPipe { private EnumSet discardedEvents = EnumSet.noneOf(EventType.class); + /** + * Creates an instance of {@link StreamEventDiscarder}. + */ public StreamEventDiscarder() { } diff --git a/metafacture-mangling/src/main/java/org/metafacture/mangling/StreamFlattener.java b/metafacture-mangling/src/main/java/org/metafacture/mangling/StreamFlattener.java index aabf055f5..d2022c440 100644 --- a/metafacture-mangling/src/main/java/org/metafacture/mangling/StreamFlattener.java +++ b/metafacture-mangling/src/main/java/org/metafacture/mangling/StreamFlattener.java @@ -62,14 +62,27 @@ public final class StreamFlattener extends DefaultStreamPipe { private final EntityPathTracker pathTracker = new EntityPathTracker(); + /** + * Creates an instance of {@link StreamFlattener}. + */ public StreamFlattener() { setEntityMarker(DEFAULT_ENTITY_MARKER); } + /** + * Gets the entity marker. + * + * @return the entity marker + */ public String getEntityMarker() { return pathTracker.getEntitySeparator(); } + /** + * Sets the entity marker. + * + * @param entityMarker the entity marker + */ public void setEntityMarker(final String entityMarker) { pathTracker.setEntitySeparator(entityMarker); } @@ -106,10 +119,20 @@ public void literal(final String name, final String value) { getReceiver().literal(pathTracker.getCurrentPathWith(name), value); } + /** + * Gets the current entity name. + * + * @return the current entity name + */ public String getCurrentEntityName() { return pathTracker.getCurrentEntityName(); } + /** + * Gets the current path. + * + * @return the current path + */ public String getCurrentPath() { return pathTracker.getCurrentPath(); } diff --git a/metafacture-monitoring/src/main/java/org/metafacture/monitoring/ObjectBatchLogger.java b/metafacture-monitoring/src/main/java/org/metafacture/monitoring/ObjectBatchLogger.java index 2554eedc8..fe6b89730 100644 --- a/metafacture-monitoring/src/main/java/org/metafacture/monitoring/ObjectBatchLogger.java +++ b/metafacture-monitoring/src/main/java/org/metafacture/monitoring/ObjectBatchLogger.java @@ -50,9 +50,9 @@ public final class ObjectBatchLogger extends DefaultObjectPipe vars = new HashMap(); private final String format; @@ -61,20 +61,39 @@ public final class ObjectBatchLogger extends DefaultObjectPipe vars) { + /** + * Constructs an ObjectBatchLogger with a format and a map of variables. + * + * @param format a format + * @param vars a map of variables + */ + ObjectBatchLogger(final String format, final Map vars) { this.format = format; this.vars.putAll(vars); } + /** + * Sets the batch size. + * + * @param batchSize the batch size + */ public void setBatchSize(final int batchSize) { this.batchSize = batchSize; } diff --git a/metafacture-monitoring/src/main/java/org/metafacture/monitoring/ObjectLogger.java b/metafacture-monitoring/src/main/java/org/metafacture/monitoring/ObjectLogger.java index 9ba9bab27..56865315f 100644 --- a/metafacture-monitoring/src/main/java/org/metafacture/monitoring/ObjectLogger.java +++ b/metafacture-monitoring/src/main/java/org/metafacture/monitoring/ObjectLogger.java @@ -45,10 +45,19 @@ public final class ObjectLogger private final String logPrefix; + /** + * Creates an instance of {@link ObjectLogger}. + */ public ObjectLogger() { this(""); } + /** + * Creates an instance of {@link ObjectLogger} by a given prefix of the log + * messages. + * + * @param logPrefix the prefix of the log messages + */ public ObjectLogger(final String logPrefix) { this.logPrefix = logPrefix; } diff --git a/metafacture-monitoring/src/main/java/org/metafacture/monitoring/ObjectTimer.java b/metafacture-monitoring/src/main/java/org/metafacture/monitoring/ObjectTimer.java index 40021a5c5..52f565006 100644 --- a/metafacture-monitoring/src/main/java/org/metafacture/monitoring/ObjectTimer.java +++ b/metafacture-monitoring/src/main/java/org/metafacture/monitoring/ObjectTimer.java @@ -38,10 +38,18 @@ public final class ObjectTimer extends TimerBase> implements ObjectPipe> { + /** + * Creates an instance of {@link ObjectTimer}. + */ public ObjectTimer() { this(""); } + /** + * Creates an instance of {@link ObjectTimer} by a given log messages prefix. + * + * @param logPrefix the prefix of the log messages + */ public ObjectTimer(final String logPrefix) { super(logPrefix); } diff --git a/metafacture-monitoring/src/main/java/org/metafacture/monitoring/StreamBatchLogger.java b/metafacture-monitoring/src/main/java/org/metafacture/monitoring/StreamBatchLogger.java index 53cca5f53..2536f8d34 100644 --- a/metafacture-monitoring/src/main/java/org/metafacture/monitoring/StreamBatchLogger.java +++ b/metafacture-monitoring/src/main/java/org/metafacture/monitoring/StreamBatchLogger.java @@ -46,15 +46,13 @@ public final class StreamBatchLogger extends ForwardingStreamPipe { public static final String BATCH_COUNT_VAR = "batches"; public static final String BATCH_SIZE_VAR = "batchSize"; public static final String TOTAL_RECORD_COUNT_VAR = "totalRecords"; + public static final String DEFAULT_FORMAT = "records processed: ${totalRecords}"; public static final long DEFAULT_BATCH_SIZE = 1000; private static final Logger LOG = LoggerFactory.getLogger(StreamBatchLogger.class); - private static final String DEFAULT_FORMAT = - "records processed: ${totalRecords}"; - private final Map vars = new HashMap<>(); private final String format; @@ -62,31 +60,66 @@ public final class StreamBatchLogger extends ForwardingStreamPipe { private long recordCount; private long batchCount; + /** + * Creates an instance of {@link StreamBatchLogger} by a given format. The + * default format: {@value #DEFAULT_FORMAT} + */ public StreamBatchLogger() { this.format = DEFAULT_FORMAT; } + /** + * Creates an instance of {@link StreamBatchLogger} by a given format. + * + * @param format the format + */ public StreamBatchLogger(final String format) { this.format = format; } + /** + * Constructs a StreamBatchLogger with a format and a map of variables. + * + * @param format a format + * @param vars a map of variables + */ public StreamBatchLogger(final String format, final Map vars) { this.format = format; this.vars.putAll(vars); } + /** + * Sets the batch size. + * + * @param batchSize the batch size + */ public void setBatchSize(final int batchSize) { this.batchSize = batchSize; } + /** + * Gets the batch size. + * + * @return the batch size + */ public long getBatchSize() { return batchSize; } + /** + * Gets the batch count. + * + * @return the batch count + */ public long getBatchCount() { return batchCount; } + /** + * Gets the record count. + * + * @return the record count + */ public long getRecordCount() { return recordCount; } diff --git a/metafacture-monitoring/src/main/java/org/metafacture/monitoring/StreamLogger.java b/metafacture-monitoring/src/main/java/org/metafacture/monitoring/StreamLogger.java index db6960e9a..071c97d63 100644 --- a/metafacture-monitoring/src/main/java/org/metafacture/monitoring/StreamLogger.java +++ b/metafacture-monitoring/src/main/java/org/metafacture/monitoring/StreamLogger.java @@ -45,10 +45,19 @@ public final class StreamLogger private final String logPrefix; + /** + * Creates an instance of {@link StreamLogger}. + */ public StreamLogger() { this(""); } + /** + * Creates an instance of {@link StreamLogger} by a given prefix used when log + * messages. + * + * @param logPrefix the prefix of the log messages + */ public StreamLogger(final String logPrefix) { this.logPrefix = logPrefix; } diff --git a/metafacture-monitoring/src/main/java/org/metafacture/monitoring/StreamTimer.java b/metafacture-monitoring/src/main/java/org/metafacture/monitoring/StreamTimer.java index 9a6690873..bfe59559f 100644 --- a/metafacture-monitoring/src/main/java/org/metafacture/monitoring/StreamTimer.java +++ b/metafacture-monitoring/src/main/java/org/metafacture/monitoring/StreamTimer.java @@ -35,10 +35,19 @@ public final class StreamTimer extends TimerBase implements StreamPipe { + /** + * Creates an instance of {@link StreamTimer}. + */ public StreamTimer() { this(""); } + /** + * Creates an instance of {@link StreamTimer} by a given prefix used when log + * messages. + * + * @param logPrefix the prefix of the log messages + */ public StreamTimer(final String logPrefix) { super(logPrefix); } diff --git a/metafacture-monitoring/src/main/java/org/metafacture/monitoring/TimerBase.java b/metafacture-monitoring/src/main/java/org/metafacture/monitoring/TimerBase.java index bfaeb9e2a..02201201d 100644 --- a/metafacture-monitoring/src/main/java/org/metafacture/monitoring/TimerBase.java +++ b/metafacture-monitoring/src/main/java/org/metafacture/monitoring/TimerBase.java @@ -51,6 +51,11 @@ public final S setReceiver(final S newReceiver) { return newReceiver; } + /** + * Gets the receiver. + * + * @return the receiver + */ public final R getReceiver() { return receiver; } diff --git a/metafacture-plumbing/src/main/java/org/metafacture/plumbing/IdentityStreamPipe.java b/metafacture-plumbing/src/main/java/org/metafacture/plumbing/IdentityStreamPipe.java index 89f6a26f5..e68909440 100644 --- a/metafacture-plumbing/src/main/java/org/metafacture/plumbing/IdentityStreamPipe.java +++ b/metafacture-plumbing/src/main/java/org/metafacture/plumbing/IdentityStreamPipe.java @@ -34,6 +34,9 @@ @FluxCommand("pass-through") public final class IdentityStreamPipe extends ForwardingStreamPipe { + /** + * Creates an instance of {@link IdentityStreamPipe}. + */ public IdentityStreamPipe() { } diff --git a/metafacture-plumbing/src/main/java/org/metafacture/plumbing/ObjectTee.java b/metafacture-plumbing/src/main/java/org/metafacture/plumbing/ObjectTee.java index 53e1bee0f..41fbfac8b 100644 --- a/metafacture-plumbing/src/main/java/org/metafacture/plumbing/ObjectTee.java +++ b/metafacture-plumbing/src/main/java/org/metafacture/plumbing/ObjectTee.java @@ -38,6 +38,9 @@ @FluxCommand("object-tee") public final class ObjectTee extends DefaultTee> implements ObjectPipe> { + /** + * Creates an instance of {@link ObjectTee}. + */ public ObjectTee() { } diff --git a/metafacture-plumbing/src/main/java/org/metafacture/plumbing/StreamBatchMerger.java b/metafacture-plumbing/src/main/java/org/metafacture/plumbing/StreamBatchMerger.java index 7b5245c3e..c422ab23a 100644 --- a/metafacture-plumbing/src/main/java/org/metafacture/plumbing/StreamBatchMerger.java +++ b/metafacture-plumbing/src/main/java/org/metafacture/plumbing/StreamBatchMerger.java @@ -45,6 +45,9 @@ public final class StreamBatchMerger extends DefaultStreamPipe { private long batchSize = DEFAULT_BATCH_SIZE; private long recordCount; + /** + * Creates an instance of {@link StreamBatchMerger}. + */ public StreamBatchMerger() { } @@ -61,6 +64,11 @@ public void setBatchSize(final long batchSize) { this.batchSize = batchSize; } + /** + * Gets the batch size. + * + * @return the batch size. + */ public long getBatchSize() { return batchSize; } diff --git a/metafacture-plumbing/src/main/java/org/metafacture/plumbing/StreamMerger.java b/metafacture-plumbing/src/main/java/org/metafacture/plumbing/StreamMerger.java index b6876f46c..ee6823988 100644 --- a/metafacture-plumbing/src/main/java/org/metafacture/plumbing/StreamMerger.java +++ b/metafacture-plumbing/src/main/java/org/metafacture/plumbing/StreamMerger.java @@ -43,6 +43,9 @@ public final class StreamMerger extends DefaultStreamPipe { private boolean hasRecordsReceived; private String currentId = ""; + /** + * Creates an instance of {@link StreamMerger}. + */ public StreamMerger() { } diff --git a/metafacture-plumbing/src/main/java/org/metafacture/plumbing/StreamTee.java b/metafacture-plumbing/src/main/java/org/metafacture/plumbing/StreamTee.java index cc82f257c..9dc76b1ae 100644 --- a/metafacture-plumbing/src/main/java/org/metafacture/plumbing/StreamTee.java +++ b/metafacture-plumbing/src/main/java/org/metafacture/plumbing/StreamTee.java @@ -36,6 +36,9 @@ @FluxCommand("stream-tee") public final class StreamTee extends DefaultTee implements StreamPipe { + /** + * Creates an instance of {@link StreamTee}. + */ public StreamTee() { } diff --git a/metafacture-plumbing/src/main/java/org/metafacture/plumbing/XmlTee.java b/metafacture-plumbing/src/main/java/org/metafacture/plumbing/XmlTee.java index cae1bed57..1ea7059b7 100644 --- a/metafacture-plumbing/src/main/java/org/metafacture/plumbing/XmlTee.java +++ b/metafacture-plumbing/src/main/java/org/metafacture/plumbing/XmlTee.java @@ -44,6 +44,9 @@ @FluxCommand("xml-tee") public final class XmlTee extends DefaultTee implements XmlPipe { + /** + * Creates an instance of {@link XmlTee}. + */ public XmlTee() { } diff --git a/metafacture-runner/src/main/java/org/metafacture/runner/Flux.java b/metafacture-runner/src/main/java/org/metafacture/runner/Flux.java index c10adffdd..9d889b450 100644 --- a/metafacture-runner/src/main/java/org/metafacture/runner/Flux.java +++ b/metafacture-runner/src/main/java/org/metafacture/runner/Flux.java @@ -47,6 +47,13 @@ private Flux() { // No instances allowed } + /** + * Runs the Flux. + * + * @param args the pathname of the flux file to run + * @throws IOException if an I/O error occurs + * @throws RecognitionException if an ANTLR error occurs + */ public static void main(final String[] args) throws IOException, RecognitionException { loadCustomJars(); diff --git a/metafacture-runner/src/main/java/org/metafacture/runner/util/DirectoryClassLoader.java b/metafacture-runner/src/main/java/org/metafacture/runner/util/DirectoryClassLoader.java index 1116928d6..2620dbcb1 100644 --- a/metafacture-runner/src/main/java/org/metafacture/runner/util/DirectoryClassLoader.java +++ b/metafacture-runner/src/main/java/org/metafacture/runner/util/DirectoryClassLoader.java @@ -45,10 +45,22 @@ public boolean accept(final File dir, final String name) { } }; + /** + * Creates an instance of {@link DirectoryClassLoader} by a given parent + * ClassLoader. + * + * @param parent the {@link ClassLoader} + */ public DirectoryClassLoader(final ClassLoader parent) { super(new URL[0], parent); } + /** + * Adds a directory and appends all jars and classes of that directory to the + * list of URLs to search for classes and resources. + * + * @param dir the directory as File to be added + */ public void addDirectory(final File dir) { for (final File file : dir.listFiles(JAR_AND_CLASS_FILTER)) { try { diff --git a/metafacture-scripting/src/main/java/org/metafacture/scripting/JScriptObjectPipe.java b/metafacture-scripting/src/main/java/org/metafacture/scripting/JScriptObjectPipe.java index 80f681cb1..223e9cd11 100644 --- a/metafacture-scripting/src/main/java/org/metafacture/scripting/JScriptObjectPipe.java +++ b/metafacture-scripting/src/main/java/org/metafacture/scripting/JScriptObjectPipe.java @@ -47,10 +47,21 @@ public final class JScriptObjectPipe extends DefaultObjectPipe metrics = new ArrayList(); + /** + * Constructs a CooccurrenceMetricCalculator with given metrics. + * + * @param allMetrics the Metrics as a comma separated String + */ public CooccurrenceMetricCalculator(final String allMetrics) { setMinCount(MIN_COUNT); for (final String metric : allMetrics.split("\\s*,\\s*")) { @@ -105,6 +110,11 @@ public CooccurrenceMetricCalculator(final String allMetrics) { } } + /** + * Constructs a CooccurrenceMetricCalculator with given metrics. + * + * @param metrics the Metrics as an array + */ public CooccurrenceMetricCalculator(final Metric... metrics) { setMinCount(MIN_COUNT); for (final Metric metric : metrics) { diff --git a/metafacture-statistics/src/main/java/org/metafacture/statistics/Counter.java b/metafacture-statistics/src/main/java/org/metafacture/statistics/Counter.java index 43b383fb4..b82387cef 100644 --- a/metafacture-statistics/src/main/java/org/metafacture/statistics/Counter.java +++ b/metafacture-statistics/src/main/java/org/metafacture/statistics/Counter.java @@ -43,6 +43,9 @@ public final class Counter extends DefaultStreamPipe { private int numEntities; private int numLiterals; + /** + * Creates an instance of {@link Counter}. + */ public Counter() { } diff --git a/metafacture-statistics/src/main/java/org/metafacture/statistics/Histogram.java b/metafacture-statistics/src/main/java/org/metafacture/statistics/Histogram.java index 56e99ba03..aad68b840 100644 --- a/metafacture-statistics/src/main/java/org/metafacture/statistics/Histogram.java +++ b/metafacture-statistics/src/main/java/org/metafacture/statistics/Histogram.java @@ -29,17 +29,21 @@ */ public final class Histogram extends DefaultStreamReceiver { - private final Map histogram = new HashMap(); + private final Map histogram = new HashMap<>(); private boolean countEntities; private boolean countLiterals; private String countField; + /** + * Creates an instance of {@link Histogram}. + */ public Histogram() { } /** - * Initialises the module with a countField. + * Creates an instance of {@link Histogram} with a field whose content is + * counted. * * @param countField name of the field whose content is counted */ @@ -47,30 +51,65 @@ public Histogram(final String countField) { setCountField(countField); } + /** + * Gets the histogram. + * + * @return the histogram + */ public Map getHistogram() { return Collections.unmodifiableMap(histogram); } + /** + * Checks wether entities are counted. + * + * @return true if entities are counted. + */ public boolean isCountEntities() { return countEntities; } + /** + * Flags wether entities should be counted. + * + * @param countEntities true if entities should be counted. + */ public void setCountEntities(final boolean countEntities) { this.countEntities = countEntities; } + /** + * Checks wether literals are counted. + * + * @return true if literals are counted + */ public boolean isCountLiterals() { return countLiterals; } + /** + * Flags wether to count literals. + * + * @param countLiterals true if literals should be counted + */ public void setCountLiterals(final boolean countLiterals) { this.countLiterals = countLiterals; } + /** + * Gets the name of the field whose content is counted. + * + * @return the name of the field whose content is counted + */ public String getCountField() { return countField; } + /** + * Set the name of the field whose content is counted. + * + * @param countField the name of the field whose content is counted + */ public void setCountField(final String countField) { this.countField = countField; } diff --git a/metafacture-statistics/src/main/java/org/metafacture/statistics/UniformSampler.java b/metafacture-statistics/src/main/java/org/metafacture/statistics/UniformSampler.java index 8af90b332..51cad1b0e 100644 --- a/metafacture-statistics/src/main/java/org/metafacture/statistics/UniformSampler.java +++ b/metafacture-statistics/src/main/java/org/metafacture/statistics/UniformSampler.java @@ -49,19 +49,39 @@ public final class UniformSampler extends private long count; + /** + * Creates an instance of {@link UniformSampler} with a given sample size. + * + * @param sampleSize the size of the sample + */ public UniformSampler(final int sampleSize) { this.sampleSize = sampleSize; sample = new ArrayList(sampleSize); } + /** + * Creates an instance of {@link UniformSampler} with a given sample size. + * + * @param sampleSize the sample size + */ public UniformSampler(final String sampleSize) { this(Integer.parseInt(sampleSize)); } + /** + * Gets the sample size. + * + * @return the sample size. + */ public int getSampleSize() { return sampleSize; } + /** + * Sets the seed. + * + * @param seed the seed. + */ public void setSeed(final long seed) { random.setSeed(seed); } diff --git a/metafacture-strings/src/main/java/org/metafacture/strings/LineRecorder.java b/metafacture-strings/src/main/java/org/metafacture/strings/LineRecorder.java index 190a07d48..97101dfa4 100644 --- a/metafacture-strings/src/main/java/org/metafacture/strings/LineRecorder.java +++ b/metafacture-strings/src/main/java/org/metafacture/strings/LineRecorder.java @@ -43,9 +43,17 @@ public final class LineRecorder implements ObjectPipe receiver; private boolean isClosed; + /** + * Creates an instance of {@link LineRecorder}. + */ public LineRecorder() { } + /** + * Sets the record marker regexp. + * + * @param regexp the regexp + */ public void setRecordMarkerRegexp(final String regexp) { recordMarkerRegexp = regexp; } diff --git a/metafacture-strings/src/main/java/org/metafacture/strings/LineSplitter.java b/metafacture-strings/src/main/java/org/metafacture/strings/LineSplitter.java index 40840fb14..d23823ec7 100644 --- a/metafacture-strings/src/main/java/org/metafacture/strings/LineSplitter.java +++ b/metafacture-strings/src/main/java/org/metafacture/strings/LineSplitter.java @@ -40,6 +40,9 @@ public final class LineSplitter extends DefaultObjectPipe - * If the pattern contains a capture group named "{@value - * #ID_CAPTURE_GROUP}", the first match of this group will be used as - * record identifier. If there is no such capture group or if it does not - * match, the empty string is used as record identifier. + * If the pattern contains a capture group named {@value #ID_CAPTURE_GROUP}, + * the first match of this group will be used as record identifier. If there + * is no such capture group or if it does not match, the empty string is used + * as record identifier. *

    * Example: The regex *

    {@literal
    @@ -93,6 +93,11 @@ public final class RegexDecoder extends DefaultObjectPipe
          * This parameter may be changed at any time. It becomes immediately
          * effective and affects all subsequently received start-record
          * events.
          *
    -     * @param normalizeIds if true identifiers are normalised, otherwise not.
    +     * @param normalizeIds if true identifiers are normalized, otherwise not.
          */
         public void setNormalizeIds(final boolean normalizeIds) {
             this.normalizeIds = normalizeIds;
         }
     
    +    /**
    +     * Checks wether IDs should be normalized.
    +     *
    +     * @return true if IDs should be normalized
    +     */
         public boolean getNormalizeIds() {
             return normalizeIds;
         }
     
         /**
    -     * Controls whether to normalise literal and entity names. By default these
    -     * are not normalised.
    +     * Controls whether to normalize literal and entity names. By default these
    +     * are not normalized.
          * 

    * This parameter may be changed at any time. It becomes immediately * effective and affects all subsequently received start-entity and * literal events. * - * @param normalizeKeys if true literal and entity names are normalised, + * @param normalizeKeys if true literal and entity names are normalized, * otherwise not. */ public void setNormalizeKeys(final boolean normalizeKeys) { this.normalizeKeys = normalizeKeys; } + /** + * Checks wether keys should be normalized. + * + * @return true if the keys should be normalized + */ public boolean getNormalizeKeys() { return normalizeKeys; } /** * Controls whether to normalise literal values. By default these are - * normalised. + * normalized. *

    * This parameter may be changed at any time. It becomes immediately * effective and affects all subsequently received literal events. * - * @param normalizeValues if true literal values are normalised, otherwise + * @param normalizeValues if true literal values are normalized, otherwise * not. */ public void setNormalizeValues(final boolean normalizeValues) { this.normalizeValues = normalizeValues; } + /** + * Checks wether values should be normalized. + * + * @return true if values should be normalized + */ public boolean getNormalizeValues() { return normalizeValues; } @@ -131,6 +149,11 @@ public void setNormalizationForm( this.normalizationForm = normalizationForm; } + /** + * Gets the normalization form. + * + * @return the {@link java.text.Normalizer.Form} + */ public Normalizer.Form getNormalizationForm() { return normalizationForm; } diff --git a/metafacture-strings/src/main/java/org/metafacture/strings/StringConcatenator.java b/metafacture-strings/src/main/java/org/metafacture/strings/StringConcatenator.java index 64d727c02..81d9bffd2 100644 --- a/metafacture-strings/src/main/java/org/metafacture/strings/StringConcatenator.java +++ b/metafacture-strings/src/main/java/org/metafacture/strings/StringConcatenator.java @@ -19,16 +19,18 @@ import org.metafacture.framework.ObjectReceiver; /** - * concatenetes all recieved Strings + * Concatenates all received Strings. * * @author markus geipel - * */ public final class StringConcatenator implements ObjectReceiver { private StringBuilder builder = new StringBuilder(); private String separator = ""; + /** + * Creates an instance of {@link StringConcatenator}. + */ public StringConcatenator() { } @@ -37,6 +39,11 @@ public void resetStream() { reset(); } + /** + * Sets a separator. + * + * @param separator the separator + */ public void setSeparator(final String separator) { this.separator = separator; } @@ -52,10 +59,18 @@ public void process(final String obj) { builder.append(obj); } + /** + * Resets the content. + */ public void reset() { builder = new StringBuilder(); } + /** + * Gets the string. + * + * @return the string + */ public String getString() { return builder.toString(); } diff --git a/metafacture-strings/src/main/java/org/metafacture/strings/StringDecoder.java b/metafacture-strings/src/main/java/org/metafacture/strings/StringDecoder.java index 85a0c9585..cac25605e 100644 --- a/metafacture-strings/src/main/java/org/metafacture/strings/StringDecoder.java +++ b/metafacture-strings/src/main/java/org/metafacture/strings/StringDecoder.java @@ -39,9 +39,8 @@ public final class StringDecoder extends DefaultObjectPipe> { /** - * determines whether string is split by the regexp or parts matching the - * regexp are extracted - * + * Determines whether the string is split by the regexp or parts matching the + * regexp are extracted. */ public enum Mode { SPLIT, EXTRACT @@ -51,10 +50,20 @@ public enum Mode { private final Pattern pattern; + /** + * Creates an instance of {@link StringDecoder} by a given pattern. + * + * @param pattern the pattern + */ public StringDecoder(final String pattern) { this.pattern = Pattern.compile(pattern); } + /** + * Sets the Mode. + * + * @param mode the {@link Mode} + */ public void setMode(final Mode mode) { this.mode = mode; } diff --git a/metafacture-strings/src/main/java/org/metafacture/strings/StringFilter.java b/metafacture-strings/src/main/java/org/metafacture/strings/StringFilter.java index c91d026d2..2bb6f065b 100644 --- a/metafacture-strings/src/main/java/org/metafacture/strings/StringFilter.java +++ b/metafacture-strings/src/main/java/org/metafacture/strings/StringFilter.java @@ -33,7 +33,7 @@ * @author Christoph Böhme * */ -@Description("Only forwards records which match (or do not match) a regular expression given in the constructor") +@Description("Only forwards records which match (or do not match) a regular expression.") @In(String.class) @Out(String.class) @FluxCommand("filter-strings") @@ -43,18 +43,38 @@ public final class StringFilter extends private final Matcher matcher; private boolean passMatches = true; + /** + * Creates an instance of {@link StringFilter} by a given pattern. + * + * @param pattern the pattern + */ public StringFilter(final String pattern) { this.matcher = Pattern.compile(pattern).matcher(""); } + /** + * Gets the pattern. + * + * @return the pattern + */ public String getPattern() { return matcher.pattern().pattern(); } + /** + * Checks wether matches are passed. + * + * @return true if matches should pass + */ public boolean isPassMatches() { return passMatches; } + /** + * Flags wether to pass matches or, inversely, pass everything but the matches. + * + * @param passMatches true if matches should pass, otherwise false + */ public void setPassMatches(final boolean passMatches) { this.passMatches = passMatches; } diff --git a/metafacture-strings/src/main/java/org/metafacture/strings/StringMatcher.java b/metafacture-strings/src/main/java/org/metafacture/strings/StringMatcher.java index f0c791310..f4b2fa260 100644 --- a/metafacture-strings/src/main/java/org/metafacture/strings/StringMatcher.java +++ b/metafacture-strings/src/main/java/org/metafacture/strings/StringMatcher.java @@ -41,21 +41,44 @@ public final class StringMatcher extends DefaultObjectPipe> { + /** + * Creates an instance of {@link StringReader}. + */ public StringReader() { } diff --git a/metafacture-strings/src/main/java/org/metafacture/strings/UnicodeNormalizer.java b/metafacture-strings/src/main/java/org/metafacture/strings/UnicodeNormalizer.java index 8163bb18b..0f9bce614 100644 --- a/metafacture-strings/src/main/java/org/metafacture/strings/UnicodeNormalizer.java +++ b/metafacture-strings/src/main/java/org/metafacture/strings/UnicodeNormalizer.java @@ -47,6 +47,9 @@ public final class UnicodeNormalizer extends DefaultObjectPipe> implements MemoryWarningSystem.Listener { /** - * specifies the comparator + * The comparators. */ public enum Compare { SUBJECT, PREDICATE, OBJECT, ALL } /** - * sort order - * + * The sort orders. */ public enum Order { INCREASING { @@ -62,19 +61,29 @@ public int order(final int indicator) { return -indicator; } }; + + /** + * Gets the indicator. If order is decreasing the the indicator is negativ, if + * order is increasing it's positive. + * + * @param indicator the indicator + * @return the indicator dependent of the order + */ public abstract int order(int indicator); } private final List buffer = new ArrayList<>(); - private final List tempFiles; + private final List tempFiles = new ArrayList<>(); private Compare compare = Compare.SUBJECT; private Order order = Order.INCREASING; private boolean numeric; private volatile boolean memoryLow; - public AbstractTripleSort() { + /** + * Constructs an AbstractTripleSort. Calls {@link MemoryWarningSystem}. + */ + protected AbstractTripleSort() { MemoryWarningSystem.addListener(this); - tempFiles = new ArrayList<>(); // Initialized here to let the compiler enforce the call to super() in subclasses. } @Override @@ -186,14 +195,35 @@ protected void onFinished() { protected abstract void sortedTriple(Triple namedValue); + /** + * Creates the Comparator. + * + * @return a Comparator of type Triple + */ public final Comparator createComparator() { return createComparator(compare, order, numeric); } + /** + * Creates an alphanumeric Comparator. + * + * @param compare one of {@link Compare} + * @param order the {@link Order} + * @return a Comparator of type Triple + */ public static Comparator createComparator(final Compare compare, final Order order) { return createComparator(compare, order, false); } + /** + * Creates a Comparator. + * + * @param compare one of {@link #Compare} + * @param order the {@link #Order} + * @param numeric "true" if comparison should be numeric. "false" if comparison + * should be alphanumeric. Defaults to "false". + * @return a Comparator of type Triple + */ private static Comparator createComparator(final Compare compare, final Order order, final boolean numeric) { final Function tripleFunction; switch (compare) { diff --git a/metafacture-triples/src/main/java/org/metafacture/triples/SortedTripleFileFacade.java b/metafacture-triples/src/main/java/org/metafacture/triples/SortedTripleFileFacade.java index 00490bd6b..9c29f5e39 100644 --- a/metafacture-triples/src/main/java/org/metafacture/triples/SortedTripleFileFacade.java +++ b/metafacture-triples/src/main/java/org/metafacture/triples/SortedTripleFileFacade.java @@ -27,6 +27,8 @@ import java.io.ObjectInputStream; /** + * A SortedTripleFileFacade created with a file. Reads a Triple from the file. + * * @author markus geipel * */ @@ -37,12 +39,24 @@ public final class SortedTripleFileFacade { private Triple triple; private boolean empty; + /** + * Constructs a SortedTripleFileFacade with a file. Reads a Triple from the + * file. + * + * @param file the File to load Triples from + * @throws IOException if Triple can't be loaded + */ public SortedTripleFileFacade(final File file) throws IOException { this.file = file; in = new ObjectInputStream(new BufferedInputStream(new FileInputStream(file), BUFFERSIZE)); next(); } + /** + * Checks wether SortedTripleFileFacade is empty. + * + * @return true if SortedTripleFileFacade is empty. + */ public boolean isEmpty() { return empty; } @@ -58,6 +72,10 @@ private void next() throws IOException { } } + /** + * Closes the {@link ObjectInputStream} and deletes the {@link #file} if it + * exists. + */ public void close() { try { in.close(); @@ -70,6 +88,11 @@ public void close() { } } + /** + * Peeks at a Triple at the top of the stack. + * + * @return the Triple at the top of the stack + */ public Triple peek() { if (isEmpty()) { return null; @@ -77,6 +100,12 @@ public Triple peek() { return triple; } + /** + * Pops a Triple from the stack. + * + * @return the Triple at the top of the stack. + * @throws IOException if the Triple can't be loaded + */ public Triple pop() throws IOException { final Triple nextTriple = peek(); next(); diff --git a/metafacture-triples/src/main/java/org/metafacture/triples/StreamToTriples.java b/metafacture-triples/src/main/java/org/metafacture/triples/StreamToTriples.java index 727245cc9..6173c7623 100644 --- a/metafacture-triples/src/main/java/org/metafacture/triples/StreamToTriples.java +++ b/metafacture-triples/src/main/java/org/metafacture/triples/StreamToTriples.java @@ -83,21 +83,44 @@ public final class StreamToTriples extends DefaultStreamPipe comparator; + /** + * Creates an instance of {@link TripleCount}. + */ public TripleCount() { } @@ -65,6 +68,11 @@ protected void sortedTriple(final Triple triple) { } } + /** + * Flags wether predicates should be counted. + * + * @param countPredicate true if predicates should be counted + */ public void setCountPredicate(final String countPredicate) { this.countPredicate = countPredicate; } @@ -93,6 +101,11 @@ private void writeResult() { } } + /** + * Compare triples by subject, predicate or object. + * + * @param countBy the {@link AbstractTripleSort.Compare} to sort by + */ public void setCountBy(final Compare countBy) { setCompare(countBy); } diff --git a/metafacture-triples/src/main/java/org/metafacture/triples/TripleFilter.java b/metafacture-triples/src/main/java/org/metafacture/triples/TripleFilter.java index 68743441c..901f86e6d 100644 --- a/metafacture-triples/src/main/java/org/metafacture/triples/TripleFilter.java +++ b/metafacture-triples/src/main/java/org/metafacture/triples/TripleFilter.java @@ -48,37 +48,80 @@ public final class TripleFilter extends DefaultObjectPipe { private Charset encoding = StandardCharsets.UTF_8; + /** + * Creates an instance of {@link TripleObjectWriter} with a given directory to + * write to. + * + * @param baseDir the path to the base directory + */ public TripleObjectWriter(final String baseDir) { this.baseDir = Paths.get(baseDir); } diff --git a/metafacture-triples/src/main/java/org/metafacture/triples/TripleReader.java b/metafacture-triples/src/main/java/org/metafacture/triples/TripleReader.java index 935d6467d..fc0711590 100644 --- a/metafacture-triples/src/main/java/org/metafacture/triples/TripleReader.java +++ b/metafacture-triples/src/main/java/org/metafacture/triples/TripleReader.java @@ -29,6 +29,8 @@ import java.io.ObjectInputStream; /** + * Reads triples. + * * @author Christoph Böhme * */ @@ -37,6 +39,9 @@ public final class TripleReader extends DefaultObjectPipe { private ObjectOutputStream outputStream; + /** + * Constructs a TripleWriter with a given file name as output path. + * + * @param filename the name of the file to write to + */ public TripleWriter(final String filename) { this.filename = filename; resetStream(); diff --git a/metafacture-triples/src/main/java/org/metafacture/triples/TriplesToStream.java b/metafacture-triples/src/main/java/org/metafacture/triples/TriplesToStream.java index c297f1ce0..d5b29ddaf 100644 --- a/metafacture-triples/src/main/java/org/metafacture/triples/TriplesToStream.java +++ b/metafacture-triples/src/main/java/org/metafacture/triples/TriplesToStream.java @@ -47,6 +47,9 @@ public final class TriplesToStream extends private final FormetaParser parser = new FormetaParser(); private final PartialRecordEmitter emitter = new PartialRecordEmitter(); + /** + * Creates an instance of {@link TriplesToStream}. + */ public TriplesToStream() { parser.setEmitter(emitter); } diff --git a/metafacture-xml/src/main/java/org/metafacture/xml/CGXmlHandler.java b/metafacture-xml/src/main/java/org/metafacture/xml/CGXmlHandler.java index e794d29a0..0c9a3d11d 100644 --- a/metafacture-xml/src/main/java/org/metafacture/xml/CGXmlHandler.java +++ b/metafacture-xml/src/main/java/org/metafacture/xml/CGXmlHandler.java @@ -77,6 +77,9 @@ public final class CGXmlHandler extends DefaultXmlPipe { private static final String VERSION = "1.0"; + /** + * Creates an instance of {@link CGXmlHandler}. + */ public CGXmlHandler() { } diff --git a/metafacture-xml/src/main/java/org/metafacture/xml/GenericXmlHandler.java b/metafacture-xml/src/main/java/org/metafacture/xml/GenericXmlHandler.java index a2813f6fa..b81193d04 100644 --- a/metafacture-xml/src/main/java/org/metafacture/xml/GenericXmlHandler.java +++ b/metafacture-xml/src/main/java/org/metafacture/xml/GenericXmlHandler.java @@ -40,6 +40,8 @@ @FluxCommand("handle-generic-xml") public final class GenericXmlHandler extends DefaultXmlPipe { + public static final String RECORD_TAG_PROPERTY = "org.culturegraph.metamorph.xml.recordtag"; + public static final boolean EMIT_NAMESPACE = false; private static final Pattern TABS = Pattern.compile("\t+"); @@ -53,8 +55,12 @@ public final class GenericXmlHandler extends DefaultXmlPipe { private boolean emitNamespace = EMIT_NAMESPACE; + /** + * Constructs a GenericXmlHandler. Sets the record tag name to the value of + * the system property {@value #RECORD_TAG_PROPERTY} if it's present. + */ public GenericXmlHandler() { - final String recordTagNameProperty = System.getProperty("org.culturegraph.metamorph.xml.recordtag"); + final String recordTagNameProperty = System.getProperty(RECORD_TAG_PROPERTY); if (recordTagNameProperty != null) { recordTagName = recordTagNameProperty; } @@ -64,7 +70,7 @@ public GenericXmlHandler() { * Creates a new {@code GenericXmlReader} with the given tag name as * marker for records. * - * @deprecated Use default constructor and set the tag name latter + * @deprecated Use default constructor and set the tag name later * with {@link #setRecordTagName(String)}. * * @param recordTagName tag name marking the start of a record. @@ -80,7 +86,7 @@ public GenericXmlHandler(final String recordTagName) { * This value may only be changed between records. If it is changed * while processing a record the behaviour of this module is undefined. *

    - * Default value: {@value DEFAULT_RECORD_TAG} + * Default value: {@value org.metafacture.framework.helpers.DefaultXmlPipe#DEFAULT_RECORD_TAG} * * @param recordTagName the tag name which marks the start of a record. */ @@ -88,14 +94,29 @@ public void setRecordTagName(final String recordTagName) { this.recordTagName = recordTagName; } + /** + * Gets the record tag name. + * + * @return the record tag name. + */ public String getRecordTagName() { return recordTagName; } + /** + * Sets the value tag name. + * + * @param valueTagName the value tag name + */ public void setValueTagName(final String valueTagName) { this.valueTagName = valueTagName; } + /** + * Gets the value tag name. + * + * @return the value tag name + */ public String getValueTagName() { return valueTagName; } @@ -105,7 +126,7 @@ public String getValueTagName() { * will be passed through as "foo:bar". For backward compatibility the default * is set to "false", thus only "bar" is emitted. *

    - * Default value: {@value EMIT_NAMESPACE} + * Default value: {@value #EMIT_NAMESPACE} * * @param emitNamespace set to "true" if namespace should be emitted. Defaults * to "false". @@ -114,14 +135,29 @@ public void setEmitNamespace(final boolean emitNamespace) { this.emitNamespace = emitNamespace; } + /** + * Checks wether the namespace should be emitted. + * + * @return true if the namespace should be emitted + */ public boolean getEmitNamespace() { return this.emitNamespace; } + /** + * Sets the attribute marker. + * + * @param attributeMarker the attribute marker + */ public void setAttributeMarker(final String attributeMarker) { this.attributeMarker = attributeMarker; } + /** + * Gets the attribute marker. + * + * @return the attribute marker + */ public String getAttributeMarker() { return attributeMarker; } diff --git a/metafacture-xml/src/main/java/org/metafacture/xml/SimpleXmlEncoder.java b/metafacture-xml/src/main/java/org/metafacture/xml/SimpleXmlEncoder.java index c0a944918..3e12f083f 100644 --- a/metafacture-xml/src/main/java/org/metafacture/xml/SimpleXmlEncoder.java +++ b/metafacture-xml/src/main/java/org/metafacture/xml/SimpleXmlEncoder.java @@ -40,7 +40,7 @@ /** * - * Encodes a stream as XML + * Encodes a stream as XML. * * @author Markus Michael Geipel * @author Christoph Böhme @@ -86,25 +86,53 @@ public final class SimpleXmlEncoder extends DefaultStreamPipe namespaces) { this.namespaces = namespaces; } + /** + * Sets the attribute marker. + * + * @param attributeMarker the attribute marker. + */ public void setAttributeMarker(final String attributeMarker) { this.attributeMarker = attributeMarker; } + /** + * Gets the attribute marker. + * + * @return the attribute marker + */ public String getAttributeMarker() { return attributeMarker; } diff --git a/metafacture-xml/src/main/java/org/metafacture/xml/XmlDecoder.java b/metafacture-xml/src/main/java/org/metafacture/xml/XmlDecoder.java index 623088949..ff0dac5e3 100644 --- a/metafacture-xml/src/main/java/org/metafacture/xml/XmlDecoder.java +++ b/metafacture-xml/src/main/java/org/metafacture/xml/XmlDecoder.java @@ -50,6 +50,10 @@ public final class XmlDecoder extends DefaultObjectPipe { private final XMLReader saxReader; + /** + * Constructs an XmlDecoder by obtaining a new instance of an + * {@link org.xml.sax.XMLReader}. + */ public XmlDecoder() { try { saxReader = XMLReaderFactory.createXMLReader(); diff --git a/metafacture-xml/src/main/java/org/metafacture/xml/XmlElementSplitter.java b/metafacture-xml/src/main/java/org/metafacture/xml/XmlElementSplitter.java index 6ecfbd31c..bca233096 100644 --- a/metafacture-xml/src/main/java/org/metafacture/xml/XmlElementSplitter.java +++ b/metafacture-xml/src/main/java/org/metafacture/xml/XmlElementSplitter.java @@ -62,8 +62,8 @@ public XmlElementSplitter() { /** * Enriched constructor setting the top level element and the Element name * - * @param aTopLevelElement the name of the top level XML tag - * @param aElementName the name of the tag defining a new Element to be split + * @param topLevelElement the name of the top level XML tag + * @param elementName the name of the tag defining a new Element to be split */ public XmlElementSplitter(final String topLevelElement, final String elementName) { setTopLevelElement(topLevelElement); @@ -83,8 +83,8 @@ public void setElementName(final String name) { /** * Sets the top-level XML document element. * - * @param root the top level element. Don't set it to omit setting top level - * element. + * @param newRoot the top level element. Leave at default to omit the + * top-level element. */ public void setTopLevelElement(final String newRoot) { root = newRoot; @@ -93,12 +93,11 @@ public void setTopLevelElement(final String newRoot) { } /** - * Sets the XML declaration. + * Sets the XML declaration. The default is + * {@code }. If an empty value is + * given, the XML declaration is skipped. * - * @param xmlDeclaration the xml declaration. Default is - * '{@code}'. - * If empty value is given, the xml declaration is - * skipped. + * @param xmlDeclaration the XML declaration */ public void setXmlDeclaration(final String xmlDeclaration) { this.xmlDeclaration = xmlDeclaration; diff --git a/metafacture-yaml/src/main/java/org/metafacture/yaml/YamlDecoder.java b/metafacture-yaml/src/main/java/org/metafacture/yaml/YamlDecoder.java index e79828ee5..b813b85d9 100644 --- a/metafacture-yaml/src/main/java/org/metafacture/yaml/YamlDecoder.java +++ b/metafacture-yaml/src/main/java/org/metafacture/yaml/YamlDecoder.java @@ -56,51 +56,95 @@ public final class YamlDecoder extends DefaultObjectPipe private final YAMLFactory yamlFactory = new YAMLFactory(); private YAMLParser yamlParser; - private String arrayMarker; - private String arrayName; - private String recordId; + private String arrayMarker = DEFAULT_ARRAY_MARKER; + private String arrayName = DEFAULT_ARRAY_NAME; + private String recordId = DEFAULT_RECORD_ID; private int recordCount; + /** + * Creates an instance of {@link YamlDecoder}. + */ public YamlDecoder() { - setArrayMarker(DEFAULT_ARRAY_MARKER); - setArrayName(DEFAULT_ARRAY_NAME); - setRecordId(DEFAULT_RECORD_ID); - - resetRecordCount(); } + /** + * Sets the array marker. Default value: + * {@value #DEFAULT_ARRAY_MARKER} + * + * @param arrayMarker the marker of the array + */ public void setArrayMarker(final String arrayMarker) { this.arrayMarker = arrayMarker; } + /** + * Gets the array marker. + * + * @return the array marker + */ public String getArrayMarker() { return arrayMarker; } + /** + * Sets the name of the array. Default value: + * {@value #DEFAULT_ARRAY_NAME} + * + * @param arrayName the name of the array + */ public void setArrayName(final String arrayName) { this.arrayName = arrayName; } + /** + * Gets the name of the array. + * + * @return the name of the array + */ public String getArrayName() { return arrayName; } + /** + * Sets the record ID. Default value: + * {@value #DEFAULT_RECORD_ID} + * + * @param recordId the record ID + */ public void setRecordId(final String recordId) { this.recordId = recordId; } + /** + * Get the record ID. + * + * @return the record ID + */ public String getRecordId() { return recordId; } + /** + * Sets the record count. + * + * @param recordCount the record count. + */ public void setRecordCount(final int recordCount) { this.recordCount = recordCount; } + /** + * Gets the record count. + * + * @return the record count + */ public int getRecordCount() { return recordCount; } + /** + * Resets the record count. + */ public void resetRecordCount() { setRecordCount(0); } diff --git a/metafacture-yaml/src/main/java/org/metafacture/yaml/YamlEncoder.java b/metafacture-yaml/src/main/java/org/metafacture/yaml/YamlEncoder.java index 76b8f37d5..8cfc3efe1 100644 --- a/metafacture-yaml/src/main/java/org/metafacture/yaml/YamlEncoder.java +++ b/metafacture-yaml/src/main/java/org/metafacture/yaml/YamlEncoder.java @@ -63,6 +63,9 @@ public final class YamlEncoder extends DefaultStreamPipe> private String arrayMarker = ARRAY_MARKER; + /** + * Creates an instance of {@link YamlEncoder} if no IOException occurs. + */ public YamlEncoder() { try { yamlGenerator = new YAMLFactory().createGenerator(writer); @@ -72,18 +75,38 @@ public YamlEncoder() { } } + /** + * Sets the array marker. + * + * @param arrayMarker the array marker + */ public void setArrayMarker(final String arrayMarker) { this.arrayMarker = arrayMarker; } + /** + * Gets the array marker. + * + * @return the array marker + */ public String getArrayMarker() { return arrayMarker; } + /** + * Flags wether the data should be pretty printed. + * + * @param prettyPrinting true if the data should be pretty printed + */ public void setPrettyPrinting(final boolean prettyPrinting) { yamlGenerator.setPrettyPrinter(prettyPrinting ? new DefaultPrettyPrinter((SerializableString) null) : null); } + /** + * Checks wether to pretty print. + * + * @return true if the data should be pretty printed + */ public boolean getPrettyPrinting() { return yamlGenerator.getPrettyPrinter() != null; } diff --git a/metamorph-api/src/main/java/org/metafacture/metamorph/api/Collect.java b/metamorph-api/src/main/java/org/metafacture/metamorph/api/Collect.java index 46c4c8699..a8bd6ffff 100644 --- a/metamorph-api/src/main/java/org/metafacture/metamorph/api/Collect.java +++ b/metamorph-api/src/main/java/org/metafacture/metamorph/api/Collect.java @@ -23,15 +23,39 @@ * */ public interface Collect extends FlushListener, ConditionAware, NamedValuePipe { - + /** + * Flags wether to wait for a flush. + * + * @param waitForFlush true if to wait for a flush + */ void setWaitForFlush(boolean waitForFlush); + /** + * Flags wether the collector acts on the same entity. + * + * @param sameEntity true if the collector should acts on the same entity + */ void setSameEntity(boolean sameEntity); + /** + * Flags wether a reset should be done. + * + * @param reset true if a reset should be done. + */ void setReset(boolean reset); + /** + * Gets the name. + * + * @return the name + */ String getName(); + /** + * Sets the name. + * + * @param name the name + */ void setName(String name); } diff --git a/metamorph-api/src/main/java/org/metafacture/metamorph/api/ConditionAware.java b/metamorph-api/src/main/java/org/metafacture/metamorph/api/ConditionAware.java index e5b8305ca..26b5ef3d7 100644 --- a/metamorph-api/src/main/java/org/metafacture/metamorph/api/ConditionAware.java +++ b/metamorph-api/src/main/java/org/metafacture/metamorph/api/ConditionAware.java @@ -23,7 +23,11 @@ * */ public interface ConditionAware { - + /** + * makes statements conditional. + * + * @param receiver the {@link NamedValueSource} + */ void setConditionSource(NamedValueSource receiver); } diff --git a/metamorph-api/src/main/java/org/metafacture/metamorph/api/FlushListener.java b/metamorph-api/src/main/java/org/metafacture/metamorph/api/FlushListener.java index 0beedb906..7b8e390e4 100644 --- a/metamorph-api/src/main/java/org/metafacture/metamorph/api/FlushListener.java +++ b/metamorph-api/src/main/java/org/metafacture/metamorph/api/FlushListener.java @@ -22,7 +22,12 @@ * @author Markus Michael Geipel */ public interface FlushListener { - + /** + * Flush collected data. + * + * @param recordCount the record count + * @param entityCount the entity count + */ void flush(int recordCount, int entityCount); } diff --git a/metamorph-api/src/main/java/org/metafacture/metamorph/api/Function.java b/metamorph-api/src/main/java/org/metafacture/metamorph/api/Function.java index 671ab7d79..6ba52263f 100644 --- a/metamorph-api/src/main/java/org/metafacture/metamorph/api/Function.java +++ b/metamorph-api/src/main/java/org/metafacture/metamorph/api/Function.java @@ -24,8 +24,19 @@ */ public interface Function extends NamedValuePipe, FlushListener { + /** + * Puts a value into the map + * + * @param key the key + * @param value the value + */ void putValue(String key, String value); + /** + * Sets maps. + * + * @param maps the {@link Maps} + */ void setMaps(Maps maps); } diff --git a/metamorph-api/src/main/java/org/metafacture/metamorph/api/Maps.java b/metamorph-api/src/main/java/org/metafacture/metamorph/api/Maps.java index b11feda4b..d9190765c 100644 --- a/metamorph-api/src/main/java/org/metafacture/metamorph/api/Maps.java +++ b/metamorph-api/src/main/java/org/metafacture/metamorph/api/Maps.java @@ -29,14 +29,47 @@ public interface Maps { String DEFAULT_MAP_KEY = "__default"; + /** + * Gets all map names. + * + * @return the {@link Collection} of all map names + */ Collection getMapNames(); + /** + * Gest a map. + * + * @param mapName the name of the map + * @return the Map + */ Map getMap(String mapName); + /** + * Gets a value from the map. + * + * @param mapName the name of the map + * @param key the key of the map + * @return the value + */ String getValue(String mapName, String key); + /** + * Returns a Map with a map name. + * + * @param mapName the name of the map + * @param map the map + * @return the Map + */ Map putMap(String mapName, Map map); + /** + * Puts a value into a map. + * + * @param mapName the name of the map + * @param key the key + * @param value the value + * @return the value + */ String putValue(String mapName, String key, String value); } diff --git a/metamorph-api/src/main/java/org/metafacture/metamorph/api/MorphBuildException.java b/metamorph-api/src/main/java/org/metafacture/metamorph/api/MorphBuildException.java index f720f71fc..ad80be220 100644 --- a/metamorph-api/src/main/java/org/metafacture/metamorph/api/MorphBuildException.java +++ b/metamorph-api/src/main/java/org/metafacture/metamorph/api/MorphBuildException.java @@ -26,10 +26,22 @@ public final class MorphBuildException extends RuntimeException { private static final long serialVersionUID = 0L; + /** + * Creates an instance of {@link MorphBuildException} by a given message. + * + * @param message the message + */ public MorphBuildException(final String message) { super(message); } + /** + * Creates an instance of {@link MorphBuildException} by a given message and + * cause. + * + * @param message the message + * @param cause the {@link Throwable} + */ public MorphBuildException(final String message, final Throwable cause) { super(message, cause); } diff --git a/metamorph-api/src/main/java/org/metafacture/metamorph/api/MorphErrorHandler.java b/metamorph-api/src/main/java/org/metafacture/metamorph/api/MorphErrorHandler.java index 8404d4c93..68b3543c1 100644 --- a/metamorph-api/src/main/java/org/metafacture/metamorph/api/MorphErrorHandler.java +++ b/metamorph-api/src/main/java/org/metafacture/metamorph/api/MorphErrorHandler.java @@ -24,7 +24,11 @@ * */ public interface MorphErrorHandler { - + /** + * Provides custom error handling. + * + * @param exception the {@link Exception} + */ void error(Exception exception); } diff --git a/metamorph-api/src/main/java/org/metafacture/metamorph/api/MorphExecutionException.java b/metamorph-api/src/main/java/org/metafacture/metamorph/api/MorphExecutionException.java index be6e6e08a..addf8cc73 100644 --- a/metamorph-api/src/main/java/org/metafacture/metamorph/api/MorphExecutionException.java +++ b/metamorph-api/src/main/java/org/metafacture/metamorph/api/MorphExecutionException.java @@ -26,10 +26,22 @@ public class MorphExecutionException extends RuntimeException { private static final long serialVersionUID = 0L; + /** + * Creates an instance of {@link MorphExecutionException} by a given message. + * + * @param message the message + */ public MorphExecutionException(final String message) { super(message); } + /** + * Creates an instance of {@link MorphExecutionException} by a given message and + * cause. + * + * @param message the message + * @param cause the @{link Throwable} + */ public MorphExecutionException(final String message, final Throwable cause) { super(message, cause); } diff --git a/metamorph-api/src/main/java/org/metafacture/metamorph/api/NamedValueReceiver.java b/metamorph-api/src/main/java/org/metafacture/metamorph/api/NamedValueReceiver.java index fb0f6e6a0..a554b73e2 100644 --- a/metamorph-api/src/main/java/org/metafacture/metamorph/api/NamedValueReceiver.java +++ b/metamorph-api/src/main/java/org/metafacture/metamorph/api/NamedValueReceiver.java @@ -24,9 +24,22 @@ * */ public interface NamedValueReceiver extends KnowsSourceLocation { - + /** + * Receives named values. + * + * @param name the name of the key + * @param value the value of the key + * @param source the {@link NamedValueSource} + * @param recordCount the record count + * @param entityCount the entity count + */ void receive(String name, String value, NamedValueSource source, int recordCount, int entityCount); + /** + * Adds a named value source. + * + * @param namedValueSource the {@link NamedValueSource} + */ void addNamedValueSource(NamedValueSource namedValueSource); } diff --git a/metamorph-api/src/main/java/org/metafacture/metamorph/api/NamedValueSource.java b/metamorph-api/src/main/java/org/metafacture/metamorph/api/NamedValueSource.java index 2ed03aab0..511a47cff 100644 --- a/metamorph-api/src/main/java/org/metafacture/metamorph/api/NamedValueSource.java +++ b/metamorph-api/src/main/java/org/metafacture/metamorph/api/NamedValueSource.java @@ -17,7 +17,7 @@ package org.metafacture.metamorph.api; /** - * Base interface for all classes in Metamorph which emit name-value-pairs. + * Base interface for all classes in Metamorph which emit name-value pairs. * * @author Markus Michael Geipel * @author Christoph Böhme diff --git a/metamorph-api/src/main/java/org/metafacture/metamorph/api/SourceLocation.java b/metamorph-api/src/main/java/org/metafacture/metamorph/api/SourceLocation.java index 3e3e01c48..d64cd81b6 100644 --- a/metamorph-api/src/main/java/org/metafacture/metamorph/api/SourceLocation.java +++ b/metamorph-api/src/main/java/org/metafacture/metamorph/api/SourceLocation.java @@ -23,11 +23,25 @@ * @author Christoph Böhme */ public interface SourceLocation { - + /** + * Gets the filename. + * + * @return the filename + */ String getFileName(); + /** + * Gest the start position. + * + * @return the start position as {@link Position} + */ Position getStartPosition(); + /** + * Gets the end position. + * + * @return the end position as {@link Position} + */ Position getEndPosition(); /** @@ -36,9 +50,18 @@ public interface SourceLocation { * @author Christoph Böhme */ interface Position { - + /** + * Gest the line number. + * + * @return the line number + */ int getLineNumber(); + /** + * Gest the column number. + * + * @return the column number. + */ int getColumnNumber(); } diff --git a/metamorph-api/src/main/java/org/metafacture/metamorph/api/helpers/AbstractCollect.java b/metamorph-api/src/main/java/org/metafacture/metamorph/api/helpers/AbstractCollect.java index 6a5892726..ecea865a6 100644 --- a/metamorph-api/src/main/java/org/metafacture/metamorph/api/helpers/AbstractCollect.java +++ b/metamorph-api/src/main/java/org/metafacture/metamorph/api/helpers/AbstractCollect.java @@ -71,6 +71,11 @@ public final void setSameEntity(final boolean sameEntity) { this.sameEntity = sameEntity; } + /** + * Checks wether a reset should be done after emitting. + * + * @return true if a reset should be done after emitting + */ public final boolean getReset() { return resetAfterEmit; } @@ -97,6 +102,11 @@ public final void setConditionSource(final NamedValueSource source) { resetCondition(); } + /** + * Gets the value. + * + * @return the value + */ public final String getValue() { return value; } diff --git a/metamorph-api/src/main/java/org/metafacture/metamorph/api/helpers/AbstractFilter.java b/metamorph-api/src/main/java/org/metafacture/metamorph/api/helpers/AbstractFilter.java index a110805da..9a05a4a0f 100644 --- a/metamorph-api/src/main/java/org/metafacture/metamorph/api/helpers/AbstractFilter.java +++ b/metamorph-api/src/main/java/org/metafacture/metamorph/api/helpers/AbstractFilter.java @@ -39,6 +39,11 @@ protected final String getString() { return string; } + /** + * Sets the string. + * + * @param string the string + */ public final void setString(final String string) { this.string = string; } diff --git a/metamorph-api/src/main/java/org/metafacture/metamorph/api/helpers/AbstractFlushingCollect.java b/metamorph-api/src/main/java/org/metafacture/metamorph/api/helpers/AbstractFlushingCollect.java index f6d99c4ae..35ab3e0bd 100644 --- a/metamorph-api/src/main/java/org/metafacture/metamorph/api/helpers/AbstractFlushingCollect.java +++ b/metamorph-api/src/main/java/org/metafacture/metamorph/api/helpers/AbstractFlushingCollect.java @@ -27,6 +27,11 @@ public abstract class AbstractFlushingCollect extends AbstractCollect { private boolean flushIncomplete = true; + /** + * Flags if to flush when incomplete. + * + * @param flushIncomplete true if it should be flushed when incomplete + */ public final void setFlushIncomplete(final boolean flushIncomplete) { this.flushIncomplete = flushIncomplete; } diff --git a/metamorph-api/src/main/java/org/metafacture/metamorph/api/helpers/AbstractFunction.java b/metamorph-api/src/main/java/org/metafacture/metamorph/api/helpers/AbstractFunction.java index 8aaf1f5da..c0cb638e2 100644 --- a/metamorph-api/src/main/java/org/metafacture/metamorph/api/helpers/AbstractFunction.java +++ b/metamorph-api/src/main/java/org/metafacture/metamorph/api/helpers/AbstractFunction.java @@ -45,17 +45,30 @@ protected final String getLocalValue(final String key) { return null; } + /** + * Gets the name of the map. + * + * @return the name of the map + */ public final String getMapName() { return mapName; } + /** + * Gets the {@link #localMap} or, if unset, a Map with the name of {@link + * #mapName}. + * + * @return the Map + */ public final Map getMap() { - if (localMap == null) { - return maps.getMap(mapName); - } - return localMap; + return localMap != null ? localMap : maps.getMap(mapName); } + /** + * Sets the name of the map. + * + * @param newMapName the name of the map + */ public final void setMap(final String newMapName) { mapName = newMapName; } @@ -68,6 +81,11 @@ public final void putValue(final String key, final String value) { localMap.put(key, value); } + /** + * Sets the maps. + * + * @param maps the {@link Maps} + */ public final void setMaps(final Maps maps) { this.maps = maps; } diff --git a/metamorph-test/src/main/java/org/metafacture/metamorph/test/MetamorphTestSuite.java b/metamorph-test/src/main/java/org/metafacture/metamorph/test/MetamorphTestSuite.java index a7534fe5c..e8b58f9e9 100644 --- a/metamorph-test/src/main/java/org/metafacture/metamorph/test/MetamorphTestSuite.java +++ b/metamorph-test/src/main/java/org/metafacture/metamorph/test/MetamorphTestSuite.java @@ -40,6 +40,13 @@ public final class MetamorphTestSuite extends ParentRunner { private final List runners; + /** + * Constructs a MetamorphTestSuite by binding a list of Metamorph-Test resources + * to a class. + * + * @param suiteRoot the {@code @TestClass} + * @throws InitializationError if definitions couldn't be loaded + */ public MetamorphTestSuite(final Class suiteRoot) throws InitializationError { super(suiteRoot); diff --git a/metamorph-test/src/main/java/org/metafacture/metamorph/test/reader/CGXmlReader.java b/metamorph-test/src/main/java/org/metafacture/metamorph/test/reader/CGXmlReader.java index ff5db8248..0c1df6934 100644 --- a/metamorph-test/src/main/java/org/metafacture/metamorph/test/reader/CGXmlReader.java +++ b/metamorph-test/src/main/java/org/metafacture/metamorph/test/reader/CGXmlReader.java @@ -26,6 +26,9 @@ */ public final class CGXmlReader extends XmlReaderBase { + /** + * Creates an instance of {@link CGXmlReader}. + */ public CGXmlReader() { super(new CGXmlHandler()); } diff --git a/metamorph-test/src/main/java/org/metafacture/metamorph/test/reader/FormetaReader.java b/metamorph-test/src/main/java/org/metafacture/metamorph/test/reader/FormetaReader.java index 912501c3f..f4a7f5c6b 100644 --- a/metamorph-test/src/main/java/org/metafacture/metamorph/test/reader/FormetaReader.java +++ b/metamorph-test/src/main/java/org/metafacture/metamorph/test/reader/FormetaReader.java @@ -27,6 +27,9 @@ */ public class FormetaReader extends ReaderBase { + /** + * Creates an instance of {@link FormetaReader}. + */ public FormetaReader() { super(new FormetaRecordsReader(), new FormetaDecoder()); } diff --git a/metamorph-test/src/main/java/org/metafacture/metamorph/test/reader/JsonLinesReader.java b/metamorph-test/src/main/java/org/metafacture/metamorph/test/reader/JsonLinesReader.java index dc4af25db..772239e60 100644 --- a/metamorph-test/src/main/java/org/metafacture/metamorph/test/reader/JsonLinesReader.java +++ b/metamorph-test/src/main/java/org/metafacture/metamorph/test/reader/JsonLinesReader.java @@ -27,6 +27,9 @@ */ public class JsonLinesReader extends ReaderBase { + /** + * Creates an instance of {@link JsonLinesReader}. + */ public JsonLinesReader() { super(new LineReader(), new JsonDecoder()); } diff --git a/metamorph-test/src/main/java/org/metafacture/metamorph/test/reader/JsonReader.java b/metamorph-test/src/main/java/org/metafacture/metamorph/test/reader/JsonReader.java index 48f601afe..656f4849d 100644 --- a/metamorph-test/src/main/java/org/metafacture/metamorph/test/reader/JsonReader.java +++ b/metamorph-test/src/main/java/org/metafacture/metamorph/test/reader/JsonReader.java @@ -27,6 +27,9 @@ */ public class JsonReader extends ReaderBase { + /** + * Creates an instance of {@link JsonReader}. + */ public JsonReader() { super(new RecordReader(), new JsonDecoder()); } diff --git a/metamorph-test/src/main/java/org/metafacture/metamorph/test/reader/MarcXmlReader.java b/metamorph-test/src/main/java/org/metafacture/metamorph/test/reader/MarcXmlReader.java index f1c1a461b..ca478f962 100644 --- a/metamorph-test/src/main/java/org/metafacture/metamorph/test/reader/MarcXmlReader.java +++ b/metamorph-test/src/main/java/org/metafacture/metamorph/test/reader/MarcXmlReader.java @@ -26,6 +26,9 @@ */ public class MarcXmlReader extends XmlReaderBase { + /** + * Creates an instance of {@link MarcXmlReader}. + */ public MarcXmlReader() { super(new MarcXmlHandler()); } diff --git a/metamorph-test/src/main/java/org/metafacture/metamorph/test/reader/MultiFormatReader.java b/metamorph-test/src/main/java/org/metafacture/metamorph/test/reader/MultiFormatReader.java index 9ce4e76a1..a20481628 100644 --- a/metamorph-test/src/main/java/org/metafacture/metamorph/test/reader/MultiFormatReader.java +++ b/metamorph-test/src/main/java/org/metafacture/metamorph/test/reader/MultiFormatReader.java @@ -31,10 +31,21 @@ public final class MultiFormatReader implements Reader { private StreamReceiver downstreamReceiver; private Reader currentReader; + /** + * Creates an instance of {@link MultiFormatReader} by a given format. + * + * @param format the format + */ public MultiFormatReader(final String format) { setFormat(format); } + /** + * Sets the format of {@link #currentReader} if the {@link #READER_FACTORY} + * contains that format. + * + * @param format the format + */ public void setFormat(final String format) { if (!READER_FACTORY.containsKey(format)) { throw new IllegalArgumentException("Format '" + format + "' not regognized"); diff --git a/metamorph-test/src/main/java/org/metafacture/metamorph/test/reader/PicaReader.java b/metamorph-test/src/main/java/org/metafacture/metamorph/test/reader/PicaReader.java index 207635740..e56e346e4 100644 --- a/metamorph-test/src/main/java/org/metafacture/metamorph/test/reader/PicaReader.java +++ b/metamorph-test/src/main/java/org/metafacture/metamorph/test/reader/PicaReader.java @@ -26,6 +26,9 @@ */ public class PicaReader extends ReaderBase { + /** + * Creates an instance of {@link PicaReader}. + */ public PicaReader() { super(new LineReader(), new PicaDecoder()); } diff --git a/metamorph-test/src/main/java/org/metafacture/metamorph/test/validators/StreamValidator.java b/metamorph-test/src/main/java/org/metafacture/metamorph/test/validators/StreamValidator.java index 49e58b731..7bbc7458a 100644 --- a/metamorph-test/src/main/java/org/metafacture/metamorph/test/validators/StreamValidator.java +++ b/metamorph-test/src/main/java/org/metafacture/metamorph/test/validators/StreamValidator.java @@ -70,6 +70,14 @@ public final class StreamValidator implements StreamReceiver { private final WellformednessChecker wellformednessChecker = new WellformednessChecker(); + /** + * Constructs a StreamValidator with a List of {@link Event}s. Validates this + * stream of events using that list of expected stream events. If the stream is + * invalid, the error handler set via {@link #setErrorHandler(Consumer)} is + * called. Checks for wellformedness and resets the stream. + * + * @param expectedStream the List of expected stream events + */ public StreamValidator(final List expectedStream) { this.eventStream = new EventNode(null, null); foldEventStream(this.eventStream, expectedStream.iterator()); @@ -92,14 +100,30 @@ public void setErrorHandler(final Consumer errorHandler) { wellformednessChecker.setErrorHandler(errorHandler); } + /** + * Gets the error handler. + * + * @return the error handler as a {@link Consumer} + */ public Consumer getErrorHandler() { return errorHandler; } + /** + * Checks wether the record order is strict. + * + * @return true if the record order is strict + */ public boolean isStrictRecordOrder() { return strictRecordOrder; } + /** + * Sets strict record order. + * + * @param strictRecordOrder "true" if the record order should be strict, or + * "false" otherwise + */ public void setStrictRecordOrder(final boolean strictRecordOrder) { if (validating) { throw new IllegalStateException(CANNOT_CHANGE_OPTIONS); @@ -108,10 +132,21 @@ public void setStrictRecordOrder(final boolean strictRecordOrder) { this.strictRecordOrder = strictRecordOrder; } + /** + * Checks wether the key order is strict. + * + * @return true if the key order is strict + */ public boolean isStrictKeyOrder() { return strictKeyOrder; } + /** + * Sets strict key order. + * + * @param strictKeyOrder "true" if key order should be strict, or + * "false" otherwise + */ public void setStrictKeyOrder(final boolean strictKeyOrder) { if (validating) { throw new IllegalStateException(CANNOT_CHANGE_OPTIONS); @@ -120,10 +155,21 @@ public void setStrictKeyOrder(final boolean strictKeyOrder) { this.strictKeyOrder = strictKeyOrder; } + /** + * Checks wether the value order is strict. + * + * @return true if the value order is strict + */ public boolean isStrictValueOrder() { return strictValueOrder; } + /** + * Sets strict value order. + * + * @param strictValueOrder "true" if value order should be strict, or + * "false" otherwise + */ public void setStrictValueOrder(final boolean strictValueOrder) { if (validating) { throw new IllegalStateException(CANNOT_CHANGE_OPTIONS); diff --git a/metamorph-test/src/main/java/org/metafacture/metamorph/test/validators/WellformednessChecker.java b/metamorph-test/src/main/java/org/metafacture/metamorph/test/validators/WellformednessChecker.java index c6eb8b972..34289cff7 100644 --- a/metamorph-test/src/main/java/org/metafacture/metamorph/test/validators/WellformednessChecker.java +++ b/metamorph-test/src/main/java/org/metafacture/metamorph/test/validators/WellformednessChecker.java @@ -58,6 +58,9 @@ public final class WellformednessChecker implements StreamReceiver { private int nestingLevel; + /** + * Creates an instance of {@link WellformednessChecker}. + */ public WellformednessChecker() { } @@ -73,6 +76,11 @@ public void setErrorHandler(final Consumer errorHandler) { this.errorHandler = errorHandler; } + /** + * Gets the error handler. + * + * @return the error handler as {@link Consumer} + */ public Consumer getErrorHandler() { return errorHandler; } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/AbstractMetamorphDomWalker.java b/metamorph/src/main/java/org/metafacture/metamorph/AbstractMetamorphDomWalker.java index 4f884b399..d3629412f 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/AbstractMetamorphDomWalker.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/AbstractMetamorphDomWalker.java @@ -31,7 +31,7 @@ import java.util.Map; /** - * Builds a {@link Metamorph} from an xml description + * Builds a {@link Metamorph} from an XML description * * @author Markus Michael Geipel */ @@ -63,6 +63,11 @@ public enum AttributeName { this.string = string; } + /** + * Gests the string. + * + * @return the string + */ public String getString() { return string; } @@ -100,11 +105,23 @@ protected final MapFactory getMapFactory() { return mapFactory; } + /** + * Walks through the Metamorph definition file. Respects the Metamorph + * variables. + * + * @param morphScript the InputSource of the Metamorph definition file + * @param newVars the Map of Metamorph variables + */ public final void walk(final InputSource morphScript, final Map newVars) { vars.putAll(newVars); walk(morphScript); } + /** + * Walks the DOM of the morph definition. + * + * @param morphScript the morph definition as {@link InputSource}. + */ public final void walk(final InputSource morphScript) { walk(DomLoader.parse(SCHEMA_FILE, morphScript)); } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/DefaultErrorHandler.java b/metamorph/src/main/java/org/metafacture/metamorph/DefaultErrorHandler.java index be7dcdfa7..5ec4ce436 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/DefaultErrorHandler.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/DefaultErrorHandler.java @@ -26,6 +26,9 @@ */ public final class DefaultErrorHandler implements MorphErrorHandler { + /** + * Creates an instance of {@link DefaultErrorHandler}. + */ public DefaultErrorHandler() { } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/Entity.java b/metamorph/src/main/java/org/metafacture/metamorph/Entity.java index 016fbe9e6..e31baec40 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/Entity.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/Entity.java @@ -45,14 +45,30 @@ public final class Entity extends AbstractFlushingCollect { private NamedValueSource nameSource; private String currentName; + /** + * Creates an instance of {@link Entity} by a given {@link Metamorph}. + * + * @param metamorph the {@link Metamorph} + */ public Entity(final Metamorph metamorph) { this.receiver = () -> metamorph.getStreamReceiver(); } + /** + * Creates an instance of {@link Entity} by a given {@link Supplier} of object + * type {@link StreamReceiver}. + * + * @param receiver the {@link Supplier} of object type {@link StreamReceiver} + */ public Entity(final Supplier receiver) { this.receiver = receiver; } + /** + * Sets the NamedValueSource the entity will act on. + * + * @param source the NamedValueSource + */ public void setNameSource(final NamedValueSource source) { nameSource = source; nameSource.setNamedValueReceiver(this); diff --git a/metamorph/src/main/java/org/metafacture/metamorph/Filter.java b/metamorph/src/main/java/org/metafacture/metamorph/Filter.java index eafb1e22f..06d409241 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/Filter.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/Filter.java @@ -45,21 +45,45 @@ public final class Filter extends DefaultStreamPipe { private final SingleValue singleValue = new SingleValue(); private final Metamorph metamorph; + /** + * Constructs a Filter from the path to a Metamorph definition. + * + * @param morphDef the path to the Metamorph definition + */ public Filter(final String morphDef) { metamorph = new Metamorph(morphDef); metamorph.setReceiver(singleValue); } + /** + * Constructs a Filter from a Metamorph. + * + * @param metamorph the Metamorph + */ public Filter(final Metamorph metamorph) { this.metamorph = metamorph; metamorph.setReceiver(singleValue); } + /** + * Constructs a Filter from the path to a Metamorph definition and a Map of + * Metamorph variables. + * + * @param morphDef the path to the Metamorph definition + * @param vars the Map of the Metamorph variables + */ public Filter(final String morphDef, final Map vars) { metamorph = new Metamorph(morphDef, vars); metamorph.setReceiver(singleValue); } + /** + * Constructs a Filter from the path to a Metamorph definition and an + * InterceptorFactory. + * + * @param morphDef the path to the Metamorph definition + * @param interceptorFactory the InterceptorFactory + */ public Filter(final String morphDef, final InterceptorFactory interceptorFactory) { metamorph = new Metamorph(morphDef, interceptorFactory); metamorph.setReceiver(singleValue); @@ -120,4 +144,5 @@ protected void onCloseStream() { buffer.clear(); metamorph.closeStream(); } + } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/Flush.java b/metamorph/src/main/java/org/metafacture/metamorph/Flush.java index e23cd8a35..734ce0480 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/Flush.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/Flush.java @@ -22,7 +22,7 @@ import org.metafacture.metamorph.api.SourceLocation; /** - * Flushes a {@link FlushListener} + * Flushes a {@link FlushListener}. * * @author Markus Geipel * @author Christoph Böhme @@ -34,6 +34,11 @@ public final class Flush implements NamedValueReceiver { private SourceLocation sourceLocation; + /** + * Creates an instance of {@link Flush} by a given {@link FlushListener}. + * + * @param listener the {@link FlushListener} + */ public Flush(final FlushListener listener) { this.listener = listener; } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/Metamorph.java b/metamorph/src/main/java/org/metafacture/metamorph/Metamorph.java index 7a6ea687c..c1aaa9027 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/Metamorph.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/Metamorph.java @@ -111,69 +111,184 @@ protected Metamorph() { init(); } + /** + * Creates an instance of {@link Metamorph} given by a morph definition as + * {@link String}. + * + * @param morphDef the {@link String} + */ public Metamorph(final String morphDef) { this(morphDef, NO_VARS); } + /** + * Creates an instance of {@link Metamorph} given by a morph definition as + * {@link String} and morph variables as a Map. + * + * @param morphDef the {@link String} + * @param vars the morph variables as a Map + */ public Metamorph(final String morphDef, final Map vars) { this(morphDef, vars, NULL_INTERCEPTOR_FACTORY); } + /** + * Creates an instance of {@link Metamorph} given by a morph definition as + * {@link String} and an {@link InterceptorFactory}. + * + * @param morphDef the {@link String} + * @param interceptorFactory the {@link InterceptorFactory} + */ public Metamorph(final String morphDef, final InterceptorFactory interceptorFactory) { this(morphDef, NO_VARS, interceptorFactory); } + /** + * Creates an instance of {@link Metamorph} given by a morph definition as + * {@link String} and morph variables as a Map and an + * {@link InterceptorFactory}. + * + * @param morphDef the {@link String} + * @param vars the morph variables as a Map + * @param interceptorFactory the {@link InterceptorFactory} + */ public Metamorph(final String morphDef, final Map vars, final InterceptorFactory interceptorFactory) { this(getInputSource(morphDef), vars, interceptorFactory); } + /** + * Creates an instance of {@link Metamorph} given by a morph definition as + * {@link Reader}. + * + * @param morphDef the {@link Reader} + */ public Metamorph(final Reader morphDef) { this(morphDef, NO_VARS); } + /** + * Creates an instance of {@link Metamorph} given by a morph definition as + * {@link Reader} and the morph variables as a Map. + * + * @param morphDef the {@link Reader} + * @param vars the morph variables as a Map + */ public Metamorph(final Reader morphDef, final Map vars) { this(morphDef, vars, NULL_INTERCEPTOR_FACTORY); } + /** + * Creates an instance of {@link Metamorph} given by a morph definition as + * {@link Reader} and an {@link InterceptorFactory}. + * + * @param morphDef the {@link Reader} + * @param interceptorFactory the {@link InterceptorFactory} + */ public Metamorph(final Reader morphDef, final InterceptorFactory interceptorFactory) { this(morphDef, NO_VARS, interceptorFactory); } + /** + * Creates an instance of {@link Metamorph} given by a morph definition as + * {@link Reader} and morph variables as a Map and an + * {@link InterceptorFactory}. + * + * @param morphDef the {@link Reader} + * @param vars the morph variables as a Map + * @param interceptorFactory the {@link InterceptorFactory} + */ public Metamorph(final Reader morphDef, final Map vars, final InterceptorFactory interceptorFactory) { this(new InputSource(morphDef), vars, interceptorFactory); } + /** + * Creates an instance of {@link Metamorph} given by a morph definition as + * {@link InputStream}. + * + * @param morphDef the {@link InputStream} + */ public Metamorph(final InputStream morphDef) { this(morphDef, NO_VARS); } + /** + * Creates an instance of {@link Metamorph} given by a morph definition as + * {@link InputStream} and morph variables as a Map. + * + * @param morphDef the {@link InputStream} + * @param vars the morph variables as a Map + */ public Metamorph(final InputStream morphDef, final Map vars) { this(morphDef, vars, NULL_INTERCEPTOR_FACTORY); } + /** + * Creates an instance of {@link Metamorph} given by a morph definition as + * {@link InputStream} and an {@link InterceptorFactory}. + * + * @param morphDef the {@link InputStream} + * @param interceptorFactory the {@link InterceptorFactory} + */ public Metamorph(final InputStream morphDef, final InterceptorFactory interceptorFactory) { this(morphDef, NO_VARS, interceptorFactory); } + /** + * Creates an instance of {@link Metamorph} given by a morph definition as + * {@link InputStream}, morph variables as a Map and an + * {@link InterceptorFactory}. + * + * @param morphDef the {@link InputStream} + * @param vars the morph variables as a Map + * @param interceptorFactory the {@link InterceptorFactory} + */ public Metamorph(final InputStream morphDef, final Map vars, final InterceptorFactory interceptorFactory) { this(new InputSource(morphDef), vars, interceptorFactory); } + /** + * Creates an instance of {@link Metamorph} given by a morph definition as + * {@link InputSource}. + * + * @param inputSource the {@link InputSource} + */ public Metamorph(final InputSource inputSource) { this(inputSource, NO_VARS); } + /** + * Creates an instance of {@link Metamorph} given by a morph definition as + * {@link InputSource} and morph variables as a Map. + * + * @param inputSource the {@link InputSource} + * @param vars the morph variables as a Map + */ public Metamorph(final InputSource inputSource, final Map vars) { this(inputSource, vars, NULL_INTERCEPTOR_FACTORY); } + /** + * Creates an instance of {@link Metamorph} given by a morph definition as + * {@link InputSource} and an {@link InterceptorFactory}. + * + * @param inputSource the {@link InputSource} + * @param interceptorFactory the {@link InterceptorFactory} + */ public Metamorph(final InputSource inputSource, final InterceptorFactory interceptorFactory) { this(inputSource, NO_VARS, interceptorFactory); } + /** + * Constructs a Metamorph by setting a morph definition as {@link InputSource}, + * a Map of variables and an {@link InterceptorFactory}. + * + * @param inputSource the InputSource + * @param vars the Map of variables + * @param interceptorFactory the InterceptorFactory + */ public Metamorph(final InputSource inputSource, final Map vars, final InterceptorFactory interceptorFactory) { buildPipeline(inputSource, vars, interceptorFactory); @@ -216,6 +331,11 @@ protected void setEntityMarker(final String entityMarker) { flattener.setEntityMarker(entityMarker); } + /** + * Sett the {@link MorphErrorHandler}. + * + * @param errorHandler the {@link MorphErrorHandler} + */ public void setErrorHandler(final MorphErrorHandler errorHandler) { this.errorHandler = errorHandler; } @@ -399,6 +519,11 @@ public R setReceiver(final R streamReceiver) { return streamReceiver; } + /** + * Gets the {@link StreamReceiver}. + * + * @return the output {@link StreamReceiver} + */ public StreamReceiver getStreamReceiver() { return outputStreamReceiver; } @@ -454,6 +579,11 @@ public Collection getMapNames() { return Collections.unmodifiableSet(maps.keySet()); } + /** + * Adds a {@link FlushListener} to the record end. + * + * @param flushListener the {@link FlushListener} + */ public void registerRecordEndFlush(final FlushListener flushListener) { recordEndListener.add(flushListener); } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/MetamorphException.java b/metamorph/src/main/java/org/metafacture/metamorph/MetamorphException.java index b22901920..dfe778d8a 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/MetamorphException.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/MetamorphException.java @@ -28,6 +28,13 @@ public class MetamorphException extends MetafactureException { private static final long serialVersionUID = 0L; + /** + * Creates an instance of {@link MetamorphException} by a given message and + * cause. + * + * @param message the message + * @param cause the {@link Throwable} + */ public MetamorphException(final String message, final Throwable cause) { super(message, cause); } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/Splitter.java b/metamorph/src/main/java/org/metafacture/metamorph/Splitter.java index 0646e38b7..4d3eeb383 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/Splitter.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/Splitter.java @@ -44,16 +44,31 @@ public final class Splitter implements StreamPipe { private final Map receiverMap = new HashMap(); private final Metamorph metamorph; + /** + * Constructs a Splitter from the path to a Metamorph definition file. + * + * @param morphDef the name of the file of the Metamorph definition + */ public Splitter(final String morphDef) { metamorph = new Metamorph(morphDef); metamorph.setReceiver(singleValue); } + /** + * Constructs a Splitter from the Reader of a Metamorph definition. + * + * @param morphDef the Reader of the metamorph definition + */ public Splitter(final Reader morphDef) { metamorph = new Metamorph(morphDef); metamorph.setReceiver(singleValue); } + /** + * Constructs a Splitter from the Metamorph. + * + * @param metamorph the Metamoprh + */ public Splitter(final Metamorph metamorph) { this.metamorph = metamorph; metamorph.setReceiver(singleValue); @@ -65,6 +80,14 @@ public R setReceiver(final R receiver) { return receiver; } + /** + * Sets the receiver. + * + * @param the type of the receiver + * @param key the name of the receiver + * @param receiver the receiver + * @return the receiver + */ public R setReceiver(final String key, final R receiver) { receiverMap.put(key, receiver); return receiver; diff --git a/metamorph/src/main/java/org/metafacture/metamorph/collectors/All.java b/metamorph/src/main/java/org/metafacture/metamorph/collectors/All.java index 8990a22a9..9bebe2f92 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/collectors/All.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/collectors/All.java @@ -36,6 +36,9 @@ public final class All extends AbstractFlushingCollect { private final Set sources = new HashSet(); private final Set sourcesLeft = new HashSet(); + /** + * Creates an instance of {@link All}. + */ public All() { } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/collectors/Any.java b/metamorph/src/main/java/org/metafacture/metamorph/collectors/Any.java index df3289813..0ba64d1b8 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/collectors/Any.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/collectors/Any.java @@ -33,6 +33,9 @@ public final class Any extends AbstractCollect { private boolean receivedInput; private boolean emittedResult; + /** + * Creates an instance of {@link Any}. + */ public Any() { } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/collectors/Choose.java b/metamorph/src/main/java/org/metafacture/metamorph/collectors/Choose.java index 8ea10b752..24a0d6f5b 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/collectors/Choose.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/collectors/Choose.java @@ -34,9 +34,12 @@ public final class Choose extends AbstractFlushingCollect { private String value; private String name; private int priority = Integer.MAX_VALUE; - private final Map priorities = new HashMap(); + private final Map priorities = new HashMap<>(); private int nextPriority; + /** + * Creates an instance of {@link Choose}. + */ public Choose() { } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/collectors/Combine.java b/metamorph/src/main/java/org/metafacture/metamorph/collectors/Combine.java index be9c4b85e..8c694abc7 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/collectors/Combine.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/collectors/Combine.java @@ -36,6 +36,9 @@ public final class Combine extends AbstractFlushingCollect { private final Set sources = new HashSet(); private final Set sourcesLeft = new HashSet(); + /** + * Creates an instance of {@link Combine}. + */ public Combine() { } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/collectors/Concat.java b/metamorph/src/main/java/org/metafacture/metamorph/collectors/Concat.java index 9e51eee71..f16d26368 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/collectors/Concat.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/collectors/Concat.java @@ -34,21 +34,44 @@ public final class Concat extends AbstractFlushingCollect { private String currentDelimiter = ""; private boolean reverse; + /** + * Creates an instance of {@link Concat}. + */ public Concat() { } + /** + * Sets the prefix. + * + * @param prefix the prefix + */ public void setPrefix(final String prefix) { this.prefix = prefix; } + /** + * Sets the postfix. + * + * @param postfix the postfix + */ public void setPostfix(final String postfix) { this.postfix = postfix; } + /** + * Sets the delimiter. + * + * @param delimiter the delimiter + */ public void setDelimiter(final String delimiter) { this.delimiter = delimiter; } + /** + * Flasg wether the concatenation should be reversely done. + * + * @param reverse true if concatenation should be done reversely + */ public void setReverse(final boolean reverse) { this.reverse = reverse; } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/collectors/EqualsFilter.java b/metamorph/src/main/java/org/metafacture/metamorph/collectors/EqualsFilter.java index 8aaf181a6..3145e8eac 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/collectors/EqualsFilter.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/collectors/EqualsFilter.java @@ -38,6 +38,9 @@ public final class EqualsFilter extends AbstractFlushingCollect { private final Set sourcesLeft = new HashSet(); private boolean isEqual = true; + /** + * Creates an instance of {@link EqualsFilter}. + */ public EqualsFilter() { } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/collectors/Group.java b/metamorph/src/main/java/org/metafacture/metamorph/collectors/Group.java index a55992487..baf3f0f75 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/collectors/Group.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/collectors/Group.java @@ -27,6 +27,9 @@ */ public final class Group extends AbstractFlushingCollect { + /** + * Creates an instance of {@link Group}. + */ public Group() { } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/collectors/None.java b/metamorph/src/main/java/org/metafacture/metamorph/collectors/None.java index 4e8f5a694..c095278c5 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/collectors/None.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/collectors/None.java @@ -33,6 +33,9 @@ public final class None extends AbstractCollect { private boolean receivedInput; private boolean emittedResult; + /** + * Creates an instance of {@link None}. + */ public None() { } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/collectors/Range.java b/metamorph/src/main/java/org/metafacture/metamorph/collectors/Range.java index 486661c27..fd700b5aa 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/collectors/Range.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/collectors/Range.java @@ -35,13 +35,26 @@ public final class Range extends AbstractFlushingCollect { private int increment; private Integer first; + /** + * Creates an instance of {@link Range}. + */ public Range() { } + /** + * Gets the incrment. + * + * @return the increment + */ public int getIncrement() { return increment; } + /** + * Sets the incremenet. + * + * @param increment the increment + */ public void setIncrement(final int increment) { this.increment = increment; } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/collectors/Square.java b/metamorph/src/main/java/org/metafacture/metamorph/collectors/Square.java index 3cc19888e..d8be1aa4d 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/collectors/Square.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/collectors/Square.java @@ -36,17 +36,35 @@ public final class Square extends AbstractFlushingCollect { private String postfix = ""; private String delimiter = ""; + /** + * Creates an instance of {@link Square}. + */ public Square() { } + /** + * Sets the prefix. + * + * @param prefix the prefix + */ public void setPrefix(final String prefix) { this.prefix = prefix; } + /** + * Sets the postfix. + * + * @param postfix the postfix + */ public void setPostfix(final String postfix) { this.postfix = postfix; } + /** + * Sets the delimiter. + * + * @param delimiter the delimiter + */ public void setDelimiter(final String delimiter) { this.delimiter = delimiter; } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/collectors/Tuples.java b/metamorph/src/main/java/org/metafacture/metamorph/collectors/Tuples.java index d36acbf85..546d17632 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/collectors/Tuples.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/collectors/Tuples.java @@ -32,18 +32,32 @@ */ public final class Tuples extends AbstractFlushingCollect { - private final ListMap listMap = new ListMap(); + public static final int MIN_N = 1; + private final ListMap listMap = new ListMap<>(); - private int minN = 1; + private int minN = MIN_N; private String separator = ""; + /** + * Creates an instance of {@link Tuples}. + */ public Tuples() { } + /** + * Sets min N. Default value: {@value #MIN_N} + * + * @param minN the min N + */ public void setMinN(final int minN) { this.minN = minN; } + /** + * Sets the separator. + * + * @param separator the separator + */ public void setSeparator(final String separator) { this.separator = separator; } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/functions/AbstractCompose.java b/metamorph/src/main/java/org/metafacture/metamorph/functions/AbstractCompose.java index 5b3808732..bacb6c889 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/functions/AbstractCompose.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/functions/AbstractCompose.java @@ -31,24 +31,36 @@ abstract class AbstractCompose extends AbstractSimpleStatelessFunction { private String postfix = ""; /** - * @param prefix - * the prefix to set + * Sets the prefix. + * + * @param prefix the prefix to set */ public void setPrefix(final String prefix) { this.prefix = prefix; } + /** + * Gets the prefix. + * + * @return the prefix + */ protected String getPrefix() { return prefix; } + /** + * Gets the postfix. + * + * @return the postfix + */ protected String getPostfix() { return postfix; } /** - * @param postfix - * the postfix to set + * Sets the posfix. + * + * @param postfix the postfix to set */ public void setPostfix(final String postfix) { this.postfix = postfix; diff --git a/metamorph/src/main/java/org/metafacture/metamorph/functions/BlackList.java b/metamorph/src/main/java/org/metafacture/metamorph/functions/BlackList.java index 7f1da50e7..9b6017541 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/functions/BlackList.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/functions/BlackList.java @@ -24,6 +24,9 @@ */ public final class BlackList extends AbstractLookup { + /** + * Creates an instance of {@link BlackList}. + */ public BlackList() { } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/functions/Buffer.java b/metamorph/src/main/java/org/metafacture/metamorph/functions/Buffer.java index 7e5af9f16..c33de7140 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/functions/Buffer.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/functions/Buffer.java @@ -34,6 +34,9 @@ public final class Buffer extends AbstractFunction { private final List receipts = new ArrayList(); private int currentRecord; + /** + * Creates an instance of {@link Buffer}. + */ public Buffer() { } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/functions/Case.java b/metamorph/src/main/java/org/metafacture/metamorph/functions/Case.java index 666132e4f..084e977d3 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/functions/Case.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/functions/Case.java @@ -32,7 +32,7 @@ */ public final class Case extends AbstractSimpleStatelessFunction { - private static final String UPPER = "upper"; + public static final String UPPER = "upper"; private static final Set LANGUAGES; private Locale locale = Locale.getDefault(); private boolean toUpper; @@ -43,6 +43,9 @@ public final class Case extends AbstractSimpleStatelessFunction { LANGUAGES = Collections.unmodifiableSet(set); } + /** + * Creates an instance of {@link Case}. + */ public Case() { } @@ -54,10 +57,20 @@ public String process(final String value) { return value.toLowerCase(locale); } + /** + * Flags wether the case should be upper. + * + * @param string the case is set to upper when set to {@value #UPPER} + */ public void setTo(final String string) { this.toUpper = UPPER.equals(string); } + /** + * Sets the language if it's included in {@link #LANGUAGES}. + * + * @param language the language + */ public void setLanguage(final String language) { if (!LANGUAGES.contains(language)) { throw new MorphBuildException("Language " + language + " not supported."); diff --git a/metamorph/src/main/java/org/metafacture/metamorph/functions/Compose.java b/metamorph/src/main/java/org/metafacture/metamorph/functions/Compose.java index 487499400..faaff9950 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/functions/Compose.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/functions/Compose.java @@ -23,6 +23,9 @@ */ public final class Compose extends AbstractCompose { + /** + * Creates an instance of {@link Compose}. + */ public Compose() { } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/functions/Constant.java b/metamorph/src/main/java/org/metafacture/metamorph/functions/Constant.java index b031a4394..8db7b004d 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/functions/Constant.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/functions/Constant.java @@ -27,6 +27,9 @@ public final class Constant extends AbstractSimpleStatelessFunction { private String constValue; + /** + * Creates an instance of {@link Constant}. + */ public Constant() { } @@ -35,6 +38,11 @@ public String process(final String value) { return constValue; } + /** + * Sets the constant. + * + * @param string the constant + */ public void setValue(final String string) { this.constValue = string; } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/functions/Contains.java b/metamorph/src/main/java/org/metafacture/metamorph/functions/Contains.java index eb497d649..06f633834 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/functions/Contains.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/functions/Contains.java @@ -25,6 +25,9 @@ */ public final class Contains extends AbstractFilter { + /** + * Creates an instance of {@link Contains}. + */ public Contains() { } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/functions/Count.java b/metamorph/src/main/java/org/metafacture/metamorph/functions/Count.java index 2aea2b7aa..7f794e3bf 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/functions/Count.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/functions/Count.java @@ -28,6 +28,9 @@ public final class Count extends AbstractStatefulFunction { private int count; + /** + * Creates an instance of {@link Count}. + */ public Count() { } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/functions/DateFormat.java b/metamorph/src/main/java/org/metafacture/metamorph/functions/DateFormat.java index 0d240e669..ee4336d29 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/functions/DateFormat.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/functions/DateFormat.java @@ -122,6 +122,9 @@ int getEraId() { SUPPORTED_LANGUAGES = Collections.unmodifiableSet(set); } + /** + * Creates an instance of {@link DateFormat}. + */ public DateFormat() { } @@ -162,22 +165,49 @@ else if (era == Era.AD) { return result; } + /** + * Sets the input format. Default value: + * {@code #DEFAULT_INPUT_FORMAT} + * + * @param inputFormat the input format + */ public final void setInputFormat(final String inputFormat) { this.inputFormat = inputFormat; } + /** + * Sets the output format. Default value: + * {@link #DEFAULT_OUTPUT_FORMAT} + * + * @param outputFormat the output format + */ public final void setOutputFormat(final DateFormats outputFormat) { this.outputFormat = outputFormat; } + /** + * Sets the output format. Default value: {@link #DEFAULT_ERA} + * + * @param era the {@link Era} + */ public final void setEra(final Era era) { this.era = era; } + /** + * Flags wether to remove leading zeros. + * + * @param removeLeadingZeros true if leading zeros should be removed + */ public final void setRemoveLeadingZeros(final boolean removeLeadingZeros) { this.removeLeadingZeros = removeLeadingZeros; } + /** + * Sets the language if it's included in {@link #SUPPORTED_LANGUAGES}. + * + * @param language the language + */ public final void setLanguage(final String language) { if (!SUPPORTED_LANGUAGES.contains(language)) { throw new MorphBuildException("Language '" + language + "' not supported."); diff --git a/metamorph/src/main/java/org/metafacture/metamorph/functions/Equals.java b/metamorph/src/main/java/org/metafacture/metamorph/functions/Equals.java index 0be5edcd8..7f280ed9c 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/functions/Equals.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/functions/Equals.java @@ -25,6 +25,9 @@ */ public final class Equals extends AbstractFilter { + /** + * Creates an instance of {@link Equals}. + */ public Equals() { } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/functions/HtmlAnchor.java b/metamorph/src/main/java/org/metafacture/metamorph/functions/HtmlAnchor.java index 37df4cf29..969d73874 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/functions/HtmlAnchor.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/functions/HtmlAnchor.java @@ -26,9 +26,17 @@ public final class HtmlAnchor extends AbstractCompose { private String title; + /** + * Creates an instance of {@link HtmlAnchor}. + */ public HtmlAnchor() { } + /** + * Sets the title. + * + * @param title the title. + */ public void setTitle(final String title) { this.title = title; } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/functions/ISBN.java b/metamorph/src/main/java/org/metafacture/metamorph/functions/ISBN.java index 353ba1845..37bbfba6f 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/functions/ISBN.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/functions/ISBN.java @@ -28,10 +28,11 @@ */ public final class ISBN extends AbstractSimpleStatelessFunction { + public static final String ISBN10 = "isbn10"; + public static final String ISBN13 = "isbn13"; + private static final String CHECK = "0123456789X0"; - private static final String ISBN10 = "isbn10"; - private static final String ISBN13 = "isbn13"; private static final Pattern ISBN_PATTERN = Pattern.compile("[\\dX]+"); private static final Pattern DIRT_PATTERN = Pattern.compile("[\\.\\-]"); private static final int ISBN10_SIZE = 10; @@ -46,9 +47,17 @@ public final class ISBN extends AbstractSimpleStatelessFunction { private boolean verifyCheckDigit; private String errorString; + /** + * Creates an instance of {@link ISBN}. + */ public ISBN() { } + /** + * Sets the error message as a placeholder if the ISBN couln't be validated. + * + * @param errorString the error message as a placeholder + */ public void setErrorString(final String errorString) { this.errorString = errorString; } @@ -75,6 +84,14 @@ else if (to13 && ISBN10_SIZE == size) { return result; } + /** + * Cleanse the ISBN free of semantic sugar and uppercase a possible "x" + * character. + * + * @param isbn the ISBN + * @return the normalized ISBN or an empty string if normalization is not + * succesful + */ public static String cleanse(final String isbn) { String normValue = isbn.replace('x', 'X'); normValue = DIRT_PATTERN.matcher(normValue).replaceAll(""); @@ -85,6 +102,11 @@ public static String cleanse(final String isbn) { return ""; } + /** + * Sets the ISBN to ISBN-10 or ISBN-13. + * + * @param toString {@value #ISBN10} or {@value #ISBN13} + */ public void setTo(final String toString) { to13 = toString.equalsIgnoreCase(ISBN13); to10 = toString.equalsIgnoreCase(ISBN10); @@ -127,6 +149,12 @@ private static int charToInt(final char cha) { return (byte) cha - (byte) '0'; } + /** + * Converts an ISBN-13 to ISBN-10. + * + * @param isbn the ISBN-13 + * @return the ISBN-10 + */ public static String isbn13to10(final String isbn) { if (isbn.length() != ISBN13_SIZE) { throw new IllegalArgumentException( @@ -137,6 +165,12 @@ public static String isbn13to10(final String isbn) { return isbn10Data + check10(isbn10Data); } + /** + * Converts an ISBN-10 to ISBN-13. + * + * @param isbn the ISBN-10 + * @return the ISBN-13 + */ public static String isbn10to13(final String isbn) { if (isbn.length() != ISBN10_SIZE) { throw new IllegalArgumentException( @@ -148,6 +182,12 @@ public static String isbn10to13(final String isbn) { return isbn13Data + check13(isbn13Data); } + /** + * Checks if an ISBN is valid. + * + * @param isbn the ISBN + * @return true if it's valid and false if not + */ public static boolean isValid(final String isbn) { boolean result = false; @@ -162,6 +202,11 @@ else if (isbn.length() == ISBN13_SIZE) { return result; } + /** + * Flags wether the check digit should be verified. + * + * @param verifyCheckDigit "true" if the check digit should be verified + */ public void setVerifyCheckDigit(final String verifyCheckDigit) { this.verifyCheckDigit = "true".equals(verifyCheckDigit); } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/functions/Lookup.java b/metamorph/src/main/java/org/metafacture/metamorph/functions/Lookup.java index e340c9b5d..0c1b48b35 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/functions/Lookup.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/functions/Lookup.java @@ -26,9 +26,17 @@ public final class Lookup extends AbstractLookup { private String defaultValue; + /** + * Creates an instance of {@link Lookup}. + */ public Lookup() { } + /** + * Sets the default value. + * + * @param newDefaultValue the default value + */ public void setDefault(final String newDefaultValue) { defaultValue = newDefaultValue; } @@ -43,6 +51,11 @@ public String process(final String key) { return returnValue; } + /** + * Sets the name of the map. + * + * @param mapName the name of the map + */ public void setIn(final String mapName) { setMap(mapName); } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/functions/NormalizeUTF8.java b/metamorph/src/main/java/org/metafacture/metamorph/functions/NormalizeUTF8.java index 23c8b3880..fa349e3b9 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/functions/NormalizeUTF8.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/functions/NormalizeUTF8.java @@ -28,6 +28,9 @@ */ public final class NormalizeUTF8 extends AbstractSimpleStatelessFunction { + /** + * Creates an instance of {@link NormalizeUTF8}. + */ public NormalizeUTF8() { } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/functions/NotContains.java b/metamorph/src/main/java/org/metafacture/metamorph/functions/NotContains.java index 15094f404..7c812fa8e 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/functions/NotContains.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/functions/NotContains.java @@ -26,6 +26,9 @@ */ public final class NotContains extends AbstractFilter { + /** + * Creates an instance of {@link NotContains}. + */ public NotContains() { } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/functions/NotEquals.java b/metamorph/src/main/java/org/metafacture/metamorph/functions/NotEquals.java index 5b5c67b99..c7339b84c 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/functions/NotEquals.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/functions/NotEquals.java @@ -26,6 +26,9 @@ */ public final class NotEquals extends AbstractFilter { + /** + * Creates an instance of {@link NotEquals}. + */ public NotEquals() { } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/functions/Occurrence.java b/metamorph/src/main/java/org/metafacture/metamorph/functions/Occurrence.java index b3b26159a..254c5fbd7 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/functions/Occurrence.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/functions/Occurrence.java @@ -32,9 +32,9 @@ */ public final class Occurrence extends AbstractStatefulFunction { - private static final String LESS_THAN = "lessThan "; - private static final String MORE_THAN = "moreThan "; - + public static final String LESS_THAN = "lessThan "; + public static final String MORE_THAN = "moreThan "; + public static final boolean SAME_ENTITY = false; private int count; private String format; @@ -45,9 +45,12 @@ public boolean accept(final int value) { } }; - private final Map variables = new HashMap(); - private boolean sameEntity; + private final Map variables = new HashMap<>(); + private boolean sameEntity = SAME_ENTITY; + /** + * Creates an instance of {@link Occurrence}. + */ public Occurrence() { } @@ -69,6 +72,11 @@ private String processMatch(final String value) { return StringUtil.format(format, variables); } + /** + * Sets the format. + * + * @param format the format + */ public void setFormat(final String format) { this.format = format; } @@ -83,10 +91,23 @@ protected boolean doResetOnEntityChange() { return sameEntity; } + /** + * Sets the inequality. Use values starting with {@value #LESS_THAN} or + * {@value #MORE_THAN}. If the value is an integer it an equal filter will be + * set. + * + * @param only set the inequality, otherwise an equal filter will be used + */ public void setOnly(final String only) { filter = parse(only); } + /** + * Sets if the occurrence must be in the same entity. Default value: + * {@value #SAME_ENTITY} + * + * @param sameEntity true if the occurrence must be in the same entity + */ public void setSameEntity(final boolean sameEntity) { this.sameEntity = sameEntity; } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/functions/Regexp.java b/metamorph/src/main/java/org/metafacture/metamorph/functions/Regexp.java index b7490eb6a..fdb769647 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/functions/Regexp.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/functions/Regexp.java @@ -36,6 +36,9 @@ public final class Regexp extends AbstractFunction { private String format; private final Map tempVars = new HashMap(); + /** + * Creates an instance of {@link Regexp}. + */ public Regexp() { } @@ -76,10 +79,20 @@ private void populateVars() { } } + /** + * Sets the matcher. + * + * @param match the matcher + */ public void setMatch(final String match) { matcher = Pattern.compile(match).matcher(""); } + /** + * Sets the format. + * + * @param format the format + */ public void setFormat(final String format) { this.format = format; } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/functions/Replace.java b/metamorph/src/main/java/org/metafacture/metamorph/functions/Replace.java index 518f8ad62..ba494d782 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/functions/Replace.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/functions/Replace.java @@ -30,6 +30,9 @@ public final class Replace extends AbstractSimpleStatelessFunction { private Pattern pattern; private String with; + /** + * Creates an instance of {@link Replace}. + */ public Replace() { } @@ -38,10 +41,20 @@ public String process(final String value) { return pattern.matcher(value).replaceAll(with); } + /** + * Sets the pattern. + * + * @param string the pattern + */ public void setPattern(final String string) { pattern = Pattern.compile(string); } + /** + * Sets the replacement. + * + * @param with the replacement + */ public void setWith(final String with) { this.with = with; } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/functions/Script.java b/metamorph/src/main/java/org/metafacture/metamorph/functions/Script.java index e1110509f..ad78c9195 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/functions/Script.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/functions/Script.java @@ -28,7 +28,7 @@ import javax.script.ScriptException; /** - * A function which executes a javascript function. + * A function which executes a JavaScript function. * * @author Markus Michael Geipel */ @@ -37,15 +37,27 @@ public final class Script extends AbstractSimpleStatelessFunction { private Invocable invocable; private String invoke; + /** + * Creates an instance of {@link Script}. + */ public Script() { } + /** + * Flags wether to invoke the script. + * + * @param invoke true if script should be invoked + */ public void setInvoke(final String invoke) { this.invoke = invoke; } + /** + * Loads a JavaScript file. + * + * @param file the filename + */ public void setFile(final String file) { - final ScriptEngineManager manager = new ScriptEngineManager(); final ScriptEngine engine = manager.getEngineByName("JavaScript"); try { @@ -56,8 +68,7 @@ public void setFile(final String file) { throw new MorphBuildException("Error in script", e); } catch (final FileNotFoundException e) { - throw new MorphBuildException("Error loading script '" + file + "'", - e); + throw new MorphBuildException("Error loading script '" + file + "'", e); } invocable = (Invocable) engine; } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/functions/SetReplace.java b/metamorph/src/main/java/org/metafacture/metamorph/functions/SetReplace.java index c699cc969..214848922 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/functions/SetReplace.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/functions/SetReplace.java @@ -27,6 +27,9 @@ public final class SetReplace extends AbstractSimpleStatelessFunction { private final SetReplacer setReplacer = new SetReplacer(); private boolean prepared; + /** + * Creates an instance of {@link SetReplace}. + */ public SetReplace() { } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/functions/Split.java b/metamorph/src/main/java/org/metafacture/metamorph/functions/Split.java index b18af6dbc..af905cf63 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/functions/Split.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/functions/Split.java @@ -30,6 +30,9 @@ public final class Split extends AbstractFunction { private Pattern delimiterPattern; + /** + * Creates an instance of {@link Split}. + */ public Split() { } @@ -42,6 +45,11 @@ public void receive(final String name, final String value, final NamedValueSourc } } + /** + * Sets the delimiter. + * + * @param delimiter the delimiter + */ public void setDelimiter(final String delimiter) { this.delimiterPattern = Pattern.compile(delimiter); } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/functions/Substring.java b/metamorph/src/main/java/org/metafacture/metamorph/functions/Substring.java index 5987b0852..da52067e8 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/functions/Substring.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/functions/Substring.java @@ -28,6 +28,9 @@ public final class Substring extends AbstractSimpleStatelessFunction { private int start; private int end; + /** + * Creates an instance of {@link Substring}. + */ public Substring() { } @@ -50,16 +53,19 @@ public String process(final String value) { } /** - * @param start - * start of substring + * Sets the start of the substring. + * + * @param start start of substring */ public void setStart(final String start) { this.start = Integer.parseInt(start); } /** - * @param end end of substring, if end==0 the the complete - * remaining string is returned + * Sets the end of the substring. + * + * @param end end of substring, if end==0 the the complete remaining string is + * returned * */ public void setEnd(final String end) { diff --git a/metamorph/src/main/java/org/metafacture/metamorph/functions/SwitchNameValue.java b/metamorph/src/main/java/org/metafacture/metamorph/functions/SwitchNameValue.java index fc6f7abcb..7330eb65b 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/functions/SwitchNameValue.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/functions/SwitchNameValue.java @@ -26,6 +26,9 @@ */ public final class SwitchNameValue extends AbstractFunction { + /** + * Creates an instance of {@link SwitchNameValue}. + */ public SwitchNameValue() { } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/functions/Timestamp.java b/metamorph/src/main/java/org/metafacture/metamorph/functions/Timestamp.java index 3c25b5f5d..80b544ee0 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/functions/Timestamp.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/functions/Timestamp.java @@ -62,6 +62,9 @@ public final class Timestamp extends AbstractSimpleStatelessFunction { SUPPORTED_LANGUAGES = Collections.unmodifiableSet(set); } + /** + * Creates an instance of {@link Timestamp}. + */ public Timestamp() { } @@ -81,14 +84,29 @@ public String process(final String value) { return dateFormat.format(new Date()); } + /** + * Sets the format. Default value: {@value #DEFAULT_FORMAT} + * + * @param format the format + */ public void setFormat(final String format) { this.format = format; } + /** + * Sets the timezone. Default value: {@value #DEFAULT_TIMEZONE} + * + * @param timezone the timezone + */ public void setTimezone(final String timezone) { this.timezone = timezone; } + /** + * Sets the language if it's included in {@link #SUPPORTED_LANGUAGES}. + * + * @param language the language + */ public void setLanguage(final String language) { if (!SUPPORTED_LANGUAGES.contains(language)) { throw new MorphBuildException("Language '" + language + "' not supported."); diff --git a/metamorph/src/main/java/org/metafacture/metamorph/functions/Trim.java b/metamorph/src/main/java/org/metafacture/metamorph/functions/Trim.java index a4881c156..f91ff79a6 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/functions/Trim.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/functions/Trim.java @@ -25,6 +25,9 @@ */ public final class Trim extends AbstractSimpleStatelessFunction { + /** + * Creates an instance of {@link Trim}. + */ public Trim() { } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/functions/URLEncode.java b/metamorph/src/main/java/org/metafacture/metamorph/functions/URLEncode.java index 3996b7e1f..90debe481 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/functions/URLEncode.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/functions/URLEncode.java @@ -30,6 +30,9 @@ */ public final class URLEncode extends AbstractSimpleStatelessFunction { + /** + * Creates an instance of {@link URLEncode}. + */ public URLEncode() { } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/functions/Unique.java b/metamorph/src/main/java/org/metafacture/metamorph/functions/Unique.java index 572fca9f0..37fed5a78 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/functions/Unique.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/functions/Unique.java @@ -29,11 +29,11 @@ */ public final class Unique extends AbstractStatefulFunction { - private static final String ENTITY = "entity"; - private static final String NAME = "name"; - private static final String VALUE = "value"; + public static final String ENTITY = "entity"; + public static final String NAME = "name"; + public static final String VALUE = "value"; - private final Set set = new HashSet(); + private final Set set = new HashSet<>(); private boolean uniqueInEntity; @@ -44,6 +44,9 @@ public String createKey(final String name, final String value) { } }; + /** + * Creates an instance of {@link Unique}. + */ public Unique() { } @@ -67,10 +70,21 @@ protected boolean doResetOnEntityChange() { return uniqueInEntity; } + /** + * Flags wether the scope is {@link #ENTITY}. + * + * @param scope the scope + */ public void setIn(final String scope) { uniqueInEntity = ENTITY.equals(scope); } + /** + * Sets the Unique part to be processed. Possible values are {@value #NAME} + * or {@value #VALUE}. + * + * @param part the part + */ public void setPart(final String part) { if (NAME.equals(part)) { keyGenerator = new KeyGenerator() { diff --git a/metamorph/src/main/java/org/metafacture/metamorph/functions/WhiteList.java b/metamorph/src/main/java/org/metafacture/metamorph/functions/WhiteList.java index 30187ada9..bbcc75fd0 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/functions/WhiteList.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/functions/WhiteList.java @@ -23,6 +23,9 @@ */ public final class WhiteList extends AbstractLookup { + /** + * Creates an instance of {@link WhiteList}. + */ public WhiteList() { } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/maps/FileMap.java b/metamorph/src/main/java/org/metafacture/metamorph/maps/FileMap.java index ff2782b8f..b1066dcac 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/maps/FileMap.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/maps/FileMap.java @@ -36,20 +36,29 @@ /** * Provides a {@link Map} based on a file. The file is supposed to be UTF-8 - * encoded. The separator is by default \t. Important: Lines - * that are not split in two parts by the separator are ignored! + * encoded. The default separator is {@code \t}. Important: + * Lines that are not split in two parts by the separator are ignored! * * @author Markus Michael Geipel */ public final class FileMap extends AbstractReadOnlyMap { - private final Map map = new HashMap(); + private final Map map = new HashMap<>(); private Pattern split = Pattern.compile("\t", Pattern.LITERAL); + /** + * Creates an instance of {@link FileMap}. + */ public FileMap() { } + /** + * Sets a comma separated list of files which are then passed to + * {@link #setFile}. + * + * @param files a comma separated list of files + */ public void setFiles(final String files) { final String[] parts = files.split("\\s*,\\s*"); for (final String part : parts) { @@ -57,6 +66,13 @@ public void setFiles(final String files) { } } + /** + * Provides a {@link Map} based on a file. The file is supposed to be UTF-8 + * encoded. The default separator is {@code \t}. Important: + * Lines that are not split in two parts by the separator are ignored! + * + * @param file the file + */ public void setFile(final String file) { try ( InputStream stream = openStream(file); @@ -116,6 +132,13 @@ private Optional openAsUrl(final String file) { } } + /** + * Sets the separator. + * + * Default value: {@code \t} + * + * @param delimiter the separator + */ public void setSeparator(final String delimiter) { split = Pattern.compile(delimiter, Pattern.LITERAL); } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/maps/JndiSqlMap.java b/metamorph/src/main/java/org/metafacture/metamorph/maps/JndiSqlMap.java index 05400ad53..58be7996b 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/maps/JndiSqlMap.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/maps/JndiSqlMap.java @@ -41,9 +41,19 @@ public final class JndiSqlMap extends AbstractReadOnlyMap implem private DataSource datasource; private String query; + /** + * Creates an instance of {@link JndiSqlMap}. + */ public JndiSqlMap() { } + /** + * Sets the {@link DataSource}. + * + * @see InitialContext + * + * @param name the name to be looked up in the InitialContext. + */ public void setDatasource(final String name) { try { datasource = (DataSource) new InitialContext().lookup(name); @@ -53,6 +63,11 @@ public void setDatasource(final String name) { } } + /** + * Sets the query. + * + * @param query the query + */ public void setQuery(final String query) { this.query = query; } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/maps/RestMap.java b/metamorph/src/main/java/org/metafacture/metamorph/maps/RestMap.java index d69a78897..1a1921947 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/maps/RestMap.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/maps/RestMap.java @@ -38,13 +38,23 @@ */ public final class RestMap extends AbstractReadOnlyMap { + public static final String CHARSET_NAME = "UTF-8"; + private static final Pattern VAR_PATTERN = Pattern.compile("${key}", Pattern.LITERAL); - private String charsetName = "UTF-8"; + private String charsetName = CHARSET_NAME; private String url; + /** + * Creates an instance of {@link RestMap}. + */ public RestMap() { } + /** + * Creates an instance of {@link RestMap} by the given URL. + * + * @param url the URL + */ public RestMap(final String url) { this.url = url; } @@ -79,10 +89,20 @@ private String readFromUrl(final String targetUrl) throws IOException, URISyntax } } + /** + * Sets the URL. + * + * @param url the URL + */ public void setUrl(final String url) { this.url = url; } + /** + * Sets the charset name. Default value: {@value #CHARSET_NAME} + * + * @param name the charset name + */ public void setCharsetName(final String name) { charsetName = name; } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/maps/SqlMap.java b/metamorph/src/main/java/org/metafacture/metamorph/maps/SqlMap.java index 8a8d53a6b..390debad2 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/maps/SqlMap.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/maps/SqlMap.java @@ -48,9 +48,15 @@ public final class SqlMap extends AbstractReadOnlyMap implements private PreparedStatement preparedStatement; + /** + * Creates an instance of {@link SqlMap}. + */ public SqlMap() { } + /** + * Initializes the prepared statement using the {@link #query}. + */ public void init() { try { preparedStatement = getMySqlConnection().prepareStatement(query); @@ -107,26 +113,56 @@ public String get(final Object key) { return resultString; } + /** + * Sets the driver. + * + * @param driver the driver + */ public void setDriver(final String driver) { this.driver = driver; } + /** + * Sets the host. + * + * @param host the host + */ public void setHost(final String host) { this.host = host; } + /** + * Sets the login. + * + * @param login the login + */ public void setLogin(final String login) { this.login = login; } + /** + * Sets the password. + * + * @param password the password + */ public void setPassword(final String password) { this.password = password; } + /** + * Sets the database. + * + * @param database the database + */ public void setDatabase(final String database) { this.database = database; } + /** + * Sets the query. + * + * @param query the query + */ public void setQuery(final String query) { this.query = query; } diff --git a/metamorph/src/main/java/org/metafacture/metamorph/xml/DomLoader.java b/metamorph/src/main/java/org/metafacture/metamorph/xml/DomLoader.java index 8ed4d4f5f..e3a48242a 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/xml/DomLoader.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/xml/DomLoader.java @@ -62,6 +62,14 @@ private DomLoader() { throw new AssertionError("No instances allowed"); } + /** + * Returns a Document built from an InputSpurce and a schema file. Removes all + * ignorable whitespace and all text nodes containing only whitespace. + * + * @param schemaFile the name of the file of the schema + * @param input the InputSource + * @return the Document + */ public static Document parse(final String schemaFile, final InputSource input) { final Document document = createEmptyDocument(); final XMLReader pipeline = createXmlFilterPipeline(schemaFile, document); diff --git a/metamorph/src/main/java/org/metafacture/metamorph/xml/Location.java b/metamorph/src/main/java/org/metafacture/metamorph/xml/Location.java index aaee029e6..a089489b0 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/xml/Location.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/xml/Location.java @@ -50,28 +50,60 @@ public void handle(final short operation, final String key, final Object data, private final Locator elementStart; private final Locator elementEnd; + /** + * Constructs a Location from a Locator as start element and a Locator as end + * element. + * + * @param elementStart the Locator as start element + * @param elementEnd the Locator as end element + */ public Location(final Locator elementStart, final Locator elementEnd) { this.elementStart = new LocatorImpl(elementStart); this.elementEnd = new LocatorImpl(elementEnd); } + /** + * Constructs a Location from another Location. + * + * @param src the Location + */ public Location(final Location src) { elementStart = new LocatorImpl(src.elementStart); elementEnd = new LocatorImpl(src.elementEnd); } + /** + * Gets the start of the element. + * + * @return the start of the element + */ public Locator getElementStart() { return elementStart; } + /** + * Gets the end of the element. + * + * @return the end of the element + */ public Locator getElementEnd() { return elementEnd; } + /** + * Gets the system ID. + * + * @return the system ID + */ public String getSystemId() { return elementStart.getSystemId(); } + /** + * Gets the public ID + * + * @return the public ID + */ public String getPublicId() { return elementStart.getPublicId(); }