1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package org.modeshape.sequencer.ddl;
25
26 import org.modeshape.common.text.ParsingException;
27 import org.modeshape.common.text.Position;
28 import org.modeshape.sequencer.ddl.DdlConstants.Problems;
29
30
31
32
33 public class DdlParserProblem extends ParsingException implements DdlConstants.Problems {
34 private static final long serialVersionUID = 2010539270968770893L;
35
36 private int level = OK;
37 private String unusedSource;
38
39
40
41
42 public DdlParserProblem( Position position ) {
43 super(position);
44
45 }
46
47
48
49
50
51
52
53 public DdlParserProblem( int level,
54 Position position,
55 String message,
56 Throwable cause ) {
57 super(position, message, cause);
58 this.level = level;
59 }
60
61
62
63
64
65
66 public DdlParserProblem( int level,
67 Position position,
68 String message ) {
69 super(position, message);
70 this.level = level;
71 }
72
73
74
75
76 public String getUnusedSource() {
77 return this.unusedSource;
78 }
79
80
81
82
83 public void setUnusedSource( String unusedSource ) {
84 if (unusedSource == null) {
85 unusedSource = "";
86 }
87 this.unusedSource = unusedSource;
88 }
89
90 public void appendSource( boolean addSpaceBefore,
91 String value ) {
92 if (addSpaceBefore) {
93 this.unusedSource = this.unusedSource + DdlConstants.SPACE;
94 }
95 this.unusedSource = this.unusedSource + value;
96 }
97
98 public void appendSource( boolean addSpaceBefore,
99 String value,
100 String... additionalStrs ) {
101 if (addSpaceBefore) {
102 this.unusedSource = this.unusedSource + DdlConstants.SPACE;
103 }
104 this.unusedSource = this.unusedSource + value;
105 }
106
107
108
109
110 public int getLevel() {
111 return level;
112 }
113
114
115
116
117 public void setLevel( int level ) {
118 this.level = level;
119 }
120
121
122
123
124
125
126 @Override
127 public String toString() {
128 if (this.level == WARNING) {
129 return ("WARNING: " + super.toString());
130 } else if (this.level == ERROR) {
131 return ("ERROR: " + super.toString());
132 }
133
134 return super.toString();
135 }
136
137 }