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–78 unchanged (78 lines)
79 public String get(final String name) {
80 if (mapping == null) {
81 throw new IllegalStateException(
82 "No header mapping was specified, the record values can't be accessed by name");
83 }
84 final Integer index = mapping.get(name);
85 return index != null ? values[index.intValue()] : null;
86 }
87
88 /**
89 * Returns true if this record is consistent, false if not. Currently, the only check is matching the record size to
90 * the header size. Some programs can export files that fails this test but still produce parsable files.
91 *
92 * @return true of this record is valid, false if not
…lines 93–168 unchanged (76 lines)

After

…lines 1–78 unchanged (78 lines)
79 public String get(final String name) {
80 if (mapping == null) {
81 throw new IllegalStateException(
82 "No header mapping was specified, the record values can't be accessed by name");
83 }
84 final Integer index = mapping.get(name);
85 try {
86 return index != null ? values[index.intValue()] : null;
87 } catch (ArrayIndexOutOfBoundsException e) {
88 throw new IllegalArgumentException(
89 String.format(
90 "Index for header '%s' is %d but CSVRecord only has %d values!",
91 name, index.intValue(), values.length));
92 }
93 }
94
95 /**
96 * Returns true if this record is consistent, false if not. Currently, the only check is matching the record size to
97 * the header size. Some programs can export files that fails this test but still produce parsable files.
98 *
…lines 99–175 unchanged (77 lines)

Before

program
block_comment "/*\n * Licensed to the Apache Software Foundation (ASF) under"...
package_declaration
package "package"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "apache"
. "."
identifier "commons"
. "."
identifier "csv"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "Serializable"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Arrays"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Iterator"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Map"
; ";"
block_comment "/**\n * A CSV record parsed from a CSV file.\n *\n * @version $"...
class_declaration
modifiers
public "public"
class "class"
identifier "CSVRecord"
super_interfaces
implements "implements"
type_list
type_identifier "Serializable"
, ","
generic_type
type_identifier "Iterable"
type_arguments
< "<"
type_identifier "String"
> ">"
class_body
{ "{"
field_declaration
modifiers
private "private"
static "static"
final "final"
integral_type
long "long"
variable_declarator
identifier "serialVersionUID"
= "="
decimal_integer_literal "1L"
; ";"
field_declaration (+21 nodes collapsed)
block_comment "/** The values of the record */"
field_declaration
modifiers
private "private"
final "final"
array_type
type_identifier "String"
dimensions
[ "["
] "]"
variable_declarator
identifier "values"
; ";"
block_comment "/** The column name to index mapping. */"
field_declaration
modifiers
private "private"
final "final"
generic_type
type_identifier "Map"
type_arguments
< "<"
type_identifier "String"
, ","
type_identifier "Integer"
> ">"
variable_declarator
identifier "mapping"
; ";"
block_comment "/** The accumulated comments (if any) */"
field_declaration
modifiers
private "private"
final "final"
type_identifier "String"
variable_declarator
identifier "comment"
; ";"
block_comment "/** The record number. */"
field_declaration
modifiers
private "private"
final "final"
integral_type
long "long"
variable_declarator
identifier "recordNumber"
; ";"
constructor_declaration (+87 nodes collapsed)
block_comment "/**\n * Returns a value by index.\n *\n * @param i\n"...
method_declaration (+25 nodes collapsed)
block_comment "/**\n * Returns a value by name.\n *\n * @param nam"...
method_declaration
modifiers
public "public"
type_identifier "String"
identifier "get"
formal_parameters
( "("
formal_parameter
modifiers
final "final"
type_identifier "String"
identifier "name"
) ")"
block
{ "{"
if_statement (+25 nodes collapsed)
local_variable_declaration
modifiers
final "final"
type_identifier "Integer"
variable_declarator
identifier "index"
= "="
method_invocation
identifier "mapping"
. "."
identifier "get"
argument_list
( "("
identifier "name"
) ")"
; ";"
return_statement (+22 nodes collapsed)
} "}"
block_comment "/**\n * Returns true if this record is consistent, false "...
method_declaration (+35 nodes collapsed)
block_comment "/**\n * Checks whether a given column is mapped.\n *\n "...
method_declaration (+35 nodes collapsed)
block_comment "/**\n * Checks whether a given columns is mapped and has "...
method_declaration (+47 nodes collapsed)
block_comment "/**\n * Returns an iterator over the values of this recor"...
method_declaration (+33 nodes collapsed)
method_declaration
array_type
type_identifier "String"
dimensions
[ "["
] "]"
identifier "values"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "values"
; ";"
} "}"
block_comment "/**\n * Returns the comment for this record, if any.\n "...
method_declaration
modifiers
public "public"
type_identifier "String"
identifier "getComment"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "comment"
; ";"
} "}"
block_comment "/**\n * Returns the number of this record in the parsed C"...
method_declaration
modifiers
public "public"
integral_type
long "long"
identifier "getRecordNumber"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "recordNumber"
; ";"
} "}"
block_comment "/**\n * Returns the number of values in this record.\n "...
method_declaration
modifiers
public "public"
integral_type
int "int"
identifier "size"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
field_access
identifier "values"
. "."
identifier "length"
; ";"
} "}"
method_declaration (+25 nodes collapsed)
} "}"

