1 /******************************************************************************* 2 * Copyright (c) 2000, 2008 IBM Corporation and others. 3 * 4 * This program and the accompanying materials 5 * are made available under the terms of the Eclipse Public License 2.0 6 * which accompanies this distribution, and is available at 7 * https://www.eclipse.org/legal/epl-2.0/ 8 * 9 * SPDX-License-Identifier: EPL-2.0 10 * 11 * Contributors: 12 * IBM Corporation - initial API and implementation 13 *******************************************************************************/ 14 package org.eclipse.text.edits; 15 16 import org.eclipse.jface.text.BadLocationException; 17 import org.eclipse.jface.text.BadPositionCategoryException; 18 import org.eclipse.jface.text.FindReplaceDocumentAdapter; 19 import org.eclipse.jface.text.IDocument; 20 import org.eclipse.jface.text.IDocumentListener; 21 import org.eclipse.jface.text.IDocumentPartitioner; 22 import org.eclipse.jface.text.IDocumentPartitioningListener; 23 import org.eclipse.jface.text.IPositionUpdater; 24 import org.eclipse.jface.text.IRegion; 25 import org.eclipse.jface.text.ITypedRegion; 26 import org.eclipse.jface.text.Position; 27 28 class EditDocument implements IDocument { 29 30 private StringBuilder fBuffer; 31 EditDocument(String content)32 public EditDocument(String content) { 33 fBuffer= new StringBuilder(content); 34 } 35 36 @Override addDocumentListener(IDocumentListener listener)37 public void addDocumentListener(IDocumentListener listener) { 38 throw new UnsupportedOperationException(); 39 } 40 41 @Override addDocumentPartitioningListener(IDocumentPartitioningListener listener)42 public void addDocumentPartitioningListener(IDocumentPartitioningListener listener) { 43 throw new UnsupportedOperationException(); 44 } 45 46 @Override addPosition(Position position)47 public void addPosition(Position position) throws BadLocationException { 48 throw new UnsupportedOperationException(); 49 } 50 51 @Override addPosition(String category, Position position)52 public void addPosition(String category, Position position) throws BadLocationException, BadPositionCategoryException { 53 throw new UnsupportedOperationException(); 54 } 55 56 @Override addPositionCategory(String category)57 public void addPositionCategory(String category) { 58 throw new UnsupportedOperationException(); 59 } 60 61 @Override addPositionUpdater(IPositionUpdater updater)62 public void addPositionUpdater(IPositionUpdater updater) { 63 throw new UnsupportedOperationException(); 64 } 65 66 @Override addPrenotifiedDocumentListener(IDocumentListener documentAdapter)67 public void addPrenotifiedDocumentListener(IDocumentListener documentAdapter) { 68 throw new UnsupportedOperationException(); 69 } 70 71 @Override computeIndexInCategory(String category, int offset)72 public int computeIndexInCategory(String category, int offset) throws BadLocationException, BadPositionCategoryException { 73 throw new UnsupportedOperationException(); 74 } 75 76 @Override computeNumberOfLines(String text)77 public int computeNumberOfLines(String text) { 78 throw new UnsupportedOperationException(); 79 } 80 81 @Override computePartitioning(int offset, int length)82 public ITypedRegion[] computePartitioning(int offset, int length) throws BadLocationException { 83 throw new UnsupportedOperationException(); 84 } 85 86 @Override containsPosition(String category, int offset, int length)87 public boolean containsPosition(String category, int offset, int length) { 88 throw new UnsupportedOperationException(); 89 } 90 91 @Override containsPositionCategory(String category)92 public boolean containsPositionCategory(String category) { 93 throw new UnsupportedOperationException(); 94 } 95 96 @Override get()97 public String get() { 98 return fBuffer.toString(); 99 } 100 101 @Override get(int offset, int length)102 public String get(int offset, int length) throws BadLocationException { 103 return fBuffer.substring(offset, offset + length); 104 } 105 106 @Override getChar(int offset)107 public char getChar(int offset) throws BadLocationException { 108 throw new UnsupportedOperationException(); 109 } 110 111 @Override getContentType(int offset)112 public String getContentType(int offset) throws BadLocationException { 113 throw new UnsupportedOperationException(); 114 } 115 116 @Override getDocumentPartitioner()117 public IDocumentPartitioner getDocumentPartitioner() { 118 throw new UnsupportedOperationException(); 119 } 120 121 @Override getLegalContentTypes()122 public String[] getLegalContentTypes() { 123 throw new UnsupportedOperationException(); 124 } 125 126 @Override getLegalLineDelimiters()127 public String[] getLegalLineDelimiters() { 128 throw new UnsupportedOperationException(); 129 } 130 131 @Override getLength()132 public int getLength() { 133 return fBuffer.length(); 134 } 135 136 @Override getLineDelimiter(int line)137 public String getLineDelimiter(int line) throws BadLocationException { 138 throw new UnsupportedOperationException(); 139 } 140 141 @Override getLineInformation(int line)142 public IRegion getLineInformation(int line) throws BadLocationException { 143 throw new UnsupportedOperationException(); 144 } 145 146 @Override getLineInformationOfOffset(int offset)147 public IRegion getLineInformationOfOffset(int offset) throws BadLocationException { 148 throw new UnsupportedOperationException(); 149 } 150 151 @Override getLineLength(int line)152 public int getLineLength(int line) throws BadLocationException { 153 throw new UnsupportedOperationException(); 154 } 155 156 @Override getLineOffset(int line)157 public int getLineOffset(int line) throws BadLocationException { 158 throw new UnsupportedOperationException(); 159 } 160 161 @Override getLineOfOffset(int offset)162 public int getLineOfOffset(int offset) throws BadLocationException { 163 throw new UnsupportedOperationException(); 164 } 165 166 @Override getNumberOfLines()167 public int getNumberOfLines() { 168 throw new UnsupportedOperationException(); 169 } 170 171 @Override getNumberOfLines(int offset, int length)172 public int getNumberOfLines(int offset, int length) throws BadLocationException { 173 throw new UnsupportedOperationException(); 174 } 175 176 @Override getPartition(int offset)177 public ITypedRegion getPartition(int offset) throws BadLocationException { 178 throw new UnsupportedOperationException(); 179 } 180 181 @Override getPositionCategories()182 public String[] getPositionCategories() { 183 throw new UnsupportedOperationException(); 184 } 185 186 @Override getPositions(String category)187 public Position[] getPositions(String category) throws BadPositionCategoryException { 188 throw new UnsupportedOperationException(); 189 } 190 191 @Override getPositionUpdaters()192 public IPositionUpdater[] getPositionUpdaters() { 193 throw new UnsupportedOperationException(); 194 } 195 196 @Override insertPositionUpdater(IPositionUpdater updater, int index)197 public void insertPositionUpdater(IPositionUpdater updater, int index) { 198 throw new UnsupportedOperationException(); 199 } 200 201 @Override removeDocumentListener(IDocumentListener listener)202 public void removeDocumentListener(IDocumentListener listener) { 203 throw new UnsupportedOperationException(); 204 } 205 206 @Override removeDocumentPartitioningListener(IDocumentPartitioningListener listener)207 public void removeDocumentPartitioningListener(IDocumentPartitioningListener listener) { 208 throw new UnsupportedOperationException(); 209 } 210 211 @Override removePosition(Position position)212 public void removePosition(Position position) { 213 throw new UnsupportedOperationException(); 214 } 215 216 @Override removePosition(String category, Position position)217 public void removePosition(String category, Position position) throws BadPositionCategoryException { 218 throw new UnsupportedOperationException(); 219 } 220 221 @Override removePositionCategory(String category)222 public void removePositionCategory(String category) throws BadPositionCategoryException { 223 throw new UnsupportedOperationException(); 224 } 225 226 @Override removePositionUpdater(IPositionUpdater updater)227 public void removePositionUpdater(IPositionUpdater updater) { 228 throw new UnsupportedOperationException(); 229 } 230 231 @Override removePrenotifiedDocumentListener(IDocumentListener documentAdapter)232 public void removePrenotifiedDocumentListener(IDocumentListener documentAdapter) { 233 throw new UnsupportedOperationException(); 234 } 235 236 @Override replace(int offset, int length, String text)237 public void replace(int offset, int length, String text) throws BadLocationException { 238 fBuffer.replace(offset, offset + length, text); 239 } 240 241 /** 242 * {@inheritDoc} 243 * 244 * @deprecated As of 3.0 search is provided by {@link FindReplaceDocumentAdapter} 245 */ 246 @Deprecated 247 @Override search(int startOffset, String findString, boolean forwardSearch, boolean caseSensitive, boolean wholeWord)248 public int search(int startOffset, String findString, boolean forwardSearch, boolean caseSensitive, boolean wholeWord) throws BadLocationException { 249 throw new UnsupportedOperationException(); 250 } 251 252 @Override set(String text)253 public void set(String text) { 254 throw new UnsupportedOperationException(); 255 } 256 257 @Override setDocumentPartitioner(IDocumentPartitioner partitioner)258 public void setDocumentPartitioner(IDocumentPartitioner partitioner) { 259 throw new UnsupportedOperationException(); 260 } 261 } 262