/[classpath]/classpath/java/util/Properties.java
ViewVC logotype

Diff of /classpath/java/util/Properties.java

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

revision 1.34 by gnu_andrew, Sun Oct 23 21:56:31 2005 UTC revision 1.35 by mark, Sat Nov 12 02:25:10 2005 UTC
# Line 219  label   = Name:\\u0020</pre> Line 219  label   = Name:\\u0020</pre>
219    
220          // The characters up to the next Whitespace, ':', or '='          // The characters up to the next Whitespace, ':', or '='
221          // describe the key.  But look for escape sequences.          // describe the key.  But look for escape sequences.
222          StringBuffer key = new StringBuffer();          // Try to short-circuit when there is no escape char.
223            int start = pos;
224            boolean needsEscape = line.indexOf('\\', pos) != -1;
225            StringBuilder key = needsEscape ? new StringBuilder() : null;
226          while (pos < line.length()          while (pos < line.length()
227                 && ! Character.isWhitespace(c = line.charAt(pos++))                 && ! Character.isWhitespace(c = line.charAt(pos++))
228                 && c != '=' && c != ':')                 && c != '=' && c != ':')
229            {            {
230              if (c == '\\')              if (needsEscape && c == '\\')
231                {                {
232                  if (pos == line.length())                  if (pos == line.length())
233                    {                    {
# Line 268  label   = Name:\\u0020</pre> Line 271  label   = Name:\\u0020</pre>
271                        }                        }
272                    }                    }
273                }                }
274              else              else if (needsEscape)
275                key.append(c);                key.append(c);
276            }            }
277    
278          boolean isDelim = (c == ':' || c == '=');          boolean isDelim = (c == ':' || c == '=');
279    
280            String keyString;
281            if (needsEscape)
282              keyString = key.toString();
283            else if (isDelim || Character.isWhitespace(c))
284              keyString = line.substring(start, pos - 1);
285            else
286              keyString = line.substring(start, pos);
287    
288          while (pos < line.length()          while (pos < line.length()
289                 && Character.isWhitespace(c = line.charAt(pos)))                 && Character.isWhitespace(c = line.charAt(pos)))
290            pos++;            pos++;
# Line 285  label   = Name:\\u0020</pre> Line 297  label   = Name:\\u0020</pre>
297                pos++;                pos++;
298            }            }
299    
300          StringBuffer element = new StringBuffer(line.length() - pos);          // Short-circuit if no escape chars found.
301            if (!needsEscape)
302              {
303                put(keyString, line.substring(pos));
304                continue;
305              }
306    
307            // Escape char found so iterate through the rest of the line.
308            StringBuilder element = new StringBuilder(line.length() - pos);
309          while (pos < line.length())          while (pos < line.length())
310            {            {
311              c = line.charAt(pos++);              c = line.charAt(pos++);
# Line 341  label   = Name:\\u0020</pre> Line 361  label   = Name:\\u0020</pre>
361              else              else
362                element.append(c);                element.append(c);
363            }            }
364          put(key.toString(), element.toString());          put(keyString, element.toString());
365        }        }
366    }    }
367    
# Line 405  label   = Name:\\u0020</pre> Line 425  label   = Name:\\u0020</pre>
425            
426      Iterator iter = entrySet ().iterator ();      Iterator iter = entrySet ().iterator ();
427      int i = size ();      int i = size ();
428      StringBuffer s = new StringBuffer (); // Reuse the same buffer.      StringBuilder s = new StringBuilder (); // Reuse the same buffer.
429      while (--i >= 0)      while (--i >= 0)
430        {        {
431          Map.Entry entry = (Map.Entry) iter.next ();          Map.Entry entry = (Map.Entry) iter.next ();
# Line 548  label   = Name:\\u0020</pre> Line 568  label   = Name:\\u0020</pre>
568     *        leading spaces must be escaped for the value     *        leading spaces must be escaped for the value
569     * @see #store(OutputStream, String)     * @see #store(OutputStream, String)
570     */     */
571    private void formatForOutput(String str, StringBuffer buffer, boolean key)    private void formatForOutput(String str, StringBuilder buffer, boolean key)
572    {    {
573      if (key)      if (key)
574        {        {

Legend:
Removed from v.1.34  
changed lines
  Added in v.1.35

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