001package com.box.sdk; 002 003import java.util.Date; 004 005import com.eclipsesource.json.JsonObject; 006import com.eclipsesource.json.JsonValue; 007 008/** 009 * Represents a watermark. 010 * Watermarks are used to protect sensitive information in the Box account. 011 * 012 * @see <a href="https://docs.box.com/reference#watermarking">Watermarking</a> 013 */ 014public class BoxWatermark extends BoxJSONObject { 015 016 /** 017 * Default imprint for watermarks. 018 */ 019 public static final String WATERMARK_DEFAULT_IMPRINT = "default"; 020 021 /** 022 * Json key for watermark. 023 * @see BoxWatermark#parseJSONMember(JsonObject.Member) 024 */ 025 public static final String WATERMARK_JSON_KEY = "watermark"; 026 027 /** 028 * Json key for created_at param. 029 * @see BoxWatermark#parseJSONMember(JsonObject.Member) 030 */ 031 public static final String CREATED_AT_JSON_KEY = "created_at"; 032 033 /** 034 * Json key for modified_at param. 035 * @see BoxWatermark#parseJSONMember(JsonObject.Member) 036 */ 037 public static final String MODIFIED_AT_JSON_KEY = "modified_at"; 038 039 /** 040 * Json key for watermark param. 041 */ 042 public static final String WATERMARK_IMPRINT_JSON_KEY = "imprint"; 043 044 /** 045 * @see #getCreatedAt() 046 */ 047 private Date createdAt; 048 049 /** 050 * @see #getModifiedAt() 051 */ 052 private Date modifiedAt; 053 054 /** 055 * Constructs an empty watermark object. 056 */ 057 public BoxWatermark() { 058 super(); 059 } 060 061 /** 062 * Constructs a watermark object by parsing information from a JSON string. 063 * @param json the JSON string to parse. 064 */ 065 public BoxWatermark(String json) { 066 super(json); 067 } 068 069 /** 070 * Constructs a watermark object using an already parsed JSON object. 071 * @param jsonObject the parsed JSON object. 072 */ 073 BoxWatermark(JsonObject jsonObject) { 074 super(jsonObject); 075 } 076 077 /** 078 * @return the time that the watermark was created. 079 */ 080 public Date getCreatedAt() { 081 return this.createdAt; 082 } 083 084 /** 085 * @return the time that the watermark was last modified. 086 */ 087 public Date getModifiedAt() { 088 return this.modifiedAt; 089 } 090 091 /** 092 * {@inheritDoc} 093 */ 094 public BoxWatermark getResource() { 095 return BoxWatermark.this; 096 } 097 098 /** 099 * {@inheritDoc} 100 */ 101 @Override 102 void parseJSONMember(JsonObject.Member member) { 103 super.parseJSONMember(member); 104 String memberName = member.getName(); 105 JsonValue value = member.getValue(); 106 if (memberName.equals(WATERMARK_JSON_KEY)) { 107 try { 108 this.createdAt = BoxDateFormat.parse(value.asObject().get(CREATED_AT_JSON_KEY).asString()); 109 this.modifiedAt = BoxDateFormat.parse(value.asObject().get(MODIFIED_AT_JSON_KEY).asString()); 110 } catch (Exception e) { 111 throw new BoxDeserializationException(memberName, value.toString(), e); 112 } 113 } 114 } 115 116}