1 19 20 package org.netbeans.lib.editor.util; 21 22 29 30 public class CharSubSequence extends AbstractCharSequence { 31 32 39 public static void checkIndexesValid(CharSequence text, int start, int end) { 40 CharSequenceUtilities.checkIndexesValid(text, start, end); 41 } 42 43 private int length; 44 45 private int start; 46 47 private CharSequence backingSequence; 48 49 61 public CharSubSequence(CharSequence backingSequence, int start, int end) { 62 checkIndexesValid(backingSequence, start, end); 63 this.backingSequence = backingSequence; 64 this.start = start; 65 this.length = end - start; 66 } 67 68 protected CharSequence backingSequence() { 69 return backingSequence; 70 } 71 72 protected int start() { 73 return start; 74 } 75 76 public int length() { 77 return length; 78 } 79 80 public char charAt(int index) { 81 CharSequenceUtilities.checkIndexValid(index, length); 82 return backingSequence.charAt(start() + index); 83 } 84 85 98 public static class StringLike extends CharSubSequence { 99 100 101 public StringLike(CharSubSequence backingSequence, int start, int end) { 102 super(backingSequence, start, end); 103 } 104 105 public int hashCode() { 106 return CharSequenceUtilities.stringLikeHashCode(this); 107 } 108 109 public boolean equals(Object o) { 110 return CharSequenceUtilities.equals(this, o); 111 } 112 113 } 114 115 } 116 | Popular Tags |