~ubuntu-branches/ubuntu/karmic/classpath/karmic

« back to all changes in this revision

Viewing changes to gnu/java/nio/charset/ISO_8859_1.java

  • Committer: Bazaar Package Importer
  • Author(s): Manny Vindiola, Manny Vindiola, James Westby
  • Date: 2008-12-18 21:24:48 UTC
  • mfrom: (1.1.6 upstream) (8.2.1 squeeze)
  • Revision ID: james.westby@ubuntu.com-20081218212448-ax2jaxx9r5175dkl
Tags: 2:0.97.2-1.1ubuntu1
[ Manny Vindiola ]
* Merge from debian unstable (LP: #309549)(LP: #237668), remaining changes:
  * debian/control:
    - Recommend firefox instead of mozilla-firefox.
  * Fix FTBFS caused by -Werror where return value of 'chdir' was ignored
    - add debian/patches/20_fix_ftbfs_warn_unused_result.dpatch
    - update debian/patches/00list
  * fix LP: #272772: packages that Depend/Recommend/Suggest firefox
     (meta-package) must alternatively Depend/Recommend/Suggest abrowser
* Fix FTBFS due to missing mozilla-plugin build dependency 
  - changed to build-depends on libxul-dev instead of iceape-dev

[ James Westby ]
* Add libsamplerate0-dev to Build-Depends to fix build error by not being
  able to find the .a file from it. This is a dependency of jack, but not
  specified in it's depends. This is probably due to bug 258491, and so if
  that is fixed try building without the extra Build-Depends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
 * ISO-8859-1 charset.
49
49
 *
50
50
 * @author Jesse Rosenstock
 
51
 * @modified Ian Rogers
51
52
 */
52
53
final class ISO_8859_1 extends Charset
53
54
{
98
99
 
99
100
  private static final class Decoder extends CharsetDecoder
100
101
  {
 
102
    /** Helper to decode loops */
 
103
    private static final ByteDecodeLoopHelper helper = new ByteDecodeLoopHelper()
 
104
    {
 
105
      protected boolean isMappable(byte b)
 
106
      {
 
107
        return true;
 
108
      }
 
109
      protected char mapToChar(byte b)
 
110
      {
 
111
        return (char)(b & 0xFF);
 
112
      }
 
113
    };
 
114
    
101
115
    // Package-private to avoid a trampoline constructor.
102
116
    Decoder (Charset cs)
103
117
    {
106
120
 
107
121
    protected CoderResult decodeLoop (ByteBuffer in, CharBuffer out)
108
122
    {
109
 
      // TODO: Optimize this in the case in.hasArray() / out.hasArray()
110
 
      while (in.hasRemaining ())
111
 
      {
112
 
        byte b = in.get ();
113
 
 
114
 
        if (!out.hasRemaining ())
115
 
          {
116
 
            in.position (in.position () - 1);
117
 
            return CoderResult.OVERFLOW;
118
 
          }
119
 
 
120
 
        out.put ((char) (b & 0xFF));
121
 
      }
122
 
 
123
 
      return CoderResult.UNDERFLOW;
 
123
      return helper.decodeLoop(in, out);
124
124
    }
125
125
  }
126
126
 
127
127
  private static final class Encoder extends CharsetEncoder
128
128
  {
 
129
    /** Helper to encode loops */
 
130
    private static final ByteEncodeLoopHelper helper = new ByteEncodeLoopHelper()
 
131
    {
 
132
      protected boolean isMappable(char c)
 
133
      {
 
134
        return c <= 0xff;
 
135
      }
 
136
      protected byte mapToByte(char c)
 
137
      {
 
138
        return (byte)c;
 
139
      }
 
140
    };
129
141
    // Package-private to avoid a trampoline constructor.
130
142
    Encoder (Charset cs)
131
143
    {
147
159
 
148
160
    protected CoderResult encodeLoop (CharBuffer in, ByteBuffer out)
149
161
    {
150
 
      // TODO: Optimize this in the case in.hasArray() / out.hasArray()
151
 
      while (in.hasRemaining ())
152
 
      {
153
 
        char c = in.get ();
154
 
 
155
 
        if (c > 0xFF)
156
 
          {
157
 
            in.position (in.position () - 1);
158
 
            return CoderResult.unmappableForLength (1);
159
 
          }
160
 
        if (!out.hasRemaining ())
161
 
          {
162
 
            in.position (in.position () - 1);
163
 
            return CoderResult.OVERFLOW;
164
 
          }
165
 
 
166
 
        out.put ((byte) c);
167
 
      }
168
 
 
169
 
      return CoderResult.UNDERFLOW;
 
162
      return helper.encodeLoop(in, out);
170
163
    }
171
164
  }
172
165
}