Project

General

Profile

« Previous | Next » 

Revision 2036

Additional Harvester development

View differences:

Harvester.java
184 184
  boolean connectToMetacat () {
185 185
    return connectToMetacat;
186 186
  }
187
  
188

  
189
  /**
190
   * Normalizes text prior to insertion into the HARVEST_LOG or
191
   * HARVEST_DETAIL_LOG tables. In particular, replaces the single quote
192
   * character with the double quote character. This prevents SQL errors
193
   * involving words that contain single quotes. Also removes \n and \r
194
   * characters from the text.
195
   * 
196
   * @param text  the original string
197
   * @return      a string containing the normalized text
198
   */
199
  String dequoteText(String text) {
200
    char c;
201
    StringBuffer stringBuffer = new StringBuffer();
187 202
    
203
    for (int i = 0; i < text.length(); i++) {
204
      c = text.charAt(i);
205
      switch (c) {
206
        case '\'':
207
          stringBuffer.append('\"');
208
          break;
209
        case '\r':
210
        case '\n':
211
          break;
212
        default:
213
          stringBuffer.append(c);
214
          break;
215
      }
216
    }
217
    
218
    return stringBuffer.toString();
219
  }
188 220

  
221

  
189 222
  /**
190 223
   * Gets the current value of the detailLogID for storage as a primary key in
191 224
   * the DETAIL_LOG_ID field of the HARVEST_DETAIL_LOG table.

Also available in: Unified diff