1 11 package org.eclipse.search.ui.text; 12 13 import org.eclipse.core.runtime.Assert; 14 15 24 public class Match { 25 26 30 public static final int UNIT_LINE= 1; 31 32 36 public static final int UNIT_CHARACTER= 2; 37 38 private static final int IS_FILTERED= 1 << 2; 39 40 private Object fElement; 41 private int fOffset; 42 private int fLength; 43 private int fFlags; 44 45 57 public Match(Object element, int unit, int offset, int length) { 58 Assert.isTrue(unit == UNIT_CHARACTER || unit == UNIT_LINE); 59 fElement= element; 60 fOffset= offset; 61 fLength= length; 62 fFlags= unit; 63 } 64 65 76 public Match(Object element, int offset, int length) { 77 this(element, UNIT_CHARACTER, offset, length); 78 } 79 80 85 public int getOffset() { 86 return fOffset; 87 } 88 89 95 public void setOffset(int offset) { 96 fOffset= offset; 97 } 98 99 104 public int getLength() { 105 return fLength; 106 } 107 108 114 public void setLength(int length) { 115 fLength= length; 116 } 117 118 123 public Object getElement() { 124 return fElement; 125 } 126 127 133 public int getBaseUnit() { 134 if ((fFlags & UNIT_LINE) != 0) 135 return UNIT_LINE; 136 return UNIT_CHARACTER; 137 } 138 139 147 public void setFiltered(boolean value) { 148 if (value) { 149 fFlags |= IS_FILTERED; 150 } else { 151 fFlags &= (~IS_FILTERED); 152 } 153 } 154 155 163 public boolean isFiltered() { 164 return (fFlags & IS_FILTERED) != 0; 165 } 166 } 167 | Popular Tags |