1   package com.stateofflow.eclipse.metrics.calculators.cohesion;
2   
3   final class Source {
4       private final String text;
5   
6       public Source(final String text) {
7           this.text = text;
8       }
9   
10      public String getFieldName(final int start, final int end) {
11          return text.substring(start, end).trim();
12      }
13  
14      public char getCharAt(final int index) {
15          return text.charAt(index);
16      }
17  
18      public String getSection(final int start, final int end) {
19          return text.substring(start, end);
20      }
21  
22      public int findPreviousNonWhitespaceIndex(final int startIndex) {
23          int index = startIndex;
24          while (Character.isWhitespace(getCharAt(index))) {
25              index--;
26          }
27  
28          return index;
29      }
30  }
31