/[classpath]/classpath/java/lang/Character.java
ViewVC logotype

Diff of /classpath/java/lang/Character.java

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

revision 1.39 by tromey, Fri Sep 16 19:13:35 2005 UTC revision 1.40 by tromey, Sat Sep 17 21:58:41 2005 UTC
# Line 1034  public final class Character implements Line 1034  public final class Character implements
1034    public static final Class TYPE = VMClassLoader.getPrimitiveClass('C');    public static final Class TYPE = VMClassLoader.getPrimitiveClass('C');
1035    
1036    /**    /**
1037       * The number of bits needed to represent a <code>char</code>.
1038       * @since 1.5
1039       */
1040      public static final int SIZE = 16;
1041    
1042      // This caches some Character values, and is used by boxing
1043      // conversions via valueOf().  We must cache at least 0..127;
1044      // this constant controls how much we actually cache.
1045      private static final int MAX_CACHE = 127;
1046      private static Character[] charCache = new Character[MAX_CACHE + 1];
1047    
1048      /**
1049     * Lu = Letter, Uppercase (Informative).     * Lu = Letter, Uppercase (Informative).
1050     *     *
1051     * @since 1.1     * @since 1.1
# Line 2317  public final class Character implements Line 2329  public final class Character implements
2329    }    }
2330    
2331    /**    /**
2332       * Returns an <code>Character</code> object wrapping the value.
2333       * In contrast to the <code>Character</code> constructor, this method
2334       * will cache some values.  It is used by boxing conversion.
2335       *
2336       * @param val the value to wrap
2337       * @return the <code>Character</code>
2338       *
2339       * @since 1.5
2340       */
2341      public static Character valueOf(char val)
2342      {
2343        if (val > MAX_CACHE)
2344          return new Character(val);
2345        synchronized (charCache)
2346          {
2347        if (charCache[val - MIN_VALUE] == null)
2348          charCache[val - MIN_VALUE] = new Character(val);
2349        return charCache[val - MIN_VALUE];
2350          }
2351      }
2352    
2353      /**
2354       * Reverse the bytes in val.
2355       * @since 1.5
2356       */
2357      public static char reverseBytes(char val)
2358      {
2359        return (char) (((val >> 8) & 0xff) | ((val << 8) & 0xff00));
2360      }
2361    
2362      /**
2363     * Converts a unicode code point to a UTF-16 representation of that     * Converts a unicode code point to a UTF-16 representation of that
2364     * code point.     * code point.
2365     *     *

Legend:
Removed from v.1.39  
changed lines
  Added in v.1.40

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