001package biweekly.property; 002 003import java.util.List; 004 005import biweekly.Warning; 006import biweekly.component.ICalComponent; 007 008/* 009 Copyright (c) 2013, Michael Angstadt 010 All rights reserved. 011 012 Redistribution and use in source and binary forms, with or without 013 modification, are permitted provided that the following conditions are met: 014 015 1. Redistributions of source code must retain the above copyright notice, this 016 list of conditions and the following disclaimer. 017 2. Redistributions in binary form must reproduce the above copyright notice, 018 this list of conditions and the following disclaimer in the documentation 019 and/or other materials provided with the distribution. 020 021 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 022 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 023 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 024 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 025 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 026 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 027 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 028 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 029 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 030 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 031 */ 032 033/** 034 * <p> 035 * Represents a response to a scheduling request. 036 * </p> 037 * <p> 038 * This property must have a status code defined. The following status code 039 * families are defined: 040 * <ul> 041 * <li><b>1.x</b> - The request has been received, but is still being processed. 042 * </li> 043 * <li><b>2.x</b> - The request was processed successfully.</li> 044 * <li><b>3.x</b> - There is a client-side problem with the request (such as 045 * some incorrect syntax).</li> 046 * <li><b>4.x</b> - A server-side error occurred.</li> 047 * </ul> 048 * </p> 049 * <p> 050 * <b>Code sample:</b> 051 * 052 * <pre class="brush:java"> 053 * VEvent event = new VEvent(); 054 * 055 * RequestStatus requestStatus = new RequestStatus("2.0"); 056 * requestStatus.setDescription("Success"); 057 * event.setRequestStatus(requestStatus); 058 * </pre> 059 * 060 * </p> 061 * @author Michael Angstadt 062 * @see <a href="http://tools.ietf.org/html/rfc5545#page-141">RFC 5545 p.141-3</a> 063 */ 064public class RequestStatus extends ICalProperty { 065 private String statusCode, description, exceptionText; 066 067 /** 068 * Creates a request status property. 069 * @param statusCode the status code (e.g. "1.1.3") 070 */ 071 public RequestStatus(String statusCode) { 072 setStatusCode(statusCode); 073 } 074 075 /** 076 * Gets the status code. The following status code families are defined: 077 * <ul> 078 * <li><b>1.x</b> - The request has been received, but is still being 079 * processed.</li> 080 * <li><b>2.x</b> - The request was processed successfully.</li> 081 * <li><b>3.x</b> - There is a client-side problem with the request (such as 082 * some incorrect syntax).</li> 083 * <li><b>4.x</b> - A server-side error occurred.</li> 084 * </ul> 085 * @return the status code (e.g. "1.1.3") 086 */ 087 public String getStatusCode() { 088 return statusCode; 089 } 090 091 /** 092 * Sets a status code. The following status code families are defined: 093 * <ul> 094 * <li><b>1.x</b> - The request has been received, but is still being 095 * processed.</li> 096 * <li><b>2.x</b> - The request was processed successfully.</li> 097 * <li><b>3.x</b> - There is a client-side problem with the request (such as 098 * some incorrect syntax).</li> 099 * <li><b>4.x</b> - A server-side error occurred.</li> 100 * </ul> 101 * @param statusCode the status code (e.g. "1.1.3") 102 */ 103 public void setStatusCode(String statusCode) { 104 this.statusCode = statusCode; 105 } 106 107 /** 108 * Gets the human-readable description of the status. 109 * @return the description (e.g. "Success") or null if not set 110 */ 111 public String getDescription() { 112 return description; 113 } 114 115 /** 116 * Sets a human-readable description of the status. 117 * @param description the description (e.g. "Success") or null to remove 118 */ 119 public void setDescription(String description) { 120 this.description = description; 121 } 122 123 /** 124 * Gets any additional data related to the response. 125 * @return the additional data or null if not set 126 */ 127 public String getExceptionText() { 128 return exceptionText; 129 } 130 131 /** 132 * Sets any additional data related to the response. 133 * @param exceptionText the additional data or null to remove 134 */ 135 public void setExceptionText(String exceptionText) { 136 this.exceptionText = exceptionText; 137 } 138 139 @Override 140 public String getLanguage() { 141 return super.getLanguage(); 142 } 143 144 @Override 145 public void setLanguage(String language) { 146 super.setLanguage(language); 147 } 148 149 @Override 150 protected void validate(List<ICalComponent> components, List<Warning> warnings) { 151 if (statusCode == null) { 152 warnings.add(Warning.validate(36)); 153 } 154 } 155}