View Javadoc

1   ////////////////////////////////////////////////////////////////////////////////
2   // MillScript-XML: an Open Spice interpreter and batch website creation tool
3   // Copyright (C) 2005 Kevin Rogers
4   //
5   // This file is part of MillScript-XML.
6   //
7   // MillScript-XML is free software; you can redistribute it and/or modify it under
8   // the terms of the GNU General Public License as published by the Free
9   // Software Foundation; either version 2 of the License, or (at your option)
10  // any later version.
11  //
12  // MillScript-XML is distributed in the hope that it will be useful, but WITHOUT
13  // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
15  // more details.
16  //
17  // You should have received a copy of the GNU General Public License along with
18  // MillScript-XML; if not, write to the Free Software Foundation, Inc., 59 Temple
19  // Place, Suite 330, Boston, MA  02111-1307  USA
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  }