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
9 * Igor Malinin - initial contribution
11 * $Id: FlatNode.java,v 1.1 2004-09-02 18:26:29 jsurfer Exp $
14 package net.sourceforge.phpeclipse.ui.text.rules;
17 * @author Igor Malinin
19 public class FlatNode {
21 /** Content-type of the node */
22 public final String type;
24 /** Flat offset of the node */
27 /** Flat length of the node */
30 public FlatNode(String type) {
35 * Checks whether the given offset is inside of this position's text range.
39 * @return <code>true</code> if offset is inside of this position
41 public boolean includes(int offset) {
42 return (this.offset <= offset && offset < this.offset + length);
46 * Checks whether the intersection of the given text range and the text
47 * range represented by this position is empty or not.
50 * the offset of the range to check
52 * the length of the range to check
53 * @return <code>true</code> if intersection is not empty
55 public boolean overlapsWith(int offset, int length) {
56 int end = offset + length;
57 int thisEnd = this.offset + this.length;
60 if (this.length > 0) {
61 return (this.offset < end && offset < thisEnd);
63 return (offset <= this.offset && this.offset < end);
66 if (this.length > 0) {
67 return (this.offset <= offset && offset < thisEnd);
70 return (this.offset == offset);
74 * @see java.lang.Object#toString()
76 public String toString() {
77 return "FlatNode[" + type + ", " + offset + ", " + length + "]";