1 | package eu.clarin.sru.server.fcs; |
---|
2 | |
---|
3 | /** |
---|
4 | * This class is used to hold information about a data view that is implemented |
---|
5 | * by the endpoint. |
---|
6 | */ |
---|
7 | public class DataView { |
---|
8 | /** |
---|
9 | * Enumeration to indicate the delivery policy of a data view. |
---|
10 | */ |
---|
11 | public enum DeliveryPolicy { |
---|
12 | /** |
---|
13 | * The data view is sent automatically by the endpoint. |
---|
14 | */ |
---|
15 | SEND_BY_DEFAULT, |
---|
16 | /** |
---|
17 | * A client must explicitly request the endpoint. |
---|
18 | */ |
---|
19 | NEED_TO_REQUEST; |
---|
20 | } // enum PayloadDelivery |
---|
21 | private final String identifier; |
---|
22 | private final String mimeType; |
---|
23 | private final DeliveryPolicy deliveryPolicy; |
---|
24 | |
---|
25 | |
---|
26 | /** |
---|
27 | * Constructor. |
---|
28 | * |
---|
29 | * @param identifier |
---|
30 | * a unique short identifier for the data view |
---|
31 | * @param mimeType |
---|
32 | * the MIME type of the data view |
---|
33 | * @param deliveryPolicy |
---|
34 | * the delivery policy for this data view |
---|
35 | */ |
---|
36 | public DataView(String identifier, String mimeType, |
---|
37 | DeliveryPolicy deliveryPolicy) { |
---|
38 | if (identifier == null) { |
---|
39 | throw new NullPointerException("identifier == null"); |
---|
40 | } |
---|
41 | if (identifier.isEmpty()) { |
---|
42 | throw new IllegalArgumentException("identifier is empty"); |
---|
43 | } |
---|
44 | this.identifier = identifier; |
---|
45 | |
---|
46 | if (mimeType == null) { |
---|
47 | throw new NullPointerException("mimeType == null"); |
---|
48 | } |
---|
49 | if (mimeType.isEmpty()) { |
---|
50 | throw new IllegalArgumentException("mimeType is empty"); |
---|
51 | } |
---|
52 | this.mimeType = mimeType; |
---|
53 | |
---|
54 | if (deliveryPolicy == null) { |
---|
55 | throw new NullPointerException("deliveryPolicy == null"); |
---|
56 | } |
---|
57 | this.deliveryPolicy = deliveryPolicy; |
---|
58 | } |
---|
59 | |
---|
60 | |
---|
61 | public String getIdentifier() { |
---|
62 | return identifier; |
---|
63 | } |
---|
64 | |
---|
65 | |
---|
66 | public String getMimeType() { |
---|
67 | return mimeType; |
---|
68 | } |
---|
69 | |
---|
70 | |
---|
71 | public DeliveryPolicy getDeliveryPolicy() { |
---|
72 | return deliveryPolicy; |
---|
73 | } |
---|
74 | |
---|
75 | |
---|
76 | @Override |
---|
77 | public String toString() { |
---|
78 | StringBuilder sb = new StringBuilder(); |
---|
79 | sb.append(getClass().getSimpleName()); |
---|
80 | sb.append("["); |
---|
81 | sb.append("identifier=").append(identifier); |
---|
82 | sb.append(", mimeType=").append(mimeType); |
---|
83 | sb.append("]"); |
---|
84 | return sb.toString(); |
---|
85 | } |
---|
86 | } // class DataView |
---|