Refactory: remove unused classes, imports, fields and methods.
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / corext / refactoring / nls / NLSElement.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation 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://www.eclipse.org/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpdt.corext.refactoring.nls;
12
13 import org.eclipse.jface.text.Region;
14 //incastrix
15 //import org.eclipse.jface.text.Assert;
16 import org.eclipse.core.runtime.Assert;
17
18 public class NLSElement {
19
20         public static final String TAG_PREFIX = "//$NON-NLS-"; //$NON-NLS-1$
21
22         public static final int TAG_PREFIX_LENGTH = TAG_PREFIX.length();
23
24         public static final String TAG_POSTFIX = "$"; //$NON-NLS-1$
25
26         public static final int TAG_POSTFIX_LENGTH = TAG_POSTFIX.length();
27
28         /** The original string denoted by the position */
29         private String fValue;
30
31         /** The position of the original string */
32         private Region fPosition;
33
34         /** Position of the // $NON_NLS_*$ tag */
35         private Region fTagPosition;
36
37         /** Index of the Element in an NLSLine */
38         //private int fIndex;
39
40         /**
41          * Creates a new NLS element for the given string and position.
42          */
43         public NLSElement(String value, int start, int length, int index) {
44                 fValue = value;
45                 //fIndex = index;
46                 Assert.isNotNull(fValue);
47                 fPosition = new Region(start, length);
48         }
49
50         /**
51          * Returns the position of the string to be NLSed.
52          * 
53          * @return Returns the position of the string to be NLSed
54          */
55 //      public Region getPosition() {
56 //              return fPosition;
57 //      }
58
59         /**
60          * Returns the actual string value.
61          * 
62          * @return the actual string value
63          */
64         public String getValue() {
65                 return fValue;
66         }
67
68         /**
69          * Sets the actual string value.
70          */
71         public void setValue(String value) {
72                 fValue = value;
73         }
74
75         /**
76          * Sets the tag position if one is associated with the NLS element.
77          */
78 //      public void setTagPosition(int start, int length) {
79 //              fTagPosition = new Region(start, length);
80 //      }
81
82         /**
83          * Returns the tag position for this element. The method can return
84          * <code>null</code>. In this case no tag has been found for this NLS
85          * element.
86          */
87 //      public Region getTagPosition() {
88 //              return fTagPosition;
89 //      }
90
91         /**
92          * Returns <code>true</code> if the NLS element has an assicated
93          * $NON-NLS-*$ tag. Otherwise <code>false</code> is returned.
94          */
95         public boolean hasTag() {
96                 return fTagPosition != null && fTagPosition.getLength() > 0;
97         }
98
99 //      public static String createTagText(int index) {
100 //              return TAG_PREFIX + index + TAG_POSTFIX;
101 //      }
102
103 //      public String getTagText() {
104 //              return TAG_PREFIX + (fIndex + 1) + TAG_POSTFIX;
105 //      }
106
107         /*
108          * (Non-Javadoc) Method declared in Object. only for debugging
109          */
110         public String toString() {
111                 return fPosition + ": " + fValue + "    Tag position: " + //$NON-NLS-2$ //$NON-NLS-1$
112                                 (hasTag() ? fTagPosition.toString() : "no tag found"); //$NON-NLS-1$
113         }
114 }