/[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.28.2.15 by gnu_andrew, Tue Aug 2 20:12:26 2005 UTC revision 1.28.2.16 by gnu_andrew, Sat Sep 10 15:31:47 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                    // First look for '' -- meaning a single quote.
318                    if (pos == i + 1)
319                      tokens.add("'");
320                    else
321                      {
322                        // Look for the terminating quote.  However, if we
323                        // see a '', that represents a literal quote and
324                        // we must iterate.
325                        StringBuffer buf = new StringBuffer();
326                        int oldPos = i + 1;
327                        do
328                          {
329                            if (pos == -1)
330                              throw new IllegalArgumentException("Quotes starting at character "
331                                                                 + i +
332                                                                 " not closed.");
333                            buf.append(pattern.substring(oldPos, pos));
334                            if (pos + 1 >= pattern.length()
335                                || pattern.charAt(pos + 1) != '\'')
336                              break;
337                            buf.append('\'');
338                            oldPos = pos + 2;
339                            pos = pattern.indexOf('\'', pos + 2);
340                          }
341                        while (true);
342                        tokens.add(buf.toString());
343                      }
344                    i = pos;
345                  }
346                else
347                  {
348                    // A special character
349                    tokens.add(new Character(thisChar));
350                  }
351            }            }
352            if ((pos+1 < pattern.length()) && (pattern.charAt(pos+1) == '\'')) {          else
353              tokens.add(pattern.substring(i+1,pos+1));            {
354            } else {              // A valid field
355              tokens.add(pattern.substring(i+1,pos));              if ((current != null) && (field == current.field))
356                  current.size++;
357                else
358                  {
359                    current = new CompiledField(field, 1, thisChar);
360                    tokens.add(current);
361                  }
362            }            }
           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);  
         }  
363        }        }
     }  
364    }    }
365    
366    /**    /**

Legend:
Removed from v.1.28.2.15  
changed lines
  Added in v.1.28.2.16

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