1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.millscript.commons.xml.token;
22
23 import org.millscript.commons.alert.Alert;
24 import org.millscript.commons.alert.AlertDecorator;
25 import org.millscript.commons.xml.api.token.PIToken;
26 import org.millscript.commons.xml.api.token.TokenVisitor;
27
28 /**
29 * This class provides a default implementation of the processing instruction
30 * token.
31 */
32 public class PITokenImpl implements AlertDecorator, PIToken {
33
34 /**
35 * The processing instruction character data.
36 */
37 private final String data;
38
39 /**
40 * The processing instruction target.
41 */
42 private final String target;
43
44 /**
45 * Contructs a new processing instruction token with the specified target
46 * and character data.
47 *
48 * @param t the processing instruction target
49 * @param d the processing instruction character data
50 */
51 public PITokenImpl( final String t, final String d ) {
52 this.data = d;
53 this.target = t;
54 }
55
56 /**
57 * @see org.millscript.commons.alert.AlertDecorator#decorate(org.millscript.commons.alert.Alert)
58 */
59 public Alert decorate( final Alert alert ) {
60 return alert.culprit(
61 "processing instruction",
62 "<?" + this.target + " ...?>"
63 );
64 }
65
66 /**
67 * @see org.millscript.commons.xml.api.token.PIToken#getData()
68 */
69 public String getData() {
70 return this.data;
71 }
72
73 /**
74 * @see org.millscript.commons.xml.api.token.PIToken#getTarget()
75 */
76 public String getTarget() {
77 return this.target;
78 }
79
80 /**
81 * @see org.millscript.commons.xml.api.token.Token#visit(org.millscript.commons.xml.api.token.TokenVisitor)
82 */
83 public void visit( final TokenVisitor tokenVisitor ) {
84 tokenVisitor.visit( this );
85 }
86
87 }