1 11 package org.eclipse.jdt.internal.corext.refactoring.nls; 12 13 import org.eclipse.core.runtime.Assert; 14 15 import org.eclipse.jface.text.Region; 16 17 public class NLSElement { 18 19 public static final String TAG_PREFIX= "//$NON-NLS-"; public static final int TAG_PREFIX_LENGTH= TAG_PREFIX.length(); 21 public static final String TAG_POSTFIX= "$"; public static final int TAG_POSTFIX_LENGTH= TAG_POSTFIX.length(); 23 24 25 private String fValue; 26 27 private Region fPosition; 28 29 30 private Region fTagPosition; 31 32 33 private int fIndex; 34 private boolean fIsEclipseNLS; 35 private AccessorClassReference fAccessorClassReference; 36 37 40 public NLSElement(String value, int start, int length, int index, boolean isEclipseNLS) { 41 fValue= value; 42 fIndex= index; 43 Assert.isNotNull(fValue); 44 fPosition= new Region(start, length); 45 fIsEclipseNLS= isEclipseNLS; 46 } 47 48 52 public Region getPosition() { 53 return fPosition; 54 } 55 56 60 public String getValue() { 61 return fValue; 62 } 63 64 67 public void setValue(String value) { 68 fValue= value; 69 } 70 71 74 public void setTagPosition(int start, int length) { 75 fTagPosition= new Region(start, length); 76 } 77 78 82 public Region getTagPosition() { 83 return fTagPosition; 84 } 85 86 90 public boolean hasTag() { 91 return fTagPosition != null && fTagPosition.getLength() > 0; 92 } 93 94 public static String createTagText(int index) { 95 return TAG_PREFIX + index + TAG_POSTFIX; 96 } 97 98 public String getTagText() { 99 return TAG_PREFIX + (fIndex + 1) + TAG_POSTFIX; 100 } 101 102 106 public String toString() { 107 return fPosition + ": " + fValue + " Tag position: " + (hasTag() ? fTagPosition.toString() : "no tag found"); } 110 111 113 121 public boolean isEclipseNLS() { 122 return fIsEclipseNLS; 123 } 124 125 135 public void setAccessorClassReference(AccessorClassReference accessorClassRef) { 136 Assert.isTrue(fIsEclipseNLS); 137 fAccessorClassReference= accessorClassRef; 138 } 139 140 150 public AccessorClassReference getAccessorClassReference() { 151 Assert.isTrue(fIsEclipseNLS); 152 return fAccessorClassReference; 153 } 154 } 155 156 | Popular Tags |