From 37f7acac321f349d2ca3d6f2461c598030439c23 Mon Sep 17 00:00:00 2001 From: "Andreas L. Delmelle" Date: Fri, 14 Jan 2011 23:57:55 +0000 Subject: [PATCH] Eliminate unnecessary boxing git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1059210 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/area/Block.java | 2 +- src/java/org/apache/fop/area/Trait.java | 257 +++++++++--------------- 2 files changed, 94 insertions(+), 165 deletions(-) diff --git a/src/java/org/apache/fop/area/Block.java b/src/java/org/apache/fop/area/Block.java index e37931510..423dcfafa 100644 --- a/src/java/org/apache/fop/area/Block.java +++ b/src/java/org/apache/fop/area/Block.java @@ -130,7 +130,7 @@ public class Block extends BlockParent { */ public int getStartIndent() { Integer startIndent = (Integer)getTrait(Trait.START_INDENT); - return (startIndent != null ? startIndent.intValue() : 0); + return (startIndent != null ? startIndent : 0); } } diff --git a/src/java/org/apache/fop/area/Trait.java b/src/java/org/apache/fop/area/Trait.java index 8114666bc..a8e1db186 100644 --- a/src/java/org/apache/fop/area/Trait.java +++ b/src/java/org/apache/fop/area/Trait.java @@ -41,167 +41,114 @@ public final class Trait implements Serializable { private Trait() { } - /** - * Id reference line, not resolved. - * not sure if this is needed. - */ + /** Id reference line, not resolved. (not sure if this is needed.) */ //public static final Integer ID_LINK = new Integer(0); /** * Internal link trait. * Contains the PageViewport key and the PROD_ID of the target area */ - public static final Integer INTERNAL_LINK = new Integer(1); + public static final Integer INTERNAL_LINK = 1; - /** - * External link. A URL link to an external resource. - */ - public static final Integer EXTERNAL_LINK = new Integer(2); + /** * External link. A URL link to an external resource. */ + public static final Integer EXTERNAL_LINK = 2; - /** - * The font triplet for the current font. - */ - public static final Integer FONT = new Integer(3); + /** The font triplet for the current font. */ + public static final Integer FONT = 3; - /** - * Font size for the current font. - */ - public static final Integer FONT_SIZE = new Integer(4); + /** Font size for the current font. */ + public static final Integer FONT_SIZE = 4; - /** - * The current color. - */ - public static final Integer COLOR = new Integer(7); + /** The current color. */ + public static final Integer COLOR = 7; - /** - * The ID of the FO that produced an area. - */ - public static final Integer PROD_ID = new Integer(8); + /** The ID of the FO that produced an area. */ + public static final Integer PROD_ID = 8; - /** - * Background trait for an area. - */ - public static final Integer BACKGROUND = new Integer(9); + /** Background trait for an area. */ + public static final Integer BACKGROUND = 9; - /** - * Underline trait used when rendering inline parent. - */ - public static final Integer UNDERLINE = new Integer(10); + /** Underline trait used when rendering inline parent. */ + public static final Integer UNDERLINE = 10; - /** - * Overline trait used when rendering inline parent. - */ - public static final Integer OVERLINE = new Integer(11); + /** Overline trait used when rendering inline parent. */ + public static final Integer OVERLINE = 11; - /** - * Linethrough trait used when rendering inline parent. - */ - public static final Integer LINETHROUGH = new Integer(12); + /** Linethrough trait used when rendering inline parent. */ + public static final Integer LINETHROUGH = 12; - /** - * Shadow offset. - */ + /** Shadow offset. */ //public static final Integer OFFSET = new Integer(13); - /** - * The shadow for text. - */ + /** The shadow for text. */ //public static final Integer SHADOW = new Integer(14); - /** - * The border start. - */ - public static final Integer BORDER_START = new Integer(15); + /** The border start. */ + public static final Integer BORDER_START = 15; - /** - * The border end. - */ - public static final Integer BORDER_END = new Integer(16); + /** The border end. */ + public static final Integer BORDER_END = 16; - /** - * The border before. - */ - public static final Integer BORDER_BEFORE = new Integer(17); + /** The border before. */ + public static final Integer BORDER_BEFORE = 17; - /** - * The border after. - */ - public static final Integer BORDER_AFTER = new Integer(18); + /** The border after. */ + public static final Integer BORDER_AFTER = 18; - /** - * The padding start. - */ - public static final Integer PADDING_START = new Integer(19); + /** The padding start. */ + public static final Integer PADDING_START = 19; - /** - * The padding end. - */ - public static final Integer PADDING_END = new Integer(20); + /** The padding end. */ + public static final Integer PADDING_END = 20; - /** - * The padding before. - */ - public static final Integer PADDING_BEFORE = new Integer(21); + /** The padding before. */ + public static final Integer PADDING_BEFORE = 21; - /** - * The padding after. - */ - public static final Integer PADDING_AFTER = new Integer(22); + /** The padding after. */ + public static final Integer PADDING_AFTER = 22; - /** - * The space start. - */ - public static final Integer SPACE_START = new Integer(23); + /** The space start. */ + public static final Integer SPACE_START = 23; - /** - * The space end. - */ - public static final Integer SPACE_END = new Integer(24); + /** The space end. */ + public static final Integer SPACE_END = 24; - /** - * break before - */ + /** break before */ //public static final Integer BREAK_BEFORE = new Integer(25); - /** - * break after - */ + /** break after */ //public static final Integer BREAK_AFTER = new Integer(26); - /** - * The start-indent trait. - */ - public static final Integer START_INDENT = new Integer(27); + /** The start-indent trait. */ + public static final Integer START_INDENT = 27; - /** - * The end-indent trait. - */ - public static final Integer END_INDENT = new Integer(28); + /** The end-indent trait. */ + public static final Integer END_INDENT = 28; /** The space-before trait. */ - public static final Integer SPACE_BEFORE = new Integer(29); + public static final Integer SPACE_BEFORE = 29; /** The space-after trait. */ - public static final Integer SPACE_AFTER = new Integer(30); + public static final Integer SPACE_AFTER = 30; /** The is-reference-area trait. */ - public static final Integer IS_REFERENCE_AREA = new Integer(31); + public static final Integer IS_REFERENCE_AREA = 31; /** The is-viewport-area trait. */ - public static final Integer IS_VIEWPORT_AREA = new Integer(32); + public static final Integer IS_VIEWPORT_AREA = 32; /** Blinking trait used when rendering inline parent. */ - public static final Integer BLINK = new Integer(33); + public static final Integer BLINK = 33; /** Trait for color of underline decorations when rendering inline parent. */ - public static final Integer UNDERLINE_COLOR = new Integer(34); + public static final Integer UNDERLINE_COLOR = 34; /** Trait for color of overline decorations when rendering inline parent. */ - public static final Integer OVERLINE_COLOR = new Integer(35); + public static final Integer OVERLINE_COLOR = 35; /** Trait for color of linethrough decorations when rendering inline parent. */ - public static final Integer LINETHROUGH_COLOR = new Integer(36); + public static final Integer LINETHROUGH_COLOR = 36; /** The ptr trait. Used for accessibility */ - public static final Integer PTR = new Integer(37); + public static final Integer PTR = 37; /** Maximum value used by trait keys */ public static final int MAX_TRAIT_KEY = 37; @@ -227,65 +174,47 @@ public final class Trait implements Serializable { } private static void put(Integer key, TraitInfo info) { - TRAIT_INFO[key.intValue()] = info; + TRAIT_INFO[key] = info; } static { // Create a hashmap mapping trait code to name for external representation //put(ID_LINK, new TraitInfo("id-link", String.class)); - put(PTR, new TraitInfo("ptr", String.class)); - put(INTERNAL_LINK, new TraitInfo("internal-link", InternalLink.class)); - put(EXTERNAL_LINK, new TraitInfo("external-link", ExternalLink.class)); - put(FONT, new TraitInfo("font", FontTriplet.class)); - put(FONT_SIZE, new TraitInfo("font-size", Integer.class)); - put(COLOR, new TraitInfo("color", Color.class)); - put(PROD_ID, new TraitInfo("prod-id", String.class)); - put(BACKGROUND, new TraitInfo("background", Background.class)); - put(UNDERLINE, new TraitInfo("underline-score", Boolean.class)); + put(PTR, new TraitInfo("ptr", String.class)); + put(INTERNAL_LINK, new TraitInfo("internal-link", InternalLink.class)); + put(EXTERNAL_LINK, new TraitInfo("external-link", ExternalLink.class)); + put(FONT, new TraitInfo("font", FontTriplet.class)); + put(FONT_SIZE, new TraitInfo("font-size", Integer.class)); + put(COLOR, new TraitInfo("color", Color.class)); + put(PROD_ID, new TraitInfo("prod-id", String.class)); + put(BACKGROUND, new TraitInfo("background", Background.class)); + put(UNDERLINE, new TraitInfo("underline-score", Boolean.class)); put(UNDERLINE_COLOR, new TraitInfo("underline-score-color", Color.class)); - put(OVERLINE, new TraitInfo("overline-score", Boolean.class)); + put(OVERLINE, new TraitInfo("overline-score", Boolean.class)); put(OVERLINE_COLOR, new TraitInfo("overline-score-color", Color.class)); - put(LINETHROUGH, new TraitInfo("through-score", Boolean.class)); + put(LINETHROUGH, new TraitInfo("through-score", Boolean.class)); put(LINETHROUGH_COLOR, new TraitInfo("through-score-color", Color.class)); - put(BLINK, new TraitInfo("blink", Boolean.class)); - //put(OFFSET, new TraitInfo("offset", Integer.class)); - //put(SHADOW, new TraitInfo("shadow", Integer.class)); - put(BORDER_START, - new TraitInfo("border-start", BorderProps.class)); - put(BORDER_END, - new TraitInfo("border-end", BorderProps.class)); - put(BORDER_BEFORE, - new TraitInfo("border-before", BorderProps.class)); - put(BORDER_AFTER, - new TraitInfo("border-after", BorderProps.class)); - put(PADDING_START, - new TraitInfo("padding-start", Integer.class)); - put(PADDING_END, - new TraitInfo("padding-end", Integer.class)); - put(PADDING_BEFORE, - new TraitInfo("padding-before", Integer.class)); - put(PADDING_AFTER, - new TraitInfo("padding-after", Integer.class)); - put(SPACE_START, - new TraitInfo("space-start", Integer.class)); - put(SPACE_END, - new TraitInfo("space-end", Integer.class)); - //put(BREAK_BEFORE, - // new TraitInfo("break-before", Integer.class)); - //put(BREAK_AFTER, - // new TraitInfo("break-after", Integer.class)); - put(START_INDENT, - new TraitInfo("start-indent", Integer.class)); - put(END_INDENT, - new TraitInfo("end-indent", Integer.class)); - put(SPACE_BEFORE, - new TraitInfo("space-before", Integer.class)); - put(SPACE_AFTER, - new TraitInfo("space-after", Integer.class)); - put(IS_REFERENCE_AREA, - new TraitInfo("is-reference-area", Boolean.class)); - put(IS_VIEWPORT_AREA, - new TraitInfo("is-viewport-area", Boolean.class)); + put(BLINK, new TraitInfo("blink", Boolean.class)); + //put(OFFSET, new TraitInfo("offset", Integer.class)); + //put(SHADOW, new TraitInfo("shadow", Integer.class)); + put(BORDER_START, new TraitInfo("border-start", BorderProps.class)); + put(BORDER_END, new TraitInfo("border-end", BorderProps.class)); + put(BORDER_BEFORE, new TraitInfo("border-before", BorderProps.class)); + put(BORDER_AFTER, new TraitInfo("border-after", BorderProps.class)); + put(PADDING_START, new TraitInfo("padding-start", Integer.class)); + put(PADDING_END, new TraitInfo("padding-end", Integer.class)); + put(PADDING_BEFORE, new TraitInfo("padding-before", Integer.class)); + put(PADDING_AFTER, new TraitInfo("padding-after", Integer.class)); + put(SPACE_START, new TraitInfo("space-start", Integer.class)); + put(SPACE_END, new TraitInfo("space-end", Integer.class)); + //put(BREAK_BEFORE, new TraitInfo("break-before", Integer.class)); + //put(BREAK_AFTER, new TraitInfo("break-after", Integer.class)); + put(START_INDENT, new TraitInfo("start-indent", Integer.class)); + put(END_INDENT, new TraitInfo("end-indent", Integer.class)); + put(SPACE_BEFORE, new TraitInfo("space-before", Integer.class)); + put(SPACE_AFTER, new TraitInfo("space-after", Integer.class)); + put(IS_REFERENCE_AREA, new TraitInfo("is-reference-area", Boolean.class)); + put(IS_VIEWPORT_AREA, new TraitInfo("is-viewport-area", Boolean.class)); } @@ -296,7 +225,7 @@ public final class Trait implements Serializable { * @return the trait name */ public static String getTraitName(Object traitCode) { - return TRAIT_INFO[((Integer)traitCode).intValue()].getName(); + return TRAIT_INFO[(Integer)traitCode].getName(); } /** @@ -306,7 +235,7 @@ public final class Trait implements Serializable { * @return the class type for the trait */ public static Class getTraitClass(Object traitCode) { - return TRAIT_INFO[((Integer)traitCode).intValue()].getClazz(); + return TRAIT_INFO[(Integer)traitCode].getClazz(); } /** @@ -482,7 +411,7 @@ public final class Trait implements Serializable { if (v.startsWith("dest=")) { dest = v.substring(5); } else if (v.startsWith("newWindow=")) { - newWindow = Boolean.valueOf(v.substring(10)).booleanValue(); + newWindow = Boolean.valueOf(v.substring(10)); } else { throw new IllegalArgumentException( "Malformed trait value for Trait.ExternalLink: " + traitValue); -- 2.39.5