View Javadoc

1   /*
2    * $Id: XMLComment.java,v 1.6 2005/06/01 14:36:03 jlerner Exp $
3    *
4    * Copyright (c) 1999-2004, BBN Technologies, LLC.
5    * All rights reserved.
6    * http://www.daml.org/legal/opensource/bbn_license.html
7    */
8   package com.bbn.swede.core.dom;
9   
10  import org.eclipse.jface.text.IRegion;
11  import org.eclipse.jface.text.Region;
12  
13  /***
14   * Custom text node implementation for XML comments.
15   * @author jlerner
16   */
17  public class XMLComment extends TextNode
18  {
19     private static final String SS_BEGIN = "<!--";
20     private static final String SS_END = "-->";
21     
22     /***
23      * Creates a new XML comment node.
24      * @param sText The full text of the comment.
25      */
26     public XMLComment(String sText)
27     {
28        super(sText);
29        _iLength = SS_BEGIN.length() + _sText.length() + SS_END.length();
30     }
31  
32     /*
33      *  (non-Javadoc)
34      * @see com.bbn.swede.core.dom.OASTNode#allowedChildren()
35      */
36     protected int[] allowedChildren()
37     {
38        return null;
39     }
40  
41     /*
42      *  (non-Javadoc)
43      * @see com.bbn.swede.core.dom.OASTNode#getNodeType()
44      */
45     public int getNodeType()
46     {
47        return OASTNode.COMMENT;
48     }
49  
50     /*
51      *  (non-Javadoc)
52      * @see com.bbn.swede.core.dom.OASTNode#generateNodeText()
53      */
54     public String generateNodeText()
55     {
56        return toString();
57     }
58  
59     /*
60      *  (non-Javadoc)
61      * @see com.bbn.swede.core.dom.OASTNode#simplePartitioning()
62      */
63     public IRegion[] simplePartitioning()
64     {
65        return new IRegion[] {new Region(getOffset(), getLength())};
66     }
67  
68     /*
69      *  (non-Javadoc)
70      * @see java.lang.Object#toString()
71      */
72     public String toString()
73     {
74        return SS_BEGIN + _sText + SS_END;
75     }
76  }