After

program
block_comment "/*\n * Licensed to the Apache Software Foundation (ASF) under"...
package_declaration
package "package"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "apache"
. "."
identifier "commons"
. "."
identifier "csv"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "io"
. "."
identifier "Serializable"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Arrays"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Iterator"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Map"
; ";"
block_comment "/**\n * A CSV record parsed from a CSV file.\n *\n * @version $"...
class_declaration
modifiers
public "public"
class "class"
identifier "CSVRecord"
super_interfaces
implements "implements"
type_list
type_identifier "Serializable"
, ","
generic_type
type_identifier "Iterable"
type_arguments
< "<"
type_identifier "String"
> ">"
class_body
{ "{"
field_declaration
modifiers
private "private"
static "static"
final "final"
integral_type
long "long"
variable_declarator
identifier "serialVersionUID"
= "="
decimal_integer_literal "1L"
; ";"
field_declaration (+21 nodes collapsed)
block_comment "/** The values of the record */"
field_declaration
modifiers
private "private"
final "final"
array_type
type_identifier "String"
dimensions
[ "["
] "]"
variable_declarator
identifier "values"
; ";"
block_comment "/** The column name to index mapping. */"
field_declaration
modifiers
private "private"
final "final"
generic_type
type_identifier "Map"
type_arguments
< "<"
type_identifier "String"
, ","
type_identifier "Integer"
> ">"
variable_declarator
identifier "mapping"
; ";"
block_comment "/** The accumulated comments (if any) */"
field_declaration
modifiers
private "private"
final "final"
type_identifier "String"
variable_declarator
identifier "comment"
; ";"
block_comment "/** The record number. */"
field_declaration
modifiers
private "private"
final "final"
integral_type
long "long"
variable_declarator
identifier "recordNumber"
; ";"
constructor_declaration (+87 nodes collapsed)
block_comment "/**\n * Returns a value by index.\n *\n * @param i\n"...
method_declaration (+25 nodes collapsed)
block_comment "/**\n * Returns a value by name.\n *\n * @param nam"...
method_declaration
modifiers
public "public"
type_identifier "String"
identifier "get"
formal_parameters
( "("
formal_parameter
modifiers
final "final"
type_identifier "String"
identifier "name"
) ")"
block
{ "{"
if_statement (+25 nodes collapsed)
local_variable_declaration
modifiers
final "final"
type_identifier "Integer"
variable_declarator
identifier "index"
= "="
method_invocation
identifier "mapping"
. "."
identifier "get"
argument_list
( "("
identifier "name"
) ")"
; ";"
try_statement
try "try"
block
{ "{"
return_statement (+22 nodes collapsed)
} "}"
catch_clause
catch "catch"
( "("
catch_formal_parameter
catch_type
type_identifier "ArrayIndexOutOfBoundsException"
identifier "e"
) ")"
block
{ "{"
throw_statement
throw "throw"
object_creation_expression
new "new"
type_identifier "IllegalArgumentException"
argument_list
( "("
method_invocation
identifier "String"
. "."
identifier "format"
argument_list
( "("
string_literal
" "\""
string_fragment "Index for header '%s' is %d but CSVRecord only has %d values"...
" "\""
, ","
identifier "name"
, ","
method_invocation
identifier "index"
. "."
identifier "intValue"
argument_list
( "("
) ")"
, ","
field_access
identifier "values"
. "."
identifier "length"
) ")"
) ")"
; ";"
} "}"
} "}"
block_comment "/**\n * Returns true if this record is consistent, false "...
method_declaration (+35 nodes collapsed)
block_comment "/**\n * Checks whether a given column is mapped.\n *\n "...
method_declaration (+35 nodes collapsed)
block_comment "/**\n * Checks whether a given columns is mapped and has "...
method_declaration (+47 nodes collapsed)
block_comment "/**\n * Returns an iterator over the values of this recor"...
method_declaration (+33 nodes collapsed)
method_declaration
array_type
type_identifier "String"
dimensions
[ "["
] "]"
identifier "values"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "values"
; ";"
} "}"
block_comment "/**\n * Returns the comment for this record, if any.\n "...
method_declaration
modifiers
public "public"
type_identifier "String"
identifier "getComment"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "comment"
; ";"
} "}"
block_comment "/**\n * Returns the number of this record in the parsed C"...
method_declaration
modifiers
public "public"
integral_type
long "long"
identifier "getRecordNumber"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "recordNumber"
; ";"
} "}"
block_comment "/**\n * Returns the number of values in this record.\n "...
method_declaration
modifiers
public "public"
integral_type
int "int"
identifier "size"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
field_access
identifier "values"
. "."
identifier "length"
; ";"
} "}"
method_declaration (+25 nodes collapsed)
} "}"