Debian Codegraph @

src/main/java/ezvcard/io/ParseContext.java

raw symbols SCIP
1 package ezvcard.io;
2
3 import java.util.ArrayList;
4 import java.util.List;
5
6 import ezvcard.VCardVersion;
7
8 /*
9 Copyright (c) 2012-2023, Michael Angstadt
10 All rights reserved.
11
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions are met:
14
15 1. Redistributions of source code must retain the above copyright notice, this
16 list of conditions and the following disclaimer.
17 2. Redistributions in binary form must reproduce the above copyright notice,
18 this list of conditions and the following disclaimer in the documentation
19 and/or other materials provided with the distribution.
20
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
25 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
32 The views and conclusions contained in the software and documentation are those
33 of the authors and should not be interpreted as representing official policies,
34 either expressed or implied, of the FreeBSD Project.
35 */
36
37 /**
38 * Stores information used during the parsing of a vCard.
39 * @author Michael Angstadt
40 */
41 public class ParseContext {
42 private VCardVersion version;
43 private List<ParseWarning> warnings = new ArrayList<>();
44 private Integer lineNumber;
45 private String propertyName;
46
47 /**
48 * Gets the version of the vCard being parsed.
49 * @return the vCard version
50 */
51 public VCardVersion getVersion() {
52 return version;
53 }
54
55 /**
56 * Sets the version of the vCard being parsed.
57 * @param version the vCard version
58 */
59 public void setVersion(VCardVersion version) {
60 this.version = version;
61 }
62
63 /**
64 * Gets the line number the parser is currently on.
65 * @return the line number or null if not applicable
66 */
67 public Integer getLineNumber() {
68 return lineNumber;
69 }
70
71 /**
72 * Sets the line number the parser is currently on.
73 * @param lineNumber the line number or null if not applicable
74 */
75 public void setLineNumber(Integer lineNumber) {
76 this.lineNumber = lineNumber;
77 }
78
79 /**
80 * Gets the name of the property that the parser is currently parsing.
81 * @return the property name (e.g. "FN") or null if not applicable
82 */
83 public String getPropertyName() {
84 return propertyName;
85 }
86
87 /**
88 * Sets the name of the property that the parser is currently parsing.
89 * @param propertyName the property name (e.g. "FN") or null if not
90 * applicable
91 */
92 public void setPropertyName(String propertyName) {
93 this.propertyName = propertyName;
94 }
95
96 /**
97 * Adds a parse warning.
98 * @param code the warning code
99 * @param args the warning message arguments
100 */
101 public void addWarning(int code, Object... args) {
102 //@formatter:off
103 warnings.add(new ParseWarning.Builder(this)
104 .message(code, args)
105 .build());
106 //@formatter:on
107 }
108
109 /**
110 * Adds a parse warning.
111 * @param message the warning message
112 */
113 public void addWarning(String message) {
114 //@formatter:off
115 warnings.add(new ParseWarning.Builder(this)
116 .message(message)
117 .build());
118 //@formatter:on
119 }
120
121 /**
122 * Gets the parse warnings.
123 * @return the parse warnings
124 */
125 public List<ParseWarning> getWarnings() {
126 return warnings;
127 }
128 }