1 | /** |
---|
2 | * This software is copyright (c) 2013-2022 by |
---|
3 | * - Leibniz-Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) |
---|
4 | * This is free software. You can redistribute it |
---|
5 | * and/or modify it under the terms described in |
---|
6 | * the GNU General Public License v3 of which you |
---|
7 | * should have received a copy. Otherwise you can download |
---|
8 | * it from |
---|
9 | * |
---|
10 | * http://www.gnu.org/licenses/gpl-3.0.txt |
---|
11 | * |
---|
12 | * @copyright Leibniz-Institut fuer Deutsche Sprache (http://www.ids-mannheim.de) |
---|
13 | * |
---|
14 | * @license http://www.gnu.org/licenses/gpl-3.0.txt |
---|
15 | * GNU General Public License v3 |
---|
16 | */ |
---|
17 | package eu.clarin.sru.server.fcs; |
---|
18 | |
---|
19 | /** |
---|
20 | * This class is used to hold information about a data view that is implemented |
---|
21 | * by the endpoint. |
---|
22 | */ |
---|
23 | public class DataView { |
---|
24 | /** |
---|
25 | * Enumeration to indicate the delivery policy of a data view. |
---|
26 | */ |
---|
27 | public enum DeliveryPolicy { |
---|
28 | /** |
---|
29 | * The data view is sent automatically by the endpoint. |
---|
30 | */ |
---|
31 | SEND_BY_DEFAULT, |
---|
32 | /** |
---|
33 | * A client must explicitly request the endpoint. |
---|
34 | */ |
---|
35 | NEED_TO_REQUEST; |
---|
36 | } // enum PayloadDelivery |
---|
37 | private final String identifier; |
---|
38 | private final String mimeType; |
---|
39 | private final DeliveryPolicy deliveryPolicy; |
---|
40 | |
---|
41 | |
---|
42 | /** |
---|
43 | * Constructor. |
---|
44 | * |
---|
45 | * @param identifier |
---|
46 | * a unique short identifier for the data view |
---|
47 | * @param mimeType |
---|
48 | * the MIME type of the data view |
---|
49 | * @param deliveryPolicy |
---|
50 | * the delivery policy for this data view |
---|
51 | */ |
---|
52 | public DataView(String identifier, String mimeType, |
---|
53 | DeliveryPolicy deliveryPolicy) { |
---|
54 | if (identifier == null) { |
---|
55 | throw new NullPointerException("identifier == null"); |
---|
56 | } |
---|
57 | if (identifier.isEmpty()) { |
---|
58 | throw new IllegalArgumentException("identifier is empty"); |
---|
59 | } |
---|
60 | this.identifier = identifier; |
---|
61 | |
---|
62 | if (mimeType == null) { |
---|
63 | throw new NullPointerException("mimeType == null"); |
---|
64 | } |
---|
65 | if (mimeType.isEmpty()) { |
---|
66 | throw new IllegalArgumentException("mimeType is empty"); |
---|
67 | } |
---|
68 | this.mimeType = mimeType; |
---|
69 | |
---|
70 | if (deliveryPolicy == null) { |
---|
71 | throw new NullPointerException("deliveryPolicy == null"); |
---|
72 | } |
---|
73 | this.deliveryPolicy = deliveryPolicy; |
---|
74 | } |
---|
75 | |
---|
76 | |
---|
77 | /** |
---|
78 | * Get the identifier of this data view. |
---|
79 | * |
---|
80 | * @return the identifier of the data view |
---|
81 | */ |
---|
82 | public String getIdentifier() { |
---|
83 | return identifier; |
---|
84 | } |
---|
85 | |
---|
86 | |
---|
87 | /** |
---|
88 | * Get the MIME type of this data view. |
---|
89 | * |
---|
90 | * @return the MIME type of this data view |
---|
91 | */ |
---|
92 | public String getMimeType() { |
---|
93 | return mimeType; |
---|
94 | } |
---|
95 | |
---|
96 | |
---|
97 | /** |
---|
98 | * Get the delivery policy for this data view. |
---|
99 | * |
---|
100 | * @return the delivery policy of this data view |
---|
101 | * @see DeliveryPolicy |
---|
102 | */ |
---|
103 | public DeliveryPolicy getDeliveryPolicy() { |
---|
104 | return deliveryPolicy; |
---|
105 | } |
---|
106 | |
---|
107 | |
---|
108 | @Override |
---|
109 | public String toString() { |
---|
110 | StringBuilder sb = new StringBuilder(); |
---|
111 | sb.append(getClass().getSimpleName()); |
---|
112 | sb.append("["); |
---|
113 | sb.append("identifier=").append(identifier); |
---|
114 | sb.append(", mimeType=").append(mimeType); |
---|
115 | sb.append("]"); |
---|
116 | return sb.toString(); |
---|
117 | } |
---|
118 | |
---|
119 | } // class DataView |
---|