Code view:

A painting is a person's account of this edit as text, recorded independently of the node mapping - a rendering often has several equally defensible answers where the mapping has one. Deletions and insertions carry no position on the opposite side in a painting, so that panel draws no caret for them.

Before

…lines 1–141 unchanged (141 lines)
142 throw new IndexOutOfBoundsException();
143 } else if (offset > b.length || offset + len > b.length) {
144 throw new IndexOutOfBoundsException();
145 } else if (len == 0) {
146 return 0;
147 } else {
148 /*
149 Rationale for while-loop on (readLen == 0):
150 -----
151 Base64.readResults() usually returns > 0 or EOF (-1). In the
152 rare case where it returns 0, we just keep trying.
153
154 This is essentially an undocumented contract for InputStream
155 implementors that want their code to work properly with
156 java.io.InputStreamReader, since the latter hates it when
157 InputStream.read(byte[]) returns a zero. Unfortunately our
158 readResults() call must return 0 if a large amount of the data
159 being decoded was non-base64, so this while-loop enables proper
160 interop with InputStreamReader for that scenario.
161 -----
162 This is a fix for CODEC-101
163 */
164 if (!base64.hasData()) {
165 byte[] buf = new byte[doEncode ? 4096 : 8192];
166 int c = in.read(buf);
167 // A little optimization to avoid System.arraycopy()
168 // when possible.
169 if (c > 0 && b.length == len) {
170 base64.setInitialBuffer(b, offset, len);
171 }
172 if (doEncode) {
173 base64.encode(buf, 0, c);
174 } else {
175 base64.decode(buf, 0, c);
176 }
177 }
178 return base64.readResults(b, offset, len);
179 }
180 }
181
182 /**
183 * {@inheritDoc}
184 *
…lines 185–191 unchanged (7 lines)

After

…lines 1–141 unchanged (141 lines)
142 throw new IndexOutOfBoundsException();
143 } else if (offset > b.length || offset + len > b.length) {
144 throw new IndexOutOfBoundsException();
145 } else if (len == 0) {
146 return 0;
147 } else {
148 int readLen = 0;
149 /*
150 Rationale for while-loop on (readLen == 0):
151 -----
152 Base64.readResults() usually returns > 0 or EOF (-1). In the
153 rare case where it returns 0, we just keep trying.
154
…lines 155–158 unchanged (4 lines)
159 readResults() call must return 0 if a large amount of the data
160 being decoded was non-base64, so this while-loop enables proper
161 interop with InputStreamReader for that scenario.
162 -----
163 This is a fix for CODEC-101
164 */
165 while (readLen == 0) {
166 if (!base64.hasData()) {
167 byte[] buf = new byte[doEncode ? 4096 : 8192];
168 int c = in.read(buf);
169 // A little optimization to avoid System.arraycopy()
170 // when possible.
171 if (c > 0 && b.length == len) {
172 base64.setInitialBuffer(b, offset, len);
173 }
174 if (doEncode) {
175 base64.encode(buf, 0, c);
176 } else {
177 base64.decode(buf, 0, c);
178 }
179 }
180 readLen = base64.readResults(b, offset, len);
181 }
182 return readLen;
183 }
184 }
185
186 /**
187 * {@inheritDoc}
188 *
…lines 189–195 unchanged (7 lines)

Before

program
block_comment "/*\n * Licensed to the Apache Software Foundation (ASF) under"...
package_declaration
package "package"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "apache"
. "."
identifier "commons"
. "."
identifier "codec"
. "."
identifier "binary"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "FilterInputStream"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "IOException"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "InputStream"
; ";"
block_comment "/**\n * Provides Base64 encoding and decoding in a streaming "...
class_declaration
modifiers
public "public"
class "class"
identifier "Base64InputStream"
superclass
extends "extends"
type_identifier "FilterInputStream"
class_body
{ "{"
field_declaration
modifiers
private "private"
final "final"
boolean_type "boolean"
variable_declarator
identifier "doEncode"
; ";"
field_declaration
modifiers
private "private"
final "final"
type_identifier "Base64"
variable_declarator
identifier "base64"
; ";"
field_declaration (+22 nodes collapsed)
block_comment "/**\n * Creates a Base64InputStream such that all data re"...
constructor_declaration (+22 nodes collapsed)
block_comment "/**\n * Creates a Base64InputStream such that all data re"...
constructor_declaration (+48 nodes collapsed)
block_comment "/**\n * Creates a Base64InputStream such that all data re"...
constructor_declaration (+64 nodes collapsed)
block_comment "/**\n * Reads one <code>byte</code> from this input strea"...
method_declaration (+104 nodes collapsed)
block_comment "/**\n * Attempts to read <code>len</code> bytes into the "...
method_declaration
modifiers
public "public"
integral_type
int "int"
identifier "read"
formal_parameters
( "("
formal_parameter
integral_type
byte "byte"
identifier "b"
dimensions
[ "["
] "]"
, ","
formal_parameter
integral_type
int "int"
identifier "offset"
, ","
formal_parameter
integral_type
int "int"
identifier "len"
) ")"
throws
throws "throws"
type_identifier "IOException"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "b"
== "=="
null_literal "null"
) ")"
block
{ "{"
throw_statement
throw "throw"
object_creation_expression
new "new"
type_identifier "NullPointerException"
argument_list
( "("
) ")"
; ";"
} "}"
else "else"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
binary_expression
identifier "offset"
< "<"
decimal_integer_literal "0"
|| "||"
binary_expression
identifier "len"
< "<"
decimal_integer_literal "0"
) ")"
block
{ "{"
throw_statement
throw "throw"
object_creation_expression
new "new"
type_identifier "IndexOutOfBoundsException"
argument_list
( "("
) ")"
; ";"
} "}"
else "else"
if_statement
if "if"
parenthesized_expression (+22 nodes collapsed)
block
{ "{"
throw_statement
throw "throw"
object_creation_expression
new "new"
type_identifier "IndexOutOfBoundsException"
argument_list
( "("
) ")"
; ";"
} "}"
else "else"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "len"
== "=="
decimal_integer_literal "0"
) ")"
block
{ "{"
return_statement
return "return"
decimal_integer_literal "0"
; ";"
} "}"
else "else"
block
{ "{"
block_comment "/*\n Rationale for while-loop on (readLen == 0):\n"...
if_statement (+134 nodes collapsed)
return_statement
return "return"
method_invocation
identifier "base64"
. "."
identifier "readResults"
argument_list
( "("
identifier "b"
, ","
identifier "offset"
, ","
identifier "len"
) ")"
; ";"
} "}"
} "}"
block_comment "/**\n * {@inheritDoc}\n * \n * @return false\n *"...
method_declaration
modifiers
public "public"
boolean_type "boolean"
identifier "markSupported"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
false "false"
; ";"
line_comment "// not an easy job to support marks"
} "}"
} "}"

After

program
block_comment "/*\n * Licensed to the Apache Software Foundation (ASF) under"...
package_declaration
package "package"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "apache"
. "."
identifier "commons"
. "."
identifier "codec"
. "."
identifier "binary"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "FilterInputStream"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "IOException"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "InputStream"
; ";"
block_comment "/**\n * Provides Base64 encoding and decoding in a streaming "...
class_declaration
modifiers
public "public"
class "class"
identifier "Base64InputStream"
superclass
extends "extends"
type_identifier "FilterInputStream"
class_body
{ "{"
field_declaration
modifiers
private "private"
final "final"
boolean_type "boolean"
variable_declarator
identifier "doEncode"
; ";"
field_declaration
modifiers
private "private"
final "final"
type_identifier "Base64"
variable_declarator
identifier "base64"
; ";"
field_declaration (+22 nodes collapsed)
block_comment "/**\n * Creates a Base64InputStream such that all data re"...
constructor_declaration (+22 nodes collapsed)
block_comment "/**\n * Creates a Base64InputStream such that all data re"...
constructor_declaration (+48 nodes collapsed)
block_comment "/**\n * Creates a Base64InputStream such that all data re"...
constructor_declaration (+64 nodes collapsed)
block_comment "/**\n * Reads one <code>byte</code> from this input strea"...
method_declaration (+104 nodes collapsed)
block_comment "/**\n * Attempts to read <code>len</code> bytes into the "...
method_declaration
modifiers
public "public"
integral_type
int "int"
identifier "read"
formal_parameters
( "("
formal_parameter
integral_type
byte "byte"
identifier "b"
dimensions
[ "["
] "]"
, ","
formal_parameter
integral_type
int "int"
identifier "offset"
, ","
formal_parameter
integral_type
int "int"
identifier "len"
) ")"
throws
throws "throws"
type_identifier "IOException"
block
{ "{"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "b"
== "=="
null_literal "null"
) ")"
block
{ "{"
throw_statement
throw "throw"
object_creation_expression
new "new"
type_identifier "NullPointerException"
argument_list
( "("
) ")"
; ";"
} "}"
else "else"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
binary_expression
identifier "offset"
< "<"
decimal_integer_literal "0"
|| "||"
binary_expression
identifier "len"
< "<"
decimal_integer_literal "0"
) ")"
block
{ "{"
throw_statement
throw "throw"
object_creation_expression
new "new"
type_identifier "IndexOutOfBoundsException"
argument_list
( "("
) ")"
; ";"
} "}"
else "else"
if_statement
if "if"
parenthesized_expression (+22 nodes collapsed)
block
{ "{"
throw_statement
throw "throw"
object_creation_expression
new "new"
type_identifier "IndexOutOfBoundsException"
argument_list
( "("
) ")"
; ";"
} "}"
else "else"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "len"
== "=="
decimal_integer_literal "0"
) ")"
block
{ "{"
return_statement
return "return"
decimal_integer_literal "0"
; ";"
} "}"
else "else"
block
{ "{"
local_variable_declaration
integral_type
int "int"
variable_declarator
identifier "readLen"
= "="
decimal_integer_literal "0"
; ";"
block_comment "/*\n Rationale for while-loop on (readLen == 0):\n"...
while_statement
while "while"
parenthesized_expression
( "("
binary_expression
identifier "readLen"
== "=="
decimal_integer_literal "0"
) ")"
block
{ "{"
if_statement (+134 nodes collapsed)
expression_statement
assignment_expression
identifier "readLen"
= "="
method_invocation
identifier "base64"
. "."
identifier "readResults"
argument_list
( "("
identifier "b"
, ","
identifier "offset"
, ","
identifier "len"
) ")"
; ";"
} "}"
return_statement
return "return"
identifier "readLen"
; ";"
} "}"
} "}"
block_comment "/**\n * {@inheritDoc}\n * \n * @return false\n *"...
method_declaration
modifiers
public "public"
boolean_type "boolean"
identifier "markSupported"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
false "false"
; ";"
line_comment "// not an easy job to support marks"
} "}"
} "}"