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

1package org.jsoup.parser;
2
3import org.jsoup.helper.Validate;
4
5import java.util.HashMap;
6import java.util.Map;
7
8/**
9 * HTML Tag capabilities.
10 *
11 * @author Jonathan Hedley, jonathan@hedley.net
12 */
13public class Tag {
14 private static final Map<String, Tag> tags = new HashMap<>(); // map of known tags
15
16 private String tagName;
17 private boolean isBlock = true; // block or inline
18 private boolean formatAsBlock = true; // should be formatted as a block
19 private boolean canContainInline = true; // only pcdata if not
20 private boolean empty = false; // can hold nothing; e.g. img
21 private boolean selfClosing = false; // can self close (<foo />). used for unknown tags that self close, without forcing them as empty.
22 private boolean preserveWhitespace = false; // for pre, textarea, script etc
23 private boolean formList = false; // a control that appears in forms: input, textarea, output etc
24 private boolean formSubmit = false; // a control that can be submitted in a form: input etc
25
26 private Tag(String tagName) {
27 this.tagName = tagName;
28 }
29
30 /**
31 * Get this tag's name.
32 *
33 * @return the tag's name
34 */
35 public String getName() {
36 return tagName;
37 }
38
39 /**
40 * Get this tag's normalized (lowercased) name.
41 * @return the tag's normal name.
42 */
43
44 /**
45 * Get a Tag by name. If not previously defined (unknown), returns a new generic tag, that can do anything.
46 * <p>
47 * Pre-defined tags (P, DIV etc) will be ==, but unknown tags are not registered and will only .equals().
48 * </p>
49 *
…lines 50–323 unchanged (274 lines)

After

1package org.jsoup.parser;
2
3import org.jsoup.helper.Validate;
4import org.jsoup.internal.Normalizer;
5
6import java.util.HashMap;
7import java.util.Map;
8
9/**
10 * HTML Tag capabilities.
11 *
12 * @author Jonathan Hedley, jonathan@hedley.net
13 */
14public class Tag {
15 private static final Map<String, Tag> tags = new HashMap<>(); // map of known tags
16
17 private String tagName;
18 private String normalName; // always the lower case version of this tag, regardless of case preservation mode
19 private boolean isBlock = true; // block or inline
20 private boolean formatAsBlock = true; // should be formatted as a block
21 private boolean canContainInline = true; // only pcdata if not
22 private boolean empty = false; // can hold nothing; e.g. img
23 private boolean selfClosing = false; // can self close (<foo />). used for unknown tags that self close, without forcing them as empty.
24 private boolean preserveWhitespace = false; // for pre, textarea, script etc
25 private boolean formList = false; // a control that appears in forms: input, textarea, output etc
26 private boolean formSubmit = false; // a control that can be submitted in a form: input etc
27
28 private Tag(String tagName) {
29 this.tagName = tagName;
30 normalName = Normalizer.lowerCase(tagName);
31 }
32
33 /**
34 * Get this tag's name.
35 *
36 * @return the tag's name
37 */
38 public String getName() {
39 return tagName;
40 }
41
42 /**
43 * Get this tag's normalized (lowercased) name.
44 * @return the tag's normal name.
45 */
46 public String normalName() {
47 return normalName;
48 }
49
50 /**
51 * Get a Tag by name. If not previously defined (unknown), returns a new generic tag, that can do anything.
52 * <p>
53 * Pre-defined tags (P, DIV etc) will be ==, but unknown tags are not registered and will only .equals().
54 * </p>
…lines 55–329 unchanged (275 lines)

Before

program
package_declaration
package "package"
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jsoup"
. "."
identifier "parser"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jsoup"
. "."
identifier "helper"
. "."
identifier "Validate"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "HashMap"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Map"
; ";"
block_comment "/**\n * HTML Tag capabilities.\n *\n * @author Jonathan Hedley,"...
class_declaration
modifiers
public "public"
class "class"
identifier "Tag"
class_body
{ "{"
field_declaration (+27 nodes collapsed)
line_comment "// map of known tags"
field_declaration
modifiers
private "private"
type_identifier "String"
variable_declarator
identifier "tagName"
; ";"
field_declaration
modifiers
private "private"
boolean_type "boolean"
variable_declarator
identifier "isBlock"
= "="
true "true"
; ";"
line_comment "// block or inline"
field_declaration
modifiers
private "private"
boolean_type "boolean"
variable_declarator
identifier "formatAsBlock"
= "="
true "true"
; ";"
line_comment "// should be formatted as a block"
field_declaration
modifiers
private "private"
boolean_type "boolean"
variable_declarator
identifier "canContainInline"
= "="
true "true"
; ";"
line_comment "// only pcdata if not"
field_declaration
modifiers
private "private"
boolean_type "boolean"
variable_declarator
identifier "empty"
= "="
false "false"
; ";"
line_comment "// can hold nothing; e.g. img"
field_declaration
modifiers
private "private"
boolean_type "boolean"
variable_declarator
identifier "selfClosing"
= "="
false "false"
; ";"
line_comment "// can self close (<foo />). used for unknown tags that self"...
field_declaration
modifiers
private "private"
boolean_type "boolean"
variable_declarator
identifier "preserveWhitespace"
= "="
false "false"
; ";"
line_comment "// for pre, textarea, script etc"
field_declaration
modifiers
private "private"
boolean_type "boolean"
variable_declarator
identifier "formList"
= "="
false "false"
; ";"
line_comment "// a control that appears in forms: input, textarea, output "...
field_declaration
modifiers
private "private"
boolean_type "boolean"
variable_declarator
identifier "formSubmit"
= "="
false "false"
; ";"
line_comment "// a control that can be submitted in a form: input etc"
constructor_declaration
modifiers
private "private"
identifier "Tag"
formal_parameters
( "("
formal_parameter
type_identifier "String"
identifier "tagName"
) ")"
constructor_body
{ "{"
expression_statement
assignment_expression
field_access
this "this"
. "."
identifier "tagName"
= "="
identifier "tagName"
; ";"
} "}"
block_comment "/**\n * Get this tag's name.\n *\n * @return the ta"...
method_declaration
modifiers
public "public"
type_identifier "String"
identifier "getName"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "tagName"
; ";"
} "}"
block_comment "/**\n * Get this tag's normalized (lowercased) name.\n "...
block_comment "/**\n * Get a Tag by name. If not previously defined (unk"...
method_declaration (+129 nodes collapsed)
block_comment "/**\n * Get a Tag by name. If not previously defined (unk"...
method_declaration (+29 nodes collapsed)
block_comment "/**\n * Gets if this is a block tag.\n *\n * @retur"...
method_declaration
modifiers
public "public"
boolean_type "boolean"
identifier "isBlock"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "isBlock"
; ";"
} "}"
block_comment "/**\n * Gets if this tag should be formatted as a block ("...
method_declaration
modifiers
public "public"
boolean_type "boolean"
identifier "formatAsBlock"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "formatAsBlock"
; ";"
} "}"
block_comment "/**\n * Gets if this tag can contain block tags.\n *\n "...
method_declaration
modifiers
public "public"
boolean_type "boolean"
identifier "canContainBlock"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "isBlock"
; ";"
} "}"
block_comment "/**\n * Gets if this tag is an inline tag.\n *\n * "...
method_declaration
modifiers
public "public"
boolean_type "boolean"
identifier "isInline"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
unary_expression
! "!"
identifier "isBlock"
; ";"
} "}"
block_comment "/**\n * Gets if this tag is a data only tag.\n *\n "...
method_declaration (+26 nodes collapsed)
block_comment "/**\n * Get if this is an empty tag\n *\n * @return"...
method_declaration
modifiers
public "public"
boolean_type "boolean"
identifier "isEmpty"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "empty"
; ";"
} "}"
block_comment "/**\n * Get if this tag is self closing.\n *\n * @r"...
method_declaration
modifiers
public "public"
boolean_type "boolean"
identifier "isSelfClosing"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
binary_expression
identifier "empty"
|| "||"
identifier "selfClosing"
; ";"
} "}"
block_comment "/**\n * Get if this is a pre-defined tag, or was auto cre"...
method_declaration (+22 nodes collapsed)
block_comment "/**\n * Check if this tagname is a known tag.\n *\n "...
method_declaration (+26 nodes collapsed)
block_comment "/**\n * Get if this tag should preserve whitespace within"...
method_declaration
modifiers
public "public"
boolean_type "boolean"
identifier "preserveWhitespace"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "preserveWhitespace"
; ";"
} "}"
block_comment "/**\n * Get if this tag represents a control associated w"...
method_declaration
modifiers
public "public"
boolean_type "boolean"
identifier "isFormListed"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "formList"
; ";"
} "}"
block_comment "/**\n * Get if this tag represents an element that should"...
method_declaration
modifiers
public "public"
boolean_type "boolean"
identifier "isFormSubmittable"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "formSubmit"
; ";"
} "}"
method_declaration
type_identifier "Tag"
identifier "setSelfClosing"
formal_parameters
( "("
) ")"
block
{ "{"
expression_statement
assignment_expression
identifier "selfClosing"
= "="
true "true"
; ";"
return_statement
return "return"
this "this"
; ";"
} "}"
method_declaration (+203 nodes collapsed)
method_declaration (+193 nodes collapsed)
method_declaration
modifiers
marker_annotation
@ "@"
identifier "Override"
public "public"
type_identifier "String"
identifier "toString"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "tagName"
; ";"
} "}"
line_comment "// internal static initialisers:"
line_comment "// prepped from http://www.w3.org/TR/REC-html40/sgml/dtd.htm"...
field_declaration (+331 nodes collapsed)
field_declaration (+346 nodes collapsed)
field_declaration (+121 nodes collapsed)
field_declaration (+111 nodes collapsed)
field_declaration (+37 nodes collapsed)
line_comment "// todo: I think we just need submit tags, and can scrub lis"...
field_declaration (+56 nodes collapsed)
field_declaration (+41 nodes collapsed)
static_initializer (+318 nodes collapsed)
method_declaration (+30 nodes collapsed)
} "}"

After

program
package_declaration
package "package"
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jsoup"
. "."
identifier "parser"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jsoup"
. "."
identifier "helper"
. "."
identifier "Validate"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "org"
. "."
identifier "jsoup"
. "."
identifier "internal"
. "."
identifier "Normalizer"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "HashMap"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Map"
; ";"
block_comment "/**\n * HTML Tag capabilities.\n *\n * @author Jonathan Hedley,"...
class_declaration
modifiers
public "public"
class "class"
identifier "Tag"
class_body
{ "{"
field_declaration (+27 nodes collapsed)
line_comment "// map of known tags"
field_declaration
modifiers
private "private"
type_identifier "String"
variable_declarator
identifier "tagName"
; ";"
field_declaration
modifiers
private "private"
type_identifier "String"
variable_declarator
identifier "normalName"
; ";"
line_comment "// always the lower case version of this tag, regardless of "...
field_declaration
modifiers
private "private"
boolean_type "boolean"
variable_declarator
identifier "isBlock"
= "="
true "true"
; ";"
line_comment "// block or inline"
field_declaration
modifiers
private "private"
boolean_type "boolean"
variable_declarator
identifier "formatAsBlock"
= "="
true "true"
; ";"
line_comment "// should be formatted as a block"
field_declaration
modifiers
private "private"
boolean_type "boolean"
variable_declarator
identifier "canContainInline"
= "="
true "true"
; ";"
line_comment "// only pcdata if not"
field_declaration
modifiers
private "private"
boolean_type "boolean"
variable_declarator
identifier "empty"
= "="
false "false"
; ";"
line_comment "// can hold nothing; e.g. img"
field_declaration
modifiers
private "private"
boolean_type "boolean"
variable_declarator
identifier "selfClosing"
= "="
false "false"
; ";"
line_comment "// can self close (<foo />). used for unknown tags that self"...
field_declaration
modifiers
private "private"
boolean_type "boolean"
variable_declarator
identifier "preserveWhitespace"
= "="
false "false"
; ";"
line_comment "// for pre, textarea, script etc"
field_declaration
modifiers
private "private"
boolean_type "boolean"
variable_declarator
identifier "formList"
= "="
false "false"
; ";"
line_comment "// a control that appears in forms: input, textarea, output "...
field_declaration
modifiers
private "private"
boolean_type "boolean"
variable_declarator
identifier "formSubmit"
= "="
false "false"
; ";"
line_comment "// a control that can be submitted in a form: input etc"
constructor_declaration
modifiers
private "private"
identifier "Tag"
formal_parameters
( "("
formal_parameter
type_identifier "String"
identifier "tagName"
) ")"
constructor_body
{ "{"
expression_statement
assignment_expression
field_access
this "this"
. "."
identifier "tagName"
= "="
identifier "tagName"
; ";"
expression_statement
assignment_expression
identifier "normalName"
= "="
method_invocation
identifier "Normalizer"
. "."
identifier "lowerCase"
argument_list
( "("
identifier "tagName"
) ")"
; ";"
} "}"
block_comment "/**\n * Get this tag's name.\n *\n * @return the ta"...
method_declaration
modifiers
public "public"
type_identifier "String"
identifier "getName"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "tagName"
; ";"
} "}"
block_comment "/**\n * Get this tag's normalized (lowercased) name.\n "...
method_declaration
modifiers
public "public"
type_identifier "String"
identifier "normalName"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "normalName"
; ";"
} "}"
block_comment "/**\n * Get a Tag by name. If not previously defined (unk"...
method_declaration (+129 nodes collapsed)
block_comment "/**\n * Get a Tag by name. If not previously defined (unk"...
method_declaration (+29 nodes collapsed)
block_comment "/**\n * Gets if this is a block tag.\n *\n * @retur"...
method_declaration
modifiers
public "public"
boolean_type "boolean"
identifier "isBlock"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "isBlock"
; ";"
} "}"
block_comment "/**\n * Gets if this tag should be formatted as a block ("...
method_declaration
modifiers
public "public"
boolean_type "boolean"
identifier "formatAsBlock"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "formatAsBlock"
; ";"
} "}"
block_comment "/**\n * Gets if this tag can contain block tags.\n *\n "...
method_declaration
modifiers
public "public"
boolean_type "boolean"
identifier "canContainBlock"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "isBlock"
; ";"
} "}"
block_comment "/**\n * Gets if this tag is an inline tag.\n *\n * "...
method_declaration
modifiers
public "public"
boolean_type "boolean"
identifier "isInline"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
unary_expression
! "!"
identifier "isBlock"
; ";"
} "}"
block_comment "/**\n * Gets if this tag is a data only tag.\n *\n "...
method_declaration (+26 nodes collapsed)
block_comment "/**\n * Get if this is an empty tag\n *\n * @return"...
method_declaration
modifiers
public "public"
boolean_type "boolean"
identifier "isEmpty"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "empty"
; ";"
} "}"
block_comment "/**\n * Get if this tag is self closing.\n *\n * @r"...
method_declaration
modifiers
public "public"
boolean_type "boolean"
identifier "isSelfClosing"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
binary_expression
identifier "empty"
|| "||"
identifier "selfClosing"
; ";"
} "}"
block_comment "/**\n * Get if this is a pre-defined tag, or was auto cre"...
method_declaration (+22 nodes collapsed)
block_comment "/**\n * Check if this tagname is a known tag.\n *\n "...
method_declaration (+26 nodes collapsed)
block_comment "/**\n * Get if this tag should preserve whitespace within"...
method_declaration
modifiers
public "public"
boolean_type "boolean"
identifier "preserveWhitespace"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "preserveWhitespace"
; ";"
} "}"
block_comment "/**\n * Get if this tag represents a control associated w"...
method_declaration
modifiers
public "public"
boolean_type "boolean"
identifier "isFormListed"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "formList"
; ";"
} "}"
block_comment "/**\n * Get if this tag represents an element that should"...
method_declaration
modifiers
public "public"
boolean_type "boolean"
identifier "isFormSubmittable"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "formSubmit"
; ";"
} "}"
method_declaration
type_identifier "Tag"
identifier "setSelfClosing"
formal_parameters
( "("
) ")"
block
{ "{"
expression_statement
assignment_expression
identifier "selfClosing"
= "="
true "true"
; ";"
return_statement
return "return"
this "this"
; ";"
} "}"
method_declaration (+203 nodes collapsed)
method_declaration (+193 nodes collapsed)
method_declaration
modifiers
marker_annotation
@ "@"
identifier "Override"
public "public"
type_identifier "String"
identifier "toString"
formal_parameters
( "("
) ")"
block
{ "{"
return_statement
return "return"
identifier "tagName"
; ";"
} "}"
line_comment "// internal static initialisers:"
line_comment "// prepped from http://www.w3.org/TR/REC-html40/sgml/dtd.htm"...
field_declaration (+331 nodes collapsed)
field_declaration (+346 nodes collapsed)
field_declaration (+121 nodes collapsed)
field_declaration (+111 nodes collapsed)
field_declaration (+37 nodes collapsed)
line_comment "// todo: I think we just need submit tags, and can scrub lis"...
field_declaration (+56 nodes collapsed)
field_declaration (+41 nodes collapsed)
static_initializer (+318 nodes collapsed)
method_declaration (+30 nodes collapsed)
} "}"