001 package biweekly.property; 002 003 import java.util.Arrays; 004 import java.util.Collection; 005 006 /* 007 Copyright (c) 2013, Michael Angstadt 008 All rights reserved. 009 010 Redistribution and use in source and binary forms, with or without 011 modification, are permitted provided that the following conditions are met: 012 013 1. Redistributions of source code must retain the above copyright notice, this 014 list of conditions and the following disclaimer. 015 2. Redistributions in binary form must reproduce the above copyright notice, 016 this list of conditions and the following disclaimer in the documentation 017 and/or other materials provided with the distribution. 018 019 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 020 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 021 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 022 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 023 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 024 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 025 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 026 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 027 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 028 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 029 */ 030 031 /** 032 * <p> 033 * Defines the level of sensitivity of the iCalendar data. If not specified, the 034 * data should be considered "public". 035 * </p> 036 * <p> 037 * <b>Examples:</b> 038 * 039 * <pre class="brush:java"> 040 * //creating a new property 041 * Classification classification = Classification.public_(); 042 * 043 * if (classification.isPublic()) { 044 * //its value is "PUBLIC" 045 * } 046 * </pre> 047 * 048 * </p> 049 * @author Michael Angstadt 050 * @rfc 5545 p.82-3 051 */ 052 public class Classification extends EnumProperty { 053 private static final String PUBLIC = "PUBLIC"; 054 private static final String PRIVATE = "PRIVATE"; 055 private static final String CONFIDENTIAL = "CONFIDENTIAL"; 056 057 /** 058 * Creates a new classification property. Use the static factory methods to 059 * create a property with a standard classification level. 060 * @param classification the classification level (e.g. "PUBLIC") 061 */ 062 public Classification(String classification) { 063 super(classification); 064 } 065 066 /** 067 * Creates a "public" classification property. 068 * @return the property 069 */ 070 public static Classification public_() { 071 return create(PUBLIC); 072 } 073 074 /** 075 * Determines if the classification level is "public". 076 * @return true if it's "public", false if not 077 */ 078 public boolean isPublic() { 079 return is(PUBLIC); 080 } 081 082 /** 083 * Creates a "private" classification property. 084 * @return the property 085 */ 086 public static Classification private_() { 087 return create(PRIVATE); 088 } 089 090 /** 091 * Determines if the classification level is "private". 092 * @return true if it's "private", false if not 093 */ 094 public boolean isPrivate() { 095 return is(PRIVATE); 096 } 097 098 /** 099 * Creates a "confidential" classification property. 100 * @return the property 101 */ 102 public static Classification confidential() { 103 return create(CONFIDENTIAL); 104 } 105 106 /** 107 * Determines if the classification level is "confidential". 108 * @return true if it's "confidential", false if not 109 */ 110 public boolean isConfidential() { 111 return is(CONFIDENTIAL); 112 } 113 114 private static Classification create(String classification) { 115 return new Classification(classification); 116 } 117 118 @Override 119 protected Collection<String> getStandardValues() { 120 return Arrays.asList(PUBLIC, PRIVATE, CONFIDENTIAL); 121 } 122 }