1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2015 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
package eu.etaxonomy.cdm.format;
|
11
|
|
12
|
/**
|
13
|
* Implementing classes provide a string representation for a given object.
|
14
|
* How the the string is built can be configured
|
15
|
* by using the {@link FormatKey} enum.<br>
|
16
|
* @author pplitzner
|
17
|
* @date Nov 30, 2015
|
18
|
*
|
19
|
*/
|
20
|
public interface ICdmFormatter {
|
21
|
|
22
|
public static enum FormatKey{
|
23
|
/*basics*/
|
24
|
COMMA,
|
25
|
OPEN_BRACKET,
|
26
|
CLOSE_BRACKET,
|
27
|
SPACE,
|
28
|
/*identifiable entity*/
|
29
|
SAMPLE_DESIGNATION,
|
30
|
/*specimenOrObservationBase*/
|
31
|
RECORD_BASIS,
|
32
|
KIND_OF_UNIT,
|
33
|
/*field unit*/
|
34
|
FIELD_NUMBER,
|
35
|
/*gathering event*/
|
36
|
GATHERING_COUNTRY,
|
37
|
GATHERING_LOCALITY_TEXT,
|
38
|
GATHERING_DATE,
|
39
|
GATHERING_COLLECTOR,
|
40
|
/*derived unit*/
|
41
|
COLLECTION_CODE,
|
42
|
COLLECTION_NAME,
|
43
|
MOST_SIGNIFICANT_IDENTIFIER,
|
44
|
ACCESSION_NUMBER,
|
45
|
BARCODE,
|
46
|
CATALOG_NUMBER,
|
47
|
/*media specimen*/
|
48
|
MEDIA_TITLE,
|
49
|
MEDIA_ARTIST,
|
50
|
/*sequence*/
|
51
|
SEQUENCE_DNA_MARKER,
|
52
|
/*single read*/
|
53
|
SINGLE_READ_PRIMER,
|
54
|
AMPLIFICATION_LABEL,
|
55
|
}
|
56
|
|
57
|
/**
|
58
|
* Returns a string representation of the given object.<br>
|
59
|
* The is built according to the formatKeys passed as arguments.<br>
|
60
|
* E.g.
|
61
|
* <code>
|
62
|
* format(derivedUnit, GATHERING_COUNTRY, COMMA, GATHERING_COLLECTOR, COMMA, OPEN_BRACKET, COLLECTION_CODE, CLOSE_BRACKET
|
63
|
* </code> will result in something like <i>Peru, L. (B)</i>
|
64
|
*
|
65
|
* @param object the object which should be formatted as a string representation
|
66
|
* @param formatKeys a list of enum values specifying the parts of which the string consists
|
67
|
* @return a string representation of the given object according to the chosen enum values
|
68
|
*/
|
69
|
public String format(Object object, FormatKey... formatKeys);
|
70
|
|
71
|
/**
|
72
|
* Returns a string representation of the given object.<br>
|
73
|
* <b>Note:</b> Only use this method if the formatKeys for this
|
74
|
* ICdmFormatter have been set before. Otherwise the string might be empty.
|
75
|
* @param object the object which should be formatted as a string representation
|
76
|
* @return a string representation of the given object
|
77
|
*/
|
78
|
public String format(Object object);
|
79
|
|
80
|
}
|