/[classpath]/classpath/java/text/SimpleDateFormat.java
ViewVC logotype

Diff of /classpath/java/text/SimpleDateFormat.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.49 by trebligd, Sat Jul 23 20:25:15 2005 UTC revision 1.50 by tromey, Tue Aug 23 17:10:16 2005 UTC
# Line 294  public class SimpleDateFormat extends Da Line 294  public class SimpleDateFormat extends Da
294      int field;      int field;
295      CompiledField current = null;      CompiledField current = null;
296    
297      for (int i=0; i<pattern.length(); i++) {      for (int i = 0; i < pattern.length(); i++)
298        thisChar = pattern.charAt(i);        {
299        field = standardChars.indexOf(thisChar);          thisChar = pattern.charAt(i);
300        if (field == -1) {          field = standardChars.indexOf(thisChar);
301          current = null;          if (field == -1)
302          if ((thisChar >= 'A' && thisChar <= 'Z')            {
303              || (thisChar >= 'a' && thisChar <= 'z')) {              current = null;
304            // Not a valid letter              if ((thisChar >= 'A' && thisChar <= 'Z')
305            throw new IllegalArgumentException("Invalid letter " + thisChar +                  || (thisChar >= 'a' && thisChar <= 'z'))
306                                               "encountered at character " + i                {
307                                               + ".");                  // Not a valid letter
308          } else if (thisChar == '\'') {                  throw new IllegalArgumentException("Invalid letter "
309            // Quoted text section; skip to next single quote                                                     + thisChar +
310            pos = pattern.indexOf('\'',i+1);                                                     "encountered at character "
311            if (pos == -1) {                                                     + i + ".");
312              throw new IllegalArgumentException("Quotes starting at character "                }
313                                                 + i + " not closed.");              else if (thisChar == '\'')
314                  {
315                    // Quoted text section; skip to next single quote
316                    pos = pattern.indexOf('\'', i + 1);
317                    if (pos == -1)
318                      {
319                        throw new IllegalArgumentException("Quotes starting at character "
320                                                           + i + " not closed.");
321                      }
322                    if ((pos + 1 < pattern.length())
323                        && (pattern.charAt(pos + 1) == '\''))
324                      tokens.add(pattern.substring(i + 1, pos + 1));
325                    else
326                      tokens.add(pattern.substring(i + 1, pos));
327                    i = pos;
328                  }
329                else
330                  {
331                    // A special character
332                    tokens.add(new Character(thisChar));
333                  }
334            }            }
335            if ((pos+1 < pattern.length()) && (pattern.charAt(pos+1) == '\'')) {          else
336              tokens.add(pattern.substring(i+1,pos+1));            {
337            } else {              // A valid field
338              tokens.add(pattern.substring(i+1,pos));              if ((current != null) && (field == current.field))
339                  current.size++;
340                else
341                  {
342                    current = new CompiledField(field, 1, thisChar);
343                    tokens.add(current);
344                  }
345            }            }
           i = pos;  
         } else {  
           // A special character  
           tokens.add(new Character(thisChar));  
         }  
       } else {  
         // A valid field  
         if ((current != null) && (field == current.field)) {  
           current.size++;  
         } else {  
           current = new CompiledField(field,1,thisChar);  
           tokens.add(current);  
         }  
346        }        }
     }  
347    }    }
348    
349    /**    /**

Legend:
Removed from v.1.49  
changed lines
  Added in v.1.50

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26