01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package javax.swing.text.html.parser;
19:
20: class HTMLText extends HTMLObject {
21:
22: /**
23: * The text that was found in the text
24: */
25: private String text;
26:
27: /**
28: * Determines whether a normal text had spaces at the begining of it (and were
29: * removed)
30: */
31: private boolean hasLeadingSpaces;
32:
33: /**
34: * Determines whether a normal text had spaces at the end of it (and were
35: * removed)
36: */
37: private boolean hasTrailingSpaces;
38:
39: /**
40: * Makes a new {@link HTMLText} object
41: *
42: * @param text
43: * The parsed text
44: * @param pos
45: * The position where the text was found
46: * @param hasLeadingSpaces
47: * Determines whether the parser text had spaces at the begining
48: * of it.
49: * @param hasTrailingSpaces
50: * Determines whether the parser text had spaces at the end
51: * of it.
52: */
53: public HTMLText(String text, int pos, boolean hasLeadingSpaces,
54: boolean hasTrailingSpaces) {
55: super (pos);
56: this .text = text;
57: this .hasLeadingSpaces = hasLeadingSpaces;
58: this .hasTrailingSpaces = hasTrailingSpaces;
59: }
60:
61: /**
62: * Returns the parsed text contained by this object.
63: *
64: * @return the parsed text.
65: */
66: public String getText() {
67: return text;
68: }
69:
70: /**
71: * Tells if the parsed text (stored in this object) has spaces at the
72: * begining of it.
73: *
74: * @return True if the parsed text had spaces at the begining of it. Otherwise it
75: * returns False.
76: */
77: public boolean hasLeadingSpaces() {
78: return hasLeadingSpaces;
79: }
80:
81: /**
82: * Tells if the parsed text (stored in this object) has spaces at the end of
83: * it.
84: *
85: * @return True if the parsed text had spaces at the end of it. Otherwise it
86: * returns False.
87: */
88: public boolean hasTrailingSpaces() {
89: return hasTrailingSpaces;
90: }
91:
92: public String toString() {
93: return text;
94: }
95:
96: }
|