Project

General

Profile

Download (2.65 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2015 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.format;
10

    
11
/**
12
 * Implementing classes provide a string representation for a given object.
13
 * How the the string is built can be configured
14
 * by using the {@link FormatKey} enum.<br>
15
 *
16
 * @author pplitzner
17
 * @since Nov 30, 2015
18
 */
19
public interface ICdmFormatter {
20

    
21
    public static enum FormatKey{
22
        /*basics*/
23
        COMMA,
24
        OPEN_BRACKET,
25
        CLOSE_BRACKET,
26
        SPACE,
27
        /*identifiable entity*/
28
        SAMPLE_DESIGNATION,
29
        /*specimenOrObservationBase*/
30
        RECORD_BASIS,
31
        KIND_OF_UNIT,
32
        /*field unit*/
33
        FIELD_NUMBER,
34
        /*gathering event*/
35
        GATHERING_COUNTRY,
36
        GATHERING_LOCALITY_TEXT,
37
        GATHERING_DATE,
38
        GATHERING_COLLECTOR,
39
        /*derived unit*/
40
        COLLECTION_CODE,
41
        COLLECTION_NAME,
42
        MOST_SIGNIFICANT_IDENTIFIER,
43
        ACCESSION_NUMBER,
44
        BARCODE,
45
        CATALOG_NUMBER,
46
        /*media specimen*/
47
        MEDIA_TITLE,
48
        MEDIA_ARTIST,
49
        MEDIA_TITLE_CACHE,
50
        /*sequence*/
51
        SEQUENCE_DNA_MARKER,
52
        /*single read*/
53
        SINGLE_READ_PRIMER,
54
        SINGLE_READ_PHEROGRAM_TITLE_CACHE,
55
        AMPLIFICATION_LABEL,
56
    }
57

    
58
    /**
59
     * Returns a string representation of the given object.<br>
60
	 * The is built according to the formatKeys passed as arguments.<br>
61
	 * E.g.
62
	 * <code>
63
	 * format(derivedUnit, GATHERING_COUNTRY, COMMA, GATHERING_COLLECTOR, COMMA, OPEN_BRACKET, COLLECTION_CODE, CLOSE_BRACKET
64
	 * </code> will result in something like <i>Peru, L. (B)</i>
65
	 *
66
	 * Note:
67
	 *
68
	 * @param object the object which should be formatted as a string representation
69
	 * @param formatKeys a list of enum values specifying the parts of which the string consists
70
	 * @throws UnsupportedOperationException if the <tt>format</tt> operation
71
     *         is not supported by this formatter
72
     * @return a string representation of the given object according to the chosen enum values
73
	 */
74
    public String format(Object object, FormatKey... formatKeys);
75

    
76
    /**
77
     * Returns a string representation of the given object.<br>
78
     * <b>Note:</b> Only use this method if the formatKeys for this
79
     * ICdmFormatter have been set before. Otherwise the string might be empty.
80
     * @param object the object which should be formatted as a string representation
81
     * @return a string representation of the given object
82
     */
83
    public String format(Object object);
84

    
85
}
(6-6/7)