- Timestamp:
- 08/09/14 20:45:17 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
FCSSimpleEndpoint/trunk/src/main/java/eu/clarin/sru/server/fcs/DataView.java
r5477 r5546 1 1 package eu.clarin.sru.server.fcs; 2 2 3 /** 4 * This class is used to hold information about a data view that is implemented 5 * by the endpoint. 6 */ 3 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; 4 24 5 public enum PayloadDelivery {6 SEND_BY_DEFAULT, NEED_TO_REQUEST;7 8 @Override9 public String toString(){10 String str = super.toString().toLowerCase();11 return str.replace("_", "-");12 }13 }14 25 15 public enum PayloadDisposition { 16 INLINE, REFERENCE; 17 18 @Override 19 public String toString(){ 20 return super.toString().toLowerCase(); 21 } 22 } 23 24 private String description; 25 private String mimeType; 26 private String payloadDisposition; 27 private String payloadDelivery; 28 private String shortIdentifier; 29 30 public DataView() { } 31 public DataView(String description, String mimeType, 32 PayloadDisposition payloadDisposition, PayloadDelivery payloadDelivery, 33 String shortId){ 34 this.description = description; 35 this.mimeType = mimeType; 36 this.payloadDisposition = payloadDisposition.toString(); 37 this.payloadDelivery = payloadDelivery.toString(); 38 this.shortIdentifier = shortId; 39 } 40 41 42 public String getDescription() { 43 return description; 44 } 45 public void setDescription(String description) { 46 this.description = description; 47 } 48 public String getMimeType() { 49 return mimeType; 50 } 51 public void setMimeType(String mimeType) { 52 this.mimeType = mimeType; 53 } 54 public String getPayloadDisposition() { 55 return payloadDisposition; 56 } 57 public void setPayloadDisposition(String payloadDisposition) { 58 this.payloadDisposition = payloadDisposition; 59 } 60 public String getPayloadDelivery() { 61 return payloadDelivery; 62 } 63 public void setPayloadDelivery(String payloadDelivery) { 64 this.payloadDelivery = payloadDelivery; 65 } 66 public String getShortIdentifier() { 67 return shortIdentifier; 68 } 69 public void setShortIdentifier(String shortIdentifier) { 70 this.shortIdentifier = shortIdentifier; 71 } 72 } 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
Note: See TracChangeset
for help on using the changeset viewer.