[Patch][gui] Improving usage of java.lang.Boolean
Michael Koch
konqueror@gmx.de
Mon Oct 25 10:39:00 GMT 2004
Hi list,
I just commited the attached patch to improved some places where an
instance of java.lang.Boolean is needed. It better to use
Boolean.valueOf() instead of creating a new instance each time.
Michael
2004-10-25 Michael Koch <konqueror@gmx.de>
* java/awt/font/TextAttribute.java,
javax/swing/JComponent.java,
javax/swing/JInternalFrame.java,
javax/swing/table/TableColumn.java,
javax/swing/text/StyleConstants.java:
Replaced "new Boolean(boolean)" with "Boolean.valueOf(boolean)".
-------------- next part --------------
Index: java/awt/font/TextAttribute.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/font/TextAttribute.java,v
retrieving revision 1.2
diff -u -r1.2 TextAttribute.java
--- java/awt/font/TextAttribute.java 31 Mar 2003 09:55:09 -0000 1.2
+++ java/awt/font/TextAttribute.java 25 Oct 2004 10:33:54 -0000
@@ -70,19 +70,19 @@
public static final Float POSTURE_REGULAR = new Float (0.0);
public static final TextAttribute RUN_DIRECTION =
new TextAttribute ("RUN_DIRECTION");
- public static final Boolean RUN_DIRECTION_LTR = new Boolean (true);
- public static final Boolean RUN_DIRECTION_RTL = new Boolean (false);
+ public static final Boolean RUN_DIRECTION_LTR = Boolean.valueOf(true);
+ public static final Boolean RUN_DIRECTION_RTL = Boolean.valueOf(false);
public static final TextAttribute SIZE = new TextAttribute ("SIZE");
public static final TextAttribute STRIKETHROUGH =
new TextAttribute ("STRIKETHROUGH");
- public static final Boolean STRIKETHROUGH_ON = new Boolean (true);
+ public static final Boolean STRIKETHROUGH_ON = Boolean.valueOf(true);
public static final TextAttribute SUPERSCRIPT =
new TextAttribute ("SUPERSCRIPT");
public static final Integer SUPERSCRIPT_SUB = new Integer (-1);
public static final Integer SUPERSCRIPT_SUPER = new Integer (1);
public static final TextAttribute SWAP_COLORS =
new TextAttribute ("SWAP_COLORS");
- public static final Boolean SWAP_COLORS_ON = new Boolean (true);
+ public static final Boolean SWAP_COLORS_ON = Boolean.valueOf(true);
public static final TextAttribute TRANSFORM = new TextAttribute ("TRANSFORM");
public static final TextAttribute UNDERLINE = new TextAttribute ("UNDERLINE");
public static final Integer UNDERLINE_LOW_DASHED = new Integer (0);
Index: javax/swing/JComponent.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/JComponent.java,v
retrieving revision 1.7.2.22
diff -u -r1.7.2.22 JComponent.java
--- javax/swing/JComponent.java 22 Oct 2004 12:41:11 -0000 1.7.2.22
+++ javax/swing/JComponent.java 25 Oct 2004 10:33:54 -0000
@@ -615,8 +615,8 @@
boolean newValue)
{
if (changeSupport != null)
- changeSupport.firePropertyChange(propertyName, new Boolean(oldValue),
- new Boolean(newValue));
+ changeSupport.firePropertyChange(propertyName, Boolean.valueOf(oldValue),
+ Boolean.valueOf(newValue));
}
/**
Index: javax/swing/JInternalFrame.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/JInternalFrame.java,v
retrieving revision 1.2.18.5
diff -u -r1.2.18.5 JInternalFrame.java
--- javax/swing/JInternalFrame.java 22 Oct 2004 12:41:12 -0000 1.2.18.5
+++ javax/swing/JInternalFrame.java 25 Oct 2004 10:33:55 -0000
@@ -1706,6 +1706,6 @@
boolean newValue)
throws PropertyVetoException
{
- super.fireVetoableChange(name, new Boolean(oldValue), new Boolean(newValue));
+ super.fireVetoableChange(name, Boolean.valueOf(oldValue), Boolean.valueOf(newValue));
}
-} // class JInternalFrame
+}
Index: javax/swing/table/TableColumn.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/table/TableColumn.java,v
retrieving revision 1.3.18.6
diff -u -r1.3.18.6 TableColumn.java
--- javax/swing/table/TableColumn.java 22 Oct 2004 18:12:56 -0000 1.3.18.6
+++ javax/swing/table/TableColumn.java 25 Oct 2004 10:33:55 -0000
@@ -219,7 +219,8 @@
private void firePropertyChange(String property, boolean oldValue,
boolean newValue)
{
- firePropertyChange(property, new Boolean(oldValue), new Boolean(newValue));
+ firePropertyChange(property, Boolean.valueOf(oldValue),
+ Boolean.valueOf(newValue));
}
/**
Index: javax/swing/text/StyleConstants.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/javax/swing/text/StyleConstants.java,v
retrieving revision 1.1.2.3
diff -u -r1.1.2.3 StyleConstants.java
--- javax/swing/text/StyleConstants.java 22 Oct 2004 17:43:55 -0000 1.1.2.3
+++ javax/swing/text/StyleConstants.java 25 Oct 2004 10:33:55 -0000
@@ -279,7 +279,7 @@
public static void setBold(MutableAttributeSet a, boolean b)
{
- a.addAttribute(Bold, new Boolean(b));
+ a.addAttribute(Bold, Boolean.valueOf(b));
}
public static void setComponent(MutableAttributeSet a, Component c)
@@ -314,7 +314,7 @@
public static void setItalic(MutableAttributeSet a, boolean b)
{
- a.addAttribute(Italic, new Boolean(b));
+ a.addAttribute(Italic, Boolean.valueOf(b));
}
public static void setLeftIndent(MutableAttributeSet a, float i)
@@ -344,17 +344,17 @@
public static void setStrikeThrough(MutableAttributeSet a, boolean b)
{
- a.addAttribute(StrikeThrough, new Boolean(b));
+ a.addAttribute(StrikeThrough, Boolean.valueOf(b));
}
public static void setSubscript(MutableAttributeSet a, boolean b)
{
- a.addAttribute(Subscript, new Boolean(b));
+ a.addAttribute(Subscript, Boolean.valueOf(b));
}
public static void setSuperscript(MutableAttributeSet a, boolean b)
{
- a.addAttribute(Superscript, new Boolean(b));
+ a.addAttribute(Superscript, Boolean.valueOf(b));
}
public static void setTabSet(MutableAttributeSet a, javax.swing.text.TabSet tabs)
@@ -364,7 +364,7 @@
public static void setUnderline(MutableAttributeSet a, boolean b)
{
- a.addAttribute(Underline, new Boolean(b));
+ a.addAttribute(Underline, Boolean.valueOf(b));
}
// The remainder are so-called "typesafe enumerations" which
More information about the Java-patches
mailing list