KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > openedit > modules > html > Token


1 /*
2  * Created on Nov 28, 2003
3  *
4 /*
5 Copyright (c) 2003 eInnovation Inc. All rights reserved
6
7 This library is free software; you can redistribute it and/or modify it under the terms
8 of the GNU Lesser General Public License as published by the Free Software Foundation;
9 either version 2.1 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU Lesser General Public License for more details.
14 */

15 package com.openedit.modules.html;
16
17 /**
18  * @author Matt Avery, mavery@einnovation.com
19  */

20 public class Token
21 {
22     protected boolean fieldInQuotes;
23     protected boolean fieldInTag;
24     protected boolean fieldInComment;
25     protected boolean fieldInParagraph;
26     
27     protected String JavaDoc fieldText;
28     
29     public Token( String JavaDoc inTokenString )
30     {
31         fieldText = inTokenString;
32     }
33
34     public boolean isAttribute()
35     {
36         if ( isInQuotes() || isInComment() )
37         {
38             return false;
39         }
40         if ( isInTag() )
41         {
42             if ( getText().indexOf( '<' ) >= 0
43               || getText().indexOf( '>' ) >= 0 )
44             {
45                 return false;
46             }
47             return true;
48         }
49         return false;
50     }
51
52     public boolean isEntity()
53     {
54         return getText().indexOf( '&' ) == 0
55             && getText().indexOf( ';' ) == ( getText().length() - 1 );
56     }
57
58     public boolean isInComment()
59     {
60         return fieldInComment;
61     }
62
63     public boolean isInQuotes()
64     {
65         return fieldInQuotes;
66     }
67
68     public boolean isInTag()
69     {
70         return fieldInTag;
71     }
72
73     public String JavaDoc getText()
74     {
75         return fieldText;
76     }
77
78     public void setInComment(boolean b)
79     {
80         fieldInComment = b;
81     }
82
83     public void setInQuotes(boolean b)
84     {
85         fieldInQuotes = b;
86     }
87
88     public void setInTag(boolean b)
89     {
90         fieldInTag = b;
91     }
92
93     public void setText(String JavaDoc string)
94     {
95         fieldText = string;
96     }
97
98     public boolean isInParagraph()
99     {
100         return fieldInParagraph;
101     }
102
103     public void setInParagraph(boolean b)
104     {
105         fieldInParagraph = b;
106     }
107
108 }
109
Popular Tags