1) Added missing strings for italic, underline and strike through.
[phpeclipse.git] / net.sourceforge.phpeclipse.ui / src / net / sourceforge / phpeclipse / ui / text / rules / FlatNode.java
1 /*
2  * Copyright (c) 2003-2004 Widespace, OU and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://solareclipse.sourceforge.net/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     Igor Malinin - initial contribution
10  * 
11  * $Id: FlatNode.java,v 1.1 2004-09-02 18:26:29 jsurfer Exp $
12  */
13
14 package net.sourceforge.phpeclipse.ui.text.rules;
15
16 /**
17  * @author Igor Malinin
18  */
19 public class FlatNode {
20
21         /** Content-type of the node */
22         public final String type;
23
24         /** Flat offset of the node */
25         public int offset;
26
27         /** Flat length of the node */
28         public int length;
29
30         public FlatNode(String type) {
31                 this.type = type;
32         }
33
34         /**
35          * Checks whether the given offset is inside of this position's text range.
36          * 
37          * @param offset
38          *            the offset to check
39          * @return <code>true</code> if offset is inside of this position
40          */
41         public boolean includes(int offset) {
42                 return (this.offset <= offset && offset < this.offset + length);
43         }
44
45         /**
46          * Checks whether the intersection of the given text range and the text
47          * range represented by this position is empty or not.
48          * 
49          * @param offset
50          *            the offset of the range to check
51          * @param length
52          *            the length of the range to check
53          * @return <code>true</code> if intersection is not empty
54          */
55         public boolean overlapsWith(int offset, int length) {
56                 int end = offset + length;
57                 int thisEnd = this.offset + this.length;
58
59                 if (length > 0) {
60                         if (this.length > 0) {
61                                 return (this.offset < end && offset < thisEnd);
62                         }
63                         return (offset <= this.offset && this.offset < end);
64                 }
65
66                 if (this.length > 0) {
67                         return (this.offset <= offset && offset < thisEnd);
68                 }
69
70                 return (this.offset == offset);
71         }
72
73         /*
74          * @see java.lang.Object#toString()
75          */
76         public String toString() {
77                 return "FlatNode[" + type + ", " + offset + ", " + length + "]";
78         }
79 }