| 1 | package ezvcard.io.text; |
| 2 | |
| 3 | import ezvcard.VCardVersion; |
| 4 | |
| 5 | /* |
| 6 | Copyright (c) 2012-2023, Michael Angstadt |
| 7 | All rights reserved. |
| 8 | |
| 9 | Redistribution and use in source and binary forms, with or without |
| 10 | modification, are permitted provided that the following conditions are met: |
| 11 | |
| 12 | 1. Redistributions of source code must retain the above copyright notice, this |
| 13 | list of conditions and the following disclaimer. |
| 14 | 2. Redistributions in binary form must reproduce the above copyright notice, |
| 15 | this list of conditions and the following disclaimer in the documentation |
| 16 | and/or other materials provided with the distribution. |
| 17 | |
| 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR |
| 22 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | */ |
| 29 | |
| 30 | /** |
| 31 | * Used to pass information about the vCard being written to the property |
| 32 | * scribes. |
| 33 | * @author Michael Angstadt |
| 34 | */ |
| 35 | public class WriteContext { |
| 36 | private final VCardVersion version; |
| 37 | private final TargetApplication targetApplication; |
| 38 | private final boolean includeTrailingSemicolons; |
| 39 | |
| 40 | /** |
| 41 | * @param version the version that the vCard should adhere to |
| 42 | * @param targetApplication the application that the vCard is being targeted |
| 43 | * for or null not to target any specific application |
| 44 | * @param includeTrailingSemicolons true to include trailing semicolon |
| 45 | * delimiters for structured property values whose list of values end with |
| 46 | * null or empty values, false not to |
| 47 | */ |
| 48 | public WriteContext(VCardVersion version, TargetApplication targetApplication, boolean includeTrailingSemicolons) { |
| 49 | this.version = version; |
| 50 | this.targetApplication = targetApplication; |
| 51 | this.includeTrailingSemicolons = includeTrailingSemicolons; |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Gets the version that the vCard should adhere to. |
| 56 | * @return the vCard version |
| 57 | */ |
| 58 | public VCardVersion getVersion() { |
| 59 | return version; |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Gets the application that the vCard is being targeted for. |
| 64 | * @return the target application or null not to target any specific |
| 65 | * application |
| 66 | */ |
| 67 | public TargetApplication getTargetApplication() { |
| 68 | return targetApplication; |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Gets whether to include trailing semicolon delimiters for structured |
| 73 | * property values whose list of values end with null or empty values. |
| 74 | * @return true to include the trailing semicolons, false not to |
| 75 | */ |
| 76 | public boolean isIncludeTrailingSemicolons() { |
| 77 | return includeTrailingSemicolons; |
| 78 | } |
| 79 | } |