jgoodies-common-1.4.0/0000755000175000017500000000000012052274630013352 5ustar tonytonyjgoodies-common-1.4.0/overview.html0000644000175000017500000000376011743062322016113 0ustar tonytony This document describes the API of the JGoodies Common, a library that provides convenience code for other JGoodies libraries and applications. It requires Java 6 or later. jgoodies-common-1.4.0/LICENSE.txt0000644000175000017500000000323412003474132015172 0ustar tonytony The BSD License for the JGoodies Common ======================================= Copyright (c) 2009-2012 JGoodies Karsten Lentzsch. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: o Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. o Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. o Neither the name of JGoodies Karsten Lentzsch nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. jgoodies-common-1.4.0/README.html0000644000175000017500000000712612003474132015176 0ustar tonytony JGoodies Common :: README
:: JGOODIES :: Common

:: Readme :: Common 1.4.0 ::

The JGoodies Common library provides convenience code for other JGoodies libraries and applications. It requires Java 6 or later. Library versions for older Java versions are available in the JGoodies Archive.

Acknowledgements

The Common project has been financed by customers of the JGoodies Swing Suite. It is only with their money that I can provide, maintain, and improve this library at no charge.

You can Help

If you save time and money using this library, please help me finance my Java desktop activities by licensing the commercial JGoodies Swing Suite.
(c) 2012 JGoodies
 
jgoodies-common-1.4.0/META-INF/0000755000175000017500000000000012003474132014505 5ustar tonytonyjgoodies-common-1.4.0/META-INF/MANIFEST.MF0000644000175000017500000000014712003474130016137 0ustar tonytonyManifest-Version: 1.0 Ant-Version: Apache Ant 1.8.2 Created-By: 1.7.0_05-b05 (Oracle Corporation) jgoodies-common-1.4.0/RELEASE-NOTES.txt0000644000175000017500000000513512003474132016060 0ustar tonytony JGoodies Common Release Notes CHANGES in 1.4.0 ------------------------------------------------------------- o Replaced AbstractBean by Bean. The old class AbstractBean is still available, but will be removed from a future version. o Introduced the StringLocalizer interface. o Added the ActionProvider interface (in JSDL Common before). o Added SystemUtils.IS_OS_WINDOWS_7 and IS_OS_WINDOWS_8; CHANGES in 1.3.1 ------------------------------------------------------------- This version is backwards compatible with the 1.3.0 release. o The javadocs, main and test sources are delivered as JARs. CHANGES in 1.3.0 ------------------------------------------------------------- o Requires Java 6. o Removed SystemUtils#IS_JAVA_5 o Removed SystemUtils#IS_JAVA_6_OR_LATER o Added null checks for the delegate format in AbstractWrappedDateFormat, EmptyDateFormat, EmptyFormat, and EmptyNumberFormat. o Added Strings#isTrimmed. o Removed code that is obsolete in Java 6. CHANGES in 1.2.1 ------------------------------------------------------------- o Fixed a bug in ArrayListModel and LinkedListModel with missing ListDataEvents in #removeAll and #retainAll. The old code depends on a specific implementation of #removeAll and #retainAll that may vary with the platform. CHANGES in 1.2 --------------------------------------------------------------- o Fixed missing contents change in LinkedListModel's list iterator. o Removed SystemUtils#IS_JAVA_1_4 o Removed SystemUtils#IS_JAVA_5_OR_LATER o Added SystemUtils#HAS_MODERN_RASTERIZER o Added SystemUtils#IS_LAF_WINDOWS_XP_ENABLED o Added SystemUtils#IS_LOW_RESOLUTION CHANGES in 1.1.1 ------------------------------------------------------------- o Added Objects#deepCopy(Object). o Source code improvements. CHANGES in 1.1 --------------------------------------------------------------- o Added interfaces ObservableBean and ObservableBean2. o Removed generics from EmptyFormat. CHANGES in 1.0.1 o Empty*Format#format returns the 'toAppendTo' parameter for the empty value instead of a new StringBuffer. CHANGES in 1.0 o Added Format wrappers: - AbstractWrappedDateFormat - EmptyDateFormat - EmptyNumberFormat - EmptyFormat o Added tests for the empty formats. o Added Preconditions#checkNotNull(String, String, Object...). jgoodies-common-1.4.0/docs/0000755000175000017500000000000012003474132014275 5ustar tonytonyjgoodies-common-1.4.0/docs/style.css0000644000175000017500000000154312003474132016152 0ustar tonytonybody, p, td, li, h1, h2, h3 { font-family: Verdana, Arial, Helvetica, Geneva, sans-serif; } body, p, td, li, h2, h3 { font-size: 12px; } h1, h2, h3 { font-weight: bold; color:#323777; margin-bottom: 11px; } h1 { font-size:14px; } h2, h3 { margin-top: 17px; } .header { font-weight: bold; color:#323777; margin-bottom: 11px; } p { margin-top: 14px; } a { text-decoration: none; color:#323788; } a:hover { text-decoration: underline; } a.nav { text-decoration: none; color:#000000; } a.nav:hover { text-decoration: underline; } pre { font-family:Courier New, Courier, monospace; font-size:12px; } ul { list-style-type: square; margin-top: 2px; } td.header { color: #FFFFFF; background-color:#323777; } td.cell { background-color:#FFFFFF; }jgoodies-common-1.4.0/docs/images/0000755000175000017500000000000012003474132015542 5ustar tonytonyjgoodies-common-1.4.0/docs/images/banner.gif0000644000175000017500000000751712003474132017510 0ustar tonytonyGIF89a.jiiQQQrrrutt:::FFFDDDnnn]\\000{zzfffbaaVVV}||ZYYpppwvvJJJ$$$<<ӨGw6SyY2֮d 8Ng[AN=iسg;ѬBǔ Q }ύ%܀#s8xVhvD ֠a!r!y6CkXcA ggYh:ces=[eE@&I{40$Vi59`ed1fbxyע Fhhv~·kG䡡\uON 7|8A饘fzç*ꧤj*M꩝R%AIe(4@J Ax%v8#k"&kN!)0M"'hAIg,]4ĺ  40; p.av o.' F4p_`t &Ԁ'h h!E1 ?[Yf6|f:oe` @:n%{=4X=jr1Cc0,EpGRr R E̐pÍo+]̀` 0ZX$Ngp`* FAPQKGpAvzMĎ먮ZV*1+IKOIO%h `Q(Z`۷ 7H`1 B/_a?3d`@JBB O*$`]@պzy_r B(4ץ fx8|^& hNCPЄ`rO@B&` [p :DŽ.`_"0ьaΨE/13pF&({ ܃x@yFR v [Ѐ0<@J- @(2+HbXº0W*m5GlFJ`.{w$p M<^ vm[Z$ xrH2YL*΀ o,3P*t ,P} u ,lwvABp7:4{g͹܏CzA7q8R W2v/K {[m"ȱ欭&ɫJDSs~#@k2a~%Zti$q OO.$G4̠|\M% 0l! 6=Y!Ӵ x3{ gLm; f4vΈ֕3b[A%8?p/$Su@Ġ|f4~Qw֏8o.2X5 @NA LTM@62 g2~_\yN})5r׳|Ly5uᅹ<)3t(0 @C'0LM07~7VInc8t@===_=67`>7g}9V?mso@BFGX"URuTcEP)] v.3 np 8tX@>/n@>Z0w@>K㳂883`chBCOqW<4aAG'uR. `-tBpp2hbp0  2QeS6 00lP{EVH؉]2npJ 8/s2V``! +ݑug'@,@.?)< dXd8E hM6G$JhI$$.SqUoCDA<40'`,S)s0I@;<@s; ِ<sА B,uu't1BIL`&'u`l@# kp'Y)A.PBKfCu+C?'T؂4(qWQ e0<ӕ^6;d)*r)2u}b#C1A$%`)"*);zz*1%D4aqQ-4a#$dvRu?s 4bBBC-n9C ,3&sOI>סO s9r"X߹mbCIs"1P#$99'Y#:Y:ўqQpY'9桒!-Bpؘ"b$Y>A$#gq:ϙCBz8$MB:<ڣCGa=zkF"r44RUQVzXY`QSJ]jX!krZše*)o|ڧT Vq规Z} w*kڨ: zک:Zz;jgoodies-common-1.4.0/docs/api/0000755000175000017500000000000012003474124015047 5ustar tonytonyjgoodies-common-1.4.0/docs/api/package-list0000644000175000017500000000024612003474124017340 0ustar tonytonycom.jgoodies.common.base com.jgoodies.common.bean com.jgoodies.common.collect com.jgoodies.common.format com.jgoodies.common.internal com.jgoodies.common.swing jgoodies-common-1.4.0/docs/api/resources/0000755000175000017500000000000012003474124017061 5ustar tonytonyjgoodies-common-1.4.0/docs/api/resources/inherit.gif0000644000175000017500000000007112003474124021210 0ustar tonytonyGIF89a, DrjԐ;߀Q@N;jgoodies-common-1.4.0/docs/api/allclasses-noframe.html0000644000175000017500000000640012003474124021510 0ustar tonytony All Classes (JGoodies Common 1.4 API) All Classes
AbstractBean
AbstractWrappedDateFormat
ArrayListModel
Bean
EmptyDateFormat
EmptyFormat
EmptyNumberFormat
IActionBean
IActionObject
LinkedListModel
Messages
MnemonicUtils
Objects
ObservableBean
ObservableBean2
ObservableList
Preconditions
RenderingUtils
StringLocalizer
Strings
SystemUtils
jgoodies-common-1.4.0/docs/api/index-all.html0000644000175000017500000023440312003474124017620 0ustar tonytony Index (JGoodies Common 1.4 API)
A B C D E F G H I J L M O P R S U

A

abbreviateCenter(String, int) - Static method in class com.jgoodies.common.base.Strings
Abbreviates the given string if it exceeds the given maximum length by replacing its center part with an ellipsis ('…').
AbstractBean - Class in com.jgoodies.common.bean
This is the deprecated abstract superclass for bean classes.
AbstractBean() - Constructor for class com.jgoodies.common.bean.AbstractBean
 
AbstractWrappedDateFormat - Class in com.jgoodies.common.format
Reduces the effort required to write custom DateFormat implementations that retain the ability to iterate through Dates with the arrow keys in formatted text fields (using an appropriate DateFormatter).
AbstractWrappedDateFormat(DateFormat) - Constructor for class com.jgoodies.common.format.AbstractWrappedDateFormat
Constructs an AbstractWrappedDateFormat that wraps the given mandatory format.
add(int, E) - Method in class com.jgoodies.common.collect.ArrayListModel
 
add(E) - Method in class com.jgoodies.common.collect.ArrayListModel
 
add(int, E) - Method in class com.jgoodies.common.collect.LinkedListModel
 
add(E) - Method in class com.jgoodies.common.collect.LinkedListModel
 
addAll(int, Collection<? extends E>) - Method in class com.jgoodies.common.collect.ArrayListModel
 
addAll(Collection<? extends E>) - Method in class com.jgoodies.common.collect.ArrayListModel
 
addAll(int, Collection<? extends E>) - Method in class com.jgoodies.common.collect.LinkedListModel
 
addFirst(E) - Method in class com.jgoodies.common.collect.LinkedListModel
 
addLast(E) - Method in class com.jgoodies.common.collect.LinkedListModel
 
addListDataListener(ListDataListener) - Method in class com.jgoodies.common.collect.ArrayListModel
 
addListDataListener(ListDataListener) - Method in class com.jgoodies.common.collect.LinkedListModel
 
addPropertyChangeListener(PropertyChangeListener) - Method in class com.jgoodies.common.bean.Bean
Adds a PropertyChangeListener to the listener list.
addPropertyChangeListener(String, PropertyChangeListener) - Method in class com.jgoodies.common.bean.Bean
Adds a PropertyChangeListener to the listener list for a specific property.
addPropertyChangeListener(PropertyChangeListener) - Method in interface com.jgoodies.common.bean.ObservableBean
Adds the given PropertyChangeListener to the listener list.
addPropertyChangeListener(String, PropertyChangeListener) - Method in interface com.jgoodies.common.bean.ObservableBean2
Adds a PropertyChangeListener to the listener list for a specific property.
addVetoableChangeListener(VetoableChangeListener) - Method in class com.jgoodies.common.bean.Bean
Adds a VetoableChangeListener to the listener list.
addVetoableChangeListener(String, VetoableChangeListener) - Method in class com.jgoodies.common.bean.Bean
Adds a VetoableChangeListener to the listener list for a specific property.
ArrayListModel<E> - Class in com.jgoodies.common.collect
Adds ListModel capabilities to its superclass.
ArrayListModel() - Constructor for class com.jgoodies.common.collect.ArrayListModel
Constructs an empty list with an initial capacity of ten.
ArrayListModel(int) - Constructor for class com.jgoodies.common.collect.ArrayListModel
Constructs an empty list with the specified initial capacity.
ArrayListModel(Collection<? extends E>) - Constructor for class com.jgoodies.common.collect.ArrayListModel
Constructs a list containing the elements of the specified collection, in the order they are returned by the collection's iterator.

B

Bean - Class in com.jgoodies.common.bean
An abstract superclass that minimizes the effort required to provide change support for bound and constrained Bean properties.
Bean() - Constructor for class com.jgoodies.common.bean.Bean
 

C

changeSupport - Variable in class com.jgoodies.common.bean.Bean
If anyPropertyChangeListeners have been registered, the changeSupport field describes them.
checkArgument(boolean, String) - Static method in class com.jgoodies.common.base.Preconditions
Checks the truth of the given expression and throws a customized IllegalArgumentException if it is false.
checkArgument(boolean, String, Object...) - Static method in class com.jgoodies.common.base.Preconditions
Checks the truth of the given expression and throws a customized IllegalArgumentException if it is false.
checkNotBlank(String, String) - Static method in class com.jgoodies.common.base.Preconditions
Checks that the given string is not blank and throws a customized NullPointerException if it is null, and a customized IllegalArgumentException if it is empty or whitespace.
checkNotBlank(String, String, Object...) - Static method in class com.jgoodies.common.base.Preconditions
Checks that the given string is not blank and throws a customized NullPointerException if it is null, and a customized IllegalArgumentException if it is empty or whitespace.
checkNotNull(T, String) - Static method in class com.jgoodies.common.base.Preconditions
Checks that the given object reference is not null and throws a customized NullPointerException if it is.
checkNotNull(T, String, Object...) - Static method in class com.jgoodies.common.base.Preconditions
Checks that the given object reference is not null and throws a customized NullPointerException if it is.
checkState(boolean, String) - Static method in class com.jgoodies.common.base.Preconditions
Checks the truth of the given expression and throws a customized IllegalStateException if it is false.
checkState(boolean, String, Object...) - Static method in class com.jgoodies.common.base.Preconditions
Checks the truth of the given expression and throws a customized IllegalStateException if it is false.
clear() - Method in class com.jgoodies.common.collect.ArrayListModel
 
clear() - Method in class com.jgoodies.common.collect.LinkedListModel
 
com.jgoodies.common.base - package com.jgoodies.common.base
Consists of frequently used utility classes for general Java code
com.jgoodies.common.bean - package com.jgoodies.common.bean
Consists of classes for working with Java Beans
com.jgoodies.common.collect - package com.jgoodies.common.collect
Consists of classes that add ListModel features to List implementations
com.jgoodies.common.format - package com.jgoodies.common.format
Consists of Format implementations and wrappers
com.jgoodies.common.internal - package com.jgoodies.common.internal
Consists of internal classes that are not part of the public API.
com.jgoodies.common.swing - package com.jgoodies.common.swing
Consists of Swing related classes
configure(AbstractButton, String) - Static method in class com.jgoodies.common.swing.MnemonicUtils
Configures the text, mnemonic and mnemonic index for target using the given text that can be marked with the mnemonic marker '&'.
configure(Action, String) - Static method in class com.jgoodies.common.swing.MnemonicUtils
Configures the text, mnemonic and mnemonic index for target using the given text that can be marked with the mnemonic marker '&'.
configure(JLabel, String) - Static method in class com.jgoodies.common.swing.MnemonicUtils
Configures the text, mnemonic and mnemonic index for target using the given text that can be marked with the mnemonic marker '&'.
createPropertyChangeSupport(Object) - Method in class com.jgoodies.common.bean.Bean
Creates and returns a PropertyChangeSupport for the given bean.

D

deepCopy(T) - Static method in class com.jgoodies.common.base.Objects
Provides a means to copy objects that do not implement Cloneable.
delegate - Variable in class com.jgoodies.common.format.AbstractWrappedDateFormat
Refers to the wrapped Format that is used to forward #format and #parseObject.
drawString(JComponent, Graphics, String, int, int) - Static method in class com.jgoodies.common.internal.RenderingUtils
Draws the string at the specified location underlining the specified character.
drawStringUnderlineCharAt(JComponent, Graphics, String, int, int, int) - Static method in class com.jgoodies.common.internal.RenderingUtils
Draws the string at the specified location underlining the specified character.

E

EmptyDateFormat - Class in com.jgoodies.common.format
Wraps a given DateFormat and adds behavior to convert to/from the empty string.
EmptyDateFormat(DateFormat) - Constructor for class com.jgoodies.common.format.EmptyDateFormat
Constructs an EmptyFormat that wraps the given mandatory format to convert null to the empty string and vice versa.
EmptyDateFormat(DateFormat, Date) - Constructor for class com.jgoodies.common.format.EmptyDateFormat
Constructs an EmptyFormat that wraps the given mandatory format to convert the given emptyValue to the empty string and vice versa.
EmptyFormat - Class in com.jgoodies.common.format
Wraps a given Format and adds behavior to convert to/from the empty string.
EmptyFormat(Format) - Constructor for class com.jgoodies.common.format.EmptyFormat
Constructs an EmptyFormat that wraps the given mandatory format to convert null to the empty string and vice versa.
EmptyFormat(Format, Object) - Constructor for class com.jgoodies.common.format.EmptyFormat
Constructs an EmptyFormat that wraps the given mandatory format to convert the given emptyValue to the empty string and vice versa.
EmptyNumberFormat - Class in com.jgoodies.common.format
Wraps a given NumberFormat and adds behavior to convert to/from the empty string.
EmptyNumberFormat(NumberFormat) - Constructor for class com.jgoodies.common.format.EmptyNumberFormat
Constructs an EmptyNumberFormat that wraps the given mandatory format to convert null to the empty string and vice versa.
EmptyNumberFormat(NumberFormat, int) - Constructor for class com.jgoodies.common.format.EmptyNumberFormat
Constructs an EmptyNumberFormat that wraps the given mandatory format to convert the given emptyValue to the empty string and vice versa.
EmptyNumberFormat(NumberFormat, Number) - Constructor for class com.jgoodies.common.format.EmptyNumberFormat
Constructs an EmptyNumberFormat that wraps the given mandatory format to convert the given emptyValue to the empty string and vice versa.
equals(Object, Object) - Static method in class com.jgoodies.common.base.Objects
Checks and answers if the two objects are both null or equal.

F

fireContentsChanged(int) - Method in class com.jgoodies.common.collect.ArrayListModel
Notifies all registered ListDataListeners that the element at the specified index has changed.
fireContentsChanged(int) - Method in class com.jgoodies.common.collect.LinkedListModel
Notifies all registered ListDataListeners that the element at the specified index has changed.
fireIndexedPropertyChange(String, int, Object, Object) - Method in class com.jgoodies.common.bean.Bean
Report a bound indexed property update to any registered listeners.
fireIndexedPropertyChange(String, int, int, int) - Method in class com.jgoodies.common.bean.Bean
Report an int bound indexed property update to any registered listeners.
fireIndexedPropertyChange(String, int, boolean, boolean) - Method in class com.jgoodies.common.bean.Bean
Report a boolean bound indexed property update to any registered listeners.
fireMultiplePropertiesChanged() - Method in class com.jgoodies.common.bean.Bean
Indicates that an arbitrary set of bound properties have changed.
firePropertyChange(PropertyChangeEvent) - Method in class com.jgoodies.common.bean.Bean
General support for reporting bound property changes.
firePropertyChange(String, Object, Object) - Method in class com.jgoodies.common.bean.Bean
Support for reporting bound property changes for Object properties.
firePropertyChange(String, boolean, boolean) - Method in class com.jgoodies.common.bean.Bean
Support for reporting bound property changes for boolean properties.
firePropertyChange(String, double, double) - Method in class com.jgoodies.common.bean.Bean
Support for reporting bound property changes for integer properties.
firePropertyChange(String, float, float) - Method in class com.jgoodies.common.bean.Bean
Support for reporting bound property changes for integer properties.
firePropertyChange(String, int, int) - Method in class com.jgoodies.common.bean.Bean
Support for reporting bound property changes for integer properties.
firePropertyChange(String, long, long) - Method in class com.jgoodies.common.bean.Bean
Support for reporting bound property changes for integer properties.
fireVetoableChange(PropertyChangeEvent) - Method in class com.jgoodies.common.bean.Bean
General support for reporting constrained property changes.
fireVetoableChange(String, Object, Object) - Method in class com.jgoodies.common.bean.Bean
Support for reporting changes for constrained Object properties.
fireVetoableChange(String, boolean, boolean) - Method in class com.jgoodies.common.bean.Bean
Support for reporting changes for constrained boolean properties.
fireVetoableChange(String, double, double) - Method in class com.jgoodies.common.bean.Bean
Support for reporting changes for constrained integer properties.
fireVetoableChange(String, int, int) - Method in class com.jgoodies.common.bean.Bean
Support for reporting changes for constrained integer properties.
fireVetoableChange(String, float, float) - Method in class com.jgoodies.common.bean.Bean
Support for reporting changes for constrained integer properties.
fireVetoableChange(String, long, long) - Method in class com.jgoodies.common.bean.Bean
Support for reporting changes for constrained integer properties.
format(Date, StringBuffer, FieldPosition) - Method in class com.jgoodies.common.format.AbstractWrappedDateFormat
 
format(Date, StringBuffer, FieldPosition) - Method in class com.jgoodies.common.format.EmptyDateFormat
 
format(Object, StringBuffer, FieldPosition) - Method in class com.jgoodies.common.format.EmptyFormat
If obj is equal to the emptyValue, toAppendTo is returned.
format(Object, StringBuffer, FieldPosition) - Method in class com.jgoodies.common.format.EmptyNumberFormat
If obj is equal to the emptyValue, toAppendTo is returned.
format(double, StringBuffer, FieldPosition) - Method in class com.jgoodies.common.format.EmptyNumberFormat
 
format(long, StringBuffer, FieldPosition) - Method in class com.jgoodies.common.format.EmptyNumberFormat
 
formatToCharacterIterator(Object) - Method in class com.jgoodies.common.format.AbstractWrappedDateFormat
 
formatToCharacterIterator(Object) - Method in class com.jgoodies.common.format.EmptyFormat
 

G

getAction(String) - Method in interface com.jgoodies.common.internal.IActionObject
Looks up and returns an Action for the given action name.
getCalendar() - Method in class com.jgoodies.common.format.AbstractWrappedDateFormat
 
getElementAt(int) - Method in class com.jgoodies.common.collect.ArrayListModel
 
getElementAt(int) - Method in class com.jgoodies.common.collect.LinkedListModel
 
getFontMetrics(JComponent, Graphics) - Static method in class com.jgoodies.common.internal.RenderingUtils
Returns the FontMetrics for the current Font of the passed in Graphics.
getListDataListeners() - Method in class com.jgoodies.common.collect.ArrayListModel
Returns an array of all the list data listeners registered on this ArrayListModel.
getListDataListeners() - Method in class com.jgoodies.common.collect.LinkedListModel
Returns an array of all the list data listeners registered on this LinkedListModel.
getNumberFormat() - Method in class com.jgoodies.common.format.AbstractWrappedDateFormat
 
getPropertyChangeListeners() - Method in class com.jgoodies.common.bean.Bean
Returns an array of all the property change listeners registered on this component.
getPropertyChangeListeners(String) - Method in class com.jgoodies.common.bean.Bean
Returns an array of all the listeners which have been associated with the named property.
getPropertyChangeListeners() - Method in interface com.jgoodies.common.bean.ObservableBean2
Returns an array of all the property change listeners registered on this component.
getPropertyChangeListeners(String) - Method in interface com.jgoodies.common.bean.ObservableBean2
Returns an array of all the listeners which have been associated with the named property.
getSize() - Method in class com.jgoodies.common.collect.ArrayListModel
 
getSize() - Method in class com.jgoodies.common.collect.LinkedListModel
 
getString(String) - Method in interface com.jgoodies.common.internal.StringLocalizer
Returns a localized String for the given key.
getSystemProperty(String) - Static method in class com.jgoodies.common.base.SystemUtils
Tries to look up the System property for the given key.
getTimeZone() - Method in class com.jgoodies.common.format.AbstractWrappedDateFormat
 
getVetoableChangeListeners() - Method in class com.jgoodies.common.bean.Bean
Returns an array of all the property change listeners registered on this component.
getVetoableChangeListeners(String) - Method in class com.jgoodies.common.bean.Bean
Returns an array of all the listeners which have been associated with the named property.

H

HAS_MODERN_RASTERIZER - Static variable in class com.jgoodies.common.base.SystemUtils
True since Java 6 update 10.

I

IActionBean - Interface in com.jgoodies.common.internal
Describes beans that can look up an Action for a given Action name.
IActionObject - Interface in com.jgoodies.common.internal
Describes an object that can look up an Action for a given Action name.
IS_JAVA_6 - Static variable in class com.jgoodies.common.base.SystemUtils
True if this is Java 6.
IS_JAVA_7 - Static variable in class com.jgoodies.common.base.SystemUtils
True if this is Java 7.
IS_JAVA_7_OR_LATER - Static variable in class com.jgoodies.common.base.SystemUtils
True if this is Java 7.x or later.
IS_LAF_WINDOWS_XP_ENABLED - Static variable in class com.jgoodies.common.base.SystemUtils
True if the Windows XP Look&Feel is enabled.
IS_LOW_RESOLUTION - Static variable in class com.jgoodies.common.base.SystemUtils
Is true if this environment's default toolkit reports a screen resolution below 120 dpi.
IS_OS_LINUX - Static variable in class com.jgoodies.common.base.SystemUtils
Is true if this is Linux.
IS_OS_MAC - Static variable in class com.jgoodies.common.base.SystemUtils
True if this is the Mac OS.
IS_OS_SOLARIS - Static variable in class com.jgoodies.common.base.SystemUtils
True if this is Solaris.
IS_OS_WINDOWS - Static variable in class com.jgoodies.common.base.SystemUtils
True if this is Windows.
IS_OS_WINDOWS_2000 - Static variable in class com.jgoodies.common.base.SystemUtils
True if this is Windows 2000.
IS_OS_WINDOWS_6_OR_LATER - Static variable in class com.jgoodies.common.base.SystemUtils
True if this is Windows Vista/Server 2008/7/2008 R2.
IS_OS_WINDOWS_7 - Static variable in class com.jgoodies.common.base.SystemUtils
True if this is Windows 7.
IS_OS_WINDOWS_8 - Static variable in class com.jgoodies.common.base.SystemUtils
True if this is Windows 8.
IS_OS_WINDOWS_98 - Static variable in class com.jgoodies.common.base.SystemUtils
True if this is Windows 98.
IS_OS_WINDOWS_ME - Static variable in class com.jgoodies.common.base.SystemUtils
True if this is Windows ME.
IS_OS_WINDOWS_VISTA - Static variable in class com.jgoodies.common.base.SystemUtils
True if this is Windows Vista or Server 2008.
IS_OS_WINDOWS_XP - Static variable in class com.jgoodies.common.base.SystemUtils
True if this is Windows XP.
isBlank(String) - Static method in class com.jgoodies.common.base.Strings
Checks if the given string is whitespace, empty ("") or null.
isEmpty(String) - Static method in class com.jgoodies.common.base.Strings
Checks if the given string is empty ("") or null.
isLenient() - Method in class com.jgoodies.common.format.AbstractWrappedDateFormat
 
isNotBlank(String) - Static method in class com.jgoodies.common.base.Strings
Checks if the given string is not empty (""), not null and not whitespace only.
isNotEmpty(String) - Static method in class com.jgoodies.common.base.Strings
Checks if the given string is not empty ("") and not null.
isTrimmed(String) - Static method in class com.jgoodies.common.base.Strings
Checks if the given string is null, empty (""), or the first and last characters are not whitespace.

J

JAVA_VERSION - Static variable in class com.jgoodies.common.base.SystemUtils
The os.name System Property.

L

LinkedListModel<E> - Class in com.jgoodies.common.collect
Adds ListModel capabilities to its superclass.
LinkedListModel() - Constructor for class com.jgoodies.common.collect.LinkedListModel
Constructs an empty LinkedListModel.
LinkedListModel(Collection<? extends E>) - Constructor for class com.jgoodies.common.collect.LinkedListModel
Constructs a LinkedListModel containing the elements of the specified collection, in the order they are returned by the collection's iterator.
listIterator(int) - Method in class com.jgoodies.common.collect.LinkedListModel
 

M

Messages - Class in com.jgoodies.common.internal
Provides standardized messages for use with the Preconditions class and in exception messages.
MnemonicUtils - Class in com.jgoodies.common.swing
Configures the text, mnemonic and mnemonic index in Actions, JLabels, and AbstractButtons.
MUST_BE_TRIMMED - Static variable in class com.jgoodies.common.internal.Messages
 
MUST_NOT_BE_BLANK - Static variable in class com.jgoodies.common.internal.Messages
 
MUST_NOT_BE_NULL - Static variable in class com.jgoodies.common.internal.Messages
 

O

Objects - Class in com.jgoodies.common.base
Provides static methods that operate on objects.
ObservableBean - Interface in com.jgoodies.common.bean
Describes objects that provide bound properties as specified in the Java Bean Specification.
ObservableBean2 - Interface in com.jgoodies.common.bean
In addition to its super interface ObservableBean, this interface describes the optional support for registering PropertyChangeListeners for an individual property name.
ObservableList<E> - Interface in com.jgoodies.common.collect
Combines the List and ListModel interfaces.
OS_NAME - Static variable in class com.jgoodies.common.base.SystemUtils
The os.name System Property.
OS_VERSION - Static variable in class com.jgoodies.common.base.SystemUtils
The os.version System Property.

P

parse(String, ParsePosition) - Method in class com.jgoodies.common.format.AbstractWrappedDateFormat
 
parse(String, ParsePosition) - Method in class com.jgoodies.common.format.EmptyDateFormat
 
parse(String) - Method in class com.jgoodies.common.format.EmptyNumberFormat
If source is empty or whitespace, the emptyValue is returned.
parse(String, ParsePosition) - Method in class com.jgoodies.common.format.EmptyNumberFormat
 
parseObject(String) - Method in class com.jgoodies.common.format.EmptyFormat
If source is empty or whitespace, the emptyValue is returned.
parseObject(String, ParsePosition) - Method in class com.jgoodies.common.format.EmptyFormat
 
parseObject(String) - Method in class com.jgoodies.common.format.EmptyNumberFormat
If source is empty or whitespace, the emptyValue is returned.
plainText(String) - Static method in class com.jgoodies.common.swing.MnemonicUtils
Returns the plain text for the given marked text by removing the mnemonic marker and marker quotes - if any.
Preconditions - Class in com.jgoodies.common.base
Reduces the code necessary to check preconditions on method state and parameters.

R

remove(int) - Method in class com.jgoodies.common.collect.ArrayListModel
 
remove(Object) - Method in class com.jgoodies.common.collect.ArrayListModel
 
remove(int) - Method in class com.jgoodies.common.collect.LinkedListModel
 
remove(Object) - Method in class com.jgoodies.common.collect.LinkedListModel
 
removeAll(Collection<?>) - Method in class com.jgoodies.common.collect.ArrayListModel
Removes from this collection all of its elements that are contained in the specified collection (optional operation).
removeAll(Collection<?>) - Method in class com.jgoodies.common.collect.LinkedListModel
Removes from this collection all of its elements that are contained in the specified collection (optional operation).
removeFirst() - Method in class com.jgoodies.common.collect.LinkedListModel
 
removeLast() - Method in class com.jgoodies.common.collect.LinkedListModel
 
removeListDataListener(ListDataListener) - Method in class com.jgoodies.common.collect.ArrayListModel
 
removeListDataListener(ListDataListener) - Method in class com.jgoodies.common.collect.LinkedListModel
 
removePropertyChangeListener(PropertyChangeListener) - Method in class com.jgoodies.common.bean.Bean
Removes a PropertyChangeListener from the listener list.
removePropertyChangeListener(String, PropertyChangeListener) - Method in class com.jgoodies.common.bean.Bean
Removes a PropertyChangeListener from the listener list for a specific property.
removePropertyChangeListener(PropertyChangeListener) - Method in interface com.jgoodies.common.bean.ObservableBean
Removes the given PropertyChangeListener from the listener list.
removePropertyChangeListener(String, PropertyChangeListener) - Method in interface com.jgoodies.common.bean.ObservableBean2
Removes a PropertyChangeListener from the listener list for a specific property.
removeRange(int, int) - Method in class com.jgoodies.common.collect.ArrayListModel
 
removeRange(int, int) - Method in class com.jgoodies.common.collect.LinkedListModel
 
removeVetoableChangeListener(VetoableChangeListener) - Method in class com.jgoodies.common.bean.Bean
Removes a VetoableChangeListener from the listener list.
removeVetoableChangeListener(String, VetoableChangeListener) - Method in class com.jgoodies.common.bean.Bean
Removes a VetoableChangeListener from the listener list for a specific property.
RenderingUtils - Class in com.jgoodies.common.internal
Provides convenience behavior for drawing strings, underline chars, and accessing font metrics.
retainAll(Collection<?>) - Method in class com.jgoodies.common.collect.ArrayListModel
Retains only the elements in this collection that are contained in the specified collection (optional operation).
retainAll(Collection<?>) - Method in class com.jgoodies.common.collect.LinkedListModel
Retains only the elements in this collection that are contained in the specified collection (optional operation).

S

set(int, E) - Method in class com.jgoodies.common.collect.ArrayListModel
 
set(int, E) - Method in class com.jgoodies.common.collect.LinkedListModel
 
setCalendar(Calendar) - Method in class com.jgoodies.common.format.AbstractWrappedDateFormat
 
setLenient(boolean) - Method in class com.jgoodies.common.format.AbstractWrappedDateFormat
 
setNumberFormat(NumberFormat) - Method in class com.jgoodies.common.format.AbstractWrappedDateFormat
 
setTimeZone(TimeZone) - Method in class com.jgoodies.common.format.AbstractWrappedDateFormat
 
startsWith(String, String) - Static method in class com.jgoodies.common.base.SystemUtils
 
startsWithIgnoreCase(String, String) - Static method in class com.jgoodies.common.base.Strings
Checks if str starts with the given prefix ignoring cases.
StringLocalizer - Interface in com.jgoodies.common.internal
Describes an object that can localize Strings accessible via a key.
Strings - Class in com.jgoodies.common.base
Provides frequently used static null-safe String testing methods .
Strings() - Constructor for class com.jgoodies.common.base.Strings
 
SystemUtils - Class in com.jgoodies.common.base
Provides convenience behavior to determine the operating system and Java version.
SystemUtils() - Constructor for class com.jgoodies.common.base.SystemUtils
 

U

USE_ELLIPSIS_NOT_THREE_DOTS - Static variable in class com.jgoodies.common.internal.Messages
 

A B C D E F G H I J L M O P R S U

Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/constant-values.html0000644000175000017500000002047012003474124021066 0ustar tonytony Constant Field Values (JGoodies Common 1.4 API)

Constant Field Values


Contents
com.jgoodies.*

com.jgoodies.common.internal.Messages
public static final String MUST_BE_TRIMMED "The %1$s must not contain leading or trailing whitespace."
public static final String MUST_NOT_BE_BLANK "The %1$s must not be null, empty, or whitespace."
public static final String MUST_NOT_BE_NULL "The %1$s must not be null."
public static final String USE_ELLIPSIS_NOT_THREE_DOTS "The @Action annotation text ends with three dots \'...\'; use the single ellipsis character \'\u2026\' (\\u2026) instead."



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/stylesheet.css0000644000175000017500000000261412003474124017755 0ustar tonytony/* Javadoc style sheet */ /* Define colors, fonts and other style attributes here to override the defaults */ /* Page background color */ body { background-color: #FFFFFF; color:#000000 } /* Headings */ h1 { font-size: 145% } /* Table colors */ .TableHeadingColor { background: #CCCCFF; color:#000000 } /* Dark mauve */ .TableSubHeadingColor { background: #EEEEFF; color:#000000 } /* Light mauve */ .TableRowColor { background: #FFFFFF; color:#000000 } /* White */ /* Font used in left-hand frame lists */ .FrameTitleFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif; color:#000000 } .FrameHeadingFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 } .FrameItemFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 } /* Navigation bar fonts and colors */ .NavBarCell1 { background-color:#EEEEFF; color:#000000} /* Light mauve */ .NavBarCell1Rev { background-color:#00008B; color:#FFFFFF} /* Dark Blue */ .NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;color:#000000;} .NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;color:#FFFFFF;} .NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} .NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} jgoodies-common-1.4.0/docs/api/allclasses-frame.html0000644000175000017500000000724412003474124021162 0ustar tonytony All Classes (JGoodies Common 1.4 API) All Classes
AbstractBean
AbstractWrappedDateFormat
ArrayListModel
Bean
EmptyDateFormat
EmptyFormat
EmptyNumberFormat
IActionBean
IActionObject
LinkedListModel
Messages
MnemonicUtils
Objects
ObservableBean
ObservableBean2
ObservableList
Preconditions
RenderingUtils
StringLocalizer
Strings
SystemUtils
jgoodies-common-1.4.0/docs/api/com/0000755000175000017500000000000012003474124015625 5ustar tonytonyjgoodies-common-1.4.0/docs/api/com/jgoodies/0000755000175000017500000000000012003474124017430 5ustar tonytonyjgoodies-common-1.4.0/docs/api/com/jgoodies/common/0000755000175000017500000000000012003474124020720 5ustar tonytonyjgoodies-common-1.4.0/docs/api/com/jgoodies/common/internal/0000755000175000017500000000000012003474124022534 5ustar tonytonyjgoodies-common-1.4.0/docs/api/com/jgoodies/common/internal/package-frame.html0000644000175000017500000000320012003474124026100 0ustar tonytony com.jgoodies.common.internal (JGoodies Common 1.4 API) com.jgoodies.common.internal
Interfaces 
IActionBean
IActionObject
StringLocalizer
Classes 
Messages
RenderingUtils
jgoodies-common-1.4.0/docs/api/com/jgoodies/common/internal/IActionObject.html0000644000175000017500000002370012003474124026101 0ustar tonytony IActionObject (JGoodies Common 1.4 API)

com.jgoodies.common.internal
Interface IActionObject

All Known Subinterfaces:
IActionBean

public interface IActionObject

Describes an object that can look up an Action for a given Action name.

Note: This class is not part of the public JGoodies Common API. It's intended for implementation purposes only. The class's API may change at any time.

Since:
1.4
Version:
$Revision: 1.1 $
Author:
Karsten Lentzsch

Method Summary
 Action getAction(String actionName)
          Looks up and returns an Action for the given action name.
 

Method Detail

getAction

Action getAction(String actionName)
Looks up and returns an Action for the given action name.

Parameters:
actionName - the string used to look up the Action
Returns:
the Action with the given action name - if any
Throws:
NullPointerException - if actionName is null


Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/internal/IActionBean.html0000644000175000017500000002545212003474124025546 0ustar tonytony IActionBean (JGoodies Common 1.4 API)

com.jgoodies.common.internal
Interface IActionBean

All Superinterfaces:
IActionObject, ObservableBean, ObservableBean2

public interface IActionBean
extends ObservableBean2, IActionObject

Describes beans that can look up an Action for a given Action name.

Note: This class is not part of the public JGoodies Common API. It's intended for implementation purposes only. The class's API may change at any time.

Since:
1.4
Version:
$Revision: 1.3 $
Author:
Karsten Lentzsch

Method Summary
 
Methods inherited from interface com.jgoodies.common.bean.ObservableBean2
addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener
 
Methods inherited from interface com.jgoodies.common.bean.ObservableBean
addPropertyChangeListener, removePropertyChangeListener
 
Methods inherited from interface com.jgoodies.common.internal.IActionObject
getAction
 



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/internal/Messages.html0000644000175000017500000003601712003474124025200 0ustar tonytony Messages (JGoodies Common 1.4 API)

com.jgoodies.common.internal
Class Messages

java.lang.Object
  extended by com.jgoodies.common.internal.Messages

public final class Messages
extends Object

Provides standardized messages for use with the Preconditions class and in exception messages. Note: This class is not part of the public JGoodies Common API. It's intended for implementation purposes only. The class's API may change at any time.

Since:
1.4
Version:
$Revision: 1.1 $
Author:
Karsten Lentzsch

Field Summary
static String MUST_BE_TRIMMED
           
static String MUST_NOT_BE_BLANK
           
static String MUST_NOT_BE_NULL
           
static String USE_ELLIPSIS_NOT_THREE_DOTS
           
 
Method Summary
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MUST_NOT_BE_NULL

public static final String MUST_NOT_BE_NULL
See Also:
Constant Field Values

MUST_NOT_BE_BLANK

public static final String MUST_NOT_BE_BLANK
See Also:
Constant Field Values

MUST_BE_TRIMMED

public static final String MUST_BE_TRIMMED
See Also:
Constant Field Values

USE_ELLIPSIS_NOT_THREE_DOTS

public static final String USE_ELLIPSIS_NOT_THREE_DOTS
See Also:
Constant Field Values


Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/internal/package-tree.html0000644000175000017500000002014512003474124025754 0ustar tonytony com.jgoodies.common.internal Class Hierarchy (JGoodies Common 1.4 API)

Hierarchy For Package com.jgoodies.common.internal

Package Hierarchies:
All Packages

Class Hierarchy

Interface Hierarchy



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/internal/package-use.html0000644000175000017500000001601212003474124025607 0ustar tonytony Uses of Package com.jgoodies.common.internal (JGoodies Common 1.4 API)

Uses of Package
com.jgoodies.common.internal

Packages that use com.jgoodies.common.internal
com.jgoodies.common.internal Consists of internal classes that are not part of the public API. 
 

Classes in com.jgoodies.common.internal used by com.jgoodies.common.internal
IActionObject
          Describes an object that can look up an Action for a given Action name.
 



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/internal/class-use/0000755000175000017500000000000012003474124024433 5ustar tonytonyjgoodies-common-1.4.0/docs/api/com/jgoodies/common/internal/class-use/IActionObject.html0000644000175000017500000002005012003474124027773 0ustar tonytony Uses of Interface com.jgoodies.common.internal.IActionObject (JGoodies Common 1.4 API)

Uses of Interface
com.jgoodies.common.internal.IActionObject

Packages that use IActionObject
com.jgoodies.common.internal Consists of internal classes that are not part of the public API. 
 

Uses of IActionObject in com.jgoodies.common.internal
 

Subinterfaces of IActionObject in com.jgoodies.common.internal
 interface IActionBean
          Describes beans that can look up an Action for a given Action name.
 



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/internal/class-use/IActionBean.html0000644000175000017500000001410712003474124027440 0ustar tonytony Uses of Interface com.jgoodies.common.internal.IActionBean (JGoodies Common 1.4 API)

Uses of Interface
com.jgoodies.common.internal.IActionBean

No usage of com.jgoodies.common.internal.IActionBean



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/internal/class-use/Messages.html0000644000175000017500000001402512003474124027072 0ustar tonytony Uses of Class com.jgoodies.common.internal.Messages (JGoodies Common 1.4 API)

Uses of Class
com.jgoodies.common.internal.Messages

No usage of com.jgoodies.common.internal.Messages



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/internal/class-use/RenderingUtils.html0000644000175000017500000001412112003474124030256 0ustar tonytony Uses of Class com.jgoodies.common.internal.RenderingUtils (JGoodies Common 1.4 API)

Uses of Class
com.jgoodies.common.internal.RenderingUtils

No usage of com.jgoodies.common.internal.RenderingUtils



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/internal/class-use/StringLocalizer.html0000644000175000017500000001415712003474124030444 0ustar tonytony Uses of Interface com.jgoodies.common.internal.StringLocalizer (JGoodies Common 1.4 API)

Uses of Interface
com.jgoodies.common.internal.StringLocalizer

No usage of com.jgoodies.common.internal.StringLocalizer



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/internal/package-summary.html0000644000175000017500000002113612003474124026513 0ustar tonytony com.jgoodies.common.internal (JGoodies Common 1.4 API)

Package com.jgoodies.common.internal

Consists of internal classes that are not part of the public API.

See:
          Description

Interface Summary
IActionBean Describes beans that can look up an Action for a given Action name.
IActionObject Describes an object that can look up an Action for a given Action name.
StringLocalizer Describes an object that can localize Strings accessible via a key.
 

Class Summary
Messages Provides standardized messages for use with the Preconditions class and in exception messages.
RenderingUtils Provides convenience behavior for drawing strings, underline chars, and accessing font metrics.
 

Package com.jgoodies.common.internal Description

Consists of internal classes that are not part of the public API. These classes should not be used by API users. They may be removed or changed without further notice.



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/internal/RenderingUtils.html0000644000175000017500000004401112003474124026360 0ustar tonytony RenderingUtils (JGoodies Common 1.4 API)

com.jgoodies.common.internal
Class RenderingUtils

java.lang.Object
  extended by com.jgoodies.common.internal.RenderingUtils

public final class RenderingUtils
extends Object

Provides convenience behavior for drawing strings, underline chars, and accessing font metrics.

Note: This class is not part of the public JGoodies Common API. It should be treated as library internal and should not be used by API users. It may be removed or changed without further notice.

Version:
$Revision: 1.2 $
Author:
Karsten Lentzsch

Method Summary
static void drawString(JComponent c, Graphics g, String text, int x, int y)
          Draws the string at the specified location underlining the specified character.
static void drawStringUnderlineCharAt(JComponent c, Graphics g, String text, int underlinedIndex, int x, int y)
          Draws the string at the specified location underlining the specified character.
static FontMetrics getFontMetrics(JComponent c, Graphics g)
          Returns the FontMetrics for the current Font of the passed in Graphics.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

drawString

public static void drawString(JComponent c,
                              Graphics g,
                              String text,
                              int x,
                              int y)
Draws the string at the specified location underlining the specified character.

Parameters:
c - JComponent that will display the string, may be null
g - Graphics to draw the text to
text - String to display
x - X coordinate to draw the text at
y - Y coordinate to draw the text at

drawStringUnderlineCharAt

public static void drawStringUnderlineCharAt(JComponent c,
                                             Graphics g,
                                             String text,
                                             int underlinedIndex,
                                             int x,
                                             int y)
Draws the string at the specified location underlining the specified character.

Parameters:
c - JComponent that will display the string, may be null
g - Graphics to draw the text to
text - String to display
underlinedIndex - Index of a character in the string to underline
x - X coordinate to draw the text at
y - Y coordinate to draw the text at

getFontMetrics

public static FontMetrics getFontMetrics(JComponent c,
                                         Graphics g)
Returns the FontMetrics for the current Font of the passed in Graphics. This method is used when a Graphics is available, typically when painting. If a Graphics is not available the JComponent method of the same name should be used.

Callers should pass in a non-null JComponent, the exception to this is if a JComponent is not readily available at the time of painting.

This does not necessarily return the FontMetrics from the Graphics.

Parameters:
c - JComponent requesting FontMetrics, may be null
g - Graphics Graphics
Returns:
the FontMetrics


Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/internal/StringLocalizer.html0000644000175000017500000002312112003474124026534 0ustar tonytony StringLocalizer (JGoodies Common 1.4 API)

com.jgoodies.common.internal
Interface StringLocalizer


public interface StringLocalizer

Describes an object that can localize Strings accessible via a key.

This interface is used by the JGoodies Forms to localize Strings from ResourceBundles and ResourceMaps (a class from JGoodies Application). The latter implements this StringLocalizer interface. Since ResourceBundle does not implement this interface, a wrapper can be used that implements this interface and just delegates to the ResourceBundle to look up the localized String.

Note: This class is not part of the public JGoodies Common API. It's intended for implementation purposes only. The class's API may change at any time.

Since:
1.4
Version:
$Revision: 1.2 $
Author:
Karsten Lentzsch

Method Summary
 String getString(String key)
          Returns a localized String for the given key.
 

Method Detail

getString

String getString(String key)
Returns a localized String for the given key.

Parameters:
key - the key used to look up the localized String
Returns:
the localized String


Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/swing/0000755000175000017500000000000012003474124022047 5ustar tonytonyjgoodies-common-1.4.0/docs/api/com/jgoodies/common/swing/package-frame.html0000644000175000017500000000167312003474124025427 0ustar tonytony com.jgoodies.common.swing (JGoodies Common 1.4 API) com.jgoodies.common.swing
Classes 
MnemonicUtils
jgoodies-common-1.4.0/docs/api/com/jgoodies/common/swing/MnemonicUtils.html0000644000175000017500000005210312003474124025524 0ustar tonytony MnemonicUtils (JGoodies Common 1.4 API)

com.jgoodies.common.swing
Class MnemonicUtils

java.lang.Object
  extended by com.jgoodies.common.swing.MnemonicUtils

public final class MnemonicUtils
extends Object

Configures the text, mnemonic and mnemonic index in Actions, JLabels, and AbstractButtons. The term marked text is used for Strings that contain a marker character that marks both the mnemonic and its index in the resulting plain text.

To set a mnemonic, add an ampersand ('&') before the character that should be the mnemonic, for example "&Save". If your text has multiple ampersands, only the first one is used to mark the mnemonic; the other ampersands appear as normal text. For example "&Look&Feel" has the first 'L' has mnemonic. If you want to use the ampersand itself in the text, use two consecutive ampersands for any ampersand that precede the one that is used to mark the mnemonic. For example the marked text "R&&D D&epartment" has "R&D Department" as text and the mnemonic is 'E'.

Examples:
Marked Text Plain Text Mnemonic Mnemonic Index Comment
Save Save 0 -1 No mnemonic
&Save Save 'S' 0  
Save &as Save as 'A' 5 Second 'a' marked
Look&Feel LookFeel 'F' 4 & should be quoted
Look&&Feel Look&Feel 0 -1 & is quoted
&Look&Feel Look&Feel L 0 Second & needs no quote
Look & Feel Look & Feel 0 -1 Whitespace cannot be marked
R&&D D&epartment R&D Department 'E' 5 First & is quoted
<html>a&b</html> <html>a<u>b</u></html> 'B' -1 'b' is underlined
<html>R&amp;D D&ep.</html> <html>R&amp;D D<u>e</u>p.</html> 'B' -1 HTML &amp; doesn't mark

Version:
$Revision: 1.1 $
Author:
Karsten Lentzsch

Method Summary
static void configure(AbstractButton target, String markedText)
          Configures the text, mnemonic and mnemonic index for target using the given text that can be marked with the mnemonic marker '&'.
static void configure(Action target, String markedText)
          Configures the text, mnemonic and mnemonic index for target using the given text that can be marked with the mnemonic marker '&'.
static void configure(JLabel target, String markedText)
          Configures the text, mnemonic and mnemonic index for target using the given text that can be marked with the mnemonic marker '&'.
static String plainText(String markedText)
          Returns the plain text for the given marked text by removing the mnemonic marker and marker quotes - if any.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

configure

public static void configure(AbstractButton target,
                             String markedText)
Configures the text, mnemonic and mnemonic index for target using the given text that can be marked with the mnemonic marker '&'. For example if markedText is "Save &as", the text will be set to "Save as", the mnemonic is 'a', and the mnemonic index is 5.

Parameters:
target - the button to be configured
markedText - the text with optional mnemonic marker
Throws:
NullPointerException - if target is null

configure

public static void configure(Action target,
                             String markedText)
Configures the text, mnemonic and mnemonic index for target using the given text that can be marked with the mnemonic marker '&'. For example if markedText is "Save &as", the text will be set to "Save as", the mnemonic is 'a', and the mnemonic index is 5.

Parameters:
target - the Action to be configured
markedText - the text with optional mnemonic marker
Throws:
NullPointerException - if target is null

configure

public static void configure(JLabel target,
                             String markedText)
Configures the text, mnemonic and mnemonic index for target using the given text that can be marked with the mnemonic marker '&'. For example if markedText is "Save &as", the text will be set to "Save as", the mnemonic is 'a', and the mnemonic index is 5.

Parameters:
target - the label to be configured
markedText - the text with optional mnemonic marker
Throws:
NullPointerException - if target is null

plainText

public static String plainText(String markedText)
Returns the plain text for the given marked text by removing the mnemonic marker and marker quotes - if any. If the marked text is HTML, the plain text has the mnemonic character underlined. See the MnemonicUtils class comment for information about how to mark a mnemonic and how to quote a marker.
 MnemonicUtils.plainText("Save")             == "Save"
 MnemonicUtils.plainText("&Save")            == "Save"
 MnemonicUtils.plainText("&Look&Feel")       == "Look&Feel"
 MnemonicUtils.plainText("Look & Feel")      == "Look & Feel"
 MnemonicUtils.plainText("R&&D D&epartment") == "R&D Department"
 MnemonicUtils.plainText("<html>a&b</html>") == "<html>a<u>b</u></html>"
 

Parameters:
markedText - the text that may contain a mnemonic marker
Returns:
the text without mnemonic marker and marker quotes


Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/swing/package-tree.html0000644000175000017500000001434212003474124025271 0ustar tonytony com.jgoodies.common.swing Class Hierarchy (JGoodies Common 1.4 API)

Hierarchy For Package com.jgoodies.common.swing

Package Hierarchies:
All Packages

Class Hierarchy



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/swing/package-use.html0000644000175000017500000001325212003474124025125 0ustar tonytony Uses of Package com.jgoodies.common.swing (JGoodies Common 1.4 API)

Uses of Package
com.jgoodies.common.swing

No usage of com.jgoodies.common.swing



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/swing/class-use/0000755000175000017500000000000012003474124023746 5ustar tonytonyjgoodies-common-1.4.0/docs/api/com/jgoodies/common/swing/class-use/MnemonicUtils.html0000644000175000017500000001405112003474124027423 0ustar tonytony Uses of Class com.jgoodies.common.swing.MnemonicUtils (JGoodies Common 1.4 API)

Uses of Class
com.jgoodies.common.swing.MnemonicUtils

No usage of com.jgoodies.common.swing.MnemonicUtils



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/swing/package-summary.html0000644000175000017500000001552412003474124026032 0ustar tonytony com.jgoodies.common.swing (JGoodies Common 1.4 API)

Package com.jgoodies.common.swing

Consists of Swing related classes

See:
          Description

Class Summary
MnemonicUtils Configures the text, mnemonic and mnemonic index in Actions, JLabels, and AbstractButtons.
 

Package com.jgoodies.common.swing Description

Consists of Swing related classes.



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/bean/0000755000175000017500000000000012003474124021625 5ustar tonytonyjgoodies-common-1.4.0/docs/api/com/jgoodies/common/bean/ObservableBean.html0000644000175000017500000003047612003474124025377 0ustar tonytony ObservableBean (JGoodies Common 1.4 API)

com.jgoodies.common.bean
Interface ObservableBean

All Known Subinterfaces:
IActionBean, ObservableBean2
All Known Implementing Classes:
AbstractBean, Bean

public interface ObservableBean

Describes objects that provide bound properties as specified in the Java Bean Specification. This interface is primarily intended to ensure compile-time safety for beans that shall be observed.

Version:
$Revision: 1.1 $
Author:
Karsten Lentzsch
See Also:
PropertyChangeListener, PropertyChangeEvent, PropertyChangeSupport

Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Adds the given PropertyChangeListener to the listener list.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes the given PropertyChangeListener from the listener list.
 

Method Detail

addPropertyChangeListener

void addPropertyChangeListener(PropertyChangeListener listener)
Adds the given PropertyChangeListener to the listener list. The listener is registered for all bound properties of this class.

Parameters:
listener - the PropertyChangeListener to be added
See Also:
removePropertyChangeListener(PropertyChangeListener)

removePropertyChangeListener

void removePropertyChangeListener(PropertyChangeListener listener)
Removes the given PropertyChangeListener from the listener list. This method should be used to remove PropertyChangeListeners that were registered for all bound properties of this class.

Parameters:
listener - the PropertyChangeListener to be removed
See Also:
addPropertyChangeListener(PropertyChangeListener)


Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/bean/package-frame.html0000644000175000017500000000273312003474124025203 0ustar tonytony com.jgoodies.common.bean (JGoodies Common 1.4 API) com.jgoodies.common.bean
Interfaces 
ObservableBean
ObservableBean2
Classes 
AbstractBean
Bean
jgoodies-common-1.4.0/docs/api/com/jgoodies/common/bean/package-tree.html0000644000175000017500000001642412003474124025052 0ustar tonytony com.jgoodies.common.bean Class Hierarchy (JGoodies Common 1.4 API)

Hierarchy For Package com.jgoodies.common.bean

Package Hierarchies:
All Packages

Class Hierarchy

Interface Hierarchy



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/bean/Bean.html0000644000175000017500000024765212003474124023400 0ustar tonytony Bean (JGoodies Common 1.4 API)

com.jgoodies.common.bean
Class Bean

java.lang.Object
  extended by com.jgoodies.common.bean.Bean
All Implemented Interfaces:
ObservableBean, ObservableBean2, Serializable
Direct Known Subclasses:
AbstractBean

public abstract class Bean
extends Object
implements Serializable, ObservableBean2

An abstract superclass that minimizes the effort required to provide change support for bound and constrained Bean properties. This class follows the conventions and recommendations as described in the Java Bean Specification.

This class uses the standard PropertyChangeSupport to notify registered listeners about changes. Subclasses can use different change support implementations by overriding createPropertyChangeSupport, for example to ensure that notifications are sent in the Event dispatch thread, or to compare old and new values with == not equals.

Version:
$Revision: 1.1 $
Author:
Karsten Lentzsch
See Also:
PropertyChangeEvent, PropertyChangeListener, PropertyChangeSupport, VetoableChangeListener, VetoableChangeSupport, Serialized Form

Field Summary
protected  PropertyChangeSupport changeSupport
          If anyPropertyChangeListeners have been registered, the changeSupport field describes them.
 
Constructor Summary
Bean()
           
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Adds a PropertyChangeListener to the listener list.
 void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Adds a PropertyChangeListener to the listener list for a specific property.
 void addVetoableChangeListener(String propertyName, VetoableChangeListener listener)
          Adds a VetoableChangeListener to the listener list for a specific property.
 void addVetoableChangeListener(VetoableChangeListener listener)
          Adds a VetoableChangeListener to the listener list.
protected  PropertyChangeSupport createPropertyChangeSupport(Object bean)
          Creates and returns a PropertyChangeSupport for the given bean.
protected  void fireIndexedPropertyChange(String propertyName, int index, boolean oldValue, boolean newValue)
          Report a boolean bound indexed property update to any registered listeners.
protected  void fireIndexedPropertyChange(String propertyName, int index, int oldValue, int newValue)
          Report an int bound indexed property update to any registered listeners.
protected  void fireIndexedPropertyChange(String propertyName, int index, Object oldValue, Object newValue)
          Report a bound indexed property update to any registered listeners.
protected  void fireMultiplePropertiesChanged()
          Indicates that an arbitrary set of bound properties have changed.
protected  void firePropertyChange(PropertyChangeEvent event)
          General support for reporting bound property changes.
protected  void firePropertyChange(String propertyName, boolean oldValue, boolean newValue)
          Support for reporting bound property changes for boolean properties.
protected  void firePropertyChange(String propertyName, double oldValue, double newValue)
          Support for reporting bound property changes for integer properties.
protected  void firePropertyChange(String propertyName, float oldValue, float newValue)
          Support for reporting bound property changes for integer properties.
protected  void firePropertyChange(String propertyName, int oldValue, int newValue)
          Support for reporting bound property changes for integer properties.
protected  void firePropertyChange(String propertyName, long oldValue, long newValue)
          Support for reporting bound property changes for integer properties.
protected  void firePropertyChange(String propertyName, Object oldValue, Object newValue)
          Support for reporting bound property changes for Object properties.
protected  void fireVetoableChange(PropertyChangeEvent event)
          General support for reporting constrained property changes.
protected  void fireVetoableChange(String propertyName, boolean oldValue, boolean newValue)
          Support for reporting changes for constrained boolean properties.
protected  void fireVetoableChange(String propertyName, double oldValue, double newValue)
          Support for reporting changes for constrained integer properties.
protected  void fireVetoableChange(String propertyName, float oldValue, float newValue)
          Support for reporting changes for constrained integer properties.
protected  void fireVetoableChange(String propertyName, int oldValue, int newValue)
          Support for reporting changes for constrained integer properties.
protected  void fireVetoableChange(String propertyName, long oldValue, long newValue)
          Support for reporting changes for constrained integer properties.
protected  void fireVetoableChange(String propertyName, Object oldValue, Object newValue)
          Support for reporting changes for constrained Object properties.
 PropertyChangeListener[] getPropertyChangeListeners()
          Returns an array of all the property change listeners registered on this component.
 PropertyChangeListener[] getPropertyChangeListeners(String propertyName)
          Returns an array of all the listeners which have been associated with the named property.
 VetoableChangeListener[] getVetoableChangeListeners()
          Returns an array of all the property change listeners registered on this component.
 VetoableChangeListener[] getVetoableChangeListeners(String propertyName)
          Returns an array of all the listeners which have been associated with the named property.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes a PropertyChangeListener from the listener list.
 void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Removes a PropertyChangeListener from the listener list for a specific property.
 void removeVetoableChangeListener(String propertyName, VetoableChangeListener listener)
          Removes a VetoableChangeListener from the listener list for a specific property.
 void removeVetoableChangeListener(VetoableChangeListener listener)
          Removes a VetoableChangeListener from the listener list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

changeSupport

protected PropertyChangeSupport changeSupport
If anyPropertyChangeListeners have been registered, the changeSupport field describes them.

See Also:
addPropertyChangeListener(PropertyChangeListener), addPropertyChangeListener(String, PropertyChangeListener), removePropertyChangeListener(PropertyChangeListener), removePropertyChangeListener(String, PropertyChangeListener), PropertyChangeSupport
Constructor Detail

Bean

public Bean()
Method Detail

addPropertyChangeListener

public final void addPropertyChangeListener(PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list. The listener is registered for all bound properties of this class.

If listener is null, no exception is thrown and no action is performed.

Specified by:
addPropertyChangeListener in interface ObservableBean
Parameters:
listener - the PropertyChangeListener to be added
See Also:
removePropertyChangeListener(PropertyChangeListener), removePropertyChangeListener(String, PropertyChangeListener), addPropertyChangeListener(String, PropertyChangeListener), getPropertyChangeListeners()

removePropertyChangeListener

public final void removePropertyChangeListener(PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list. This method should be used to remove PropertyChangeListeners that were registered for all bound properties of this class.

If listener is null, no exception is thrown and no action is performed.

Specified by:
removePropertyChangeListener in interface ObservableBean
Parameters:
listener - the PropertyChangeListener to be removed
See Also:
addPropertyChangeListener(PropertyChangeListener), addPropertyChangeListener(String, PropertyChangeListener), removePropertyChangeListener(String, PropertyChangeListener), getPropertyChangeListeners()

addPropertyChangeListener

public final void addPropertyChangeListener(String propertyName,
                                            PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list for a specific property. The specified property may be user-defined.

Note that if this Model is inheriting a bound property, then no event will be fired in response to a change in the inherited property.

If listener is null, no exception is thrown and no action is performed.

Specified by:
addPropertyChangeListener in interface ObservableBean2
Parameters:
propertyName - one of the property names listed above
listener - the PropertyChangeListener to be added
See Also:
removePropertyChangeListener(String, PropertyChangeListener), addPropertyChangeListener(String, PropertyChangeListener), getPropertyChangeListeners(String)

removePropertyChangeListener

public final void removePropertyChangeListener(String propertyName,
                                               PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list for a specific property. This method should be used to remove PropertyChangeListeners that were registered for a specific bound property.

If listener is null, no exception is thrown and no action is performed.

Specified by:
removePropertyChangeListener in interface ObservableBean2
Parameters:
propertyName - a valid property name
listener - the PropertyChangeListener to be removed
See Also:
addPropertyChangeListener(String, PropertyChangeListener), removePropertyChangeListener(PropertyChangeListener), getPropertyChangeListeners(String)

addVetoableChangeListener

public final void addVetoableChangeListener(VetoableChangeListener listener)
Adds a VetoableChangeListener to the listener list. The listener is registered for all bound properties of this class.

If listener is null, no exception is thrown and no action is performed.

Parameters:
listener - the VetoableChangeListener to be added
See Also:
removeVetoableChangeListener(String, VetoableChangeListener), addVetoableChangeListener(String, VetoableChangeListener), getVetoableChangeListeners()

removeVetoableChangeListener

public final void removeVetoableChangeListener(VetoableChangeListener listener)
Removes a VetoableChangeListener from the listener list. This method should be used to remove VetoableChangeListeners that were registered for all bound properties of this class.

If listener is null, no exception is thrown and no action is performed.

Parameters:
listener - the VetoableChangeListener to be removed
See Also:
addVetoableChangeListener(String, VetoableChangeListener), removeVetoableChangeListener(String, VetoableChangeListener), getVetoableChangeListeners()

addVetoableChangeListener

public final void addVetoableChangeListener(String propertyName,
                                            VetoableChangeListener listener)
Adds a VetoableChangeListener to the listener list for a specific property. The specified property may be user-defined.

Note that if this Model is inheriting a bound property, then no event will be fired in response to a change in the inherited property.

If listener is null, no exception is thrown and no action is performed.

Parameters:
propertyName - one of the property names listed above
listener - the VetoableChangeListener to be added
See Also:
removeVetoableChangeListener(String, VetoableChangeListener), addVetoableChangeListener(String, VetoableChangeListener), getVetoableChangeListeners(String)

removeVetoableChangeListener

public final void removeVetoableChangeListener(String propertyName,
                                               VetoableChangeListener listener)
Removes a VetoableChangeListener from the listener list for a specific property. This method should be used to remove VetoableChangeListeners that were registered for a specific bound property.

If listener is null, no exception is thrown and no action is performed.

Parameters:
propertyName - a valid property name
listener - the VetoableChangeListener to be removed
See Also:
addVetoableChangeListener(String, VetoableChangeListener), removeVetoableChangeListener(VetoableChangeListener), getVetoableChangeListeners(String)

getPropertyChangeListeners

public final PropertyChangeListener[] getPropertyChangeListeners()
Returns an array of all the property change listeners registered on this component.

Specified by:
getPropertyChangeListeners in interface ObservableBean2
Returns:
all of this component's PropertyChangeListeners or an empty array if no property change listeners are currently registered
See Also:
addPropertyChangeListener(PropertyChangeListener), removePropertyChangeListener(PropertyChangeListener), getPropertyChangeListeners(String), PropertyChangeSupport.getPropertyChangeListeners()

getPropertyChangeListeners

public final PropertyChangeListener[] getPropertyChangeListeners(String propertyName)
Returns an array of all the listeners which have been associated with the named property.

Specified by:
getPropertyChangeListeners in interface ObservableBean2
Parameters:
propertyName - the name of the property to lookup listeners
Returns:
all of the PropertyChangeListeners associated with the named property or an empty array if no listeners have been added
See Also:
addPropertyChangeListener(String, PropertyChangeListener), removePropertyChangeListener(String, PropertyChangeListener), getPropertyChangeListeners()

getVetoableChangeListeners

public final VetoableChangeListener[] getVetoableChangeListeners()
Returns an array of all the property change listeners registered on this component.

Returns:
all of this component's VetoableChangeListeners or an empty array if no property change listeners are currently registered
See Also:
addVetoableChangeListener(VetoableChangeListener), removeVetoableChangeListener(VetoableChangeListener), getVetoableChangeListeners(String), VetoableChangeSupport.getVetoableChangeListeners()

getVetoableChangeListeners

public final VetoableChangeListener[] getVetoableChangeListeners(String propertyName)
Returns an array of all the listeners which have been associated with the named property.

Parameters:
propertyName - the name of the property to lookup listeners
Returns:
all of the VetoableChangeListeners associated with the named property or an empty array if no listeners have been added
See Also:
addVetoableChangeListener(String, VetoableChangeListener), removeVetoableChangeListener(String, VetoableChangeListener), getVetoableChangeListeners()

createPropertyChangeSupport

protected PropertyChangeSupport createPropertyChangeSupport(Object bean)
Creates and returns a PropertyChangeSupport for the given bean. Invoked by the first call to addPropertyChangeListener(java.beans.PropertyChangeListener) when lazily creating the sole change support instance used throughout this bean.

This default implementation creates a PropertyChangeSupport. Subclasses may override to return other change support implementations. For example to ensure that listeners are notified in the Event dispatch thread (EDT change support). The JGoodies Binding uses an extended change support that allows to configure whether the old and new value are compared with == or equals.

Parameters:
bean - the bean to create a change support for
Returns:
the new change support

firePropertyChange

protected final void firePropertyChange(PropertyChangeEvent event)
General support for reporting bound property changes. Sends the given PropertyChangeEvent to any registered PropertyChangeListener.

Most bean setters will invoke the fireXXX methods that get a property name and the old and new value. However some frameworks and setters may prefer to use this general method. Also, this method allows to fire IndexedPropertyChangeEvents that have been introduced in Java 5.

Parameters:
event - describes the property change
Since:
1.3

firePropertyChange

protected final void firePropertyChange(String propertyName,
                                        Object oldValue,
                                        Object newValue)
Support for reporting bound property changes for Object properties. This method can be called when a bound property has changed and it will send the appropriate PropertyChangeEvent to any registered PropertyChangeListeners.

Parameters:
propertyName - the property whose value has changed
oldValue - the property's previous value
newValue - the property's new value

firePropertyChange

protected final void firePropertyChange(String propertyName,
                                        boolean oldValue,
                                        boolean newValue)
Support for reporting bound property changes for boolean properties. This method can be called when a bound property has changed and it will send the appropriate PropertyChangeEvent to any registered PropertyChangeListeners.

Parameters:
propertyName - the property whose value has changed
oldValue - the property's previous value
newValue - the property's new value

firePropertyChange

protected final void firePropertyChange(String propertyName,
                                        double oldValue,
                                        double newValue)
Support for reporting bound property changes for integer properties. This method can be called when a bound property has changed and it will send the appropriate PropertyChangeEvent to any registered PropertyChangeListeners.

Parameters:
propertyName - the property whose value has changed
oldValue - the property's previous value
newValue - the property's new value

firePropertyChange

protected final void firePropertyChange(String propertyName,
                                        float oldValue,
                                        float newValue)
Support for reporting bound property changes for integer properties. This method can be called when a bound property has changed and it will send the appropriate PropertyChangeEvent to any registered PropertyChangeListeners.

Parameters:
propertyName - the property whose value has changed
oldValue - the property's previous value
newValue - the property's new value

firePropertyChange

protected final void firePropertyChange(String propertyName,
                                        int oldValue,
                                        int newValue)
Support for reporting bound property changes for integer properties. This method can be called when a bound property has changed and it will send the appropriate PropertyChangeEvent to any registered PropertyChangeListeners.

Parameters:
propertyName - the property whose value has changed
oldValue - the property's previous value
newValue - the property's new value

firePropertyChange

protected final void firePropertyChange(String propertyName,
                                        long oldValue,
                                        long newValue)
Support for reporting bound property changes for integer properties. This method can be called when a bound property has changed and it will send the appropriate PropertyChangeEvent to any registered PropertyChangeListeners.

Parameters:
propertyName - the property whose value has changed
oldValue - the property's previous value
newValue - the property's new value

fireMultiplePropertiesChanged

protected final void fireMultiplePropertiesChanged()
Indicates that an arbitrary set of bound properties have changed. Sends a PropertyChangeEvent with property name, old and new value set to null to any registered PropertyChangeListeners.

Since:
1.0.3
See Also:
PropertyChangeEvent

fireIndexedPropertyChange

protected final void fireIndexedPropertyChange(String propertyName,
                                               int index,
                                               Object oldValue,
                                               Object newValue)
Report a bound indexed property update to any registered listeners.

No event is fired if old and new values are equal and non-null.

Parameters:
propertyName - The programmatic name of the property that was changed.
index - index of the property element that was changed.
oldValue - The old value of the property.
newValue - The new value of the property.
Since:
2.0

fireIndexedPropertyChange

protected final void fireIndexedPropertyChange(String propertyName,
                                               int index,
                                               int oldValue,
                                               int newValue)
Report an int bound indexed property update to any registered listeners.

No event is fired if old and new values are equal and non-null.

This is merely a convenience wrapper around the more general fireIndexedPropertyChange method which takes Object values.

Parameters:
propertyName - The programmatic name of the property that was changed.
index - index of the property element that was changed.
oldValue - The old value of the property.
newValue - The new value of the property.
Since:
2.0

fireIndexedPropertyChange

protected final void fireIndexedPropertyChange(String propertyName,
                                               int index,
                                               boolean oldValue,
                                               boolean newValue)
Report a boolean bound indexed property update to any registered listeners.

No event is fired if old and new values are equal and non-null.

This is merely a convenience wrapper around the more general fireIndexedPropertyChange method which takes Object values.

Parameters:
propertyName - The programmatic name of the property that was changed.
index - index of the property element that was changed.
oldValue - The old value of the property.
newValue - The new value of the property.
Since:
2.0

fireVetoableChange

protected final void fireVetoableChange(PropertyChangeEvent event)
                                 throws PropertyVetoException
General support for reporting constrained property changes. Sends the given PropertyChangeEvent to any registered PropertyChangeListener.

Most bean setters will invoke the fireXXX methods that get a property name and the old and new value. However some frameworks and setters may prefer to use this general method. Also, this method allows to fire IndexedPropertyChangeEvents that have been introduced in Java 5.

Parameters:
event - describes the property change
Throws:
PropertyVetoException - if a constrained property change is rejected
Since:
1.3

fireVetoableChange

protected final void fireVetoableChange(String propertyName,
                                        Object oldValue,
                                        Object newValue)
                                 throws PropertyVetoException
Support for reporting changes for constrained Object properties. This method can be called before a constrained property will be changed and it will send the appropriate PropertyChangeEvent to any registered VetoableChangeListeners.

Parameters:
propertyName - the property whose value has changed
oldValue - the property's previous value
newValue - the property's new value
Throws:
PropertyVetoException - if a constrained property change is rejected

fireVetoableChange

protected final void fireVetoableChange(String propertyName,
                                        boolean oldValue,
                                        boolean newValue)
                                 throws PropertyVetoException
Support for reporting changes for constrained boolean properties. This method can be called before a constrained property will be changed and it will send the appropriate PropertyChangeEvent to any registered VetoableChangeListeners.

Parameters:
propertyName - the property whose value has changed
oldValue - the property's previous value
newValue - the property's new value
Throws:
PropertyVetoException - if a constrained property change is rejected

fireVetoableChange

protected final void fireVetoableChange(String propertyName,
                                        double oldValue,
                                        double newValue)
                                 throws PropertyVetoException
Support for reporting changes for constrained integer properties. This method can be called before a constrained property will be changed and it will send the appropriate PropertyChangeEvent to any registered VetoableChangeListeners.

Parameters:
propertyName - the property whose value has changed
oldValue - the property's previous value
newValue - the property's new value
Throws:
PropertyVetoException - if a constrained property change is rejected

fireVetoableChange

protected final void fireVetoableChange(String propertyName,
                                        int oldValue,
                                        int newValue)
                                 throws PropertyVetoException
Support for reporting changes for constrained integer properties. This method can be called before a constrained property will be changed and it will send the appropriate PropertyChangeEvent to any registered VetoableChangeListeners.

Parameters:
propertyName - the property whose value has changed
oldValue - the property's previous value
newValue - the property's new value
Throws:
PropertyVetoException - if a constrained property change is rejected

fireVetoableChange

protected final void fireVetoableChange(String propertyName,
                                        float oldValue,
                                        float newValue)
                                 throws PropertyVetoException
Support for reporting changes for constrained integer properties. This method can be called before a constrained property will be changed and it will send the appropriate PropertyChangeEvent to any registered VetoableChangeListeners.

Parameters:
propertyName - the property whose value has changed
oldValue - the property's previous value
newValue - the property's new value
Throws:
PropertyVetoException - if a constrained property change is rejected

fireVetoableChange

protected final void fireVetoableChange(String propertyName,
                                        long oldValue,
                                        long newValue)
                                 throws PropertyVetoException
Support for reporting changes for constrained integer properties. This method can be called before a constrained property will be changed and it will send the appropriate PropertyChangeEvent to any registered VetoableChangeListeners.

Parameters:
propertyName - the property whose value has changed
oldValue - the property's previous value
newValue - the property's new value
Throws:
PropertyVetoException - if a constrained property change is rejected


Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/bean/package-use.html0000644000175000017500000002256512003474124024712 0ustar tonytony Uses of Package com.jgoodies.common.bean (JGoodies Common 1.4 API)

Uses of Package
com.jgoodies.common.bean

Packages that use com.jgoodies.common.bean
com.jgoodies.common.bean Consists of classes for working with Java Beans 
com.jgoodies.common.internal Consists of internal classes that are not part of the public API. 
 

Classes in com.jgoodies.common.bean used by com.jgoodies.common.bean
Bean
          An abstract superclass that minimizes the effort required to provide change support for bound and constrained Bean properties.
ObservableBean
          Describes objects that provide bound properties as specified in the Java Bean Specification.
ObservableBean2
          In addition to its super interface ObservableBean, this interface describes the optional support for registering PropertyChangeListeners for an individual property name.
 

Classes in com.jgoodies.common.bean used by com.jgoodies.common.internal
ObservableBean
          Describes objects that provide bound properties as specified in the Java Bean Specification.
ObservableBean2
          In addition to its super interface ObservableBean, this interface describes the optional support for registering PropertyChangeListeners for an individual property name.
 



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/bean/class-use/0000755000175000017500000000000012003474124023524 5ustar tonytonyjgoodies-common-1.4.0/docs/api/com/jgoodies/common/bean/class-use/ObservableBean.html0000644000175000017500000002604512003474124027273 0ustar tonytony Uses of Interface com.jgoodies.common.bean.ObservableBean (JGoodies Common 1.4 API)

Uses of Interface
com.jgoodies.common.bean.ObservableBean

Packages that use ObservableBean
com.jgoodies.common.bean Consists of classes for working with Java Beans 
com.jgoodies.common.internal Consists of internal classes that are not part of the public API. 
 

Uses of ObservableBean in com.jgoodies.common.bean
 

Subinterfaces of ObservableBean in com.jgoodies.common.bean
 interface ObservableBean2
          In addition to its super interface ObservableBean, this interface describes the optional support for registering PropertyChangeListeners for an individual property name.
 

Classes in com.jgoodies.common.bean that implement ObservableBean
 class AbstractBean
          This is the deprecated abstract superclass for bean classes.
 class Bean
          An abstract superclass that minimizes the effort required to provide change support for bound and constrained Bean properties.
 

Uses of ObservableBean in com.jgoodies.common.internal
 

Subinterfaces of ObservableBean in com.jgoodies.common.internal
 interface IActionBean
          Describes beans that can look up an Action for a given Action name.
 



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/bean/class-use/Bean.html0000644000175000017500000001737712003474124025276 0ustar tonytony Uses of Class com.jgoodies.common.bean.Bean (JGoodies Common 1.4 API)

Uses of Class
com.jgoodies.common.bean.Bean

Packages that use Bean
com.jgoodies.common.bean Consists of classes for working with Java Beans 
 

Uses of Bean in com.jgoodies.common.bean
 

Subclasses of Bean in com.jgoodies.common.bean
 class AbstractBean
          This is the deprecated abstract superclass for bean classes.
 



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/bean/class-use/ObservableBean2.html0000644000175000017500000002407512003474124027356 0ustar tonytony Uses of Interface com.jgoodies.common.bean.ObservableBean2 (JGoodies Common 1.4 API)

Uses of Interface
com.jgoodies.common.bean.ObservableBean2

Packages that use ObservableBean2
com.jgoodies.common.bean Consists of classes for working with Java Beans 
com.jgoodies.common.internal Consists of internal classes that are not part of the public API. 
 

Uses of ObservableBean2 in com.jgoodies.common.bean
 

Classes in com.jgoodies.common.bean that implement ObservableBean2
 class AbstractBean
          This is the deprecated abstract superclass for bean classes.
 class Bean
          An abstract superclass that minimizes the effort required to provide change support for bound and constrained Bean properties.
 

Uses of ObservableBean2 in com.jgoodies.common.internal
 

Subinterfaces of ObservableBean2 in com.jgoodies.common.internal
 interface IActionBean
          Describes beans that can look up an Action for a given Action name.
 



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/bean/class-use/AbstractBean.html0000644000175000017500000001402512003474124026745 0ustar tonytony Uses of Class com.jgoodies.common.bean.AbstractBean (JGoodies Common 1.4 API)

Uses of Class
com.jgoodies.common.bean.AbstractBean

No usage of com.jgoodies.common.bean.AbstractBean



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/bean/package-summary.html0000644000175000017500000002045312003474124025605 0ustar tonytony com.jgoodies.common.bean (JGoodies Common 1.4 API)

Package com.jgoodies.common.bean

Consists of classes for working with Java Beans

See:
          Description

Interface Summary
ObservableBean Describes objects that provide bound properties as specified in the Java Bean Specification.
ObservableBean2 In addition to its super interface ObservableBean, this interface describes the optional support for registering PropertyChangeListeners for an individual property name.
 

Class Summary
AbstractBean This is the deprecated abstract superclass for bean classes.
Bean An abstract superclass that minimizes the effort required to provide change support for bound and constrained Bean properties.
 

Package com.jgoodies.common.bean Description

Consists of classes for working with Java Beans.



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/bean/ObservableBean2.html0000644000175000017500000005027512003474124025460 0ustar tonytony ObservableBean2 (JGoodies Common 1.4 API)

com.jgoodies.common.bean
Interface ObservableBean2

All Superinterfaces:
ObservableBean
All Known Subinterfaces:
IActionBean
All Known Implementing Classes:
AbstractBean, Bean

public interface ObservableBean2
extends ObservableBean

In addition to its super interface ObservableBean, this interface describes the optional support for registering PropertyChangeListeners for an individual property name. This interface is primarily intended to ensure compile-time safety for beans that shall be observed.

Version:
$Revision: 1.1 $
Author:
Karsten Lentzsch
See Also:
PropertyChangeListener, PropertyChangeEvent, PropertyChangeSupport

Method Summary
 void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Adds a PropertyChangeListener to the listener list for a specific property.
 PropertyChangeListener[] getPropertyChangeListeners()
          Returns an array of all the property change listeners registered on this component.
 PropertyChangeListener[] getPropertyChangeListeners(String propertyName)
          Returns an array of all the listeners which have been associated with the named property.
 void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Removes a PropertyChangeListener from the listener list for a specific property.
 
Methods inherited from interface com.jgoodies.common.bean.ObservableBean
addPropertyChangeListener, removePropertyChangeListener
 

Method Detail

addPropertyChangeListener

void addPropertyChangeListener(String propertyName,
                               PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list for a specific property. The specified property may be user-defined.

Note that if this bean is inheriting a bound property, then no event will be fired in response to a change in the inherited property.

If listener is null, no exception is thrown and no action is performed.

Parameters:
propertyName - one of the property names listed above
listener - the PropertyChangeListener to be added
See Also:
ObservableBean.removePropertyChangeListener(PropertyChangeListener), removePropertyChangeListener(String, PropertyChangeListener), ObservableBean.addPropertyChangeListener(PropertyChangeListener), getPropertyChangeListeners(String)

removePropertyChangeListener

void removePropertyChangeListener(String propertyName,
                                  PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list for a specific property. This method should be used to remove PropertyChangeListeners that were registered for a specific bound property.

If listener is null, no exception is thrown and no action is performed.

Parameters:
propertyName - a valid property name
listener - the PropertyChangeListener to be removed
See Also:
ObservableBean.addPropertyChangeListener(PropertyChangeListener), addPropertyChangeListener(String, PropertyChangeListener), ObservableBean.removePropertyChangeListener(PropertyChangeListener), getPropertyChangeListeners(String)

getPropertyChangeListeners

PropertyChangeListener[] getPropertyChangeListeners()
Returns an array of all the property change listeners registered on this component.

Returns:
all of this component's PropertyChangeListeners or an empty array if no property change listeners are currently registered
See Also:
ObservableBean.addPropertyChangeListener(PropertyChangeListener), ObservableBean.removePropertyChangeListener(PropertyChangeListener), getPropertyChangeListeners(String), PropertyChangeSupport.getPropertyChangeListeners()

getPropertyChangeListeners

PropertyChangeListener[] getPropertyChangeListeners(String propertyName)
Returns an array of all the listeners which have been associated with the named property.

Parameters:
propertyName - the name of the property to lookup listeners
Returns:
all of the PropertyChangeListeners associated with the named property or an empty array if no listeners have been added
See Also:
addPropertyChangeListener(String, PropertyChangeListener), removePropertyChangeListener(String, PropertyChangeListener), getPropertyChangeListeners()


Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/bean/AbstractBean.html0000644000175000017500000004550012003474124025050 0ustar tonytony AbstractBean (JGoodies Common 1.4 API)

com.jgoodies.common.bean
Class AbstractBean

java.lang.Object
  extended by com.jgoodies.common.bean.Bean
      extended by com.jgoodies.common.bean.AbstractBean
All Implemented Interfaces:
ObservableBean, ObservableBean2, Serializable

public abstract class AbstractBean
extends Bean

This is the deprecated abstract superclass for bean classes. Use Bean instead.

Version:
$Revision: 1.2 $
Author:
Karsten Lentzsch
See Also:
PropertyChangeEvent, PropertyChangeListener, PropertyChangeSupport, VetoableChangeListener, VetoableChangeSupport, Serialized Form

Field Summary
 
Fields inherited from class com.jgoodies.common.bean.Bean
changeSupport
 
Constructor Summary
AbstractBean()
           
 
Method Summary
 
Methods inherited from class com.jgoodies.common.bean.Bean
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, createPropertyChangeSupport, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, fireMultiplePropertiesChanged, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractBean

public AbstractBean()


Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/format/0000755000175000017500000000000012003474124022210 5ustar tonytonyjgoodies-common-1.4.0/docs/api/com/jgoodies/common/format/package-frame.html0000644000175000017500000000250112003474124025557 0ustar tonytony com.jgoodies.common.format (JGoodies Common 1.4 API) com.jgoodies.common.format
Classes 
AbstractWrappedDateFormat
EmptyDateFormat
EmptyFormat
EmptyNumberFormat
jgoodies-common-1.4.0/docs/api/com/jgoodies/common/format/EmptyDateFormat.html0000644000175000017500000010366112003474124026152 0ustar tonytony EmptyDateFormat (JGoodies Common 1.4 API)

com.jgoodies.common.format
Class EmptyDateFormat

java.lang.Object
  extended by java.text.Format
      extended by java.text.DateFormat
          extended by com.jgoodies.common.format.AbstractWrappedDateFormat
              extended by com.jgoodies.common.format.EmptyDateFormat
All Implemented Interfaces:
Serializable, Cloneable

public final class EmptyDateFormat
extends AbstractWrappedDateFormat

Wraps a given DateFormat and adds behavior to convert to/from the empty string. Therefore it holds an empty value that is mapped to/from the empty string. The #format result of the empty value is the empty string, and the #parse result of the empty string is the empty value. In all other cases the formatting and parsing is forwarded to the wrapped DateFormat.

Often the empty value is null but you can construct an EmptyDateFormat with a given Date.

Examples:

 new EmptyDateFormat(DateFormat.getDateInstance());
 new EmptyDateFormat(DateFormat.getDateInstance(), new Date());

 new EmptyDateFormat(DateFormat.getDateInstance(DateFormat.SHORT));
 new EmptyDateFormat(DateFormat.getDateInstance(DateFormat.SHORT), new Date());
 

Version:
$Revision: 1.1 $
Author:
Karsten Lentzsch
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.text.DateFormat
DateFormat.Field
 
Field Summary
 
Fields inherited from class com.jgoodies.common.format.AbstractWrappedDateFormat
delegate
 
Fields inherited from class java.text.DateFormat
AM_PM_FIELD, calendar, DATE_FIELD, DAY_OF_WEEK_FIELD, DAY_OF_WEEK_IN_MONTH_FIELD, DAY_OF_YEAR_FIELD, DEFAULT, ERA_FIELD, FULL, HOUR_OF_DAY0_FIELD, HOUR_OF_DAY1_FIELD, HOUR0_FIELD, HOUR1_FIELD, LONG, MEDIUM, MILLISECOND_FIELD, MINUTE_FIELD, MONTH_FIELD, numberFormat, SECOND_FIELD, SHORT, TIMEZONE_FIELD, WEEK_OF_MONTH_FIELD, WEEK_OF_YEAR_FIELD, YEAR_FIELD
 
Constructor Summary
EmptyDateFormat(DateFormat delegate)
          Constructs an EmptyFormat that wraps the given mandatory format to convert null to the empty string and vice versa.
EmptyDateFormat(DateFormat delegate, Date emptyValue)
          Constructs an EmptyFormat that wraps the given mandatory format to convert the given emptyValue to the empty string and vice versa.
 
Method Summary
 StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition pos)
           
 Date parse(String source, ParsePosition pos)
           
 
Methods inherited from class com.jgoodies.common.format.AbstractWrappedDateFormat
formatToCharacterIterator, getCalendar, getNumberFormat, getTimeZone, isLenient, setCalendar, setLenient, setNumberFormat, setTimeZone
 
Methods inherited from class java.text.DateFormat
clone, equals, format, format, getAvailableLocales, getDateInstance, getDateInstance, getDateInstance, getDateTimeInstance, getDateTimeInstance, getDateTimeInstance, getInstance, getTimeInstance, getTimeInstance, getTimeInstance, hashCode, parse, parseObject
 
Methods inherited from class java.text.Format
format, parseObject
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EmptyDateFormat

public EmptyDateFormat(DateFormat delegate)
Constructs an EmptyFormat that wraps the given mandatory format to convert null to the empty string and vice versa.

Parameters:
delegate - the format that handles the standard cases
Throws:
NullPointerException - if delegate is null

EmptyDateFormat

public EmptyDateFormat(DateFormat delegate,
                       Date emptyValue)
Constructs an EmptyFormat that wraps the given mandatory format to convert the given emptyValue to the empty string and vice versa.

Parameters:
delegate - the format that handles non-null values
emptyValue - the representation of the empty string
Throws:
NullPointerException - if delegate is null
Method Detail

format

public StringBuffer format(Date date,
                           StringBuffer toAppendTo,
                           FieldPosition pos)
Specified by:
format in class AbstractWrappedDateFormat

parse

public Date parse(String source,
                  ParsePosition pos)
Specified by:
parse in class AbstractWrappedDateFormat


Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/format/package-tree.html0000644000175000017500000001761612003474124025441 0ustar tonytony com.jgoodies.common.format Class Hierarchy (JGoodies Common 1.4 API)

Hierarchy For Package com.jgoodies.common.format

Package Hierarchies:
All Packages

Class Hierarchy



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/format/package-use.html0000644000175000017500000001616512003474124025274 0ustar tonytony Uses of Package com.jgoodies.common.format (JGoodies Common 1.4 API)

Uses of Package
com.jgoodies.common.format

Packages that use com.jgoodies.common.format
com.jgoodies.common.format Consists of Format implementations and wrappers 
 

Classes in com.jgoodies.common.format used by com.jgoodies.common.format
AbstractWrappedDateFormat
          Reduces the effort required to write custom DateFormat implementations that retain the ability to iterate through Dates with the arrow keys in formatted text fields (using an appropriate DateFormatter).
 



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/format/class-use/0000755000175000017500000000000012003474124024107 5ustar tonytonyjgoodies-common-1.4.0/docs/api/com/jgoodies/common/format/class-use/EmptyDateFormat.html0000644000175000017500000001410712003474124030045 0ustar tonytony Uses of Class com.jgoodies.common.format.EmptyDateFormat (JGoodies Common 1.4 API)

Uses of Class
com.jgoodies.common.format.EmptyDateFormat

No usage of com.jgoodies.common.format.EmptyDateFormat



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/format/class-use/EmptyNumberFormat.html0000644000175000017500000001413312003474124030417 0ustar tonytony Uses of Class com.jgoodies.common.format.EmptyNumberFormat (JGoodies Common 1.4 API)

Uses of Class
com.jgoodies.common.format.EmptyNumberFormat

No usage of com.jgoodies.common.format.EmptyNumberFormat



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/format/class-use/AbstractWrappedDateFormat.html0000644000175000017500000002044312003474124032035 0ustar tonytony Uses of Class com.jgoodies.common.format.AbstractWrappedDateFormat (JGoodies Common 1.4 API)

Uses of Class
com.jgoodies.common.format.AbstractWrappedDateFormat

Packages that use AbstractWrappedDateFormat
com.jgoodies.common.format Consists of Format implementations and wrappers 
 

Uses of AbstractWrappedDateFormat in com.jgoodies.common.format
 

Subclasses of AbstractWrappedDateFormat in com.jgoodies.common.format
 class EmptyDateFormat
          Wraps a given DateFormat and adds behavior to convert to/from the empty string.
 



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/format/class-use/EmptyFormat.html0000644000175000017500000001403712003474124027251 0ustar tonytony Uses of Class com.jgoodies.common.format.EmptyFormat (JGoodies Common 1.4 API)

Uses of Class
com.jgoodies.common.format.EmptyFormat

No usage of com.jgoodies.common.format.EmptyFormat



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/format/package-summary.html0000644000175000017500000002035312003474124026167 0ustar tonytony com.jgoodies.common.format (JGoodies Common 1.4 API)

Package com.jgoodies.common.format

Consists of Format implementations and wrappers

See:
          Description

Class Summary
AbstractWrappedDateFormat Reduces the effort required to write custom DateFormat implementations that retain the ability to iterate through Dates with the arrow keys in formatted text fields (using an appropriate DateFormatter).
EmptyDateFormat Wraps a given DateFormat and adds behavior to convert to/from the empty string.
EmptyFormat Wraps a given Format and adds behavior to convert to/from the empty string.
EmptyNumberFormat Wraps a given NumberFormat and adds behavior to convert to/from the empty string.
 

Package com.jgoodies.common.format Description

Consists of Format implementations and wrappers.



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/format/EmptyNumberFormat.html0000644000175000017500000012120112003474124026513 0ustar tonytony EmptyNumberFormat (JGoodies Common 1.4 API)

com.jgoodies.common.format
Class EmptyNumberFormat

java.lang.Object
  extended by java.text.Format
      extended by java.text.NumberFormat
          extended by com.jgoodies.common.format.EmptyNumberFormat
All Implemented Interfaces:
Serializable, Cloneable

public final class EmptyNumberFormat
extends NumberFormat

Wraps a given NumberFormat and adds behavior to convert to/from the empty string. Therefore it holds an empty value that is mapped to/from the empty string. The #format result of the empty value is the empty string, and the #parse result of the empty string is the empty value. In all other cases the formatting and parsing is forwarded to the wrapped NumberFormat.

Examples:

 new EmptyNumberFormat(NumberFormat().getInstance());
 new EmptyNumberFormat(NumberFormat().getIntegerInstance(), -1);
 

Version:
$Revision: 1.1 $
Author:
Karsten Lentzsch
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.text.NumberFormat
NumberFormat.Field
 
Field Summary
 
Fields inherited from class java.text.NumberFormat
FRACTION_FIELD, INTEGER_FIELD
 
Constructor Summary
EmptyNumberFormat(NumberFormat delegate)
          Constructs an EmptyNumberFormat that wraps the given mandatory format to convert null to the empty string and vice versa.
EmptyNumberFormat(NumberFormat delegate, int emptyValue)
          Constructs an EmptyNumberFormat that wraps the given mandatory format to convert the given emptyValue to the empty string and vice versa.
EmptyNumberFormat(NumberFormat delegate, Number emptyValue)
          Constructs an EmptyNumberFormat that wraps the given mandatory format to convert the given emptyValue to the empty string and vice versa.
 
Method Summary
 StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos)
           
 StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos)
           
 StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos)
           If obj is equal to the emptyValue, toAppendTo is returned.
 Number parse(String source)
           If source is empty or whitespace, the emptyValue is returned.
 Number parse(String source, ParsePosition pos)
           
 Object parseObject(String source)
           If source is empty or whitespace, the emptyValue is returned.
 
Methods inherited from class java.text.NumberFormat
clone, equals, format, format, getAvailableLocales, getCurrency, getCurrencyInstance, getCurrencyInstance, getInstance, getInstance, getIntegerInstance, getIntegerInstance, getMaximumFractionDigits, getMaximumIntegerDigits, getMinimumFractionDigits, getMinimumIntegerDigits, getNumberInstance, getNumberInstance, getPercentInstance, getPercentInstance, getRoundingMode, hashCode, isGroupingUsed, isParseIntegerOnly, parseObject, setCurrency, setGroupingUsed, setMaximumFractionDigits, setMaximumIntegerDigits, setMinimumFractionDigits, setMinimumIntegerDigits, setParseIntegerOnly, setRoundingMode
 
Methods inherited from class java.text.Format
format, formatToCharacterIterator
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EmptyNumberFormat

public EmptyNumberFormat(NumberFormat delegate)
Constructs an EmptyNumberFormat that wraps the given mandatory format to convert null to the empty string and vice versa.

Parameters:
delegate - the format that handles the standard cases
Throws:
NullPointerException - if delegate is null

EmptyNumberFormat

public EmptyNumberFormat(NumberFormat delegate,
                         int emptyValue)
Constructs an EmptyNumberFormat that wraps the given mandatory format to convert the given emptyValue to the empty string and vice versa.

Parameters:
delegate - the format that handles non-null values
emptyValue - the representation of the empty string
Throws:
NullPointerException - if delegate is null

EmptyNumberFormat

public EmptyNumberFormat(NumberFormat delegate,
                         Number emptyValue)
Constructs an EmptyNumberFormat that wraps the given mandatory format to convert the given emptyValue to the empty string and vice versa.

Parameters:
delegate - the format that handles non-null values
emptyValue - the representation of the empty string
Throws:
NullPointerException - if delegate is null
Method Detail

format

public StringBuffer format(Object obj,
                           StringBuffer toAppendTo,
                           FieldPosition pos)

If obj is equal to the emptyValue, toAppendTo is returned. Otherwise the format is forwarded to the delegate.

Overrides:
format in class NumberFormat

format

public StringBuffer format(double number,
                           StringBuffer toAppendTo,
                           FieldPosition pos)
Specified by:
format in class NumberFormat

format

public StringBuffer format(long number,
                           StringBuffer toAppendTo,
                           FieldPosition pos)
Specified by:
format in class NumberFormat

parseObject

public Object parseObject(String source)
                   throws ParseException

If source is empty or whitespace, the emptyValue is returned. Otherwise parsing is forwarded to the delegate - indirectly via parse(String, ParsePosition).

Overrides:
parseObject in class Format
Throws:
ParseException

parse

public Number parse(String source)
             throws ParseException

If source is empty or whitespace, the emptyValue is returned. Otherwise parsing is forwarded to the delegate - indirectly via parse(String, ParsePosition).

Overrides:
parse in class NumberFormat
Throws:
ParseException

parse

public Number parse(String source,
                    ParsePosition pos)
Specified by:
parse in class NumberFormat


Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/format/AbstractWrappedDateFormat.html0000644000175000017500000012374312003474124030145 0ustar tonytony AbstractWrappedDateFormat (JGoodies Common 1.4 API)

com.jgoodies.common.format
Class AbstractWrappedDateFormat

java.lang.Object
  extended by java.text.Format
      extended by java.text.DateFormat
          extended by com.jgoodies.common.format.AbstractWrappedDateFormat
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
EmptyDateFormat

public abstract class AbstractWrappedDateFormat
extends DateFormat

Reduces the effort required to write custom DateFormat implementations that retain the ability to iterate through Dates with the arrow keys in formatted text fields (using an appropriate DateFormatter). This class wraps a given DateFormat and delegates most of its behavior to the delegate, except for the abstract methods format(Date, StringBuffer, FieldPosition) and parse(String, ParsePosition) that can be overridden by a subclass. For example the subclass EmptyDateFormat wraps a DateFormat but it parses the empty String and returns null where the predefined Java DateFormats throw an exception.

Version:
$Revision: 1.1 $
Author:
Karsten Lentzsch
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.text.DateFormat
DateFormat.Field
 
Field Summary
protected  DateFormat delegate
          Refers to the wrapped Format that is used to forward #format and #parseObject.
 
Fields inherited from class java.text.DateFormat
AM_PM_FIELD, calendar, DATE_FIELD, DAY_OF_WEEK_FIELD, DAY_OF_WEEK_IN_MONTH_FIELD, DAY_OF_YEAR_FIELD, DEFAULT, ERA_FIELD, FULL, HOUR_OF_DAY0_FIELD, HOUR_OF_DAY1_FIELD, HOUR0_FIELD, HOUR1_FIELD, LONG, MEDIUM, MILLISECOND_FIELD, MINUTE_FIELD, MONTH_FIELD, numberFormat, SECOND_FIELD, SHORT, TIMEZONE_FIELD, WEEK_OF_MONTH_FIELD, WEEK_OF_YEAR_FIELD, YEAR_FIELD
 
Constructor Summary
AbstractWrappedDateFormat(DateFormat delegate)
          Constructs an AbstractWrappedDateFormat that wraps the given mandatory format.
 
Method Summary
abstract  StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition pos)
           
 AttributedCharacterIterator formatToCharacterIterator(Object obj)
           
 Calendar getCalendar()
           
 NumberFormat getNumberFormat()
           
 TimeZone getTimeZone()
           
 boolean isLenient()
           
abstract  Date parse(String source, ParsePosition pos)
           
 void setCalendar(Calendar newCalendar)
           
 void setLenient(boolean lenient)
           
 void setNumberFormat(NumberFormat newNumberFormat)
           
 void setTimeZone(TimeZone zone)
           
 
Methods inherited from class java.text.DateFormat
clone, equals, format, format, getAvailableLocales, getDateInstance, getDateInstance, getDateInstance, getDateTimeInstance, getDateTimeInstance, getDateTimeInstance, getInstance, getTimeInstance, getTimeInstance, getTimeInstance, hashCode, parse, parseObject
 
Methods inherited from class java.text.Format
format, parseObject
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

delegate

protected final DateFormat delegate
Refers to the wrapped Format that is used to forward #format and #parseObject.

Constructor Detail

AbstractWrappedDateFormat

public AbstractWrappedDateFormat(DateFormat delegate)
Constructs an AbstractWrappedDateFormat that wraps the given mandatory format.

Parameters:
delegate - the format that handles the standard cases
Throws:
NullPointerException - if delegate is null
Method Detail

format

public abstract StringBuffer format(Date date,
                                    StringBuffer toAppendTo,
                                    FieldPosition pos)
Specified by:
format in class DateFormat

parse

public abstract Date parse(String source,
                           ParsePosition pos)
Specified by:
parse in class DateFormat

getCalendar

public Calendar getCalendar()
Overrides:
getCalendar in class DateFormat

setCalendar

public void setCalendar(Calendar newCalendar)
Overrides:
setCalendar in class DateFormat

getNumberFormat

public NumberFormat getNumberFormat()
Overrides:
getNumberFormat in class DateFormat

setNumberFormat

public void setNumberFormat(NumberFormat newNumberFormat)
Overrides:
setNumberFormat in class DateFormat

getTimeZone

public TimeZone getTimeZone()
Overrides:
getTimeZone in class DateFormat

setTimeZone

public void setTimeZone(TimeZone zone)
Overrides:
setTimeZone in class DateFormat

isLenient

public boolean isLenient()
Overrides:
isLenient in class DateFormat

setLenient

public void setLenient(boolean lenient)
Overrides:
setLenient in class DateFormat

formatToCharacterIterator

public AttributedCharacterIterator formatToCharacterIterator(Object obj)
Overrides:
formatToCharacterIterator in class Format


Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/format/EmptyFormat.html0000644000175000017500000006443712003474124025363 0ustar tonytony EmptyFormat (JGoodies Common 1.4 API)

com.jgoodies.common.format
Class EmptyFormat

java.lang.Object
  extended by java.text.Format
      extended by com.jgoodies.common.format.EmptyFormat
All Implemented Interfaces:
Serializable, Cloneable

public class EmptyFormat
extends Format

Wraps a given Format and adds behavior to convert to/from the empty string. Therefore it holds an empty value (often null) that is mapped to/from the empty string. The #format result of the empty value is the empty string, and the #parse result of the empty string is the empty value. In all other cases the formatting and parsing is forwarded to the wrapped Format.

If you want to wrap a DateFormat or NumberFormat, you may use EmptyDateFormat or EmptyNumberFormat resp. Examples:

 new EmptyFormat(new WeightFormat());
 

Version:
$Revision: 1.1 $
Author:
Karsten Lentzsch
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.text.Format
Format.Field
 
Constructor Summary
EmptyFormat(Format delegate)
          Constructs an EmptyFormat that wraps the given mandatory format to convert null to the empty string and vice versa.
EmptyFormat(Format delegate, Object emptyValue)
          Constructs an EmptyFormat that wraps the given mandatory format to convert the given emptyValue to the empty string and vice versa.
 
Method Summary
 StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos)
           If obj is equal to the emptyValue, toAppendTo is returned.
 AttributedCharacterIterator formatToCharacterIterator(Object obj)
           
 Object parseObject(String source)
           If source is empty or whitespace, the emptyValue is returned.
 Object parseObject(String source, ParsePosition pos)
           
 
Methods inherited from class java.text.Format
clone, format
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EmptyFormat

public EmptyFormat(Format delegate)
Constructs an EmptyFormat that wraps the given mandatory format to convert null to the empty string and vice versa.

Parameters:
delegate - the format that handles the standard cases
Throws:
NullPointerException - if delegate is null

EmptyFormat

public EmptyFormat(Format delegate,
                   Object emptyValue)
Constructs an EmptyFormat that wraps the given mandatory format to convert the given emptyValue to the empty string and vice versa.

Parameters:
delegate - the format that handles non-null values
emptyValue - the representation of the empty string
Throws:
NullPointerException - if delegate is null
Method Detail

format

public StringBuffer format(Object obj,
                           StringBuffer toAppendTo,
                           FieldPosition pos)

If obj is equal to the emptyValue, toAppendTo is returned. Otherwise the format is forwarded to the delegate.

Specified by:
format in class Format

parseObject

public Object parseObject(String source)
                   throws ParseException

If source is empty or whitespace, the emptyValue is returned. Otherwise parsing is forwarded to the delegate.

Overrides:
parseObject in class Format
Throws:
ParseException

parseObject

public final Object parseObject(String source,
                                ParsePosition pos)
Specified by:
parseObject in class Format

formatToCharacterIterator

public final AttributedCharacterIterator formatToCharacterIterator(Object obj)
Overrides:
formatToCharacterIterator in class Format


Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/base/0000755000175000017500000000000012003474124021632 5ustar tonytonyjgoodies-common-1.4.0/docs/api/com/jgoodies/common/base/package-frame.html0000644000175000017500000000236712003474124025213 0ustar tonytony com.jgoodies.common.base (JGoodies Common 1.4 API) com.jgoodies.common.base
Classes 
Objects
Preconditions
Strings
SystemUtils
jgoodies-common-1.4.0/docs/api/com/jgoodies/common/base/Objects.html0000644000175000017500000003360512003474124024120 0ustar tonytony Objects (JGoodies Common 1.4 API)

com.jgoodies.common.base
Class Objects

java.lang.Object
  extended by com.jgoodies.common.base.Objects

public final class Objects
extends Object

Provides static methods that operate on objects.

Version:
$Revision: 1.1 $
Author:
Karsten Lentzsch

Method Summary
static
<T extends Serializable>
T
deepCopy(T original)
          Provides a means to copy objects that do not implement Cloneable.
static boolean equals(Object o1, Object o2)
          Checks and answers if the two objects are both null or equal.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

deepCopy

public static <T extends Serializable> T deepCopy(T original)
Provides a means to copy objects that do not implement Cloneable. Performs a deep copy where the copied object has no references to the original object for any object that implements Serializable. If the original is null, this method just returns null.

Type Parameters:
T - the type of the object to be cloned
Parameters:
original - the object to copied, may be null
Returns:
the copied object
Since:
1.1.1

equals

public static boolean equals(Object o1,
                             Object o2)
Checks and answers if the two objects are both null or equal.
 Objects.equals(null, null) == true
 Objects.equals("Hi", "Hi") == true
 Objects.equals("Hi", null) == false
 Objects.equals(null, "Hi") == false
 Objects.equals("Hi", "Ho") == false
 

Parameters:
o1 - the first object to compare
o2 - the second object to compare
Returns:
boolean true if and only if both objects are null or equal according to equals invoked on the first object


Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/base/package-tree.html0000644000175000017500000001530312003474124025052 0ustar tonytony com.jgoodies.common.base Class Hierarchy (JGoodies Common 1.4 API)

Hierarchy For Package com.jgoodies.common.base

Package Hierarchies:
All Packages

Class Hierarchy



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/base/Strings.html0000644000175000017500000006105212003474124024155 0ustar tonytony Strings (JGoodies Common 1.4 API)

com.jgoodies.common.base
Class Strings

java.lang.Object
  extended by com.jgoodies.common.base.Strings

public class Strings
extends Object

Provides frequently used static null-safe String testing methods .

Version:
$Revision: 1.1 $
Author:
Karsten Lentzsch

Constructor Summary
protected Strings()
           
 
Method Summary
static String abbreviateCenter(String str, int maxLength)
          Abbreviates the given string if it exceeds the given maximum length by replacing its center part with an ellipsis ('…').
static boolean isBlank(String str)
          Checks if the given string is whitespace, empty ("") or null.
static boolean isEmpty(String str)
          Checks if the given string is empty ("") or null.
static boolean isNotBlank(String str)
          Checks if the given string is not empty (""), not null and not whitespace only.
static boolean isNotEmpty(String str)
          Checks if the given string is not empty ("") and not null.
static boolean isTrimmed(String str)
          Checks if the given string is null, empty (""), or the first and last characters are not whitespace.
static boolean startsWithIgnoreCase(String str, String prefix)
          Checks if str starts with the given prefix ignoring cases.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Strings

protected Strings()
Method Detail

isBlank

public static boolean isBlank(String str)
Checks if the given string is whitespace, empty ("") or null.
 Strings.isBlank(null)    == true
 Strings.isBlank("")      == true
 Strings.isBlank(" ")     == true
 Strings.isBlank(" abc")  == false
 Strings.isBlank("abc ")  == false
 Strings.isBlank(" abc ") == false
 

Parameters:
str - the string to check, may be null
Returns:
true if the string is whitespace, empty or null
See Also:
isEmpty(String)

isNotBlank

public static boolean isNotBlank(String str)
Checks if the given string is not empty (""), not null and not whitespace only.
 Strings.isNotBlank(null)    == false
 Strings.isNotBlank("")      == false
 Strings.isNotBlank(" ")     == false
 Strings.isNotBlank(" abc")  == true
 Strings.isNotBlank("abc ")  == true
 Strings.isNotBlank(" abc ") == true
 

Parameters:
str - the string to check, may be null
Returns:
true if the string is not empty and not null and not whitespace only
See Also:
isEmpty(String)

isEmpty

public static boolean isEmpty(String str)
Checks if the given string is empty ("") or null.
 Strings.isEmpty(null)  == true
 Strings.isEmpty("")    == true
 Strings.isEmpty(" ")   == false
 Strings.isEmpty("Hi ") == false
 

Parameters:
str - the string to check, may be null
Returns:
true if the string is empty or null
See Also:
isBlank(String)

isNotEmpty

public static boolean isNotEmpty(String str)
Checks if the given string is not empty ("") and not null.
 Strings.isNotEmpty(null)  == false
 Strings.isNotEmpty("")    == false
 Strings.isNotEmpty(" ")   == true
 Strings.isNotEmpty("Hi")  == true
 Strings.isNotEmpty("Hi ") == true
 

Parameters:
str - the string to check, may be null
Returns:
true if the string is not empty and not null
See Also:
isBlank(String)

isTrimmed

public static boolean isTrimmed(String str)
Checks if the given string is null, empty (""), or the first and last characters are not whitespace.
 Strings.isTrimmed(null)  == true
 Strings.isTrimmed("")    == true
 Strings.isTrimmed(" ")   == false
 Strings.isTrimmed("Hi")  == true
 Strings.isTrimmed("Hi ") == false
 Strings.isTrimmed(" Hi") == false
 

Parameters:
str - the string to check, may be null
Returns:
true if the string is null, empty, or the first and last characters are not whitespace.
Since:
1.3

startsWithIgnoreCase

public static boolean startsWithIgnoreCase(String str,
                                           String prefix)
Checks if str starts with the given prefix ignoring cases. null is handled safely; if both arguments are null, true is returned, false otherwise.
 Strings.startsWithIgnoreCase(null, null)      == true
 Strings.startsWithIgnoreCase("a", null)       == false
 Strings.startsWithIgnoreCase(null, "a")       == false
 Strings.startsWithIgnoreCase("",  "")         == true
 Strings.startsWithIgnoreCase(" ", "")         == true
 Strings.startsWithIgnoreCase("John", "J")     == true
 Strings.startsWithIgnoreCase("John", "Jo")    == true
 Strings.startsWithIgnoreCase("John", "Joh")   == true
 Strings.startsWithIgnoreCase("John", "joh")   == true
 Strings.startsWithIgnoreCase("john", "Joh")   == true
 Strings.startsWithIgnoreCase("john", "joh")   == true
 Strings.startsWithIgnoreCase("John", "John")  == true
 Strings.startsWithIgnoreCase("John", "john")  == true
 Strings.startsWithIgnoreCase("John", "Jonny") == false
 

Parameters:
str - the test string to check, may be null
prefix - the prefix to check for, may be null
Returns:
true, if the string starts with the prefix, ignoring cases, false otherwise
See Also:
String.startsWith(java.lang.String)

abbreviateCenter

public static String abbreviateCenter(String str,
                                      int maxLength)
Abbreviates the given string if it exceeds the given maximum length by replacing its center part with an ellipsis ('…'). If the string is null or shorter than the limit, it is returned as is.

 Strings.abbreviateCenter(null,      3) == null
 Strings.abbreviateCenter("",        3) == ""
 Strings.abbreviateCenter(" ",       3) == " "
 Strings.abbreviateCenter("a",       3) == "a"
 Strings.abbreviateCenter("ab",      3) == "ab"
 Strings.abbreviateCenter("abc",     3) == "abc"
 Strings.abbreviateCenter("abcd",    3) == "a…d"
 Strings.abbreviateCenter("abcde",   3) == "a…e"
 Strings.abbreviateCenter("abcde",   4) == "ab…e"
 Strings.abbreviateCenter("abcdef",  4) == "ab…f"
 Strings.abbreviateCenter("abcdefg", 5) == "ab…fg"
 

Parameters:
str - the source string
maxLength - the maximum length of the result string
Returns:
str if its length is less than or equal to maxLength, an abbreviated string with length maxLength where the center is replaced by an ellipsis


Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/base/package-use.html0000644000175000017500000001324412003474124024711 0ustar tonytony Uses of Package com.jgoodies.common.base (JGoodies Common 1.4 API)

Uses of Package
com.jgoodies.common.base

No usage of com.jgoodies.common.base



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/base/Preconditions.html0000644000175000017500000010626212003474124025347 0ustar tonytony Preconditions (JGoodies Common 1.4 API)

com.jgoodies.common.base
Class Preconditions

java.lang.Object
  extended by com.jgoodies.common.base.Preconditions

public final class Preconditions
extends Object

Reduces the code necessary to check preconditions on method state and parameters.

Version:
$Revision: 1.1 $
Author:
Karsten Lentzsch

Method Summary
static void checkArgument(boolean expression, String message)
          Checks the truth of the given expression and throws a customized IllegalArgumentException if it is false.
static void checkArgument(boolean expression, String messageFormat, Object... messageArgs)
          Checks the truth of the given expression and throws a customized IllegalArgumentException if it is false.
static String checkNotBlank(String str, String message)
          Checks that the given string is not blank and throws a customized NullPointerException if it is null, and a customized IllegalArgumentException if it is empty or whitespace.
static String checkNotBlank(String str, String messageFormat, Object... messageArgs)
          Checks that the given string is not blank and throws a customized NullPointerException if it is null, and a customized IllegalArgumentException if it is empty or whitespace.
static
<T> T
checkNotNull(T reference, String message)
          Checks that the given object reference is not null and throws a customized NullPointerException if it is.
static
<T> T
checkNotNull(T reference, String messageFormat, Object... messageArgs)
          Checks that the given object reference is not null and throws a customized NullPointerException if it is.
static void checkState(boolean expression, String message)
          Checks the truth of the given expression and throws a customized IllegalStateException if it is false.
static void checkState(boolean expression, String messageFormat, Object... messageArgs)
          Checks the truth of the given expression and throws a customized IllegalStateException if it is false.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

checkArgument

public static void checkArgument(boolean expression,
                                 String message)
Checks the truth of the given expression and throws a customized IllegalArgumentException if it is false. Intended for doing parameter validation in methods and constructors, e.g.:
 public void foo(int count) {
    Preconditions.checkArgument(count > 0, "count must be positive.");
 }
 

Parameters:
expression - the precondition to check involving one ore more parameters to the calling method or constructor
message - the detail message to be used in the event that an exception is thrown
Throws:
IllegalArgumentException - if expression is false

checkArgument

public static void checkArgument(boolean expression,
                                 String messageFormat,
                                 Object... messageArgs)
Checks the truth of the given expression and throws a customized IllegalArgumentException if it is false. Intended for doing parameter validation in methods and constructors, e.g.:
 public void foo(int count) {
    Preconditions.checkArgument(count > 0, "count must be positive: %s.", count);
 }
 

Parameters:
expression - the precondition to check involving one ore more parameters to the calling method or constructor
messageFormat - a format string for the detail message to be used in the event that an exception is thrown.
messageArgs - the arguments referenced by the format specifiers in the messageFormat
Throws:
IllegalArgumentException - if expression is false

checkNotNull

public static <T> T checkNotNull(T reference,
                                 String message)
Checks that the given object reference is not null and throws a customized NullPointerException if it is. Intended for doing parameter validation in methods and constructors, e.g.:
 public void foo(Bar bar, Baz baz) {
      this.bar = Preconditions.checkNotNull(bar, "bar must not be null.");
      Preconditions.checkNotBull(baz, "baz must not be null.");
 }
 

Type Parameters:
T - the type of the reference
Parameters:
reference - the object reference to check for being null
message - the detail message to be used in the event that an exception is thrown
Returns:
reference if not null
Throws:
NullPointerException - if reference is null

checkNotNull

public static <T> T checkNotNull(T reference,
                                 String messageFormat,
                                 Object... messageArgs)
Checks that the given object reference is not null and throws a customized NullPointerException if it is. Intended for doing parameter validation in methods and constructors, e.g.:
 public void foo(Bar bar, Baz baz) {
      this.bar = Preconditions.checkNotNull(bar, "bar must not be null.");
      Preconditions.checkNotBull(baz, "The %s must not be null.", "baz");
 }
 

Type Parameters:
T - the type of the reference
Parameters:
reference - the object reference to check for being null
messageFormat - a format string for the detail message to be used in the event that an exception is thrown.
messageArgs - the arguments referenced by the format specifiers in the messageFormat
Returns:
reference if not null
Throws:
NullPointerException - if reference is null

checkState

public static void checkState(boolean expression,
                              String message)
Checks the truth of the given expression and throws a customized IllegalStateException if it is false. Intended for doing validation in methods involving the state of the calling instance, but not involving parameters of the calling method, e.g.:
 public void unlock() {
    Preconditions.checkState(locked, "Must be locked to be unlocked.");
 }
 

Parameters:
expression - the precondition to check involving the state of the calling instance
message - the detail message to be used in the event that an exception is thrown
Throws:
IllegalStateException - if expression is false

checkState

public static void checkState(boolean expression,
                              String messageFormat,
                              Object... messageArgs)
Checks the truth of the given expression and throws a customized IllegalStateException if it is false. Intended for doing validation in methods involving the state of the calling instance, but not involving parameters of the calling method, e.g.:
 public void unlock() {
    Preconditions.checkState(locked,
        "Must be locked to be unlocked. Most recent lock: %s",
        mostRecentLock);
 }
 

Parameters:
expression - the precondition to check involving the state of the calling instance
messageFormat - a format string for the detail message to be used in the event that an exception is thrown.
messageArgs - the arguments referenced by the format specifiers in the messageFormat
Throws:
IllegalStateException - if expression is false

checkNotBlank

public static String checkNotBlank(String str,
                                   String message)
Checks that the given string is not blank and throws a customized NullPointerException if it is null, and a customized IllegalArgumentException if it is empty or whitespace. Intended for doing parameter validation in methods and constructors, e.g.:
 public void foo(String text) {
      checkNotBlank(text, "The text must not be null, empty or whitespace.");
 }
 

Parameters:
str - the string to check for being blank
message - the detail message to be used in the event that an exception is thrown
Returns:
str if not null
Throws:
NullPointerException - if str is null
IllegalArgumentException - if str is empty or whitespace

checkNotBlank

public static String checkNotBlank(String str,
                                   String messageFormat,
                                   Object... messageArgs)
Checks that the given string is not blank and throws a customized NullPointerException if it is null, and a customized IllegalArgumentException if it is empty or whitespace. Intended for doing parameter validation in methods and constructors, e.g.:
 public void foo(String text, String id) {
      checkNotBlank(
          text,
          "The text for %s must not be null, empty or whitespace.",
          id);
 }
 

Parameters:
str - the string to check for being blank
messageFormat - a format string for the detail message to be used in the event that an exception is thrown.
messageArgs - the arguments referenced by the format specifiers in the messageFormat
Returns:
str if not null
Throws:
NullPointerException - if str is null
IllegalArgumentException - if str is empty or whitespace


Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/base/class-use/0000755000175000017500000000000012003474124023531 5ustar tonytonyjgoodies-common-1.4.0/docs/api/com/jgoodies/common/base/class-use/Objects.html0000644000175000017500000001374312003474124026020 0ustar tonytony Uses of Class com.jgoodies.common.base.Objects (JGoodies Common 1.4 API)

Uses of Class
com.jgoodies.common.base.Objects

No usage of com.jgoodies.common.base.Objects



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/base/class-use/Strings.html0000644000175000017500000001374312003474124026060 0ustar tonytony Uses of Class com.jgoodies.common.base.Strings (JGoodies Common 1.4 API)

Uses of Class
com.jgoodies.common.base.Strings

No usage of com.jgoodies.common.base.Strings



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/base/class-use/Preconditions.html0000644000175000017500000001403712003474124027244 0ustar tonytony Uses of Class com.jgoodies.common.base.Preconditions (JGoodies Common 1.4 API)

Uses of Class
com.jgoodies.common.base.Preconditions

No usage of com.jgoodies.common.base.Preconditions



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/base/class-use/SystemUtils.html0000644000175000017500000001401312003474124026723 0ustar tonytony Uses of Class com.jgoodies.common.base.SystemUtils (JGoodies Common 1.4 API)

Uses of Class
com.jgoodies.common.base.SystemUtils

No usage of com.jgoodies.common.base.SystemUtils



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/base/SystemUtils.html0000644000175000017500000007201412003474124025031 0ustar tonytony SystemUtils (JGoodies Common 1.4 API)

com.jgoodies.common.base
Class SystemUtils

java.lang.Object
  extended by com.jgoodies.common.base.SystemUtils

public class SystemUtils
extends Object

Provides convenience behavior to determine the operating system and Java version.

Version:
$Revision: 1.2 $
Author:
Karsten Lentzsch

Field Summary
static boolean HAS_MODERN_RASTERIZER
          True since Java 6 update 10.
static boolean IS_JAVA_6
          True if this is Java 6.
static boolean IS_JAVA_7
          True if this is Java 7.
static boolean IS_JAVA_7_OR_LATER
          True if this is Java 7.x or later.
static boolean IS_LAF_WINDOWS_XP_ENABLED
          True if the Windows XP Look&Feel is enabled.
static boolean IS_LOW_RESOLUTION
          Is true if this environment's default toolkit reports a screen resolution below 120 dpi.
static boolean IS_OS_LINUX
          Is true if this is Linux.
static boolean IS_OS_MAC
          True if this is the Mac OS.
static boolean IS_OS_SOLARIS
          True if this is Solaris.
static boolean IS_OS_WINDOWS
          True if this is Windows.
static boolean IS_OS_WINDOWS_2000
          True if this is Windows 2000.
static boolean IS_OS_WINDOWS_6_OR_LATER
          True if this is Windows Vista/Server 2008/7/2008 R2.
static boolean IS_OS_WINDOWS_7
          True if this is Windows 7.
static boolean IS_OS_WINDOWS_8
          True if this is Windows 8.
static boolean IS_OS_WINDOWS_98
          True if this is Windows 98.
static boolean IS_OS_WINDOWS_ME
          True if this is Windows ME.
static boolean IS_OS_WINDOWS_VISTA
          True if this is Windows Vista or Server 2008.
static boolean IS_OS_WINDOWS_XP
          True if this is Windows XP.
protected static String JAVA_VERSION
          The os.name System Property.
protected static String OS_NAME
          The os.name System Property.
protected static String OS_VERSION
          The os.version System Property.
 
Constructor Summary
protected SystemUtils()
           
 
Method Summary
protected static String getSystemProperty(String key)
          Tries to look up the System property for the given key.
protected static boolean startsWith(String str, String prefix)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OS_NAME

protected static final String OS_NAME
The os.name System Property. Operating system name.

Defaults to null, if the runtime does not have security access to read this property or the property does not exist.


OS_VERSION

protected static final String OS_VERSION
The os.version System Property. Operating system version.

Defaults to null, if the runtime does not have security access to read this property or the property does not exist.


JAVA_VERSION

protected static final String JAVA_VERSION
The os.name System Property. Operating system name.

Defaults to null, if the runtime does not have security access to read this property or the property does not exist.


IS_OS_LINUX

public static final boolean IS_OS_LINUX
Is true if this is Linux.


IS_OS_MAC

public static final boolean IS_OS_MAC
True if this is the Mac OS.


IS_OS_SOLARIS

public static final boolean IS_OS_SOLARIS
True if this is Solaris.


IS_OS_WINDOWS

public static final boolean IS_OS_WINDOWS
True if this is Windows.


IS_OS_WINDOWS_98

public static final boolean IS_OS_WINDOWS_98
True if this is Windows 98.


IS_OS_WINDOWS_ME

public static final boolean IS_OS_WINDOWS_ME
True if this is Windows ME.


IS_OS_WINDOWS_2000

public static final boolean IS_OS_WINDOWS_2000
True if this is Windows 2000.


IS_OS_WINDOWS_XP

public static final boolean IS_OS_WINDOWS_XP
True if this is Windows XP.


IS_OS_WINDOWS_VISTA

public static final boolean IS_OS_WINDOWS_VISTA
True if this is Windows Vista or Server 2008.


IS_OS_WINDOWS_7

public static final boolean IS_OS_WINDOWS_7
True if this is Windows 7.


IS_OS_WINDOWS_8

public static final boolean IS_OS_WINDOWS_8
True if this is Windows 8.


IS_OS_WINDOWS_6_OR_LATER

public static final boolean IS_OS_WINDOWS_6_OR_LATER
True if this is Windows Vista/Server 2008/7/2008 R2.


IS_JAVA_6

public static final boolean IS_JAVA_6
True if this is Java 6. We check for a prefix of 1.6.


IS_JAVA_7

public static final boolean IS_JAVA_7
True if this is Java 7. We check for a prefix of 1.7.


IS_JAVA_7_OR_LATER

public static final boolean IS_JAVA_7_OR_LATER
True if this is Java 7.x or later. We check that it's not 1.6.


HAS_MODERN_RASTERIZER

public static final boolean HAS_MODERN_RASTERIZER
True since Java 6 update 10.

Since:
1.2

IS_LAF_WINDOWS_XP_ENABLED

public static final boolean IS_LAF_WINDOWS_XP_ENABLED
True if the Windows XP Look&Feel is enabled.

Since:
1.2

IS_LOW_RESOLUTION

public static final boolean IS_LOW_RESOLUTION
Is true if this environment's default toolkit reports a screen resolution below 120 dpi.

Since:
1.2
Constructor Detail

SystemUtils

protected SystemUtils()
Method Detail

getSystemProperty

protected static String getSystemProperty(String key)
Tries to look up the System property for the given key. In untrusted environments this may throw a SecurityException. In this case we catch the exception and answer an empty string.

Parameters:
key - the name of the system property
Returns:
the system property's String value, or null if there's no such value, or an empty String when a SecurityException has been caught

startsWith

protected static boolean startsWith(String str,
                                    String prefix)


Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/base/package-summary.html0000644000175000017500000001725612003474124025621 0ustar tonytony com.jgoodies.common.base (JGoodies Common 1.4 API)

Package com.jgoodies.common.base

Consists of frequently used utility classes for general Java code

See:
          Description

Class Summary
Objects Provides static methods that operate on objects.
Preconditions Reduces the code necessary to check preconditions on method state and parameters.
Strings Provides frequently used static null-safe String testing methods .
SystemUtils Provides convenience behavior to determine the operating system and Java version.
 

Package com.jgoodies.common.base Description

Consists of frequently used utility classes for general Java code.



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/collect/0000755000175000017500000000000012003474124022345 5ustar tonytonyjgoodies-common-1.4.0/docs/api/com/jgoodies/common/collect/LinkedListModel.html0000644000175000017500000022020112003474124026253 0ustar tonytony LinkedListModel (JGoodies Common 1.4 API)

com.jgoodies.common.collect
Class LinkedListModel<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.AbstractSequentialList<E>
              extended by java.util.LinkedList<E>
                  extended by com.jgoodies.common.collect.LinkedListModel<E>
Type Parameters:
E - the type of the list elements
All Implemented Interfaces:
ObservableList<E>, Serializable, Cloneable, Iterable<E>, Collection<E>, Deque<E>, List<E>, Queue<E>, ListModel

public class LinkedListModel<E>
extends LinkedList<E>
implements ObservableList<E>

Adds ListModel capabilities to its superclass. It allows to observe changes in the content and structure. Useful for Lists that are bound to list views such as JList, JComboBox and JTable.

This class should be be final and it will be marked final in a future version, if its subclass in the JGoodies Binding has been removed.

Version:
$Revision: 1.1 $
Author:
Karsten Lentzsch
See Also:
ObservableList, ArrayListModel, Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
LinkedListModel()
          Constructs an empty LinkedListModel.
LinkedListModel(Collection<? extends E> c)
          Constructs a LinkedListModel containing the elements of the specified collection, in the order they are returned by the collection's iterator.
 
Method Summary
 boolean add(E e)
           
 void add(int index, E element)
           
 boolean addAll(int index, Collection<? extends E> c)
           
 void addFirst(E e)
           
 void addLast(E e)
           
 void addListDataListener(ListDataListener l)
           
 void clear()
           
 void fireContentsChanged(int index)
          Notifies all registered ListDataListeners that the element at the specified index has changed.
 E getElementAt(int index)
           
 ListDataListener[] getListDataListeners()
          Returns an array of all the list data listeners registered on this LinkedListModel.
 int getSize()
           
 ListIterator<E> listIterator(int index)
           
 E remove(int index)
           
 boolean remove(Object o)
           
 boolean removeAll(Collection<?> c)
          Removes from this collection all of its elements that are contained in the specified collection (optional operation).
 E removeFirst()
           
 E removeLast()
           
 void removeListDataListener(ListDataListener l)
           
protected  void removeRange(int fromIndex, int toIndex)
           
 boolean retainAll(Collection<?> c)
          Retains only the elements in this collection that are contained in the specified collection (optional operation).
 E set(int index, E element)
           
 
Methods inherited from class java.util.LinkedList
addAll, clone, contains, descendingIterator, element, get, getFirst, getLast, indexOf, lastIndexOf, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, pop, push, remove, removeFirstOccurrence, removeLastOccurrence, size, toArray, toArray
 
Methods inherited from class java.util.AbstractSequentialList
iterator
 
Methods inherited from class java.util.AbstractList
equals, hashCode, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
addAll, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, size, subList, toArray, toArray
 
Methods inherited from interface java.util.Deque
iterator
 

Constructor Detail

LinkedListModel

public LinkedListModel()
Constructs an empty LinkedListModel.


LinkedListModel

public LinkedListModel(Collection<? extends E> c)
Constructs a LinkedListModel containing the elements of the specified collection, in the order they are returned by the collection's iterator.

Parameters:
c - the collection whose elements are to be placed into this list.
Throws:
NullPointerException - if c is null
Method Detail

add

public final void add(int index,
                      E element)
Specified by:
add in interface List<E>
Overrides:
add in class LinkedList<E>

add

public final boolean add(E e)
Specified by:
add in interface Collection<E>
Specified by:
add in interface Deque<E>
Specified by:
add in interface List<E>
Specified by:
add in interface Queue<E>
Overrides:
add in class LinkedList<E>

addAll

public final boolean addAll(int index,
                            Collection<? extends E> c)
Specified by:
addAll in interface List<E>
Overrides:
addAll in class LinkedList<E>

removeAll

public boolean removeAll(Collection<?> c)
Removes from this collection all of its elements that are contained in the specified collection (optional operation).

This implementation iterates over this collection, checking each element returned by the iterator in turn to see if it's contained in the specified collection. If it's so contained, it's removed from this collection with the iterator's remove method.

Note that this implementation will throw an UnsupportedOperationException if the iterator returned by the iterator method does not implement the remove method and this collection contains one or more elements in common with the specified collection.

Specified by:
removeAll in interface Collection<E>
Specified by:
removeAll in interface List<E>
Overrides:
removeAll in class AbstractCollection<E>
Parameters:
c - elements to be removed from this collection.
Returns:
true if this collection changed as a result of the call.
Throws:
UnsupportedOperationException - if the removeAll method is not supported by this collection.
NullPointerException - if the specified collection is null.
See Also:
remove(Object), LinkedList.contains(Object)

retainAll

public boolean retainAll(Collection<?> c)
Retains only the elements in this collection that are contained in the specified collection (optional operation). In other words, removes from this collection all of its elements that are not contained in the specified collection.

This implementation iterates over this collection, checking each element returned by the iterator in turn to see if it's contained in the specified collection. If it's not so contained, it's removed from this collection with the iterator's remove method.

Note that this implementation will throw an UnsupportedOperationException if the iterator returned by the iterator method does not implement the remove method and this collection contains one or more elements not present in the specified collection.

Specified by:
retainAll in interface Collection<E>
Specified by:
retainAll in interface List<E>
Overrides:
retainAll in class AbstractCollection<E>
Parameters:
c - elements to be retained in this collection.
Returns:
true if this collection changed as a result of the call.
Throws:
UnsupportedOperationException - if the retainAll method is not supported by this Collection.
NullPointerException - if the specified collection is null.
See Also:
remove(Object), LinkedList.contains(Object)

addFirst

public final void addFirst(E e)
Specified by:
addFirst in interface Deque<E>
Overrides:
addFirst in class LinkedList<E>

addLast

public final void addLast(E e)
Specified by:
addLast in interface Deque<E>
Overrides:
addLast in class LinkedList<E>

clear

public final void clear()
Specified by:
clear in interface Collection<E>
Specified by:
clear in interface List<E>
Overrides:
clear in class LinkedList<E>

remove

public final E remove(int index)
Specified by:
remove in interface List<E>
Overrides:
remove in class LinkedList<E>

remove

public final boolean remove(Object o)
Specified by:
remove in interface Collection<E>
Specified by:
remove in interface Deque<E>
Specified by:
remove in interface List<E>
Overrides:
remove in class LinkedList<E>

removeFirst

public final E removeFirst()
Specified by:
removeFirst in interface Deque<E>
Overrides:
removeFirst in class LinkedList<E>

removeLast

public final E removeLast()
Specified by:
removeLast in interface Deque<E>
Overrides:
removeLast in class LinkedList<E>

removeRange

protected final void removeRange(int fromIndex,
                                 int toIndex)
Overrides:
removeRange in class AbstractList<E>

set

public final E set(int index,
                   E element)
Specified by:
set in interface List<E>
Overrides:
set in class LinkedList<E>

listIterator

public final ListIterator<E> listIterator(int index)
Specified by:
listIterator in interface List<E>
Overrides:
listIterator in class LinkedList<E>

addListDataListener

public final void addListDataListener(ListDataListener l)
Specified by:
addListDataListener in interface ListModel

removeListDataListener

public final void removeListDataListener(ListDataListener l)
Specified by:
removeListDataListener in interface ListModel

getElementAt

public final E getElementAt(int index)
Specified by:
getElementAt in interface ListModel

getSize

public final int getSize()
Specified by:
getSize in interface ListModel

fireContentsChanged

public final void fireContentsChanged(int index)
Notifies all registered ListDataListeners that the element at the specified index has changed. Useful if there's a content change without any structural change.

This method must be called after the element of the list changes.

Parameters:
index - the index of the element that has changed
See Also:
EventListenerList

getListDataListeners

public final ListDataListener[] getListDataListeners()
Returns an array of all the list data listeners registered on this LinkedListModel.

Returns:
all of this model's ListDataListeners, or an empty array if no list data listeners are currently registered
See Also:
addListDataListener(ListDataListener), removeListDataListener(ListDataListener)


Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/collect/package-frame.html0000644000175000017500000000260412003474124025720 0ustar tonytony com.jgoodies.common.collect (JGoodies Common 1.4 API) com.jgoodies.common.collect
Interfaces 
ObservableList
Classes 
ArrayListModel
LinkedListModel
jgoodies-common-1.4.0/docs/api/com/jgoodies/common/collect/package-tree.html0000644000175000017500000002652512003474124025575 0ustar tonytony com.jgoodies.common.collect Class Hierarchy (JGoodies Common 1.4 API)

Hierarchy For Package com.jgoodies.common.collect

Package Hierarchies:
All Packages

Class Hierarchy

Interface Hierarchy



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/collect/ArrayListModel.html0000644000175000017500000017105012003474124026132 0ustar tonytony ArrayListModel (JGoodies Common 1.4 API)

com.jgoodies.common.collect
Class ArrayListModel<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<E>
              extended by com.jgoodies.common.collect.ArrayListModel<E>
Type Parameters:
E - the type of the list elements
All Implemented Interfaces:
ObservableList<E>, Serializable, Cloneable, Iterable<E>, Collection<E>, List<E>, RandomAccess, ListModel

public class ArrayListModel<E>
extends ArrayList<E>
implements ObservableList<E>

Adds ListModel capabilities to its superclass. It allows to observe changes in the content and structure. Useful for Lists that are bound to list views such as JList, JComboBox and JTable.

This class should be be final and it will be marked final in a future version, if its subclass in the JGoodies Binding has been removed.

Version:
$Revision: 1.1 $
Author:
Karsten Lentzsch
See Also:
ObservableList, LinkedListModel, Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
ArrayListModel()
          Constructs an empty list with an initial capacity of ten.
ArrayListModel(Collection<? extends E> c)
          Constructs a list containing the elements of the specified collection, in the order they are returned by the collection's iterator.
ArrayListModel(int initialCapacity)
          Constructs an empty list with the specified initial capacity.
 
Method Summary
 boolean add(E e)
           
 void add(int index, E element)
           
 boolean addAll(Collection<? extends E> c)
           
 boolean addAll(int index, Collection<? extends E> c)
           
 void addListDataListener(ListDataListener l)
           
 void clear()
           
 void fireContentsChanged(int index)
          Notifies all registered ListDataListeners that the element at the specified index has changed.
 Object getElementAt(int index)
           
 ListDataListener[] getListDataListeners()
          Returns an array of all the list data listeners registered on this ArrayListModel.
 int getSize()
           
 E remove(int index)
           
 boolean remove(Object o)
           
 boolean removeAll(Collection<?> c)
          Removes from this collection all of its elements that are contained in the specified collection (optional operation).
 void removeListDataListener(ListDataListener l)
           
protected  void removeRange(int fromIndex, int toIndex)
           
 boolean retainAll(Collection<?> c)
          Retains only the elements in this collection that are contained in the specified collection (optional operation).
 E set(int index, E element)
           
 
Methods inherited from class java.util.ArrayList
clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, size, subList, toArray, toArray
 

Constructor Detail

ArrayListModel

public ArrayListModel()
Constructs an empty list with an initial capacity of ten.


ArrayListModel

public ArrayListModel(int initialCapacity)
Constructs an empty list with the specified initial capacity.

Parameters:
initialCapacity - the initial capacity of the list.
Throws:
IllegalArgumentException - if the specified initial capacity is negative

ArrayListModel

public ArrayListModel(Collection<? extends E> c)
Constructs a list containing the elements of the specified collection, in the order they are returned by the collection's iterator. The ArrayListModel instance has an initial capacity of 110% the size of the specified collection.

Parameters:
c - the collection whose elements are to be placed into this list.
Throws:
NullPointerException - if the specified collection is null
Method Detail

add

public final void add(int index,
                      E element)
Specified by:
add in interface List<E>
Overrides:
add in class ArrayList<E>

add

public final boolean add(E e)
Specified by:
add in interface Collection<E>
Specified by:
add in interface List<E>
Overrides:
add in class ArrayList<E>

addAll

public final boolean addAll(int index,
                            Collection<? extends E> c)
Specified by:
addAll in interface List<E>
Overrides:
addAll in class ArrayList<E>

addAll

public final boolean addAll(Collection<? extends E> c)
Specified by:
addAll in interface Collection<E>
Specified by:
addAll in interface List<E>
Overrides:
addAll in class ArrayList<E>

removeAll

public boolean removeAll(Collection<?> c)
Removes from this collection all of its elements that are contained in the specified collection (optional operation).

This implementation iterates over this collection, checking each element returned by the iterator in turn to see if it's contained in the specified collection. If it's so contained, it's removed from this collection with the iterator's remove method.

Note that this implementation will throw an UnsupportedOperationException if the iterator returned by the iterator method does not implement the remove method and this collection contains one or more elements in common with the specified collection.

Specified by:
removeAll in interface Collection<E>
Specified by:
removeAll in interface List<E>
Overrides:
removeAll in class AbstractCollection<E>
Parameters:
c - elements to be removed from this collection.
Returns:
true if this collection changed as a result of the call.
Throws:
UnsupportedOperationException - if the removeAll method is not supported by this collection.
NullPointerException - if the specified collection is null.
See Also:
remove(Object), ArrayList.contains(Object)

retainAll

public boolean retainAll(Collection<?> c)
Retains only the elements in this collection that are contained in the specified collection (optional operation). In other words, removes from this collection all of its elements that are not contained in the specified collection.

This implementation iterates over this collection, checking each element returned by the iterator in turn to see if it's contained in the specified collection. If it's not so contained, it's removed from this collection with the iterator's remove method.

Note that this implementation will throw an UnsupportedOperationException if the iterator returned by the iterator method does not implement the remove method and this collection contains one or more elements not present in the specified collection.

Specified by:
retainAll in interface Collection<E>
Specified by:
retainAll in interface List<E>
Overrides:
retainAll in class AbstractCollection<E>
Parameters:
c - elements to be retained in this collection.
Returns:
true if this collection changed as a result of the call.
Throws:
UnsupportedOperationException - if the retainAll method is not supported by this Collection.
NullPointerException - if the specified collection is null.
See Also:
remove(Object), ArrayList.contains(Object)

clear

public final void clear()
Specified by:
clear in interface Collection<E>
Specified by:
clear in interface List<E>
Overrides:
clear in class ArrayList<E>

remove

public final E remove(int index)
Specified by:
remove in interface List<E>
Overrides:
remove in class ArrayList<E>

remove

public final boolean remove(Object o)
Specified by:
remove in interface Collection<E>
Specified by:
remove in interface List<E>
Overrides:
remove in class ArrayList<E>

removeRange

protected final void removeRange(int fromIndex,
                                 int toIndex)
Overrides:
removeRange in class ArrayList<E>

set

public final E set(int index,
                   E element)
Specified by:
set in interface List<E>
Overrides:
set in class ArrayList<E>

addListDataListener

public final void addListDataListener(ListDataListener l)
Specified by:
addListDataListener in interface ListModel

removeListDataListener

public final void removeListDataListener(ListDataListener l)
Specified by:
removeListDataListener in interface ListModel

getElementAt

public final Object getElementAt(int index)
Specified by:
getElementAt in interface ListModel

getSize

public final int getSize()
Specified by:
getSize in interface ListModel

fireContentsChanged

public final void fireContentsChanged(int index)
Notifies all registered ListDataListeners that the element at the specified index has changed. Useful if there's a content change without any structural change.

This method must be called after the element of the list changes.

Parameters:
index - the index of the element that has changed
See Also:
EventListenerList

getListDataListeners

public final ListDataListener[] getListDataListeners()
Returns an array of all the list data listeners registered on this ArrayListModel.

Returns:
all of this model's ListDataListeners, or an empty array if no list data listeners are currently registered
See Also:
addListDataListener(ListDataListener), removeListDataListener(ListDataListener)


Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/collect/package-use.html0000644000175000017500000001644112003474124025426 0ustar tonytony Uses of Package com.jgoodies.common.collect (JGoodies Common 1.4 API)

Uses of Package
com.jgoodies.common.collect

Packages that use com.jgoodies.common.collect
com.jgoodies.common.collect Consists of classes that add ListModel features to List implementations 
 

Classes in com.jgoodies.common.collect used by com.jgoodies.common.collect
ObservableList
          Combines the List and ListModel interfaces.
 



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/collect/class-use/0000755000175000017500000000000012003474124024244 5ustar tonytonyjgoodies-common-1.4.0/docs/api/com/jgoodies/common/collect/class-use/LinkedListModel.html0000644000175000017500000001412112003474124030154 0ustar tonytony Uses of Class com.jgoodies.common.collect.LinkedListModel (JGoodies Common 1.4 API)

Uses of Class
com.jgoodies.common.collect.LinkedListModel

No usage of com.jgoodies.common.collect.LinkedListModel



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/collect/class-use/ArrayListModel.html0000644000175000017500000001410712003474124030030 0ustar tonytony Uses of Class com.jgoodies.common.collect.ArrayListModel (JGoodies Common 1.4 API)

Uses of Class
com.jgoodies.common.collect.ArrayListModel

No usage of com.jgoodies.common.collect.ArrayListModel



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/collect/class-use/ObservableList.html0000644000175000017500000002143412003474124030056 0ustar tonytony Uses of Interface com.jgoodies.common.collect.ObservableList (JGoodies Common 1.4 API)

Uses of Interface
com.jgoodies.common.collect.ObservableList

Packages that use ObservableList
com.jgoodies.common.collect Consists of classes that add ListModel features to List implementations 
 

Uses of ObservableList in com.jgoodies.common.collect
 

Classes in com.jgoodies.common.collect that implement ObservableList
 class ArrayListModel<E>
          Adds ListModel capabilities to its superclass.
 class LinkedListModel<E>
          Adds ListModel capabilities to its superclass.
 



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/collect/package-summary.html0000644000175000017500000002071712003474124026330 0ustar tonytony com.jgoodies.common.collect (JGoodies Common 1.4 API)

Package com.jgoodies.common.collect

Consists of classes that add ListModel features to List implementations

See:
          Description

Interface Summary
ObservableList<E> Combines the List and ListModel interfaces.
 

Class Summary
ArrayListModel<E> Adds ListModel capabilities to its superclass.
LinkedListModel<E> Adds ListModel capabilities to its superclass.
 

Package com.jgoodies.common.collect Description

Consists of classes that add ListModel features to List implementations.



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/com/jgoodies/common/collect/ObservableList.html0000644000175000017500000003665512003474124026172 0ustar tonytony ObservableList (JGoodies Common 1.4 API)

com.jgoodies.common.collect
Interface ObservableList<E>

Type Parameters:
E - the type of the list elements
All Superinterfaces:
Collection<E>, Iterable<E>, List<E>, ListModel
All Known Implementing Classes:
ArrayListModel, LinkedListModel

public interface ObservableList<E>
extends List<E>, ListModel

Combines the List and ListModel interfaces. Useful to specify a type that operates like a List and is published as a ListModel so it can be bound to user interface components such as JList, JTable and JComboBox.

The JGoodies Common ships two predefined implementations: ArrayListModel and LinkedListModel.

Version:
$Revision: 1.1 $
Author:
Karsten Lentzsch

Method Summary
 
Methods inherited from interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, size, subList, toArray, toArray
 
Methods inherited from interface javax.swing.ListModel
addListDataListener, getElementAt, getSize, removeListDataListener
 



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/index.html0000644000175000017500000000264412003474124017052 0ustar tonytony JGoodies Common 1.4 API <H2> Frame Alert</H2> <P> This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. <BR> Link to<A HREF="overview-summary.html">Non-frame version.</A> jgoodies-common-1.4.0/docs/api/deprecated-list.html0000644000175000017500000001234312003474124021011 0ustar tonytony Deprecated List (JGoodies Common 1.4 API)

Deprecated API


Contents


Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/overview-summary.html0000644000175000017500000001645612003474124021312 0ustar tonytony Overview (JGoodies Common 1.4 API)

JGoodies Common 1.4 API

This document describes the API of the JGoodies Common, a library that provides convenience code for other JGoodies libraries and applications.

See:
          Description

Packages
com.jgoodies.common.base Consists of frequently used utility classes for general Java code
com.jgoodies.common.bean Consists of classes for working with Java Beans
com.jgoodies.common.collect Consists of classes that add ListModel features to List implementations
com.jgoodies.common.format Consists of Format implementations and wrappers
com.jgoodies.common.internal Consists of internal classes that are not part of the public API.
com.jgoodies.common.swing Consists of Swing related classes

 

This document describes the API of the JGoodies Common, a library that provides convenience code for other JGoodies libraries and applications. It requires Java 6 or later.



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/serialized-form.html0000644000175000017500000004652712003474124021047 0ustar tonytony Serialized Form (JGoodies Common 1.4 API)

Serialized Form


Package com.jgoodies.common.bean

Class com.jgoodies.common.bean.AbstractBean extends Bean implements Serializable

Class com.jgoodies.common.bean.Bean extends Object implements Serializable

Serialized Fields

changeSupport

PropertyChangeSupport changeSupport
If anyPropertyChangeListeners have been registered, the changeSupport field describes them.

See Also:
Bean.addPropertyChangeListener(PropertyChangeListener), Bean.addPropertyChangeListener(String, PropertyChangeListener), Bean.removePropertyChangeListener(PropertyChangeListener), Bean.removePropertyChangeListener(String, PropertyChangeListener), PropertyChangeSupport

vetoSupport

VetoableChangeSupport vetoSupport
If any VetoableChangeListeners have been registered, the vetoSupport field describes them.

See Also:
Bean.addVetoableChangeListener(VetoableChangeListener), Bean.addVetoableChangeListener(String, VetoableChangeListener), Bean.removeVetoableChangeListener(VetoableChangeListener), Bean.removeVetoableChangeListener(String, VetoableChangeListener), Bean.fireVetoableChange(String, Object, Object)

Package com.jgoodies.common.collect

Class com.jgoodies.common.collect.ArrayListModel extends ArrayList<E> implements Serializable

serialVersionUID: -6165677201152015546L

Serialized Fields

listenerList

EventListenerList listenerList
Holds the registered ListDataListeners. The list that holds these listeners is initialized lazily in #getEventListenerList.

See Also:
ArrayListModel.addListDataListener(ListDataListener), ArrayListModel.removeListDataListener(ListDataListener)

Class com.jgoodies.common.collect.LinkedListModel extends LinkedList<E> implements Serializable

serialVersionUID: 5753378113505707237L

Serialized Fields

listenerList

EventListenerList listenerList
Holds the registered ListDataListeners. The list that holds these listeners is initialized lazily in #getEventListenerList.

See Also:
LinkedListModel.addListDataListener(ListDataListener), LinkedListModel.removeListDataListener(ListDataListener)

Package com.jgoodies.common.format

Class com.jgoodies.common.format.AbstractWrappedDateFormat extends DateFormat implements Serializable

Serialized Fields

delegate

DateFormat delegate
Refers to the wrapped Format that is used to forward #format and #parseObject.

Class com.jgoodies.common.format.EmptyDateFormat extends AbstractWrappedDateFormat implements Serializable

Serialized Fields

emptyValue

Date emptyValue
Holds the object that represents the empty value. The result of formatting this value is the empty string; the result of parsing an empty string is this object.

Class com.jgoodies.common.format.EmptyFormat extends Format implements Serializable

Serialized Fields

delegate

Format delegate
Refers to the wrapped Format that is used to forward #format and #parseObject.


emptyValue

Object emptyValue
Holds the object that represents the empty value. The result of formatting this value is the empty string; the result of parsing an empty string is this object.

Class com.jgoodies.common.format.EmptyNumberFormat extends NumberFormat implements Serializable

Serialized Fields

delegate

NumberFormat delegate

emptyValue

Number emptyValue



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/overview-frame.html0000644000175000017500000000340112003474124020671 0ustar tonytony Overview List (JGoodies Common 1.4 API)
All Classes

Packages
com.jgoodies.common.base
com.jgoodies.common.bean
com.jgoodies.common.collect
com.jgoodies.common.format
com.jgoodies.common.internal
com.jgoodies.common.swing

  jgoodies-common-1.4.0/docs/api/help-doc.html0000644000175000017500000002350612003474124017436 0ustar tonytony API Help (JGoodies Common 1.4 API)



How This API Document Is Organized

This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.

Overview

The Overview page is the front page of this API document and provides a list of all packages with a summary for each. This page can also contain an overall description of the set of packages.

Package

Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain four categories:

  • Interfaces (italic)
  • Classes
  • Enums
  • Exceptions
  • Errors
  • Annotation Types

Class/Interface

Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

  • Class inheritance diagram
  • Direct Subclasses
  • All Known Subinterfaces
  • All Known Implementing Classes
  • Class/interface declaration
  • Class/interface description

  • Nested Class Summary
  • Field Summary
  • Constructor Summary
  • Method Summary

  • Field Detail
  • Constructor Detail
  • Method Detail
Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.

Annotation Type

Each annotation type has its own separate page with the following sections:

  • Annotation Type declaration
  • Annotation Type description
  • Required Element Summary
  • Optional Element Summary
  • Element Detail

Enum

Each enum has its own separate page with the following sections:

  • Enum declaration
  • Enum description
  • Enum Constant Summary
  • Enum Constant Detail

Use

Each documented package, class and interface has its own Use page. This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its Use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. You can access this page by first going to the package, class or interface, then clicking on the "Use" link in the navigation bar.

Tree (Class Hierarchy)

There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.
  • When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
  • When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.

Deprecated API

The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.

Index

The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.

Prev/Next

These links take you to the next or previous class, interface, package, or related page.

Frames/No Frames

These links show and hide the HTML frames. All pages are available with or without frames.

Serialized Form

Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.

Constant Field Values

The Constant Field Values page lists the static final fields and their values.

This help file applies to API documentation generated using the standard doclet.



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/docs/api/overview-tree.html0000644000175000017500000004361712003474124020553 0ustar tonytony Class Hierarchy (JGoodies Common 1.4 API)

Hierarchy For All Packages

Package Hierarchies:
com.jgoodies.common.base, com.jgoodies.common.bean, com.jgoodies.common.collect, com.jgoodies.common.format, com.jgoodies.common.internal, com.jgoodies.common.swing

Class Hierarchy

Interface Hierarchy



Copyright © 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. jgoodies-common-1.4.0/src/0000755000175000017500000000000012052274566014151 5ustar tonytonyjgoodies-common-1.4.0/src/main/0000755000175000017500000000000012052274566015075 5ustar tonytonyjgoodies-common-1.4.0/src/main/java/0000755000175000017500000000000012052274512016005 5ustar tonytonyjgoodies-common-1.4.0/src/main/java/overview.html0000644000175000017500000000376011743062322020547 0ustar tonytony This document describes the API of the JGoodies Common, a library that provides convenience code for other JGoodies libraries and applications. It requires Java 6 or later. jgoodies-common-1.4.0/src/main/java/META-INF/0000755000175000017500000000000012003474132017141 5ustar tonytonyjgoodies-common-1.4.0/src/main/java/META-INF/MANIFEST.MF0000644000175000017500000000014712003474130020573 0ustar tonytonyManifest-Version: 1.0 Ant-Version: Apache Ant 1.8.2 Created-By: 1.7.0_05-b05 (Oracle Corporation) jgoodies-common-1.4.0/src/main/java/com/0000755000175000017500000000000011731046166016570 5ustar tonytonyjgoodies-common-1.4.0/src/main/java/com/jgoodies/0000755000175000017500000000000011731046166020373 5ustar tonytonyjgoodies-common-1.4.0/src/main/java/com/jgoodies/common/0000755000175000017500000000000011731046166021663 5ustar tonytonyjgoodies-common-1.4.0/src/main/java/com/jgoodies/common/internal/0000755000175000017500000000000011772611670023502 5ustar tonytonyjgoodies-common-1.4.0/src/main/java/com/jgoodies/common/internal/package.html0000644000175000017500000000425511730624764025773 0ustar tonytony Consists of internal classes that are not part of the public API. These classes should not be used by API users. They may be removed or changed without further notice. jgoodies-common-1.4.0/src/main/java/com/jgoodies/common/internal/StringLocalizer.java0000644000175000017500000000520111762120100027434 0ustar tonytony/* * Copyright (c) 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jgoodies.common.internal; /** * Describes an object that can localize Strings accessible via a key.

* * This interface is used by the JGoodies Forms to localize Strings * from ResourceBundles and ResourceMaps (a class from JGoodies Application). * The latter implements this StringLocalizer interface. Since ResourceBundle * does not implement this interface, a wrapper can be used that implements * this interface and just delegates to the ResourceBundle to look up the * localized String.

* * Note: This class is not part of the public JGoodies Common API. * It's intended for implementation purposes only. * The class's API may change at any time. * * @author Karsten Lentzsch * @version $Revision: 1.2 $ * * @since 1.4 */ public interface StringLocalizer { /** * Returns a localized String for the given key. * * @param key the key used to look up the localized String * @return the localized String */ String getString(String key); } jgoodies-common-1.4.0/src/main/java/com/jgoodies/common/internal/IActionBean.java0000644000175000017500000000421711762120100026443 0ustar tonytony/* * Copyright (c) 2002-2012 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jgoodies.common.internal; import com.jgoodies.common.bean.ObservableBean2; /** * Describes beans that can look up an Action for a given Action name.

* * Note: This class is not part of the public JGoodies Common API. * It's intended for implementation purposes only. * The class's API may change at any time. * * @author Karsten Lentzsch * @version $Revision: 1.3 $ * * @since 1.4 */ public interface IActionBean extends ObservableBean2, IActionObject { // Just a combined interface }jgoodies-common-1.4.0/src/main/java/com/jgoodies/common/internal/RenderingUtils.java0000644000175000017500000002630111762120100027263 0ustar tonytony/* * Copyright (c) 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jgoodies.common.internal; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.GraphicsDevice; import java.awt.PrintGraphics; import java.awt.RenderingHints; import java.awt.Toolkit; import java.awt.print.PrinterGraphics; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import javax.swing.JComponent; import javax.swing.plaf.basic.BasicGraphicsUtils; /** * Provides convenience behavior for drawing strings, underline chars, * and accessing font metrics.

* * Note: This class is not part of the public * JGoodies Common API. * It should be treated as library internal and should not be used by * API users. It may be removed or changed without further notice. * * @author Karsten Lentzsch * @version $Revision: 1.2 $ */ public final class RenderingUtils { private static final String PROP_DESKTOPHINTS = "awt.font.desktophints"; private static final String SWING_UTILITIES2_NAME = "sun.swing.SwingUtilities2"; /** * Holds the public static method {@code SwingUtilities2#drawString}. */ private static Method drawStringMethod = null; /** * Holds the public static method * {@code SwingUtilities2#drawStringUnderlinedAt}. */ private static Method drawStringUnderlineCharAtMethod = null; /** * Holds the public static method {@code SwingUtilities2#getFontMetrics}. */ private static Method getFontMetricsMethod = null; static { drawStringMethod = getMethodDrawString(); drawStringUnderlineCharAtMethod = getMethodDrawStringUnderlineCharAt(); getFontMetricsMethod = getMethodGetFontMetrics(); } private RenderingUtils() { // Overrides default constructor; prevents instantiation. } /** * Draws the string at the specified location underlining the specified * character. * * @param c JComponent that will display the string, may be null * @param g Graphics to draw the text to * @param text String to display * @param x X coordinate to draw the text at * @param y Y coordinate to draw the text at */ public static void drawString(JComponent c, Graphics g, String text, int x, int y) { if (drawStringMethod != null) { try { drawStringMethod.invoke(null, c, g, text, Integer.valueOf(x), Integer.valueOf(y)); return; } catch (IllegalArgumentException e) { // Use the BasicGraphicsUtils as fallback } catch (IllegalAccessException e) { // Use the BasicGraphicsUtils as fallback } catch (InvocationTargetException e) { // Use the BasicGraphicsUtils as fallback } } Graphics2D g2 = (Graphics2D) g; Map oldRenderingHints = installDesktopHints(g2); BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, -1, x, y); if (oldRenderingHints != null) { g2.addRenderingHints(oldRenderingHints); } } /** * Draws the string at the specified location underlining the specified * character. * * @param c JComponent that will display the string, may be null * @param g Graphics to draw the text to * @param text String to display * @param underlinedIndex Index of a character in the string to underline * @param x X coordinate to draw the text at * @param y Y coordinate to draw the text at */ public static void drawStringUnderlineCharAt(JComponent c, Graphics g, String text, int underlinedIndex, int x, int y) { if (drawStringUnderlineCharAtMethod != null) { try { drawStringUnderlineCharAtMethod.invoke(null, new Object[] {c, g, text, new Integer(underlinedIndex), new Integer(x), new Integer(y)}); return; } catch (IllegalArgumentException e) { // Use the BasicGraphicsUtils as fallback } catch (IllegalAccessException e) { // Use the BasicGraphicsUtils as fallback } catch (InvocationTargetException e) { // Use the BasicGraphicsUtils as fallback } } Graphics2D g2 = (Graphics2D) g; Map oldRenderingHints = installDesktopHints(g2); BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, underlinedIndex, x, y); if (oldRenderingHints != null) { g2.addRenderingHints(oldRenderingHints); } } /** * Returns the FontMetrics for the current Font of the passed * in Graphics. This method is used when a Graphics * is available, typically when painting. If a Graphics is not * available the JComponent method of the same name should be used. *

* Callers should pass in a non-null JComponent, the exception * to this is if a JComponent is not readily available at the time of * painting. *

* This does not necessarily return the FontMetrics from the * Graphics. * * @param c JComponent requesting FontMetrics, may be null * @param g Graphics Graphics * @return the FontMetrics */ public static FontMetrics getFontMetrics(JComponent c, Graphics g) { if (getFontMetricsMethod != null) { try { return (FontMetrics) getFontMetricsMethod.invoke(null, new Object[] {c, g}); } catch (IllegalArgumentException e) { // Use the fallback } catch (IllegalAccessException e) { // Use the fallback } catch (InvocationTargetException e) { // Use the fallback } } return c.getFontMetrics(g.getFont()); } // Private Helper Code **************************************************** private static Method getMethodDrawString() { try { Class clazz = Class.forName(SWING_UTILITIES2_NAME); return clazz.getMethod( "drawString", new Class[] {JComponent.class, Graphics.class, String.class, Integer.TYPE, Integer.TYPE} ); } catch (ClassNotFoundException e) { // returns null } catch (SecurityException e) { // returns null } catch (NoSuchMethodException e) { // returns null } return null; } private static Method getMethodDrawStringUnderlineCharAt() { try { Class clazz = Class.forName(SWING_UTILITIES2_NAME); return clazz.getMethod( "drawStringUnderlineCharAt", new Class[] {JComponent.class, Graphics.class, String.class, Integer.TYPE, Integer.TYPE, Integer.TYPE} ); } catch (ClassNotFoundException e) { // returns null } catch (SecurityException e) { // returns null } catch (NoSuchMethodException e) { // returns null } return null; } private static Method getMethodGetFontMetrics() { try { Class clazz = Class.forName(SWING_UTILITIES2_NAME); return clazz.getMethod( "getFontMetrics", new Class[] {JComponent.class, Graphics.class} ); } catch (ClassNotFoundException e) { // returns null } catch (SecurityException e) { // returns null } catch (NoSuchMethodException e) { // returns null } return null; } private static Map installDesktopHints(Graphics2D g2) { Map oldRenderingHints = null; Map desktopHints = desktopHints(g2); if (desktopHints != null && !desktopHints.isEmpty()) { oldRenderingHints = new HashMap(desktopHints.size()); RenderingHints.Key key; for (Iterator i = desktopHints.keySet().iterator(); i.hasNext();) { key = (RenderingHints.Key) i.next(); oldRenderingHints.put(key, g2.getRenderingHint(key)); } g2.addRenderingHints(desktopHints); } return oldRenderingHints; } private static Map desktopHints(Graphics2D g2) { if (isPrinting(g2)) { return null; } Toolkit toolkit = Toolkit.getDefaultToolkit(); GraphicsDevice device = g2.getDeviceConfiguration().getDevice(); Map desktopHints = (Map) toolkit.getDesktopProperty( PROP_DESKTOPHINTS + '.' + device.getIDstring()); if (desktopHints == null) { desktopHints = (Map) toolkit.getDesktopProperty(PROP_DESKTOPHINTS); } // It is possible to get a non-empty map but with disabled AA. if (desktopHints != null) { Object aaHint = desktopHints.get(RenderingHints.KEY_TEXT_ANTIALIASING); if (aaHint == RenderingHints.VALUE_TEXT_ANTIALIAS_OFF || aaHint == RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT) { desktopHints = null; } } return desktopHints; } private static boolean isPrinting(Graphics g) { return g instanceof PrintGraphics || g instanceof PrinterGraphics; } } jgoodies-common-1.4.0/src/main/java/com/jgoodies/common/internal/IActionObject.java0000644000175000017500000000201211761646274027023 0ustar tonytony/* * Copyright (c) 2006-2012 JGoodies Karsten Lentzsch. All Rights Reserved. * * This software is the proprietary information of JGoodies Karsten Lentzsch. * Use is subject to license terms. * */ package com.jgoodies.common.internal; import javax.swing.Action; /** * Describes an object that can look up an Action for a given Action name.

* * Note: This class is not part of the public JGoodies Common API. * It's intended for implementation purposes only. * The class's API may change at any time. * * @author Karsten Lentzsch * @version $Revision: 1.1 $ * * @since 1.4 */ public interface IActionObject { /** * Looks up and returns an Action for the given action name. * * @param actionName the string used to look up the Action * @return the Action with the given action name - if any * * @throws NullPointerException if {@code actionName} is {@code null} */ Action getAction(String actionName); } jgoodies-common-1.4.0/src/main/java/com/jgoodies/common/internal/Messages.java0000644000175000017500000000515611773057036026124 0ustar tonytony/* * Copyright (c) 2002-2012 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jgoodies.common.internal; /** * Provides standardized messages for use with the Preconditions class * and in exception messages. * * Note: This class is not part of the public JGoodies Common API. * It's intended for implementation purposes only. * The class's API may change at any time. * * @author Karsten Lentzsch * @version $Revision: 1.1 $ * * @since 1.4 */ public final class Messages { private Messages() { // Overrides default constructor; prevents instantiation. } public static final String MUST_NOT_BE_NULL = "The %1$s must not be null."; public static final String MUST_NOT_BE_BLANK = "The %1$s must not be null, empty, or whitespace."; public static final String MUST_BE_TRIMMED = "The %1$s must not contain leading or trailing whitespace."; public static final String USE_ELLIPSIS_NOT_THREE_DOTS = "The @Action annotation text ends with three dots '...'; use the single ellipsis character '\u2026' (\\u2026) instead."; }jgoodies-common-1.4.0/src/main/java/com/jgoodies/common/swing/0000755000175000017500000000000011731046166023012 5ustar tonytonyjgoodies-common-1.4.0/src/main/java/com/jgoodies/common/swing/package.html0000644000175000017500000000404511730624764025303 0ustar tonytony Consists of Swing related classes. jgoodies-common-1.4.0/src/main/java/com/jgoodies/common/swing/MnemonicUtils.java0000644000175000017500000003555111730624764026461 0ustar tonytony/* * Copyright (c) 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jgoodies.common.swing; import static com.jgoodies.common.base.Preconditions.checkNotNull; import java.awt.event.KeyEvent; import java.text.CharacterIterator; import java.text.StringCharacterIterator; import javax.swing.AbstractButton; import javax.swing.Action; import javax.swing.JLabel; import com.jgoodies.common.base.Strings; /** * Configures the text, mnemonic and mnemonic index in Actions, JLabels, * and AbstractButtons. The term marked text is used for Strings * that contain a marker character that marks both the mnemonic and * its index in the resulting plain text.

* * To set a mnemonic, add an ampersand ('&') before the character * that should be the mnemonic, for example "&Save". * If your text has multiple ampersands, only the first one is used to mark * the mnemonic; the other ampersands appear as normal text. * For example "&Look&Feel" has the first 'L' has mnemonic. * If you want to use the ampersand itself in the text, use two consecutive * ampersands for any ampersand that precede the one that is used to mark * the mnemonic. For example the marked text "R&&D D&epartment" * has "R&D Department" as text and the mnemonic is 'E'.

* * Examples: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Marked TextPlain TextMnemonicMnemonic IndexComment
SaveSave0-1No mnemonic
&SaveSave'S'0 
Save &asSave as'A'5Second 'a' marked
Look&FeelLookFeel'F'4& should be quoted
Look&&FeelLook&Feel0-1& is quoted
&Look&FeelLook&FeelL0Second & needs no quote
Look & FeelLook & Feel0-1Whitespace cannot be marked
R&&D D&epartmentR&D Department'E'5First & is quoted
<html>a&b</html><html>a<u>b</u></html>'B'-1'b' is underlined
<html>R&amp;D D&ep.</html><html>R&amp;D D<u>e</u>p.</html>'B'-1HTML &amp; doesn't mark
* * @author Karsten Lentzsch * @version $Revision: 1.1 $ */ public final class MnemonicUtils { /** * The single mnemonic marker. Future versions of this class shall * support other markers, for example the underline char ('_'). */ static final char MNEMONIC_MARKER = '&'; // Instance Creation ****************************************************** private MnemonicUtils() { // Suppresses default constructor, prevents instantiation. } // Setting Text, Mnemonic and Index *************************************** /** * Configures the text, mnemonic and mnemonic index for {@code target} * using the given text that can be marked with the mnemonic marker '&'. * For example if {@code markedText} is "Save &as", the text * will be set to "Save as", the mnemonic is 'a', and the * mnemonic index is 5. * * @param target the button to be configured * @param markedText the text with optional mnemonic marker * @throws NullPointerException if {@code target} is {@code null} */ public static void configure(AbstractButton target, String markedText) { checkNotNull(target, "target must not be null."); configure0(target, new MnemonicText(markedText, MNEMONIC_MARKER)); } /** * Configures the text, mnemonic and mnemonic index for {@code target} * using the given text that can be marked with the mnemonic marker '&'. * For example if {@code markedText} is "Save &as", the text * will be set to "Save as", the mnemonic is 'a', and the * mnemonic index is 5. * * @param target the Action to be configured * @param markedText the text with optional mnemonic marker * @throws NullPointerException if {@code target} is {@code null} */ public static void configure(Action target, String markedText) { checkNotNull(target, "target must not be null."); configure0(target, new MnemonicText(markedText, MNEMONIC_MARKER)); } /** * Configures the text, mnemonic and mnemonic index for {@code target} * using the given text that can be marked with the mnemonic marker '&'. * For example if {@code markedText} is "Save &as", the text * will be set to "Save as", the mnemonic is 'a', and the * mnemonic index is 5. * * @param target the label to be configured * @param markedText the text with optional mnemonic marker * @throws NullPointerException if {@code target} is {@code null} */ public static void configure(JLabel target, String markedText) { checkNotNull(target, "target must not be null."); configure0(target, new MnemonicText(markedText, MNEMONIC_MARKER)); } // Misc ******************************************************************* /** * Returns the plain text for the given marked text by removing * the mnemonic marker and marker quotes - if any. If the marked text * is HTML, the plain text has the mnemonic character underlined. * * See the {@link MnemonicUtils} class comment for information * about how to mark a mnemonic and how to quote a marker. * *

     * MnemonicUtils.plainText("Save")             == "Save"
     * MnemonicUtils.plainText("&Save")            == "Save"
     * MnemonicUtils.plainText("&Look&Feel")       == "Look&Feel"
     * MnemonicUtils.plainText("Look & Feel")      == "Look & Feel"
     * MnemonicUtils.plainText("R&&D D&epartment") == "R&D Department"
     * MnemonicUtils.plainText("<html>a&b</html>") == "<html>a<u>b</u></html>"
     * 
* * @param markedText the text that may contain a mnemonic marker * @return the text without mnemonic marker and marker quotes */ public static String plainText(String markedText) { return new MnemonicText(markedText, MNEMONIC_MARKER).text; } // Testing API ************************************************************ /** * Extracts and returns the mnemonic from the given marked text. * * @param markedText the text with optional mnemonic marker * @return the mnemonic or {@code 0} if no mnemonic is marked */ static int mnemonic(String markedText) { return new MnemonicText(markedText, MNEMONIC_MARKER).key; } /** * Finds and returns the index of the mnemonic in the marked text. * * @param markedText the text with optional mnemonic marker * @return the mnemonic index or {@code -1} if there's no mnemonic * or the text is HTML */ static int mnemonicIndex(String markedText) { return new MnemonicText(markedText, MNEMONIC_MARKER).index; } // Implementation ********************************************************* private static void configure0(AbstractButton button, MnemonicText mnemonicText) { button.setText(mnemonicText.text); button.setMnemonic(mnemonicText.key); button.setDisplayedMnemonicIndex(mnemonicText.index); } /* * We set the mnemonic only if non-null. This works around a bug in * AbstractButton that can configure itself from an Action with mnemonic * set to null but throws an NPE if the Action's mnemonic becomes * null afterwards. * * @see AbstractButton.ButtonActionPropertyChangeListener */ private static void configure0(Action action, MnemonicText mnemonicText) { Integer keyValue = Integer.valueOf(mnemonicText.key); Integer indexValue = mnemonicText.index == -1 ? null : Integer.valueOf(mnemonicText.index); action.putValue(Action.NAME, mnemonicText.text); action.putValue(Action.MNEMONIC_KEY, keyValue); action.putValue(Action.DISPLAYED_MNEMONIC_INDEX_KEY, indexValue); } private static void configure0(JLabel label, MnemonicText mnemonicText) { label.setText(mnemonicText.text); label.setDisplayedMnemonic(mnemonicText.key); label.setDisplayedMnemonicIndex(mnemonicText.index); } // Helper Code ************************************************************ private static final class MnemonicText { String text; int key; int index; private MnemonicText(String markedText, char marker) { int i; if ( markedText == null || markedText.length() <= 1 || (i = markedText.indexOf(marker)) == -1) { text = markedText; key = KeyEvent.VK_UNDEFINED; index = -1; return; } boolean html = Strings.startsWithIgnoreCase(markedText, ""); StringBuilder builder = new StringBuilder(); int begin = 0; int quotedMarkers = 0; int markerIndex = -1; boolean marked = false; char markedChar = 0; CharacterIterator sci = new StringCharacterIterator(markedText); do { builder.append(markedText.substring(begin, i)); char current = sci.setIndex(i); char next = sci.next(); if (html) { int entityEnd = indexOfEntityEnd(markedText, i); if (entityEnd == -1) { marked = true; builder.append("").append(next).append(""); begin = i+2; markedChar = next; } else { builder.append(markedText.substring(i, entityEnd)); begin = entityEnd; } } else { if (next == marker) { // "Look&&Feel" builder.append(next); begin = i+2; quotedMarkers++; } else if (Character.isWhitespace(next)) { // "Look & Feel" builder.append(current).append(next); begin = i+2; } else if (next == CharacterIterator.DONE) { builder.append(current); begin = i+2; } else { builder.append(next); begin = i+2; markerIndex = i - quotedMarkers; marked = true; markedChar = next; } } i = markedText.indexOf(marker, begin); } while (i != -1 && !marked); if (begin < markedText.length()) { builder.append(markedText.substring(begin)); } text = builder.toString(); index = markerIndex; if (marked) { key = mnemonicKey(markedChar); } else { key = KeyEvent.VK_UNDEFINED; } } private static int indexOfEntityEnd(String htmlText, int start) { CharacterIterator sci = new StringCharacterIterator(htmlText, start); char c; do { c = sci.next(); if (c == ';') { return sci.getIndex(); } if (!Character.isLetterOrDigit(c)) { return -1; } } while (c != CharacterIterator.DONE); return -1; } /* A general purpose way to map from a char to a KeyCode is needed. An * AWT RFE has been filed: * http://bt2ws.central.sun.com/CrPrint?id=6559449 * CR 6559449 java/classes_awt Support for converting from char to KeyEvent VK_ keycode */ private static int mnemonicKey(char c) { int vk = c; if (vk >= 'a' && vk <= 'z') { vk -= 'a' - 'A'; } return vk; } } } jgoodies-common-1.4.0/src/main/java/com/jgoodies/common/bean/0000755000175000017500000000000011762120100022551 5ustar tonytonyjgoodies-common-1.4.0/src/main/java/com/jgoodies/common/bean/package.html0000644000175000017500000000406311730624764025061 0ustar tonytony Consists of classes for working with Java Beans. jgoodies-common-1.4.0/src/main/java/com/jgoodies/common/bean/ObservableBean2.java0000644000175000017500000001230311730624764026373 0ustar tonytony/* * Copyright (c) 2002-2012 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jgoodies.common.bean; import java.beans.PropertyChangeListener; /** * In addition to its super interface ObservableBean, this interface * describes the optional support for registering PropertyChangeListeners * for an individual property name. * This interface is primarily intended to ensure compile-time safety * for beans that shall be observed. * * @author Karsten Lentzsch * @version $Revision: 1.1 $ * * @see PropertyChangeListener * @see java.beans.PropertyChangeEvent * @see java.beans.PropertyChangeSupport */ public interface ObservableBean2 extends ObservableBean { /** * Adds a PropertyChangeListener to the listener list for a specific * property. The specified property may be user-defined.

* * Note that if this bean is inheriting a bound property, then no event * will be fired in response to a change in the inherited property.

* * If listener is null, no exception is thrown and no action is performed. * * @param propertyName one of the property names listed above * @param listener the PropertyChangeListener to be added * * @see #removePropertyChangeListener(PropertyChangeListener) * @see #removePropertyChangeListener(String, PropertyChangeListener) * @see #addPropertyChangeListener(PropertyChangeListener) * @see #getPropertyChangeListeners(String) */ void addPropertyChangeListener(String propertyName, PropertyChangeListener listener); /** * Removes a PropertyChangeListener from the listener list for a specific * property. This method should be used to remove PropertyChangeListeners * that were registered for a specific bound property.

* * If listener is null, no exception is thrown and no action is performed. * * @param propertyName a valid property name * @param listener the PropertyChangeListener to be removed * * @see #addPropertyChangeListener(PropertyChangeListener) * @see #addPropertyChangeListener(String, PropertyChangeListener) * @see #removePropertyChangeListener(PropertyChangeListener) * @see #getPropertyChangeListeners(String) */ void removePropertyChangeListener(String propertyName, PropertyChangeListener listener); /** * Returns an array of all the property change listeners * registered on this component. * * @return all of this component's {@code PropertyChangeListener}s * or an empty array if no property change * listeners are currently registered * * @see #addPropertyChangeListener(PropertyChangeListener) * @see #removePropertyChangeListener(PropertyChangeListener) * @see #getPropertyChangeListeners(String) * @see java.beans.PropertyChangeSupport#getPropertyChangeListeners() */ PropertyChangeListener[] getPropertyChangeListeners(); /** * Returns an array of all the listeners which have been associated * with the named property. * * @param propertyName the name of the property to lookup listeners * @return all of the {@code PropertyChangeListeners} associated with * the named property or an empty array if no listeners have * been added * * @see #addPropertyChangeListener(String, PropertyChangeListener) * @see #removePropertyChangeListener(String, PropertyChangeListener) * @see #getPropertyChangeListeners() */ PropertyChangeListener[] getPropertyChangeListeners(String propertyName); } jgoodies-common-1.4.0/src/main/java/com/jgoodies/common/bean/ObservableBean.java0000644000175000017500000000601611730624764026315 0ustar tonytony/* * Copyright (c) 2002-2012 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jgoodies.common.bean; import java.beans.PropertyChangeListener; /** * Describes objects that provide bound properties as specified in the * Java * Bean Specification. * This interface is primarily intended to ensure compile-time safety * for beans that shall be observed. * * @author Karsten Lentzsch * @version $Revision: 1.1 $ * * @see PropertyChangeListener * @see java.beans.PropertyChangeEvent * @see java.beans.PropertyChangeSupport */ public interface ObservableBean { /** * Adds the given PropertyChangeListener to the listener list. * The listener is registered for all bound properties of this class. * * @param listener the PropertyChangeListener to be added * * @see #removePropertyChangeListener(PropertyChangeListener) */ void addPropertyChangeListener(PropertyChangeListener listener); /** * Removes the given PropertyChangeListener from the listener list. * This method should be used to remove PropertyChangeListeners that were * registered for all bound properties of this class. * * @param listener the PropertyChangeListener to be removed * * @see #addPropertyChangeListener(PropertyChangeListener) */ void removePropertyChangeListener(PropertyChangeListener listener); } jgoodies-common-1.4.0/src/main/java/com/jgoodies/common/bean/AbstractBean.java0000644000175000017500000000442311762120100025750 0ustar tonytony/* * Copyright (c) 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jgoodies.common.bean; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.beans.VetoableChangeListener; import java.beans.VetoableChangeSupport; /** * This is the deprecated abstract superclass for bean classes. * Use {@link Bean} instead. * * @author Karsten Lentzsch * @version $Revision: 1.2 $ * * @see PropertyChangeEvent * @see PropertyChangeListener * @see PropertyChangeSupport * @see VetoableChangeListener * @see VetoableChangeSupport */ public abstract class AbstractBean extends Bean { // Just a subclass of Bean. } jgoodies-common-1.4.0/src/main/java/com/jgoodies/common/bean/Bean.java0000644000175000017500000010100111761430352024266 0ustar tonytony/* * Copyright (c) 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jgoodies.common.bean; import java.beans.*; import java.io.Serializable; /** * An abstract superclass that minimizes the effort required to provide * change support for bound and constrained Bean properties. * This class follows the conventions and recommendations as described * in the Java Bean Specification.

* * This class uses the standard {@link PropertyChangeSupport} to notify * registered listeners about changes. Subclasses can use different change * support implementations by overriding {@code createPropertyChangeSupport}, * for example to ensure that notifications are sent in the Event dispatch * thread, or to compare old and new values with {@code ==} not {@code equals}. * * @author Karsten Lentzsch * @version $Revision: 1.1 $ * * @see PropertyChangeEvent * @see PropertyChangeListener * @see PropertyChangeSupport * @see VetoableChangeListener * @see VetoableChangeSupport */ public abstract class Bean implements Serializable, ObservableBean2 { /** * If any{@code PropertyChangeListeners} have been registered, * the {@code changeSupport} field describes them. * * @see #addPropertyChangeListener(PropertyChangeListener) * @see #addPropertyChangeListener(String, PropertyChangeListener) * @see #removePropertyChangeListener(PropertyChangeListener) * @see #removePropertyChangeListener(String, PropertyChangeListener) * @see PropertyChangeSupport */ protected PropertyChangeSupport changeSupport; /** * If any {@code VetoableChangeListeners} have been registered, * the {@code vetoSupport} field describes them. * * @see #addVetoableChangeListener(VetoableChangeListener) * @see #addVetoableChangeListener(String, VetoableChangeListener) * @see #removeVetoableChangeListener(VetoableChangeListener) * @see #removeVetoableChangeListener(String, VetoableChangeListener) * @see #fireVetoableChange(String, Object, Object) */ private VetoableChangeSupport vetoSupport; // Managing Property Change Listeners ********************************** /** * Adds a PropertyChangeListener to the listener list. The listener is * registered for all bound properties of this class.

* * If listener is {@code null}, no exception is thrown * and no action is performed. * * @param listener the PropertyChangeListener to be added * * @see #removePropertyChangeListener(PropertyChangeListener) * @see #removePropertyChangeListener(String, PropertyChangeListener) * @see #addPropertyChangeListener(String, PropertyChangeListener) * @see #getPropertyChangeListeners() */ @Override public final synchronized void addPropertyChangeListener( PropertyChangeListener listener) { if (listener == null) { return; } if (changeSupport == null) { changeSupport = createPropertyChangeSupport(this); } changeSupport.addPropertyChangeListener(listener); } /** * Removes a PropertyChangeListener from the listener list. This method * should be used to remove PropertyChangeListeners that were registered * for all bound properties of this class.

* * If listener is {@code null}, no exception is thrown and no action is performed. * * @param listener the PropertyChangeListener to be removed * @see #addPropertyChangeListener(PropertyChangeListener) * @see #addPropertyChangeListener(String, PropertyChangeListener) * @see #removePropertyChangeListener(String, PropertyChangeListener) * @see #getPropertyChangeListeners() */ @Override public final synchronized void removePropertyChangeListener( PropertyChangeListener listener) { if (listener == null || changeSupport == null) { return; } changeSupport.removePropertyChangeListener(listener); } /** * Adds a PropertyChangeListener to the listener list for a specific * property. The specified property may be user-defined.

* * Note that if this Model is inheriting a bound property, then no event * will be fired in response to a change in the inherited property.

* * If listener is {@code null}, no exception is thrown and no action is performed. * * @param propertyName one of the property names listed above * @param listener the PropertyChangeListener to be added * * @see #removePropertyChangeListener(String, PropertyChangeListener) * @see #addPropertyChangeListener(String, PropertyChangeListener) * @see #getPropertyChangeListeners(String) */ @Override public final synchronized void addPropertyChangeListener( String propertyName, PropertyChangeListener listener) { if (listener == null) { return; } if (changeSupport == null) { changeSupport = createPropertyChangeSupport(this); } changeSupport.addPropertyChangeListener(propertyName, listener); } /** * Removes a PropertyChangeListener from the listener list for a specific * property. This method should be used to remove PropertyChangeListeners * that were registered for a specific bound property.

* * If listener is {@code null}, no exception is thrown and no action is performed. * * @param propertyName a valid property name * @param listener the PropertyChangeListener to be removed * * @see #addPropertyChangeListener(String, PropertyChangeListener) * @see #removePropertyChangeListener(PropertyChangeListener) * @see #getPropertyChangeListeners(String) */ @Override public final synchronized void removePropertyChangeListener( String propertyName, PropertyChangeListener listener) { if (listener == null || changeSupport == null) { return; } changeSupport.removePropertyChangeListener(propertyName, listener); } // Managing Vetoable Change Listeners *********************************** /** * Adds a VetoableChangeListener to the listener list. The listener is * registered for all bound properties of this class.

* * If listener is {@code null}, no exception is thrown and no action is * performed. * * @param listener the VetoableChangeListener to be added * * @see #removeVetoableChangeListener(String, VetoableChangeListener) * @see #addVetoableChangeListener(String, VetoableChangeListener) * @see #getVetoableChangeListeners() */ public final synchronized void addVetoableChangeListener( VetoableChangeListener listener) { if (listener == null) { return; } if (vetoSupport == null) { vetoSupport = new VetoableChangeSupport(this); } vetoSupport.addVetoableChangeListener(listener); } /** * Removes a VetoableChangeListener from the listener list. This method * should be used to remove VetoableChangeListeners that were registered * for all bound properties of this class.

* * If listener is {@code null}, no exception is thrown and no action is performed. * * @param listener the VetoableChangeListener to be removed * * @see #addVetoableChangeListener(String, VetoableChangeListener) * @see #removeVetoableChangeListener(String, VetoableChangeListener) * @see #getVetoableChangeListeners() */ public final synchronized void removeVetoableChangeListener( VetoableChangeListener listener) { if (listener == null || vetoSupport == null) { return; } vetoSupport.removeVetoableChangeListener(listener); } /** * Adds a VetoableChangeListener to the listener list for a specific * property. The specified property may be user-defined.

* * Note that if this Model is inheriting a bound property, then no event * will be fired in response to a change in the inherited property.

* * If listener is {@code null}, no exception is thrown and no action is performed. * * @param propertyName one of the property names listed above * @param listener the VetoableChangeListener to be added * * @see #removeVetoableChangeListener(String, VetoableChangeListener) * @see #addVetoableChangeListener(String, VetoableChangeListener) * @see #getVetoableChangeListeners(String) */ public final synchronized void addVetoableChangeListener( String propertyName, VetoableChangeListener listener) { if (listener == null) { return; } if (vetoSupport == null) { vetoSupport = new VetoableChangeSupport(this); } vetoSupport.addVetoableChangeListener(propertyName, listener); } /** * Removes a VetoableChangeListener from the listener list for a specific * property. This method should be used to remove VetoableChangeListeners * that were registered for a specific bound property.

* * If listener is {@code null}, no exception is thrown and no action is performed. * * @param propertyName a valid property name * @param listener the VetoableChangeListener to be removed * * @see #addVetoableChangeListener(String, VetoableChangeListener) * @see #removeVetoableChangeListener(VetoableChangeListener) * @see #getVetoableChangeListeners(String) */ public final synchronized void removeVetoableChangeListener( String propertyName, VetoableChangeListener listener) { if (listener == null || vetoSupport == null) { return; } vetoSupport.removeVetoableChangeListener(propertyName, listener); } // Requesting Listener Sets *********************************************** /** * Returns an array of all the property change listeners * registered on this component. * * @return all of this component's {@code PropertyChangeListener}s * or an empty array if no property change * listeners are currently registered * * @see #addPropertyChangeListener(PropertyChangeListener) * @see #removePropertyChangeListener(PropertyChangeListener) * @see #getPropertyChangeListeners(String) * @see PropertyChangeSupport#getPropertyChangeListeners() */ @Override public final synchronized PropertyChangeListener[] getPropertyChangeListeners() { if (changeSupport == null) { return new PropertyChangeListener[0]; } return changeSupport.getPropertyChangeListeners(); } /** * Returns an array of all the listeners which have been associated * with the named property. * * @param propertyName the name of the property to lookup listeners * @return all of the {@code PropertyChangeListeners} associated with * the named property or an empty array if no listeners have * been added * * @see #addPropertyChangeListener(String, PropertyChangeListener) * @see #removePropertyChangeListener(String, PropertyChangeListener) * @see #getPropertyChangeListeners() */ @Override public final synchronized PropertyChangeListener[] getPropertyChangeListeners(String propertyName) { if (changeSupport == null) { return new PropertyChangeListener[0]; } return changeSupport.getPropertyChangeListeners(propertyName); } /** * Returns an array of all the property change listeners * registered on this component. * * @return all of this component's {@code VetoableChangeListener}s * or an empty array if no property change * listeners are currently registered * * @see #addVetoableChangeListener(VetoableChangeListener) * @see #removeVetoableChangeListener(VetoableChangeListener) * @see #getVetoableChangeListeners(String) * @see VetoableChangeSupport#getVetoableChangeListeners() */ public final synchronized VetoableChangeListener[] getVetoableChangeListeners() { if (vetoSupport == null) { return new VetoableChangeListener[0]; } return vetoSupport.getVetoableChangeListeners(); } /** * Returns an array of all the listeners which have been associated * with the named property. * * @param propertyName the name of the property to lookup listeners * @return all of the {@code VetoableChangeListeners} associated with * the named property or an empty array if no listeners have * been added * * @see #addVetoableChangeListener(String, VetoableChangeListener) * @see #removeVetoableChangeListener(String, VetoableChangeListener) * @see #getVetoableChangeListeners() */ public final synchronized VetoableChangeListener[] getVetoableChangeListeners(String propertyName) { if (vetoSupport == null) { return new VetoableChangeListener[0]; } return vetoSupport.getVetoableChangeListeners(propertyName); } /** * Creates and returns a PropertyChangeSupport for the given bean. * Invoked by the first call to {@link #addPropertyChangeListener} * when lazily creating the sole change support instance used throughout * this bean.

* * This default implementation creates a {@code PropertyChangeSupport}. * Subclasses may override to return other change support implementations. * For example to ensure that listeners are notified in the Event dispatch * thread (EDT change support). * The JGoodies Binding uses an extended change support that allows * to configure whether the old and new value are compared with * {@code ==} or {@code equals}. * * @param bean the bean to create a change support for * @return the new change support */ protected PropertyChangeSupport createPropertyChangeSupport(final Object bean) { return new PropertyChangeSupport(bean); } // Firing Changes for Bound Properties ********************************** /** * General support for reporting bound property changes. Sends the given * PropertyChangeEvent to any registered PropertyChangeListener.

* * Most bean setters will invoke the fireXXX methods that get * a property name and the old and new value. However some frameworks * and setters may prefer to use this general method. * Also, this method allows to fire IndexedPropertyChangeEvents * that have been introduced in Java 5. * * @param event describes the property change * * @since 1.3 */ protected final void firePropertyChange(PropertyChangeEvent event) { PropertyChangeSupport aChangeSupport = this.changeSupport; if (aChangeSupport == null) { return; } aChangeSupport.firePropertyChange(event); } /** * Support for reporting bound property changes for Object properties. * This method can be called when a bound property has changed and it will * send the appropriate PropertyChangeEvent to any registered * PropertyChangeListeners. * * @param propertyName the property whose value has changed * @param oldValue the property's previous value * @param newValue the property's new value */ protected final void firePropertyChange(String propertyName, Object oldValue, Object newValue) { PropertyChangeSupport aChangeSupport = this.changeSupport; if (aChangeSupport == null) { return; } aChangeSupport.firePropertyChange(propertyName, oldValue, newValue); } /** * Support for reporting bound property changes for boolean properties. * This method can be called when a bound property has changed and it will * send the appropriate PropertyChangeEvent to any registered * PropertyChangeListeners. * * @param propertyName the property whose value has changed * @param oldValue the property's previous value * @param newValue the property's new value */ protected final void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) { PropertyChangeSupport aChangeSupport = this.changeSupport; if (aChangeSupport == null) { return; } aChangeSupport.firePropertyChange(propertyName, oldValue, newValue); } /** * Support for reporting bound property changes for integer properties. * This method can be called when a bound property has changed and it will * send the appropriate PropertyChangeEvent to any registered * PropertyChangeListeners. * * @param propertyName the property whose value has changed * @param oldValue the property's previous value * @param newValue the property's new value */ protected final void firePropertyChange(String propertyName, double oldValue, double newValue) { firePropertyChange(propertyName, Double.valueOf(oldValue), Double.valueOf(newValue)); } /** * Support for reporting bound property changes for integer properties. * This method can be called when a bound property has changed and it will * send the appropriate PropertyChangeEvent to any registered * PropertyChangeListeners. * * @param propertyName the property whose value has changed * @param oldValue the property's previous value * @param newValue the property's new value */ protected final void firePropertyChange(String propertyName, float oldValue, float newValue) { firePropertyChange(propertyName, Float.valueOf(oldValue), Float.valueOf(newValue)); } /** * Support for reporting bound property changes for integer properties. * This method can be called when a bound property has changed and it will * send the appropriate PropertyChangeEvent to any registered * PropertyChangeListeners. * * @param propertyName the property whose value has changed * @param oldValue the property's previous value * @param newValue the property's new value */ protected final void firePropertyChange(String propertyName, int oldValue, int newValue) { PropertyChangeSupport aChangeSupport = this.changeSupport; if (aChangeSupport == null) { return; } aChangeSupport.firePropertyChange(propertyName, Integer.valueOf(oldValue), Integer.valueOf(newValue)); } /** * Support for reporting bound property changes for integer properties. * This method can be called when a bound property has changed and it will * send the appropriate PropertyChangeEvent to any registered * PropertyChangeListeners. * * @param propertyName the property whose value has changed * @param oldValue the property's previous value * @param newValue the property's new value */ protected final void firePropertyChange(String propertyName, long oldValue, long newValue) { firePropertyChange(propertyName, Long.valueOf(oldValue), Long.valueOf(newValue)); } /** * Indicates that an arbitrary set of bound properties have changed. * Sends a PropertyChangeEvent with property name, old and new value * set to {@code null} to any registered PropertyChangeListeners. * * @see java.beans.PropertyChangeEvent * * @since 1.0.3 */ protected final void fireMultiplePropertiesChanged() { firePropertyChange(null, null, null); } // Firing Indexed Changes ************************************************* /** * Report a bound indexed property update to any registered listeners.

* * No event is fired if old and new values are equal and non-null. * * @param propertyName The programmatic name of the property that * was changed. * @param index index of the property element that was changed. * @param oldValue The old value of the property. * @param newValue The new value of the property. * * @since 2.0 */ protected final void fireIndexedPropertyChange(String propertyName, int index, Object oldValue, Object newValue) { PropertyChangeSupport aChangeSupport = this.changeSupport; if (aChangeSupport == null) { return; } aChangeSupport.fireIndexedPropertyChange(propertyName, index, oldValue, newValue); } /** * Report an {@code int} bound indexed property update * to any registered listeners.

* * No event is fired if old and new values are equal and non-null.

* * This is merely a convenience wrapper around the more general * fireIndexedPropertyChange method which takes Object values. * * @param propertyName The programmatic name of the property that * was changed. * @param index index of the property element that was changed. * @param oldValue The old value of the property. * @param newValue The new value of the property. * * @since 2.0 */ protected final void fireIndexedPropertyChange(String propertyName, int index, int oldValue, int newValue) { if (oldValue == newValue) { return; } fireIndexedPropertyChange(propertyName, index, Integer.valueOf(oldValue), Integer.valueOf(newValue)); } /** * Report a {@code boolean} bound indexed property update * to any registered listeners.

* * No event is fired if old and new values are equal and non-null.

* * This is merely a convenience wrapper around the more general * fireIndexedPropertyChange method which takes Object values. * * @param propertyName The programmatic name of the property that * was changed. * @param index index of the property element that was changed. * @param oldValue The old value of the property. * @param newValue The new value of the property. * * @since 2.0 */ protected final void fireIndexedPropertyChange(String propertyName, int index, boolean oldValue, boolean newValue) { if (oldValue == newValue) { return; } fireIndexedPropertyChange(propertyName, index, Boolean.valueOf(oldValue), Boolean.valueOf(newValue)); } // Firing Changes for Constrained Properties **************************** /** * General support for reporting constrained property changes. Sends the * given PropertyChangeEvent to any registered PropertyChangeListener.

* * Most bean setters will invoke the fireXXX methods that get * a property name and the old and new value. However some frameworks * and setters may prefer to use this general method. * Also, this method allows to fire IndexedPropertyChangeEvents * that have been introduced in Java 5. * * @param event describes the property change * @throws PropertyVetoException if a constrained property change is rejected * * @since 1.3 */ protected final void fireVetoableChange(PropertyChangeEvent event) throws PropertyVetoException { VetoableChangeSupport aVetoSupport = this.vetoSupport; if (aVetoSupport == null) { return; } aVetoSupport.fireVetoableChange(event); } /** * Support for reporting changes for constrained Object properties. This * method can be called before a constrained property will be changed and * it will send the appropriate PropertyChangeEvent to any registered * VetoableChangeListeners. * * @param propertyName the property whose value has changed * @param oldValue the property's previous value * @param newValue the property's new value * @throws PropertyVetoException if a constrained property change is rejected */ protected final void fireVetoableChange(String propertyName, Object oldValue, Object newValue) throws PropertyVetoException { VetoableChangeSupport aVetoSupport = this.vetoSupport; if (aVetoSupport == null) { return; } aVetoSupport.fireVetoableChange(propertyName, oldValue, newValue); } /** * Support for reporting changes for constrained boolean properties. This * method can be called before a constrained property will be changed and * it will send the appropriate PropertyChangeEvent to any registered * VetoableChangeListeners. * * @param propertyName the property whose value has changed * @param oldValue the property's previous value * @param newValue the property's new value * @throws PropertyVetoException if a constrained property change is rejected */ protected final void fireVetoableChange(String propertyName, boolean oldValue, boolean newValue) throws PropertyVetoException { VetoableChangeSupport aVetoSupport = this.vetoSupport; if (aVetoSupport == null) { return; } aVetoSupport.fireVetoableChange(propertyName, oldValue, newValue); } /** * Support for reporting changes for constrained integer properties. This * method can be called before a constrained property will be changed and * it will send the appropriate PropertyChangeEvent to any registered * VetoableChangeListeners. * * @param propertyName the property whose value has changed * @param oldValue the property's previous value * @param newValue the property's new value * @throws PropertyVetoException if a constrained property change is rejected */ protected final void fireVetoableChange(String propertyName, double oldValue, double newValue) throws PropertyVetoException { fireVetoableChange(propertyName, Double.valueOf(oldValue), Double.valueOf(newValue)); } /** * Support for reporting changes for constrained integer properties. This * method can be called before a constrained property will be changed and * it will send the appropriate PropertyChangeEvent to any registered * VetoableChangeListeners. * * @param propertyName the property whose value has changed * @param oldValue the property's previous value * @param newValue the property's new value * @throws PropertyVetoException if a constrained property change is rejected */ protected final void fireVetoableChange(String propertyName, int oldValue, int newValue) throws PropertyVetoException { VetoableChangeSupport aVetoSupport = this.vetoSupport; if (aVetoSupport == null) { return; } aVetoSupport.fireVetoableChange(propertyName, Integer.valueOf(oldValue), Integer.valueOf(newValue)); } /** * Support for reporting changes for constrained integer properties. This * method can be called before a constrained property will be changed and * it will send the appropriate PropertyChangeEvent to any registered * VetoableChangeListeners. * * @param propertyName the property whose value has changed * @param oldValue the property's previous value * @param newValue the property's new value * @throws PropertyVetoException if a constrained property change is rejected */ protected final void fireVetoableChange(String propertyName, float oldValue, float newValue) throws PropertyVetoException { fireVetoableChange(propertyName, Float.valueOf(oldValue), Float.valueOf(newValue)); } /** * Support for reporting changes for constrained integer properties. This * method can be called before a constrained property will be changed and * it will send the appropriate PropertyChangeEvent to any registered * VetoableChangeListeners. * * @param propertyName the property whose value has changed * @param oldValue the property's previous value * @param newValue the property's new value * @throws PropertyVetoException if a constrained property change is rejected */ protected final void fireVetoableChange(String propertyName, long oldValue, long newValue) throws PropertyVetoException { fireVetoableChange(propertyName, Long.valueOf(oldValue), Long.valueOf(newValue)); } } jgoodies-common-1.4.0/src/main/java/com/jgoodies/common/format/0000755000175000017500000000000011731046166023153 5ustar tonytonyjgoodies-common-1.4.0/src/main/java/com/jgoodies/common/format/package.html0000644000175000017500000000406311730624764025444 0ustar tonytony Consists of Format implementations and wrappers. jgoodies-common-1.4.0/src/main/java/com/jgoodies/common/format/EmptyNumberFormat.java0000644000175000017500000001470211730624764027447 0ustar tonytony/* * Copyright (c) 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jgoodies.common.format; import static com.jgoodies.common.base.Preconditions.checkNotNull; import java.text.FieldPosition; import java.text.NumberFormat; import java.text.ParseException; import java.text.ParsePosition; import com.jgoodies.common.base.Objects; import com.jgoodies.common.base.Strings; /** * Wraps a given {@code NumberFormat} and adds behavior to convert to/from * the empty string. Therefore it holds an empty value that is * mapped to/from the empty string. The {@code #format} result * of the empty value is the empty string, and the {@code #parse} * result of the empty string is the empty value. In all other cases * the formatting and parsing is forwarded to the wrapped NumberFormat.

* * Examples:

 * new EmptyNumberFormat(NumberFormat().getInstance());
 * new EmptyNumberFormat(NumberFormat().getIntegerInstance(), -1);
 * 
* * @author Karsten Lentzsch * @version $Revision: 1.1 $ */ public final class EmptyNumberFormat extends NumberFormat { private final NumberFormat delegate; private final Number emptyValue; // Instance Creation **************************************************** /** * Constructs an EmptyNumberFormat that wraps the given mandatory format * to convert {@code null} to the empty string and vice versa. * * @param delegate the format that handles the standard cases * * @throws NullPointerException if {@code delegate} is {@code null} */ public EmptyNumberFormat(NumberFormat delegate) { this(delegate, null); } /** * Constructs an EmptyNumberFormat that wraps the given mandatory format * to convert the given {@code emptyValue} to the empty string * and vice versa. * * @param delegate the format that handles non-{@code null} values * @param emptyValue the representation of the empty string * * @throws NullPointerException if {@code delegate} is {@code null} */ public EmptyNumberFormat(NumberFormat delegate, int emptyValue) { this(delegate, Integer.valueOf(emptyValue)); } /** * Constructs an EmptyNumberFormat that wraps the given mandatory format * to convert the given {@code emptyValue} to the empty string * and vice versa. * * @param delegate the format that handles non-{@code null} values * @param emptyValue the representation of the empty string * * @throws NullPointerException if {@code delegate} is {@code null} */ public EmptyNumberFormat(NumberFormat delegate, Number emptyValue) { this.delegate = checkNotNull(delegate, "The delegate format must not be null."); this.emptyValue = emptyValue; } // Overriding Superclass Behavior ***************************************** /** * {@inheritDoc}

* * If {@code obj} is equal to the emptyValue, * {@code toAppendTo} is returned. Otherwise the format * is forwarded to the delegate. */ @Override public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos) { return Objects.equals(obj, emptyValue) ? toAppendTo : delegate.format(obj, toAppendTo, pos); } @Override public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) { return delegate.format(number, toAppendTo, pos); } @Override public StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos) { return delegate.format(number, toAppendTo, pos); } /** * {@inheritDoc}

* * If {@code source} is empty or whitespace, the emptyValue * is returned. Otherwise parsing is forwarded to the delegate * - indirectly via {@link #parse(String, ParsePosition)}. */ @Override public Object parseObject(String source) throws ParseException { return Strings.isBlank(source) ? emptyValue : super.parseObject(source); } /** * {@inheritDoc}

* * If {@code source} is empty or whitespace, the emptyValue * is returned. Otherwise parsing is forwarded to the delegate * - indirectly via {@link #parse(String, ParsePosition)}. */ @Override public Number parse(String source) throws ParseException { return Strings.isBlank(source) ? emptyValue : super.parse(source); } @Override public Number parse(String source, ParsePosition pos) { return delegate.parse(source, pos); } } jgoodies-common-1.4.0/src/main/java/com/jgoodies/common/format/EmptyDateFormat.java0000644000175000017500000001152511730624764027074 0ustar tonytony/* * Copyright (c) 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jgoodies.common.format; import java.text.DateFormat; import java.text.FieldPosition; import java.text.ParsePosition; import java.util.Date; import com.jgoodies.common.base.Objects; import com.jgoodies.common.base.Strings; /** * Wraps a given {@link DateFormat} and adds behavior to convert to/from * the empty string. Therefore it holds an empty value that is * mapped to/from the empty string. The {@code #format} result * of the empty value is the empty string, and the {@code #parse} * result of the empty string is the empty value. In all other cases * the formatting and parsing is forwarded to the wrapped DateFormat.

* * Often the empty value is {@code null} but you can construct an * EmptyDateFormat with a given {@code Date}.

* * Examples:

 * new EmptyDateFormat(DateFormat.getDateInstance());
 * new EmptyDateFormat(DateFormat.getDateInstance(), new Date());
 *
 * new EmptyDateFormat(DateFormat.getDateInstance(DateFormat.SHORT));
 * new EmptyDateFormat(DateFormat.getDateInstance(DateFormat.SHORT), new Date());
 * 
* * @author Karsten Lentzsch * @version $Revision: 1.1 $ */ public final class EmptyDateFormat extends AbstractWrappedDateFormat { /** * Holds the object that represents the empty value. * The result of formatting this value is the empty string; * the result of parsing an empty string is this object. */ private final Date emptyValue; // Instance Creation **************************************************** /** * Constructs an {@code EmptyFormat} that wraps the given mandatory format * to convert {@code null} to the empty string and vice versa. * * @param delegate the format that handles the standard cases * * @throws NullPointerException if {@code delegate} is {@code null} */ public EmptyDateFormat(DateFormat delegate) { this(delegate, null); } /** * Constructs an {@code EmptyFormat} that wraps the given mandatory format * to convert the given {@code emptyValue} to the empty string * and vice versa. * * @param delegate the format that handles non-{@code null} values * @param emptyValue the representation of the empty string * * @throws NullPointerException if {@code delegate} is {@code null} */ public EmptyDateFormat(DateFormat delegate, Date emptyValue) { super(delegate); this.emptyValue = emptyValue; } // Overriding Superclass Behavior ***************************************** @Override public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition pos) { return Objects.equals(date, emptyValue) ? toAppendTo : delegate.format(date, toAppendTo, pos); } @Override public Date parse(String source, ParsePosition pos) { if (Strings.isBlank(source)) { // DateFormat#parse(String) throws a ParseException, // if the parse position is 0. We change it to 1. pos.setIndex(1); return emptyValue; } return delegate.parse(source, pos); } } jgoodies-common-1.4.0/src/main/java/com/jgoodies/common/format/AbstractWrappedDateFormat.java0000644000175000017500000001156011730624764031063 0ustar tonytony/* * Copyright (c) 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jgoodies.common.format; import static com.jgoodies.common.base.Preconditions.checkNotNull; import java.text.AttributedCharacterIterator; import java.text.DateFormat; import java.text.FieldPosition; import java.text.NumberFormat; import java.text.ParsePosition; import java.util.Calendar; import java.util.Date; import java.util.TimeZone; /** * Reduces the effort required to write custom DateFormat implementations * that retain the ability to iterate through Dates with the arrow keys * in formatted text fields (using an appropriate DateFormatter). * * This class wraps a given {@code DateFormat} and delegates most * of its behavior to the delegate, except for the abstract methods * {@link #format(Date, StringBuffer, FieldPosition)} and * {@link #parse(String, ParsePosition)} that can be overridden by * a subclass. For example the subclass EmptyDateFormat wraps a DateFormat * but it parses the empty String and returns {@code null} where the * predefined Java DateFormats throw an exception.

* * @author Karsten Lentzsch * @version $Revision: 1.1 $ */ public abstract class AbstractWrappedDateFormat extends DateFormat { /** * Refers to the wrapped Format that is used to forward * {@code #format} and {@code #parseObject}. */ protected final DateFormat delegate; // Instance Creation ****************************************************** /** * Constructs an AbstractWrappedDateFormat that wraps the given mandatory * format. * * @param delegate the format that handles the standard cases * * @throws NullPointerException if {@code delegate} is {@code null} */ public AbstractWrappedDateFormat(DateFormat delegate) { this.delegate = checkNotNull(delegate, "The delegate format must not be null."); } // Abstract Behavior ****************************************************** @Override public abstract StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition pos); @Override public abstract Date parse(String source, ParsePosition pos); // Pure Delegation ******************************************************** @Override public Calendar getCalendar() { return delegate.getCalendar(); } @Override public void setCalendar(Calendar newCalendar) { delegate.setCalendar(newCalendar); } @Override public NumberFormat getNumberFormat() { return delegate.getNumberFormat(); } @Override public void setNumberFormat(NumberFormat newNumberFormat) { delegate.setNumberFormat(newNumberFormat); } @Override public TimeZone getTimeZone() { return delegate.getTimeZone(); } @Override public void setTimeZone(TimeZone zone) { delegate.setTimeZone(zone); } @Override public boolean isLenient() { return delegate.isLenient(); } @Override public void setLenient(boolean lenient) { delegate.setLenient(lenient); } @Override public AttributedCharacterIterator formatToCharacterIterator(Object obj) { return delegate.formatToCharacterIterator(obj); } } jgoodies-common-1.4.0/src/main/java/com/jgoodies/common/format/EmptyFormat.java0000644000175000017500000001272011730624764026274 0ustar tonytony/* * Copyright (c) 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jgoodies.common.format; import static com.jgoodies.common.base.Preconditions.checkNotNull; import java.text.AttributedCharacterIterator; import java.text.FieldPosition; import java.text.Format; import java.text.ParseException; import java.text.ParsePosition; import com.jgoodies.common.base.Objects; import com.jgoodies.common.base.Strings; /** * Wraps a given {@code Format} and adds behavior to convert to/from * the empty string. Therefore it holds an empty value * (often {@code null}) that is * mapped to/from the empty string. The {@code #format} result * of the empty value is the empty string, and the {@code #parse} * result of the empty string is the empty value. In all other cases * the formatting and parsing is forwarded to the wrapped Format.

* * If you want to wrap a DateFormat or NumberFormat, you may use * {@link EmptyDateFormat} or {@link EmptyNumberFormat} resp. * * Examples:

 * new EmptyFormat(new WeightFormat());
 * 
* * @author Karsten Lentzsch * @version $Revision: 1.1 $ */ public class EmptyFormat extends Format { /** * Refers to the wrapped Format that is used to forward * {@code #format} and {@code #parseObject}. */ private final Format delegate; /** * Holds the object that represents the empty value. * The result of formatting this value is the empty string; * the result of parsing an empty string is this object. */ private final Object emptyValue; // Instance Creation **************************************************** /** * Constructs an EmptyFormat that wraps the given mandatory format * to convert {@code null} to the empty string and vice versa. * * @param delegate the format that handles the standard cases * * @throws NullPointerException if {@code delegate} is {@code null} */ public EmptyFormat(Format delegate) { this(delegate, null); } /** * Constructs an EmptyFormat that wraps the given mandatory format * to convert the given {@code emptyValue} to the empty string * and vice versa. * * @param delegate the format that handles non-{@code null} values * @param emptyValue the representation of the empty string * * @throws NullPointerException if {@code delegate} is {@code null} */ public EmptyFormat(Format delegate, Object emptyValue) { this.delegate = checkNotNull(delegate, "The delegate format must not be null."); this.emptyValue = emptyValue; } // Overriding Superclass Behavior ***************************************** /** * {@inheritDoc}

* * If {@code obj} is equal to the emptyValue, * {@code toAppendTo} is returned. Otherwise the format * is forwarded to the delegate. */ @Override public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos) { return Objects.equals(obj, emptyValue) ? toAppendTo : delegate.format(obj, toAppendTo, pos); } /** * {@inheritDoc}

* * If {@code source} is empty or whitespace, the emptyValue * is returned. Otherwise parsing is forwarded to the delegate. */ @Override public Object parseObject(String source) throws ParseException { return Strings.isBlank(source) ? emptyValue : super.parseObject(source); } @Override public final Object parseObject(String source, ParsePosition pos) { return delegate.parseObject(source, pos); } @Override public final AttributedCharacterIterator formatToCharacterIterator(Object obj) { return delegate.formatToCharacterIterator(obj); } } jgoodies-common-1.4.0/src/main/java/com/jgoodies/common/base/0000755000175000017500000000000011746220404022570 5ustar tonytonyjgoodies-common-1.4.0/src/main/java/com/jgoodies/common/base/package.html0000644000175000017500000000410511730624762025061 0ustar tonytony Consists of frequently used utility classes for general Java code. jgoodies-common-1.4.0/src/main/java/com/jgoodies/common/base/Preconditions.java0000644000175000017500000002745211730624762026275 0ustar tonytony/* * Copyright (c) 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jgoodies.common.base; import java.util.Formatter; /** * Reduces the code necessary to check preconditions on method state and * parameters. * * @author Karsten Lentzsch * @version $Revision: 1.1 $ */ public final class Preconditions { private Preconditions() { // Override default constructor; prevents instantiation. } // Tests that throw IllegalArgumentExceptions ***************************** /** * Checks the truth of the given expression and throws a customized * {@link IllegalArgumentException} if it is false. Intended for doing * parameter validation in methods and constructors, e.g.: *

     * public void foo(int count) {
     *    Preconditions.checkArgument(count > 0, "count must be positive.");
     * }
     * 
* * @param expression the precondition to check involving one ore more * parameters to the calling method or constructor * @param message the detail message to be used in the event that * an exception is thrown * @throws IllegalArgumentException if {@code expression} is false */ public static void checkArgument(boolean expression, String message) { if (!expression) { throw new IllegalArgumentException(message); } } /** * Checks the truth of the given expression and throws a customized * {@link IllegalArgumentException} if it is false. Intended for doing * parameter validation in methods and constructors, e.g.: *
     * public void foo(int count) {
     *    Preconditions.checkArgument(count > 0, "count must be positive: %s.", count);
     * }
     * 
* * @param expression the precondition to check involving one ore more * parameters to the calling method or constructor * @param messageFormat a {@link Formatter format} string for the detail message to be used * in the event that an exception is thrown. * @param messageArgs the arguments referenced by the format specifiers * in the {@code messageFormat} * @throws IllegalArgumentException if {@code expression} is false */ public static void checkArgument( boolean expression, String messageFormat, Object... messageArgs) { if (!expression) { throw new IllegalArgumentException(format(messageFormat, messageArgs)); } } // Tests Throwing NullPointerExceptions *********************************** /** * Checks that the given object reference is not {@code null} * and throws a customized {@link NullPointerException} if it is. * Intended for doing parameter validation in methods and constructors, * e.g.: *
     * public void foo(Bar bar, Baz baz) {
     *      this.bar = Preconditions.checkNotNull(bar, "bar must not be null.");
     *      Preconditions.checkNotBull(baz, "baz must not be null.");
     * }
     * 
* * @param reference the object reference to check for being {@code null} * @param message the detail message to be used in the event that * an exception is thrown * @param the type of the reference * @return {@code reference} if not {@code null} * @throws NullPointerException if {@code reference} is {@code null} */ public static T checkNotNull(T reference, String message) { if (reference == null) { throw new NullPointerException(message); } return reference; } /** * Checks that the given object reference is not {@code null} * and throws a customized {@link NullPointerException} if it is. * Intended for doing parameter validation in methods and constructors, * e.g.: *
     * public void foo(Bar bar, Baz baz) {
     *      this.bar = Preconditions.checkNotNull(bar, "bar must not be null.");
     *      Preconditions.checkNotBull(baz, "The %s must not be null.", "baz");
     * }
     * 
* * @param reference the object reference to check for being {@code null} * @param messageFormat a {@link Formatter format} string for the detail message to be used * in the event that an exception is thrown. * @param messageArgs the arguments referenced by the format specifiers * in the {@code messageFormat} * @param the type of the reference * @return {@code reference} if not {@code null} * @throws NullPointerException if {@code reference} is {@code null} */ public static T checkNotNull( T reference, String messageFormat, Object... messageArgs) { if (reference == null) { throw new NullPointerException(format(messageFormat, messageArgs)); } return reference; } // Tests Throwing IllegalStateExceptions ********************************** /** * Checks the truth of the given expression and throws a customized * {@link IllegalStateException} if it is false. Intended for doing * validation in methods involving the state of the calling instance, * but not involving parameters of the calling method, e.g.: *
     * public void unlock() {
     *    Preconditions.checkState(locked, "Must be locked to be unlocked.");
     * }
     * 
* * @param expression the precondition to check involving the state * of the calling instance * @param message the detail message to be used in the event that * an exception is thrown * @throws IllegalStateException if {@code expression} is false */ public static void checkState(boolean expression, String message) { if (!expression) { throw new IllegalStateException(message); } } /** * Checks the truth of the given expression and throws a customized * {@link IllegalStateException} if it is false. Intended for doing * validation in methods involving the state of the calling instance, * but not involving parameters of the calling method, e.g.: *
     * public void unlock() {
     *    Preconditions.checkState(locked,
     *        "Must be locked to be unlocked. Most recent lock: %s",
     *        mostRecentLock);
     * }
     * 
* * @param expression the precondition to check involving the state * of the calling instance * @param messageFormat a {@link Formatter format} string for the detail message to be used * in the event that an exception is thrown. * @param messageArgs the arguments referenced by the format specifiers * in the {@code messageFormat} * @throws IllegalStateException if {@code expression} is false */ public static void checkState( boolean expression, String messageFormat, Object... messageArgs) { if (!expression) { throw new IllegalStateException(format(messageFormat, messageArgs)); } } // Combined Tests Throwing Multiple Exceptions **************************** /** * Checks that the given string is not blank and throws a customized * {@link NullPointerException} if it is {@code null}, and a customized * {@link IllegalArgumentException} if it is empty or whitespace. * Intended for doing parameter validation in methods and constructors, * e.g.: *
     * public void foo(String text) {
     *      checkNotBlank(text, "The text must not be null, empty or whitespace.");
     * }
     * 
* * @param str the string to check for being blank * @param message the detail message to be used in the event that * an exception is thrown * @return {@code str} if not {@code null} * @throws NullPointerException if {@code str} is {@code null} * @throws IllegalArgumentException if {@code str} is empty or whitespace */ public static String checkNotBlank(String str, String message) { checkNotNull(str, message); checkArgument(Strings.isNotBlank(str), message); return str; } /** * Checks that the given string is not blank and throws a customized * {@link NullPointerException} if it is {@code null}, and a customized * {@link IllegalArgumentException} if it is empty or whitespace. * Intended for doing parameter validation in methods and constructors, * e.g.: *
     * public void foo(String text, String id) {
     *      checkNotBlank(
     *          text,
     *          "The text for %s must not be null, empty or whitespace.",
     *          id);
     * }
     * 
* * @param str the string to check for being blank * @param messageFormat a {@link Formatter format} string for the detail message to be used * in the event that an exception is thrown. * @param messageArgs the arguments referenced by the format specifiers * in the {@code messageFormat} * @return {@code str} if not {@code null} * @throws NullPointerException if {@code str} is {@code null} * @throws IllegalArgumentException if {@code str} is empty or whitespace */ public static String checkNotBlank( String str, String messageFormat, Object... messageArgs) { checkNotNull(str, messageFormat, messageArgs); checkArgument(Strings.isNotBlank(str), messageFormat, messageArgs); return str; } // Helper Code ************************************************************ static String format(String messageFormat, Object... messageArgs) { return String.format(messageFormat, messageArgs); } } jgoodies-common-1.4.0/src/main/java/com/jgoodies/common/base/Objects.java0000644000175000017500000000774211730624762025046 0ustar tonytony/* * Copyright (c) 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jgoodies.common.base; import java.io.*; /** * Provides static methods that operate on objects. * * @author Karsten Lentzsch * @version $Revision: 1.1 $ */ public final class Objects { private Objects() { // Override default constructor; prevents instantiation. } // API ******************************************************************** /** * Provides a means to copy objects that do not implement Cloneable. * Performs a deep copy where the copied object has no references * to the original object for any object that implements Serializable. * If the original is {@code null}, this method just returns {@code null}. * * @param the type of the object to be cloned * @param original the object to copied, may be {@code null} * @return the copied object * * @since 1.1.1 */ public static T deepCopy(T original) { if (original == null) { return null; } try { final ByteArrayOutputStream baos = new ByteArrayOutputStream(1024); final ObjectOutputStream oas = new ObjectOutputStream(baos); oas.writeObject(original); oas.flush(); // close is unnecessary final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); final ObjectInputStream ois = new ObjectInputStream(bais); return (T) ois.readObject(); } catch (Throwable e) { throw new RuntimeException("Deep copy failed", e); } } /** * Checks and answers if the two objects are both {@code null} or equal. * *
     * Objects.equals(null, null) == true
     * Objects.equals("Hi", "Hi") == true
     * Objects.equals("Hi", null) == false
     * Objects.equals(null, "Hi") == false
     * Objects.equals("Hi", "Ho") == false
     * 
* * @param o1 the first object to compare * @param o2 the second object to compare * @return boolean {@code true} if and only if * both objects are {@code null} or equal according to * {@link Object#equals(Object) equals} invoked on the * first object */ public static boolean equals(Object o1, Object o2) { return o1 == o2 || o1 != null && o1.equals(o2); } } jgoodies-common-1.4.0/src/main/java/com/jgoodies/common/base/Strings.java0000644000175000017500000002273611730624762025106 0ustar tonytony/* * Copyright (c) 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jgoodies.common.base; /** * Provides frequently used static null-safe String testing methods . * * @author Karsten Lentzsch * @version $Revision: 1.1 $ */ public class Strings { protected Strings() { // Override default constructor; prevents direct instantiation. } // String Validations *************************************************** /** * Checks if the given string is whitespace, empty ("") or {@code null}. * *
     * Strings.isBlank(null)    == true
     * Strings.isBlank("")      == true
     * Strings.isBlank(" ")     == true
     * Strings.isBlank(" abc")  == false
     * Strings.isBlank("abc ")  == false
     * Strings.isBlank(" abc ") == false
     * 
* * @param str the string to check, may be {@code null} * @return {@code true} if the string is whitespace, empty * or {@code null} * * @see #isEmpty(String) */ public static boolean isBlank(String str) { int length; if (str == null || (length = str.length()) == 0) { return true; } for (int i = length - 1; i >= 0; i--) { if (!Character.isWhitespace(str.charAt(i))) { return false; } } return true; } /** * Checks if the given string is not empty (""), * not {@code null} and not whitespace only. * *
     * Strings.isNotBlank(null)    == false
     * Strings.isNotBlank("")      == false
     * Strings.isNotBlank(" ")     == false
     * Strings.isNotBlank(" abc")  == true
     * Strings.isNotBlank("abc ")  == true
     * Strings.isNotBlank(" abc ") == true
     * 
* * @param str the string to check, may be {@code null} * @return {@code true} if the string is not empty * and not {@code null} and not whitespace only * * @see #isEmpty(String) */ public static boolean isNotBlank(String str) { int length; if (str == null || (length = str.length()) == 0) { return false; } for (int i = length - 1; i >= 0; i--) { if (!Character.isWhitespace(str.charAt(i))) { return true; } } return false; } /** * Checks if the given string is empty ("") or {@code null}. * *
     * Strings.isEmpty(null)  == true
     * Strings.isEmpty("")    == true
     * Strings.isEmpty(" ")   == false
     * Strings.isEmpty("Hi ") == false
     * 
* * @param str the string to check, may be {@code null} * @return {@code true} if the string is empty or {@code null} * * @see #isBlank(String) */ public static boolean isEmpty(String str) { return str == null || str.length() == 0; } /** * Checks if the given string is not empty ("") * and not {@code null}. * *
     * Strings.isNotEmpty(null)  == false
     * Strings.isNotEmpty("")    == false
     * Strings.isNotEmpty(" ")   == true
     * Strings.isNotEmpty("Hi")  == true
     * Strings.isNotEmpty("Hi ") == true
     * 
* * @param str the string to check, may be {@code null} * @return {@code true} if the string is not empty and not {@code null} * * @see #isBlank(String) */ public static boolean isNotEmpty(String str) { return str != null && str.length() > 0; } /** * Checks if the given string is {@code null}, empty (""), * or the first and last characters are not whitespace. * *
     * Strings.isTrimmed(null)  == true
     * Strings.isTrimmed("")    == true
     * Strings.isTrimmed(" ")   == false
     * Strings.isTrimmed("Hi")  == true
     * Strings.isTrimmed("Hi ") == false
     * Strings.isTrimmed(" Hi") == false
     * 
* * @param str the string to check, may be {@code null} * @return {@code true} if the string is {@code null}, empty, * or the first and last characters are not whitespace. * * @since 1.3 */ public static boolean isTrimmed(String str) { int length; if (str == null || (length = str.length()) == 0) { return true; } return !Character.isWhitespace(str.charAt(0)) && !Character.isWhitespace(str.charAt(length-1)); } /** * Checks if {@code str} starts with the given prefix ignoring cases. * {@code null} is handled safely; if both arguments are null, true * is returned, false otherwise. * *
     * Strings.startsWithIgnoreCase(null, null)      == true
     * Strings.startsWithIgnoreCase("a", null)       == false
     * Strings.startsWithIgnoreCase(null, "a")       == false
     * Strings.startsWithIgnoreCase("",  "")         == true
     * Strings.startsWithIgnoreCase(" ", "")         == true
     * Strings.startsWithIgnoreCase("John", "J")     == true
     * Strings.startsWithIgnoreCase("John", "Jo")    == true
     * Strings.startsWithIgnoreCase("John", "Joh")   == true
     * Strings.startsWithIgnoreCase("John", "joh")   == true
     * Strings.startsWithIgnoreCase("john", "Joh")   == true
     * Strings.startsWithIgnoreCase("john", "joh")   == true
     * Strings.startsWithIgnoreCase("John", "John")  == true
     * Strings.startsWithIgnoreCase("John", "john")  == true
     * Strings.startsWithIgnoreCase("John", "Jonny") == false
     * 
* * @param str the test string to check, may be null * @param prefix the prefix to check for, may be null * @return {@code true}, if the string starts with the prefix, ignoring cases, * {@code false} otherwise * * @see String#startsWith(java.lang.String) */ public static boolean startsWithIgnoreCase(String str, String prefix) { if (str == null) { return prefix == null; } if (prefix == null) { // str is not null return false; } return str.regionMatches(true, 0, prefix, 0, prefix.length()); } /** * Abbreviates the given string if it exceeds the given maximum length * by replacing its center part with an ellipsis ('…'). * If the string is {@code null} or shorter than the limit, * it is returned as is.

* *

     * Strings.abbreviateCenter(null,      3) == null
     * Strings.abbreviateCenter("",        3) == ""
     * Strings.abbreviateCenter(" ",       3) == " "
     * Strings.abbreviateCenter("a",       3) == "a"
     * Strings.abbreviateCenter("ab",      3) == "ab"
     * Strings.abbreviateCenter("abc",     3) == "abc"
     * Strings.abbreviateCenter("abcd",    3) == "a…d"
     * Strings.abbreviateCenter("abcde",   3) == "a…e"
     * Strings.abbreviateCenter("abcde",   4) == "ab…e"
     * Strings.abbreviateCenter("abcdef",  4) == "ab…f"
     * Strings.abbreviateCenter("abcdefg", 5) == "ab…fg"
     * 
* * @param str the source string * @param maxLength the maximum length of the result string * @return {@code str} if its length is less than or equal to {@code maxLength}, * an abbreviated string with length {@code maxLength} where * the center is replaced by an ellipsis */ public static String abbreviateCenter(String str, int maxLength) { if (str == null) { return null; } final int length = str.length(); if (length <= maxLength) { return str; } int headLength = maxLength / 2; int tailLength = maxLength - headLength - 1; String head = str.substring(0, headLength); String tail = str.substring(length - tailLength, length); return head + "\u2026" + tail; } } jgoodies-common-1.4.0/src/main/java/com/jgoodies/common/base/SystemUtils.java0000644000175000017500000002270711754435356025765 0ustar tonytony/* * Copyright (c) 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jgoodies.common.base; import java.awt.HeadlessException; import java.awt.Toolkit; import java.util.logging.Logger; /** * Provides convenience behavior to determine the operating system * and Java version. * * @author Karsten Lentzsch * @version $Revision: 1.2 $ */ public class SystemUtils { // Internal Constants ***************************************************** /** * The {@code os.name} System Property. Operating system name.

* * Defaults to {@code null}, if the runtime does not have security * access to read this property or the property does not exist. */ protected static final String OS_NAME = getSystemProperty("os.name"); /** * The {@code os.version} System Property. Operating system version.

* * Defaults to {@code null}, if the runtime does not have security * access to read this property or the property does not exist. */ protected static final String OS_VERSION = getSystemProperty("os.version"); /** * The {@code os.name} System Property. Operating system name.

* * Defaults to {@code null}, if the runtime does not have security * access to read this property or the property does not exist. */ protected static final String JAVA_VERSION = getSystemProperty("java.version"); // Requesting the OS and OS Version *************************************** /** * Is true if this is Linux. */ public static final boolean IS_OS_LINUX = startsWith(OS_NAME, "Linux") || startsWith(OS_NAME, "LINUX"); /** * True if this is the Mac OS. */ public static final boolean IS_OS_MAC = startsWith(OS_NAME, "Mac OS"); /** * True if this is Solaris. */ public static final boolean IS_OS_SOLARIS = startsWith(OS_NAME, "Solaris"); /** * True if this is Windows. */ public static final boolean IS_OS_WINDOWS = startsWith(OS_NAME, "Windows"); /** * True if this is Windows 98. */ public static final boolean IS_OS_WINDOWS_98 = startsWith(OS_NAME, "Windows 9") && startsWith(OS_VERSION, "4.1"); /** * True if this is Windows ME. */ public static final boolean IS_OS_WINDOWS_ME = startsWith(OS_NAME, "Windows") && startsWith(OS_VERSION, "4.9"); /** * True if this is Windows 2000. */ public static final boolean IS_OS_WINDOWS_2000 = startsWith(OS_NAME, "Windows") && startsWith(OS_VERSION, "5.0"); /** * True if this is Windows XP. */ public static final boolean IS_OS_WINDOWS_XP = startsWith(OS_NAME, "Windows") && startsWith(OS_VERSION, "5.1"); /** * True if this is Windows Vista or Server 2008. */ public static final boolean IS_OS_WINDOWS_VISTA = startsWith(OS_NAME, "Windows") && startsWith(OS_VERSION, "6.0"); /** * True if this is Windows 7. */ public static final boolean IS_OS_WINDOWS_7 = startsWith(OS_NAME, "Windows") && startsWith(OS_VERSION, "6.1"); /** * True if this is Windows 8. */ public static final boolean IS_OS_WINDOWS_8 = startsWith(OS_NAME, "Windows") && startsWith(OS_VERSION, "6.2"); /** * True if this is Windows Vista/Server 2008/7/2008 R2. */ public static final boolean IS_OS_WINDOWS_6_OR_LATER = startsWith(OS_NAME, "Windows") && startsWith(OS_VERSION, "6."); // Requesting the Java Version ******************************************** /** * True if this is Java 6. We check for a prefix of 1.6. */ public static final boolean IS_JAVA_6 = startsWith(JAVA_VERSION, "1.6"); /** * True if this is Java 7. We check for a prefix of 1.7. */ public static final boolean IS_JAVA_7 = startsWith(JAVA_VERSION, "1.7"); /** * True if this is Java 7.x or later. We check that it's not 1.6. */ public static final boolean IS_JAVA_7_OR_LATER = !IS_JAVA_6; // Visual Properties ****************************************************** /** * True since Java 6 update 10. * * @since 1.2 */ public static final boolean HAS_MODERN_RASTERIZER = hasModernRasterizer(); /** * True if the Windows XP Look&Feel is enabled. * * @since 1.2 */ public static final boolean IS_LAF_WINDOWS_XP_ENABLED = isWindowsXPLafEnabled(); /** * Is true if this environment's default toolkit reports a screen resolution * below 120 dpi.

* * @since 1.2 */ public static final boolean IS_LOW_RESOLUTION = isLowResolution(); // Internal *************************************************************** private static final String AWT_UTILITIES_CLASS_NAME = "com.sun.awt.AWTUtilities"; protected SystemUtils() { // Override default constructor; prevents instantiation. } /** * Tries to look up the System property for the given key. * In untrusted environments this may throw a SecurityException. * In this case we catch the exception and answer an empty string. * * @param key the name of the system property * @return the system property's String value, or {@code null} if there's * no such value, or an empty String when * a SecurityException has been caught */ protected static String getSystemProperty(String key) { try { return System.getProperty(key); } catch (SecurityException e) { Logger.getLogger(SystemUtils.class.getName()).warning( "Can't access the System property " + key + "."); return ""; } } protected static boolean startsWith(String str, String prefix) { return str != null && str.startsWith(prefix); } /** * Checks and answers whether this Java runtime has a modern rasterizer * or not. More precisely this method aims to understand whether a good * or poor rasterizer is used. Sun's Java runtime has improved its * rasterizer in the 1.6 N series after build 12. * * @return {@code true} if the AWTUtilities class is available, * {@code false} if this class is not in the class path. */ private static boolean hasModernRasterizer() { try { Class.forName(AWT_UTILITIES_CLASS_NAME); return true; } catch (ClassNotFoundException e) { return false; } } /** * Checks and answers whether the Windows XP style is enabled. * This method is intended to be called only if a Windows look&feel * is about to be installed or already active in the UIManager. * The XP style of the Windows look&feel is enabled by default on * Windows XP platforms since the J2SE 1.4.2; it can be disabled either * in the Windows desktop as well as in the Java runtime by setting * a System property.

* * First checks the platform, platform version and Java version. Then * checks whether the desktop property win.xpstyle.themeActive * is set or not. * * @return true if the Windows XP style is enabled */ private static boolean isWindowsXPLafEnabled() { return IS_OS_WINDOWS && Boolean.TRUE.equals(Toolkit.getDefaultToolkit(). getDesktopProperty("win.xpstyle.themeActive")) && getSystemProperty("swing.noxp") == null; } private static boolean isLowResolution() { try { return Toolkit.getDefaultToolkit().getScreenResolution() < 120; } catch (HeadlessException e) { return true; } } } jgoodies-common-1.4.0/src/main/java/com/jgoodies/common/collect/0000755000175000017500000000000011731046166023310 5ustar tonytonyjgoodies-common-1.4.0/src/main/java/com/jgoodies/common/collect/package.html0000644000175000017500000000411311730624764025575 0ustar tonytony Consists of classes that add ListModel features to List implementations. jgoodies-common-1.4.0/src/main/java/com/jgoodies/common/collect/ObservableList.java0000644000175000017500000000456211730624764027107 0ustar tonytony/* * Copyright (c) 2002-2012 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jgoodies.common.collect; import java.util.List; import javax.swing.ListModel; /** * Combines the {@link List} and {@link ListModel} interfaces. * Useful to specify a type that operates like a List and is published * as a ListModel so it can be bound to user interface components * such as {@code JList}, {@code JTable} and {@code JComboBox}.

* * The JGoodies Common ships two predefined implementations: * {@link ArrayListModel} and {@link LinkedListModel}.

* * @author Karsten Lentzsch * @version $Revision: 1.1 $ * * @param the type of the list elements */ public interface ObservableList extends List, ListModel { // This interface just combines List and ListModel and // doesn't add anything new. } jgoodies-common-1.4.0/src/main/java/com/jgoodies/common/collect/LinkedListModel.java0000644000175000017500000004146511730624764027215 0ustar tonytony/* * Copyright (c) 2002-2012 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jgoodies.common.collect; import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; import java.util.ListIterator; import javax.swing.event.EventListenerList; import javax.swing.event.ListDataEvent; import javax.swing.event.ListDataListener; /** * Adds {@link javax.swing.ListModel} capabilities to its superclass. * It allows to observe changes in the content and structure. Useful for * Lists that are bound to list views such as JList, JComboBox and JTable.

* * This class should be be final and it will be marked final in a future * version, if its subclass in the JGoodies Binding has been removed.

* * @author Karsten Lentzsch * @version $Revision: 1.1 $ * * @see ObservableList * @see ArrayListModel * * @param the type of the list elements */ public class LinkedListModel extends LinkedList implements ObservableList { private static final long serialVersionUID = 5753378113505707237L; // Instance Creation ****************************************************** /** * Constructs an empty LinkedListModel. */ public LinkedListModel() { // Just invoke the super constructor implicitly. } /** * Constructs a LinkedListModel containing the elements of the specified * collection, in the order they are returned by the collection's * iterator. * * @param c the collection whose elements are to be placed into this list. * @throws NullPointerException if {@code c} is {@code null} */ public LinkedListModel(Collection c) { super(c); } // Overriding Superclass Behavior ***************************************** @Override public final void add(int index, E element) { super.add(index, element); fireIntervalAdded(index, index); } @Override public final boolean add(E e) { int newIndex = size(); super.add(e); fireIntervalAdded(newIndex, newIndex); return true; } @Override public final boolean addAll(int index, Collection c) { boolean changed = super.addAll(index, c); if (changed) { int lastIndex = index + c.size() - 1; fireIntervalAdded(index, lastIndex); } return changed; } /** * Removes from this collection all of its elements that are contained in * the specified collection (optional operation).

* * This implementation iterates over this collection, checking each * element returned by the iterator in turn to see if it's contained * in the specified collection. If it's so contained, it's removed from * this collection with the iterator's remove method.

* * Note that this implementation will throw an * UnsupportedOperationException if the iterator returned by the * iterator method does not implement the remove method * and this collection contains one or more elements in common with the * specified collection. * * @param c elements to be removed from this collection. * @return true if this collection changed as a result of the * call. * @throws UnsupportedOperationException if the removeAll method * is not supported by this collection. * @throws NullPointerException if the specified collection is null. * * @see #remove(Object) * @see #contains(Object) */ @Override public boolean removeAll(Collection c) { boolean modified = false; Iterator e = iterator(); while (e.hasNext()) { if (c.contains(e.next())) { e.remove(); modified = true; } } return modified; } /** * Retains only the elements in this collection that are contained in the * specified collection (optional operation). In other words, removes * from this collection all of its elements that are not contained in the * specified collection.

* * This implementation iterates over this collection, checking each * element returned by the iterator in turn to see if it's contained * in the specified collection. If it's not so contained, it's removed * from this collection with the iterator's remove method.

* * Note that this implementation will throw an * UnsupportedOperationException if the iterator returned by the * iterator method does not implement the remove method * and this collection contains one or more elements not present in the * specified collection. * * @param c elements to be retained in this collection. * @return true if this collection changed as a result of the * call. * @throws UnsupportedOperationException if the retainAll method * is not supported by this Collection. * @throws NullPointerException if the specified collection is null. * * @see #remove(Object) * @see #contains(Object) */ @Override public boolean retainAll(Collection c) { boolean modified = false; Iterator e = iterator(); while (e.hasNext()) { if (!c.contains(e.next())) { e.remove(); modified = true; } } return modified; } @Override public final void addFirst(E e) { super.addFirst(e); fireIntervalAdded(0, 0); } @Override public final void addLast(E e) { int newIndex = size(); super.addLast(e); fireIntervalAdded(newIndex, newIndex); } @Override public final void clear() { if (isEmpty()) { return; } int oldLastIndex = size() - 1; super.clear(); fireIntervalRemoved(0, oldLastIndex); } @Override public final E remove(int index) { E removedElement = super.remove(index); fireIntervalRemoved(index, index); return removedElement; } @Override public final boolean remove(Object o) { int index = indexOf(o); if (index == -1) { return false; } remove(index); return true; } @Override public final E removeFirst() { E first = super.removeFirst(); fireIntervalRemoved(0, 0); return first; } @Override public final E removeLast() { int lastIndex = size() - 1; E last = super.removeLast(); fireIntervalRemoved(lastIndex, lastIndex); return last; } @Override protected final void removeRange(int fromIndex, int toIndex) { super.removeRange(fromIndex, toIndex); fireIntervalRemoved(fromIndex, toIndex - 1); } @Override public final E set(int index, E element) { E previousElement = super.set(index, element); fireContentsChanged(index, index); return previousElement; } @Override public final ListIterator listIterator(int index) { return new ReportingListIterator(super.listIterator(index)); } // ListModel Field ******************************************************** /** * Holds the registered ListDataListeners. The list that holds these * listeners is initialized lazily in {@code #getEventListenerList}. * * @see #addListDataListener(ListDataListener) * @see #removeListDataListener(ListDataListener) */ private EventListenerList listenerList; // ListModel Implementation *********************************************** @Override public final void addListDataListener(ListDataListener l) { getEventListenerList().add(ListDataListener.class, l); } @Override public final void removeListDataListener(ListDataListener l) { getEventListenerList().remove(ListDataListener.class, l); } @Override public final E getElementAt(int index) { return get(index); } @Override public final int getSize() { return size(); } // Explicit Change Notification ******************************************* /** * Notifies all registered {@code ListDataListeners} that the element * at the specified index has changed. Useful if there's a content change * without any structural change.

* * This method must be called after the element of the list changes. * * @param index the index of the element that has changed * * @see EventListenerList */ public final void fireContentsChanged(int index) { fireContentsChanged(index, index); } // ListModel Helper Code ************************************************** /** * Returns an array of all the list data listeners * registered on this {@code LinkedListModel}. * * @return all of this model's {@code ListDataListener}s, * or an empty array if no list data listeners * are currently registered * * @see #addListDataListener(ListDataListener) * @see #removeListDataListener(ListDataListener) */ public final ListDataListener[] getListDataListeners() { return getEventListenerList().getListeners(ListDataListener.class); } /** * This method must be called after one or more elements * of the list change. The changed elements * are specified by the closed interval index0, index1 -- the end points * are included. Note that index0 need not be less than or equal to index1. * * @param index0 one end of the new interval * @param index1 the other end of the new interval * @see EventListenerList */ private void fireContentsChanged(int index0, int index1) { Object[] listeners = getEventListenerList().getListenerList(); ListDataEvent e = null; for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == ListDataListener.class) { if (e == null) { e = new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, index0, index1); } ((ListDataListener) listeners[i + 1]).contentsChanged(e); } } } /** * This method must be called after one or more elements * are added to the model. The new elements * are specified by a closed interval index0, index1 -- the end points * are included. Note that index0 need not be less than or equal to index1. * * @param index0 one end of the new interval * @param index1 the other end of the new interval * @see EventListenerList */ private void fireIntervalAdded(int index0, int index1) { Object[] listeners = getEventListenerList().getListenerList(); ListDataEvent e = null; for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == ListDataListener.class) { if (e == null) { e = new ListDataEvent(this, ListDataEvent.INTERVAL_ADDED, index0, index1); } ((ListDataListener) listeners[i + 1]).intervalAdded(e); } } } /** * This method must be called after one or more elements * are removed from the model. * {@code index0} and {@code index1} are the end points * of the interval that's been removed. Note that {@code index0} * need not be less than or equal to {@code index1}. * * @param index0 one end of the removed interval, * including {@code index0} * @param index1 the other end of the removed interval, * including {@code index1} * @see EventListenerList */ private void fireIntervalRemoved(int index0, int index1) { Object[] listeners = getEventListenerList().getListenerList(); ListDataEvent e = null; for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == ListDataListener.class) { if (e == null) { e = new ListDataEvent(this, ListDataEvent.INTERVAL_REMOVED, index0, index1); } ((ListDataListener) listeners[i + 1]).intervalRemoved(e); } } } /** * Lazily initializes and returns the event listener list used * to notify registered listeners. * * @return the event listener list used to notify listeners */ private EventListenerList getEventListenerList() { if (listenerList == null) { listenerList = new EventListenerList(); } return listenerList; } // Helper Class *********************************************************** /** * A ListIterator that fires ListDataEvents if elements are added or removed. */ private final class ReportingListIterator implements ListIterator { /** * Refers to the wrapped ListIterator that is used * to forward all ListIterator methods to. */ private final ListIterator delegate; /** * Holds the object that was returned last by the underlying * ListIteratur. Used to determine the index of the element removed. */ private int lastReturnedIndex; ReportingListIterator(ListIterator delegate) { this.delegate = delegate; lastReturnedIndex = -1; } @Override public boolean hasNext() { return delegate.hasNext(); } @Override public E next() { lastReturnedIndex = nextIndex(); return delegate.next(); } @Override public boolean hasPrevious() { return delegate.hasPrevious(); } @Override public E previous() { lastReturnedIndex = previousIndex(); return delegate.previous(); } @Override public int nextIndex() { return delegate.nextIndex(); } @Override public int previousIndex() { return delegate.previousIndex(); } @Override public void remove() { int oldSize = size(); delegate.remove(); int newSize = size(); if (newSize < oldSize) { LinkedListModel.this.fireIntervalRemoved(lastReturnedIndex, lastReturnedIndex); } } @Override public void set(E e) { delegate.set(e); LinkedListModel.this.fireContentsChanged(lastReturnedIndex); } @Override public void add(E e) { delegate.add(e); int newIndex = previousIndex(); LinkedListModel.this.fireIntervalAdded(newIndex, newIndex); lastReturnedIndex = -1; } } } jgoodies-common-1.4.0/src/main/java/com/jgoodies/common/collect/ArrayListModel.java0000644000175000017500000003510511730624764027057 0ustar tonytony/* * Copyright (c) 2002-2012 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jgoodies.common.collect; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import javax.swing.event.EventListenerList; import javax.swing.event.ListDataEvent; import javax.swing.event.ListDataListener; /** * Adds {@link javax.swing.ListModel} capabilities to its superclass. * It allows to observe changes in the content and structure. Useful for * Lists that are bound to list views such as JList, JComboBox and JTable.

* * This class should be be final and it will be marked final in a future * version, if its subclass in the JGoodies Binding has been removed. * * @author Karsten Lentzsch * @version $Revision: 1.1 $ * * @see ObservableList * @see LinkedListModel * * @param the type of the list elements */ public class ArrayListModel extends ArrayList implements ObservableList { private static final long serialVersionUID = -6165677201152015546L; // Instance Creation ****************************************************** /** * Constructs an empty list with an initial capacity of ten. */ public ArrayListModel() { this(10); } /** * Constructs an empty list with the specified initial capacity. * * @param initialCapacity the initial capacity of the list. * @throws IllegalArgumentException if the specified initial capacity * is negative */ public ArrayListModel(int initialCapacity) { super(initialCapacity); } /** * Constructs a list containing the elements of the specified collection, * in the order they are returned by the collection's iterator. * The {@code ArrayListModel} instance has an initial capacity of * 110% the size of the specified collection. * * @param c the collection whose elements are to be placed into this list. * @throws NullPointerException if the specified collection is * {@code null} */ public ArrayListModel(Collection c) { super(c); } // Overriding Superclass Behavior ***************************************** @Override public final void add(int index, E element) { super.add(index, element); fireIntervalAdded(index, index); } @Override public final boolean add(E e) { int newIndex = size(); super.add(e); fireIntervalAdded(newIndex, newIndex); return true; } @Override public final boolean addAll(int index, Collection c) { boolean changed = super.addAll(index, c); if (changed) { int lastIndex = index + c.size() - 1; fireIntervalAdded(index, lastIndex); } return changed; } @Override public final boolean addAll(Collection c) { int firstIndex = size(); boolean changed = super.addAll(c); if (changed) { int lastIndex = firstIndex + c.size() - 1; fireIntervalAdded(firstIndex, lastIndex); } return changed; } /** * Removes from this collection all of its elements that are contained in * the specified collection (optional operation).

* * This implementation iterates over this collection, checking each * element returned by the iterator in turn to see if it's contained * in the specified collection. If it's so contained, it's removed from * this collection with the iterator's remove method.

* * Note that this implementation will throw an * UnsupportedOperationException if the iterator returned by the * iterator method does not implement the remove method * and this collection contains one or more elements in common with the * specified collection. * * @param c elements to be removed from this collection. * @return true if this collection changed as a result of the * call. * @throws UnsupportedOperationException if the removeAll method * is not supported by this collection. * @throws NullPointerException if the specified collection is null. * * @see #remove(Object) * @see #contains(Object) */ @Override public boolean removeAll(Collection c) { boolean modified = false; Iterator e = iterator(); while (e.hasNext()) { if (c.contains(e.next())) { e.remove(); modified = true; } } return modified; } /** * Retains only the elements in this collection that are contained in the * specified collection (optional operation). In other words, removes * from this collection all of its elements that are not contained in the * specified collection.

* * This implementation iterates over this collection, checking each * element returned by the iterator in turn to see if it's contained * in the specified collection. If it's not so contained, it's removed * from this collection with the iterator's remove method.

* * Note that this implementation will throw an * UnsupportedOperationException if the iterator returned by the * iterator method does not implement the remove method * and this collection contains one or more elements not present in the * specified collection. * * @param c elements to be retained in this collection. * @return true if this collection changed as a result of the * call. * @throws UnsupportedOperationException if the retainAll method * is not supported by this Collection. * @throws NullPointerException if the specified collection is null. * * @see #remove(Object) * @see #contains(Object) */ @Override public boolean retainAll(Collection c) { boolean modified = false; Iterator e = iterator(); while (e.hasNext()) { if (!c.contains(e.next())) { e.remove(); modified = true; } } return modified; } @Override public final void clear() { if (isEmpty()) { return; } int oldLastIndex = size() - 1; super.clear(); fireIntervalRemoved(0, oldLastIndex); } @Override public final E remove(int index) { E removedElement = super.remove(index); fireIntervalRemoved(index, index); return removedElement; } @Override public final boolean remove(Object o) { int index = indexOf(o); boolean contained = index != -1; if (contained) { remove(index); } return contained; } @Override protected final void removeRange(int fromIndex, int toIndex) { super.removeRange(fromIndex, toIndex); fireIntervalRemoved(fromIndex, toIndex - 1); } @Override public final E set(int index, E element) { E previousElement = super.set(index, element); fireContentsChanged(index, index); return previousElement; } // ListModel Field ******************************************************** /** * Holds the registered ListDataListeners. The list that holds these * listeners is initialized lazily in {@code #getEventListenerList}. * * @see #addListDataListener(ListDataListener) * @see #removeListDataListener(ListDataListener) */ private EventListenerList listenerList; // ListModel Implementation *********************************************** @Override public final void addListDataListener(ListDataListener l) { getEventListenerList().add(ListDataListener.class, l); } @Override public final void removeListDataListener(ListDataListener l) { getEventListenerList().remove(ListDataListener.class, l); } @Override public final Object getElementAt(int index) { return get(index); } @Override public final int getSize() { return size(); } // Explicit Change Notification ******************************************* /** * Notifies all registered {@code ListDataListeners} that the element * at the specified index has changed. Useful if there's a content change * without any structural change.

* * This method must be called after the element of the list changes. * * @param index the index of the element that has changed * * @see EventListenerList */ public final void fireContentsChanged(int index) { fireContentsChanged(index, index); } // ListModel Helper Code ************************************************** /** * Returns an array of all the list data listeners * registered on this {@code ArrayListModel}. * * @return all of this model's {@code ListDataListener}s, * or an empty array if no list data listeners * are currently registered * * @see #addListDataListener(ListDataListener) * @see #removeListDataListener(ListDataListener) */ public final ListDataListener[] getListDataListeners() { return getEventListenerList().getListeners(ListDataListener.class); } /** * This method must be called after one or more elements * of the list change. The changed elements * are specified by the closed interval index0, index1 -- the end points * are included. Note that index0 need not be less than or equal to index1. * * @param index0 one end of the new interval * @param index1 the other end of the new interval * @see EventListenerList */ private void fireContentsChanged(int index0, int index1) { Object[] listeners = getEventListenerList().getListenerList(); ListDataEvent e = null; for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == ListDataListener.class) { if (e == null) { e = new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, index0, index1); } ((ListDataListener) listeners[i + 1]).contentsChanged(e); } } } /** * This method must be called after one or more elements * are added to the model. The new elements * are specified by a closed interval index0, index1 -- the end points * are included. Note that index0 need not be less than or equal to index1. * * @param index0 one end of the new interval * @param index1 the other end of the new interval * @see EventListenerList */ private void fireIntervalAdded(int index0, int index1) { Object[] listeners = getEventListenerList().getListenerList(); ListDataEvent e = null; for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == ListDataListener.class) { if (e == null) { e = new ListDataEvent(this, ListDataEvent.INTERVAL_ADDED, index0, index1); } ((ListDataListener) listeners[i + 1]).intervalAdded(e); } } } /** * This method must be called after one or more elements * are removed from the model. * {@code index0} and {@code index1} are the end points * of the interval that's been removed. Note that {@code index0} * need not be less than or equal to {@code index1}. * * @param index0 one end of the removed interval, * including {@code index0} * @param index1 the other end of the removed interval, * including {@code index1} * @see EventListenerList */ private void fireIntervalRemoved(int index0, int index1) { Object[] listeners = getEventListenerList().getListenerList(); ListDataEvent e = null; for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == ListDataListener.class) { if (e == null) { e = new ListDataEvent(this, ListDataEvent.INTERVAL_REMOVED, index0, index1); } ((ListDataListener) listeners[i + 1]).intervalRemoved(e); } } } /** * Lazily initializes and returns the event listener list used * to notify registered listeners. * * @return the event listener list used to notify listeners */ private EventListenerList getEventListenerList() { if (listenerList == null) { listenerList = new EventListenerList(); } return listenerList; } } jgoodies-common-1.4.0/src/test/0000755000175000017500000000000012052274600015115 5ustar tonytonyjgoodies-common-1.4.0/src/test/java/0000755000175000017500000000000012052274610016037 5ustar tonytonyjgoodies-common-1.4.0/src/test/java/META-INF/0000755000175000017500000000000012003474132017174 5ustar tonytonyjgoodies-common-1.4.0/src/test/java/META-INF/MANIFEST.MF0000644000175000017500000000014712003474130020626 0ustar tonytonyManifest-Version: 1.0 Ant-Version: Apache Ant 1.8.2 Created-By: 1.7.0_05-b05 (Oracle Corporation) jgoodies-common-1.4.0/src/test/java/com/0000755000175000017500000000000011731046166016623 5ustar tonytonyjgoodies-common-1.4.0/src/test/java/com/jgoodies/0000755000175000017500000000000011731046166020426 5ustar tonytonyjgoodies-common-1.4.0/src/test/java/com/jgoodies/common/0000755000175000017500000000000011731046166021716 5ustar tonytonyjgoodies-common-1.4.0/src/test/java/com/jgoodies/common/swing/0000755000175000017500000000000011731046166023045 5ustar tonytonyjgoodies-common-1.4.0/src/test/java/com/jgoodies/common/swing/MnemonicUtilsTest.java0000644000175000017500000002053311730624764027346 0ustar tonytony/* * Copyright (c) 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jgoodies.common.swing; import static org.junit.Assert.assertEquals; import javax.swing.JLabel; import org.junit.Test; /** * Tests the {@link MnemonicUtils} class. * * @author Karsten Lentzsch * @version $Revision: 1.1 $ */ @SuppressWarnings("static-method") public final class MnemonicUtilsTest { @Test public void htmlText() { testMnemonic("abc&def", "abcdef", 'D', -1); testMnemonic("a&bcdef", "a&bcdef", 0, -1); testMnemonic("a&bc&def", "a&bcdef", 'D', -1); } @Test public void mix() { testMnemonic("Save", "Save", 0, -1); testMnemonic("S&ave", "Save", 'A', 1); testMnemonic("Save &as", "Save as", 'A', 5); testMnemonic("Look&Feel", "LookFeel", 'F', 4); testMnemonic("Look&&Feel", "Look&Feel", 0, -1); testMnemonic("Look&&&Feel", "Look&Feel", 'F', 5); testMnemonic("Look & Feel", "Look & Feel", 0, -1); testMnemonic("Look & &Feel", "Look & Feel", 'F', 7); testMnemonic("Look & Feel&", "Look & Feel&", 0, -1); testMnemonic("Look & Feel& ", "Look & Feel& ", 0, -1); testMnemonic("&&abc&&def&&g", "&abc&def&g", 0, -1); testMnemonic("&&abc&&def&g", "&abc&defg", 'G', 8); } @Test public void testLabelWithoutMnemonic() { testMnemonic("", "", 0, -1); testMnemonic(" ", " ", 0, -1); testMnemonic(" ", " ", 0, -1); testMnemonic(" ", " ", 0, -1); testMnemonic("a", "a", 0, -1); testMnemonic("a ", "a ", 0, -1); testMnemonic(" a", " a", 0, -1); testMnemonic(" a ", " a ", 0, -1); testMnemonic("abcd", "abcd", 0, -1); testMnemonic("abcd ", "abcd ", 0, -1); } @Test public void testLabelWithSingleMnemonicMarker() { testMnemonic("&x", "x", 'X', 0); testMnemonic("a&x", "ax", 'X', 1); testMnemonic("ab&x", "abx", 'X', 2); testMnemonic("abc&x", "abcx", 'X', 3); testMnemonic("abc&x ", "abcx ", 'X', 3); testMnemonic("x&x", "xx", 'X', 1); testMnemonic("xa&x", "xax", 'X', 2); testMnemonic("xab&x", "xabx", 'X', 3); testMnemonic("xabc&x", "xabcx", 'X', 4); testMnemonic("xabc&x ", "xabcx ", 'X', 4); testMnemonic("X&x", "Xx", 'X', 1); testMnemonic("Xa&x", "Xax", 'X', 2); testMnemonic("Xab&x", "Xabx", 'X', 3); testMnemonic("Xabc&x", "Xabcx", 'X', 4); testMnemonic("Xabc&x ", "Xabcx ", 'X', 4); } @Test public void testLabelWithSingleQuotedMnemonicMarker() { testMnemonic("&&", "&", 0, -1); testMnemonic("a&&", "a&", 0, -1); testMnemonic("ab&&", "ab&", 0, -1); testMnemonic("abc&&", "abc&", 0, -1); testMnemonic("abc&& ", "abc& ", 0, -1); testMnemonic("abc&&a", "abc&a", 0, -1); testMnemonic("abc&&ab", "abc&ab", 0, -1); testMnemonic("abc&&ab ", "abc&ab ", 0, -1); } @Test public void testLabelWithMultipleMnemonicMarkers() { testMnemonic("&x&x", "x&x", 'X', 0); testMnemonic("a&x&x", "ax&x", 'X', 1); testMnemonic("ab&x&x", "abx&x", 'X', 2); testMnemonic("abc&x&x", "abcx&x", 'X', 3); testMnemonic("abc&x &x", "abcx &x", 'X', 3); testMnemonic("x&x&x", "xx&x", 'X', 1); testMnemonic("xa&x&x", "xax&x", 'X', 2); testMnemonic("xab&x&x", "xabx&x", 'X', 3); testMnemonic("xabc&x&x", "xabcx&x", 'X', 4); testMnemonic("xabc&x &x", "xabcx &x",'X', 4); testMnemonic("X&x&x", "Xx&x", 'X', 1); testMnemonic("Xa&x&x", "Xax&x", 'X', 2); testMnemonic("Xab&x&x", "Xabx&x", 'X', 3); testMnemonic("Xabc&x&x", "Xabcx&x", 'X', 4); testMnemonic("Xabc&x &x", "Xabcx &x",'X', 4); } @Test public void testLabelWithQuotedMarkerBeforeMnemonic() { testMnemonic("L&&F &choice", "L&F choice", 'C', 4); testMnemonic("&&&x", "&x", 'X', 1); testMnemonic("&&a&x", "&ax", 'X', 2); testMnemonic("&&ab&x", "&abx", 'X', 3); testMnemonic("&&abc&x", "&abcx", 'X', 4); testMnemonic("&&abc&x ", "&abcx ", 'X', 4); testMnemonic("&&x&x", "&xx", 'X', 2); testMnemonic("&&xa&x", "&xax", 'X', 3); testMnemonic("&&xab&x", "&xabx", 'X', 4); testMnemonic("&&xabc&x", "&xabcx", 'X', 5); testMnemonic("&&xabc&x ", "&xabcx ", 'X', 5); testMnemonic("&&X&x", "&Xx", 'X', 2); testMnemonic("X&&a&x", "X&ax", 'X', 3); testMnemonic("X&&ab&x", "X&abx", 'X', 4); testMnemonic("X&&abc&x", "X&abcx", 'X', 5); testMnemonic("X&&abc&x ", "X&abcx ", 'X', 5); } @Test public void testLabelWithQuotedMarkerAfterMnemonic() { testMnemonic("&Look&&Feel choice", "Look&&Feel choice", 'L', 0); testMnemonic("&x&&", "x&&", 'X', 0); testMnemonic("a&x&&", "ax&&", 'X', 1); testMnemonic("ab&x&&", "abx&&", 'X', 2); testMnemonic("abc&x&&", "abcx&&", 'X', 3); testMnemonic("abc&x &&", "abcx &&", 'X', 3); testMnemonic("a&x&&b", "ax&&b", 'X', 1); testMnemonic("a&xb&&c", "axb&&c", 'X', 1); testMnemonic("a&xbc&&", "axbc&&", 'X', 1); testMnemonic("a&xb&&c", "axb&&c", 'X', 1); } @Test public void testLabelWithQuotedMarkersBeforeAndAfterMnemonic() { testMnemonic("a&&b&&c&&d&x&&e&&f&&", "a&b&c&dx&&e&&f&&", 'X', 7); testMnemonic("a&&b&&c&&d&x&&e&&f&&g", "a&b&c&dx&&e&&f&&g",'X', 7); } // Helper Code ************************************************************ private static void testMnemonic(String markedText, String expectedPlainText, int expectedMnemonic, int expectedMnemonicIndex) { JLabel label = new JLabel(""); MnemonicUtils.configure(label, markedText); assertEquals("Text", expectedPlainText, label.getText()); assertEquals("Mnemonic", expectedMnemonic, label.getDisplayedMnemonic()); assertEquals("Mnemonic index", expectedMnemonicIndex, label.getDisplayedMnemonicIndex()); } } jgoodies-common-1.4.0/src/test/java/com/jgoodies/common/format/0000755000175000017500000000000011731046166023206 5ustar tonytonyjgoodies-common-1.4.0/src/test/java/com/jgoodies/common/format/FormatTest.java0000644000175000017500000001142211730624764026146 0ustar tonytony/* * Copyright (c) 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jgoodies.common.format; import static org.junit.Assert.assertEquals; import java.text.DateFormat; import java.text.NumberFormat; import java.text.ParseException; import java.util.Date; import org.junit.Assert; import org.junit.Test; /** * Tests classes {@link EmptyDateFormat} and {@link EmptyNumberFormat}. * * @author Karsten Lentzsch * @version $Revision: 1.1 $ */ public final class FormatTest { @SuppressWarnings({"deprecation", "static-method"}) @Test public void emptyDateFormat() { Date day1 = new Date(1967, 11, 5); Date day2 = new Date(2010, 4, 17); DateFormat defaultFormat = DateFormat.getDateInstance(); DateFormat emptyFormat1 = new EmptyDateFormat(defaultFormat); DateFormat emptyFormat2 = new EmptyDateFormat(defaultFormat, day2); String formatted = defaultFormat.format(day1); testParseDate("Empty", emptyFormat1, "", null); testParseDate("Whitespace", emptyFormat1, " ", null); testParseDate("Empty", emptyFormat2, "", day2); testParseDate("Whitespace", emptyFormat2, " ", day2); testParseDate("Day1 (raw)", defaultFormat, formatted, day1); testParseDate("Day1 (wrapped)", emptyFormat1, formatted, day1); testParseDate("Day1 (wrapped)", emptyFormat2, formatted, day1); } @SuppressWarnings("static-method") @Test public void emptyNumberFormat() { Number number1 = Long.valueOf(42); Number number2 = Double.valueOf(1.03d); NumberFormat defaultFormat = NumberFormat.getInstance(); NumberFormat emptyFormat1 = new EmptyNumberFormat(defaultFormat); NumberFormat emptyFormat2 = new EmptyNumberFormat(defaultFormat, number2); String formatted = defaultFormat.format(number1); testParseNumber("Empty", emptyFormat1, "", null); testParseNumber("Whitespace", emptyFormat1, " ", null); testParseNumber("Empty", emptyFormat2, "", number2); testParseNumber("Whitespace", emptyFormat2, " ", number2); testParseNumber("Number1 (raw)", defaultFormat, formatted, number1); testParseNumber("Number1 (wrapped)", emptyFormat1, formatted, number1); testParseNumber("Number1 (wrapped)", emptyFormat2, formatted, number1); } // Helper Code ************************************************************ private static void testParseDate(String message, DateFormat format, String source, Date expected) { try { Object actual = format.parse(source); assertEquals(message, expected, actual); } catch (ParseException e) { Assert.fail(e.getLocalizedMessage()); } } private static void testParseNumber(String message, NumberFormat format, String source, Number expected) { try { Object actual = format.parse(source); assertEquals(message, expected, actual); } catch (ParseException e) { Assert.fail(e.getLocalizedMessage()); } } } jgoodies-common-1.4.0/src/test/java/com/jgoodies/common/base/0000755000175000017500000000000011731046166022630 5ustar tonytonyjgoodies-common-1.4.0/src/test/java/com/jgoodies/common/base/SystemUtilsTest.java0000644000175000017500000000447511730624764026657 0ustar tonytony/* * Copyright (c) 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jgoodies.common.base; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeTrue; import org.junit.Test; /** * Tests the {@link SystemUtils} class. * * @author Karsten Lentzsch * @version $Revision: 1.1 $ */ @SuppressWarnings("static-method") public final class SystemUtilsTest { @Test public void testJava6() { assumeTrue(SystemUtils.IS_JAVA_6); assertFalse(SystemUtils.IS_JAVA_7); } @Test public void testJava7() { assumeTrue(SystemUtils.IS_JAVA_7); assertTrue(SystemUtils.IS_JAVA_7_OR_LATER); assertFalse(SystemUtils.IS_JAVA_6); } } jgoodies-common-1.4.0/src/test/java/com/jgoodies/common/base/ObjectsTest.java0000644000175000017500000000436111730624764025735 0ustar tonytony/* * Copyright (c) 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jgoodies.common.base; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import org.junit.Test; /** * Tests the {@link Objects} operations. * * @author Karsten Lentzsch * @version $Revision: 1.1 $ */ public final class ObjectsTest { @SuppressWarnings("static-method") @Test public void objectEquality() { assertTrue(Objects.equals(null, null)); assertTrue(Objects.equals("Hi", "Hi")); assertFalse(Objects.equals("Hi", null)); assertFalse(Objects.equals(null, "Hi")); assertFalse(Objects.equals("Hi", "Ho")); } } jgoodies-common-1.4.0/src/test/java/com/jgoodies/common/base/PreconditionsTest.java0000644000175000017500000000542111730624764027162 0ustar tonytony/* * Copyright (c) 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jgoodies.common.base; import org.junit.Test; /** * Tests the {@link Preconditions} class. * * @author Karsten Lentzsch * @version $Revision: 1.1 $ */ @SuppressWarnings("static-method") public final class PreconditionsTest { @Test public void checkValidArgument() { int count = 1; Preconditions.checkArgument(count > 0, "a message"); } @Test(expected=IllegalArgumentException.class) public void checkInvalidArgument() { int count = 0; Preconditions.checkArgument(count > 0, "a message"); } @Test public void checkNonNull() { Preconditions.checkNotNull("Hello", "a message"); } @Test(expected=NullPointerException.class) public void checkNull() { Preconditions.checkNotNull(null, "a message"); } @Test public void checkValidState() { boolean locked = true; Preconditions.checkArgument(locked, "a message"); } @Test(expected=IllegalStateException.class) public void checkInvalidState() { boolean locked = false; Preconditions.checkState(locked, "a message"); } } jgoodies-common-1.4.0/src/test/java/com/jgoodies/common/base/StringsTest.java0000644000175000017500000001417511730624764026001 0ustar tonytony/* * Copyright (c) 2003-2012 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jgoodies.common.base; import junit.framework.TestCase; import org.junit.Assert; import org.junit.Test; /** * A test case for class {@link Strings}. * * @author Karsten Lentzsch * @version $Revision: 1.1 $ */ public final class StringsTest extends TestCase { private static final String EMPTY = ""; private static final String BLANK = " "; private static final String TEXT = "abc"; private static final String SPACE_TEXT = " abc"; private static final String TEXT_SPACE = "abc "; private static final String SPACE_TEXT_SPACE = " abc "; // String Tests *********************************************************** @Test public static void testIsBlank() { assertTrue ("Null is blank", Strings.isBlank(null)); assertTrue ("EMPTY is blank", Strings.isBlank(EMPTY)); assertTrue ("BLANK is blank", Strings.isBlank(BLANK)); assertFalse("SPACE_TEXT is not blank", Strings.isBlank(SPACE_TEXT)); assertFalse("TEXT_SPACE is not blank", Strings.isBlank(TEXT_SPACE)); assertFalse("SPACE_TEXT_SPACE is not blank", Strings.isBlank(SPACE_TEXT_SPACE)); } @Test public static void testIsNotBlank() { assertFalse("Null is not not-blank", Strings.isNotBlank(null)); assertFalse("EMPTY is not not-blank", Strings.isNotBlank(EMPTY)); assertFalse("BLANK is not not-blank", Strings.isNotBlank(BLANK)); assertTrue ("SPACE_TEXT is not-blank", Strings.isNotBlank(SPACE_TEXT)); assertTrue ("TEXT_SPACE is not-blank", Strings.isNotBlank(TEXT_SPACE)); assertTrue ("SPACE_TEXT_SPACE is not-blank", Strings.isNotBlank(SPACE_TEXT_SPACE)); } @Test public static void testIsEmpty() { assertTrue ("Null is empty", Strings.isEmpty(null)); assertTrue ("EMPTY is empty", Strings.isEmpty(EMPTY)); assertFalse("BLANK is not empty", Strings.isEmpty(BLANK)); assertFalse("SPACE_TEXT is not blank", Strings.isEmpty(SPACE_TEXT)); assertFalse("TEXT_SPACE is not blank", Strings.isEmpty(TEXT_SPACE)); assertFalse("SPACE_TEXT_SPACE is not blank", Strings.isEmpty(SPACE_TEXT_SPACE)); } @Test public static void testIsNotEmpty() { assertFalse("Null is not not-empty", Strings.isNotEmpty(null)); assertFalse("EMPTY is not not-empty", Strings.isNotEmpty(EMPTY)); assertTrue ("BLANK is not-empty", Strings.isNotEmpty(BLANK)); assertTrue ("SPACE_TEXT is not-empty", Strings.isNotEmpty(SPACE_TEXT)); assertTrue ("TEXT_SPACE is not-empty", Strings.isNotEmpty(TEXT_SPACE)); assertTrue ("SPACE_TEXT_SPACE is not-empty", Strings.isNotEmpty(SPACE_TEXT_SPACE)); } @Test public static void testIsTrimmed() { assertTrue ("Null is trimmed", Strings.isTrimmed(null)); assertTrue ("EMPTY is trimmed", Strings.isTrimmed(EMPTY)); assertFalse("BLANK is not trimmed", Strings.isTrimmed(BLANK)); assertTrue ("TEXT is trimmed", Strings.isTrimmed(TEXT)); assertFalse("SPACE_TEXT is not trimmed", Strings.isTrimmed(SPACE_TEXT)); assertFalse("TEXT_SPACE is not trimmed", Strings.isTrimmed(TEXT_SPACE)); assertFalse("SPACE_TEXT_SPACE is not trimmed", Strings.isTrimmed(SPACE_TEXT_SPACE)); } // Operations ********************************************************* @Test public static void testAbbreviateCenter() { final String empty = ""; final String blank = " "; final String abc = "abc"; Assert.assertSame(null, Strings.abbreviateCenter(null, 3)); Assert.assertSame(empty, Strings.abbreviateCenter(empty, 3)); Assert.assertSame(blank, Strings.abbreviateCenter(blank, 3)); Assert.assertSame(abc, Strings.abbreviateCenter(abc, 3)); Assert.assertEquals("a\u2026d", Strings.abbreviateCenter("abcd", 3)); Assert.assertEquals("a\u2026e", Strings.abbreviateCenter("abcde", 3)); Assert.assertEquals("ab\u2026e", Strings.abbreviateCenter("abcde", 4)); Assert.assertEquals("ab\u2026f", Strings.abbreviateCenter("abcdef", 4)); Assert.assertEquals("ab\u2026fg", Strings.abbreviateCenter("abcdefg", 5)); } } jgoodies-common-1.4.0/src/test/java/com/jgoodies/common/collect/0000755000175000017500000000000011731046166023343 5ustar tonytonyjgoodies-common-1.4.0/src/test/java/com/jgoodies/common/collect/ObservableListTest.java0000644000175000017500000011350211730624764027775 0ustar tonytony/* * Copyright (c) 2002-2012 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jgoodies.common.collect; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.ListIterator; import javax.swing.event.ListDataEvent; import javax.swing.event.ListDataListener; import junit.framework.TestCase; import org.junit.Test; import com.jgoodies.common.test.event.ListDataReport; /** * A test case for classes {@link ArrayListModel} and {@link LinkedListModel}. * * @author Karsten Lentzsch * @version $Revision: 1.1 $ */ @SuppressWarnings("static-method") public final class ObservableListTest extends TestCase { /** * Tests the constructor that accepts a collection as initial content. */ @SuppressWarnings("unused") @Test public void testListConstructor() { new ArrayListModel(createEmptyArrayListModel()); new LinkedListModel(createEmptyArrayListModel()); new ArrayListModel(createSingleElementArrayListModel()); new LinkedListModel(createSingleElementLinkedListModel()); new ArrayListModel(createFilledArrayListModel()); new LinkedListModel(createFilledLinkedListModel()); } /** * Tests a single add operation on different observable lists. */ @Test public void testAdd() { testAdd(createEmptyArrayListModel()); testAdd(createEmptyLinkedListModel()); testAdd(createSingleElementArrayListModel()); testAdd(createSingleElementLinkedListModel()); testAdd(createFilledArrayListModel()); testAdd(createFilledLinkedListModel()); } /** * Tests a single indexed add operation on different observable lists. */ @Test public void testAddIndexed() { testAddIndexed(createEmptyArrayListModel(), 0); testAddIndexed(createEmptyLinkedListModel(), 0); testAddIndexed(createSingleElementArrayListModel(), 0); testAddIndexed(createSingleElementLinkedListModel(), 0); testAddIndexed(createSingleElementArrayListModel(), 1); testAddIndexed(createSingleElementLinkedListModel(), 1); int size1 = createFilledArrayListModel().size(); for (int i = 0; i <= size1; i++) { testAddIndexed(createFilledArrayListModel(), i); } int size2 = createFilledLinkedListModel().size(); for (int i = 0; i <= size2; i++) { testAddIndexed(createFilledLinkedListModel(), i); } } /** * Tests a multiple add operation on different combinations of observable lists. */ @Test public void testAddAll() { testAddAll(createEmptyArrayListModel(), createEmptyArrayListModel()); testAddAll(createEmptyLinkedListModel(), createEmptyArrayListModel()); testAddAll(createEmptyArrayListModel(), createSingleElementArrayListModel()); testAddAll(createEmptyLinkedListModel(), createSingleElementArrayListModel()); testAddAll(createEmptyArrayListModel(), createFilledArrayListModel()); testAddAll(createEmptyLinkedListModel(), createFilledArrayListModel()); testAddAll(createSingleElementArrayListModel(), createEmptyArrayListModel()); testAddAll(createSingleElementLinkedListModel(), createEmptyArrayListModel()); testAddAll(createSingleElementArrayListModel(), createSingleElementArrayListModel()); testAddAll(createSingleElementLinkedListModel(), createSingleElementArrayListModel()); testAddAll(createSingleElementArrayListModel(), createFilledArrayListModel()); testAddAll(createSingleElementLinkedListModel(), createFilledArrayListModel()); testAddAll(createFilledArrayListModel(), createEmptyArrayListModel()); testAddAll(createFilledLinkedListModel(), createEmptyArrayListModel()); testAddAll(createFilledArrayListModel(), createSingleElementArrayListModel()); testAddAll(createFilledLinkedListModel(), createSingleElementArrayListModel()); testAddAll(createFilledArrayListModel(), createFilledArrayListModel()); testAddAll(createFilledLinkedListModel(), createFilledLinkedListModel()); } /** * Tests indexed multiple add operations on different combinations of * observable lists. */ @Test public void testAddAllIndexed() { testAddAllIndexed(createEmptyArrayListModel(), createFilledArrayListModel(), 0); testAddAllIndexed(createEmptyLinkedListModel(), createFilledArrayListModel(), 0); testAddAllIndexed(createSingleElementArrayListModel(), createFilledArrayListModel(), 0); testAddAllIndexed(createSingleElementLinkedListModel(), createFilledArrayListModel(), 0); testAddAllIndexed(createSingleElementArrayListModel(), createFilledArrayListModel(), 1); testAddAllIndexed(createSingleElementLinkedListModel(), createFilledArrayListModel(), 1); int size1 = createFilledArrayListModel().size(); for (int i = 0; i <= size1; i++) { testAddAllIndexed(createFilledArrayListModel(), createFilledArrayListModel(), i); } int size2 = createFilledLinkedListModel().size(); for (int i = 0; i <= size2; i++) { testAddAllIndexed(createFilledLinkedListModel(), createFilledArrayListModel(), i); } } /** * Tests the #clear operation on different observable lists. */ @Test public void testClear() { testClear(createEmptyArrayListModel()); testClear(createEmptyLinkedListModel()); testClear(createSingleElementArrayListModel()); testClear(createSingleElementLinkedListModel()); testClear(createFilledArrayListModel()); testClear(createFilledLinkedListModel()); } /** * Tests the #remove(int) operation on different observable lists. */ @Test public void testRemoveIndex() { testRemoveIndex(createEmptyArrayListModel(), -1); testRemoveIndex(createEmptyLinkedListModel(), -1); testRemoveIndex(createEmptyArrayListModel(), 0); testRemoveIndex(createEmptyLinkedListModel(), 0); testRemoveIndex(createEmptyArrayListModel(), 1); testRemoveIndex(createEmptyLinkedListModel(), 1); testRemoveIndex(createSingleElementArrayListModel(), -1); testRemoveIndex(createSingleElementLinkedListModel(), -1); testRemoveIndex(createSingleElementArrayListModel(), 0); testRemoveIndex(createSingleElementLinkedListModel(), 0); testRemoveIndex(createSingleElementArrayListModel(), 1); testRemoveIndex(createSingleElementLinkedListModel(), 1); int size1 = createFilledArrayListModel().size(); for (int i = -1; i <= size1; i++) { testRemoveIndex(createFilledArrayListModel(), i); } int size2 = createFilledLinkedListModel().size(); for (int i = -1; i <= size2; i++) { testRemoveIndex(createFilledLinkedListModel(), i); } } /** * Tests the #remove(Object) operation on different observable lists. */ @Test public void testRemoveObject() { testRemoveObject(createEmptyArrayListModel(), -1); testRemoveObject(createEmptyLinkedListModel(), -1); testRemoveObject(createEmptyArrayListModel(), 0); testRemoveObject(createEmptyLinkedListModel(), 0); testRemoveObject(createEmptyArrayListModel(), 1); testRemoveObject(createEmptyLinkedListModel(), 1); testRemoveObject(createSingleElementArrayListModel(), -1); testRemoveObject(createSingleElementLinkedListModel(), -1); testRemoveObject(createSingleElementArrayListModel(), 0); testRemoveObject(createSingleElementLinkedListModel(), 0); testRemoveObject(createSingleElementArrayListModel(), 1); testRemoveObject(createSingleElementLinkedListModel(), 1); int size1 = createFilledArrayListModel().size(); for (int i = -1; i <= size1; i++) { testRemoveObject(createFilledArrayListModel(), i); } int size2 = createFilledLinkedListModel().size(); for (int i = -1; i <= size2; i++) { testRemoveObject(createFilledLinkedListModel(), i); } } /** * Tests #removeAll on different combinations of observable lists. */ @Test public void testRemoveAll() { testRemoveAll(createEmptyArrayListModel(), createEmptyArrayListModel()); testRemoveAll(createEmptyLinkedListModel(), createEmptyArrayListModel()); testRemoveAll(createEmptyArrayListModel(), createSingleElementArrayListModel()); testRemoveAll(createEmptyLinkedListModel(), createSingleElementArrayListModel()); testRemoveAll(createEmptyArrayListModel(), createFilledArrayListModel()); testRemoveAll(createEmptyLinkedListModel(), createFilledArrayListModel()); testRemoveAll(createSingleElementArrayListModel(), createEmptyArrayListModel()); testRemoveAll(createSingleElementLinkedListModel(), createEmptyArrayListModel()); testRemoveAll(createSingleElementArrayListModel(), createSingleElementArrayListModel()); testRemoveAll(createSingleElementLinkedListModel(), createSingleElementArrayListModel()); testRemoveAll(createSingleElementArrayListModel(), createFilledArrayListModel()); testRemoveAll(createSingleElementLinkedListModel(), createFilledArrayListModel()); testRemoveAll(createFilledArrayListModel(), createEmptyArrayListModel()); testRemoveAll(createFilledLinkedListModel(), createEmptyArrayListModel()); testRemoveAll(createFilledArrayListModel(), createSingleElementArrayListModel()); testRemoveAll(createFilledLinkedListModel(), createSingleElementArrayListModel()); testRemoveAll(createFilledArrayListModel(), createFilledArrayListModel()); testRemoveAll(createFilledLinkedListModel(), createFilledLinkedListModel()); } /** * Tests #retainAll on different combinations of observable lists. */ @Test public void testRetainAll() { testRetainAll(createEmptyArrayListModel(), createEmptyArrayListModel()); testRetainAll(createEmptyLinkedListModel(), createEmptyArrayListModel()); testRetainAll(createEmptyArrayListModel(), createSingleElementArrayListModel()); testRetainAll(createEmptyLinkedListModel(), createSingleElementArrayListModel()); testRetainAll(createEmptyArrayListModel(), createFilledArrayListModel()); testRetainAll(createEmptyLinkedListModel(), createFilledArrayListModel()); testRetainAll(createSingleElementArrayListModel(), createEmptyArrayListModel()); testRetainAll(createSingleElementLinkedListModel(), createEmptyArrayListModel()); testRetainAll(createSingleElementArrayListModel(), createSingleElementArrayListModel()); testRetainAll(createSingleElementLinkedListModel(), createSingleElementArrayListModel()); testRetainAll(createSingleElementArrayListModel(), createFilledArrayListModel()); testRetainAll(createSingleElementLinkedListModel(), createFilledArrayListModel()); testRetainAll(createFilledArrayListModel(), createEmptyArrayListModel()); testRetainAll(createFilledLinkedListModel(), createEmptyArrayListModel()); testRetainAll(createFilledArrayListModel(), createSingleElementArrayListModel()); testRetainAll(createFilledLinkedListModel(), createSingleElementArrayListModel()); testRetainAll(createFilledArrayListModel(), createFilledArrayListModel()); testRetainAll(createFilledLinkedListModel(), createFilledLinkedListModel()); } /** * Tests the #set operation on different observable lists. */ @Test public void testSet() { testSet(createEmptyArrayListModel(), 0); testSet(createEmptyLinkedListModel(), 0); testSet(createSingleElementArrayListModel(), 0); testSet(createSingleElementLinkedListModel(), 0); testSet(createSingleElementArrayListModel(), 1); testSet(createSingleElementLinkedListModel(), 1); int size1 = createFilledArrayListModel().size(); for (int i = 0; i < size1; i++) { testSet(createFilledArrayListModel(), i); } int size2 = createFilledLinkedListModel().size(); for (int i = 0; i < size2; i++) { testSet(createFilledLinkedListModel(), i); } } /** * Tests the list iterator's add operation on different observable lists. */ @Test public void testListIteratorAdd() { testListIteratorAdd(createEmptyArrayListModel(), 0, 0); testListIteratorAdd(createEmptyLinkedListModel(), 0, 0); testListIteratorAdd(createSingleElementArrayListModel(), 0, 0); testListIteratorAdd(createSingleElementArrayListModel(), 0, 1); testListIteratorAdd(createSingleElementArrayListModel(), 1, 1); testListIteratorAdd(createSingleElementLinkedListModel(), 0, 0); testListIteratorAdd(createSingleElementLinkedListModel(), 0, 1); testListIteratorAdd(createSingleElementLinkedListModel(), 1, 1); int size1 = createFilledArrayListModel().size(); for (int i = 0; i <= size1; i++) { for (int j = i; j <= size1; j++) { testListIteratorAdd(createFilledArrayListModel(), i, j); } } int size2 = createFilledLinkedListModel().size(); for (int i = 0; i <= size2; i++) { for (int j = i; j <= size2; j++) { testListIteratorAdd(createFilledLinkedListModel(), i, j); } } } /** * Tests the list iterator's remove operation on different observable lists. */ @Test public void testListIteratorRemove() { testListIteratorRemove(createEmptyArrayListModel(), 0, 0); testListIteratorRemove(createEmptyLinkedListModel(), 0, 0); testListIteratorRemove(createSingleElementArrayListModel(), 0, 0); testListIteratorRemove(createSingleElementArrayListModel(), 0, 1); testListIteratorRemove(createSingleElementArrayListModel(), 1, 1); testListIteratorRemove(createSingleElementLinkedListModel(), 0, 0); testListIteratorRemove(createSingleElementLinkedListModel(), 0, 1); testListIteratorRemove(createSingleElementLinkedListModel(), 1, 1); int size1 = createFilledArrayListModel().size(); for (int i = 0; i < size1; i++) { for (int j = i; j < size1; j++) { testListIteratorRemove(createFilledArrayListModel(), i, j); } } int size2 = createFilledLinkedListModel().size(); for (int i = 0; i < size2; i++) { for (int j = i; j < size2; j++) { testListIteratorRemove(createFilledLinkedListModel(), i, j); } } } /** * Tests the list iterator's remove operation on different observable lists. */ @Test public void testListIteratorSet() { testListIteratorSet(createEmptyArrayListModel(), 0, 0); testListIteratorSet(createEmptyLinkedListModel(), 0, 0); testListIteratorSet(createSingleElementArrayListModel(), 0, 0); testListIteratorSet(createSingleElementArrayListModel(), 0, 1); testListIteratorSet(createSingleElementArrayListModel(), 1, 1); testListIteratorSet(createSingleElementLinkedListModel(), 0, 0); testListIteratorSet(createSingleElementLinkedListModel(), 0, 1); testListIteratorSet(createSingleElementLinkedListModel(), 1, 1); int size1 = createFilledArrayListModel().size(); for (int i = 0; i < size1; i++) { for (int j = i; j < size1; j++) { testListIteratorSet(createFilledArrayListModel(), i, j); } } int size2 = createFilledLinkedListModel().size(); for (int i = 0; i < size2; i++) { for (int j = i; j < size2; j++) { testListIteratorSet(createFilledLinkedListModel(), i, j); } } } /** * Tests the iterator's remove operation on different observable lists. */ @Test public void testIteratorRemove() { testIteratorRemove(createEmptyArrayListModel(), 0); testIteratorRemove(createEmptyLinkedListModel(), 0); testIteratorRemove(createSingleElementArrayListModel(), 0); testIteratorRemove(createSingleElementArrayListModel(), 1); testIteratorRemove(createSingleElementLinkedListModel(), 0); testIteratorRemove(createSingleElementLinkedListModel(), 1); int size1 = createFilledArrayListModel().size(); for (int i = 0; i < size1; i++) { testIteratorRemove(createFilledArrayListModel(), i); } int size2 = createFilledLinkedListModel().size(); for (int i = 0; i < size2; i++) { testIteratorRemove(createFilledLinkedListModel(), i); } } // Test the Event Listener List ****************************************** @Test public void testGetListDataListenersWithoutListeners() { ListDataListener[] listeners = createEmptyArrayListModel().getListDataListeners(); assertEquals("The list of ArrayListModel's ListDataListeners is empty.", 0, listeners.length); listeners = createEmptyLinkedListModel().getListDataListeners(); assertEquals("The list of LinkedListModel's ListDataListeners is empty.", 0, listeners.length); } // Test Implementations ************************************************** private static void testAdd(ObservableList list) { ListDataReport listDataReport = new ListDataReport(); list.addListDataListener(listDataReport); list.add("OneAdded"); assertEquals("An element has been added.", 1, listDataReport.eventCountAdd()); assertEquals("One event has been fired.", 1, listDataReport.eventCount()); list.add("TwoAdded"); assertEquals("Another element has been added.", 2, listDataReport.eventCountAdd()); assertEquals("Another event has been fired.", 2, listDataReport.eventCountAdd()); } private static void testAddIndexed(ObservableList list, int index) { ListDataReport listDataReport = new ListDataReport(); list.addListDataListener(listDataReport); list.add(index, "OneAdded"); assertEquals("An element has been added.", 1, listDataReport.eventCountAdd()); assertEquals("One event has been fired.", 1, listDataReport.eventCount()); assertEquals("Proper index0 (first add).", index, listDataReport.lastEvent().getIndex0()); assertEquals("Proper index1 (first add).", index, listDataReport.lastEvent().getIndex1()); list.add(index, "TwoAdded"); assertEquals("Another element has been added.", 2, listDataReport.eventCountAdd()); assertEquals("Another event has been fired.", 2, listDataReport.eventCount()); assertEquals("Proper index0 (second add).", index, listDataReport.lastEvent().getIndex0()); assertEquals("Proper index1 (second add).", index, listDataReport.lastEvent().getIndex1()); } private static void testAddAll(ObservableList list, List additions) { ListDataReport listDataReport = new ListDataReport(); list.addListDataListener(listDataReport); int addCount = additions.size(); int eventCount = additions.isEmpty() ? 0 : 1; int addIndex0 = list.size(); int addIndex1 = addIndex0 + addCount - 1; list.addAll(additions); assertEquals("Elements have been added.", eventCount, listDataReport.eventCountAdd()); assertEquals("One event has been fired.", eventCount, listDataReport.eventCount()); if (!additions.isEmpty()) { assertEquals("Proper index0 (first addAll).", addIndex0, listDataReport.lastEvent().getIndex0()); assertEquals("Proper index1 (first addAll).", addIndex1, listDataReport.lastEvent().getIndex1()); } addIndex0 = list.size(); addIndex1 = addIndex0 + addCount - 1; list.addAll(additions); assertEquals("More elements have been added.", 2 * eventCount, listDataReport.eventCountAdd()); assertEquals("Another event has been fired.", 2 * eventCount, listDataReport.eventCountAdd()); if (!additions.isEmpty()) { assertEquals("Proper index0 (second addAll).", addIndex0, listDataReport.lastEvent().getIndex0()); assertEquals("Proper index1 (second addAll).", addIndex1, listDataReport.lastEvent().getIndex1()); } } private static void testAddAllIndexed(ObservableList list, List additions, int index) { ListDataReport listDataReport = new ListDataReport(); list.addListDataListener(listDataReport); int addCount = additions.size(); int eventCount = additions.isEmpty() ? 0 : 1; int addIndex0 = index; int addIndex1 = addIndex0 + addCount - 1; list.addAll(index, additions); assertEquals("Elements have been added.", eventCount, listDataReport.eventCountAdd()); assertEquals("One event has been fired.", eventCount, listDataReport.eventCount()); if (!additions.isEmpty()) { assertEquals("Proper index0 (first addAll).", addIndex0, listDataReport.lastEvent().getIndex0()); assertEquals("Proper index1 (first addAll).", addIndex1, listDataReport.lastEvent().getIndex1()); } addIndex0 = index; addIndex1 = addIndex0 + addCount - 1; list.addAll(index, additions); assertEquals("More elements have been added.", 2 * eventCount, listDataReport.eventCountAdd()); assertEquals("Another event has been fired.", 2 * eventCount, listDataReport.eventCountAdd()); if (!additions.isEmpty()) { assertEquals("Proper index0 (second addAll).", addIndex0, listDataReport.lastEvent().getIndex0()); assertEquals("Proper index1 (second addAll).", addIndex1, listDataReport.lastEvent().getIndex1()); } } private static void testClear(ObservableList list) { ListDataReport listDataReport = new ListDataReport(); list.addListDataListener(listDataReport); int eventCount = list.isEmpty() ? 0 : 1; int index0 = 0; int index1 = list.size() - 1; list.clear(); assertEquals("All elements have been removed.", eventCount, listDataReport.eventCountRemove()); assertEquals("One event has been fired.", eventCount, listDataReport.eventCount()); if (!list.isEmpty()) { assertEquals("Proper index0 (first clear).", index0, listDataReport.lastEvent().getIndex0()); assertEquals("Proper index1 (first clear).", index1, listDataReport.lastEvent().getIndex1()); } list.clear(); assertEquals("No further elements have been removed.", eventCount, listDataReport.eventCount()); } private static void testRemoveIndex(ObservableList list, int index) { ListDataReport listDataReport = new ListDataReport(); list.addListDataListener(listDataReport); if (index < 0 || index >= list.size()) { try { list.remove(index); fail("IndexOutOfBoundsException expected when removing index " + index); } catch (IndexOutOfBoundsException e) { // Do nothing; this is the expected behavior. } } else { list.remove(index); assertEquals("An element has been removed.", 1, listDataReport.eventCountRemove()); assertEquals("One event has been fired.", 1, listDataReport.eventCount()); assertEquals("Proper index0 (first remove).", index, listDataReport.lastEvent().getIndex0()); assertEquals("Proper index1 (first remove).", index, listDataReport.lastEvent().getIndex1()); } if (index < 0 || index >= list.size()) { try { list.remove(index); fail("IndexOutOfBoundsException expected when removing index " + index); } catch (IndexOutOfBoundsException e) { // Do nothing; this is the expected behavior. } } else { list.remove(index); assertEquals("Another element has been removed.", 2, listDataReport.eventCountRemove()); assertEquals("Another event has been fired.", 2, listDataReport.eventCount()); assertEquals("Proper index0 (second remove).", index, listDataReport.lastEvent().getIndex0()); assertEquals("Proper index1 (second remove).", index, listDataReport.lastEvent().getIndex1()); } } private static void testRemoveObject(ObservableList list, int index) { ListDataReport listDataReport = new ListDataReport(); list.addListDataListener(listDataReport); boolean contained = index >= 0 && index < list.size(); Object object = contained ? list.get(index) : "AnObjectNotContainedInTheCollection"; boolean removed = list.remove(object); assertEquals("Index != -1 iff the list changed.", contained, removed); if (removed) { assertEquals("An element has been removed.", 1, listDataReport.eventCountRemove()); assertEquals("One event has been fired.", 1, listDataReport.eventCount()); assertEquals("Proper index0 (first remove).", index, listDataReport.lastEvent().getIndex0()); assertEquals("Proper index1 (first remove).", index, listDataReport.lastEvent().getIndex1()); } } private static void testRemoveAll(ObservableList list, List removals) { ListDataReport listDataReport = new ListDataReport(); list.addListDataListener(listDataReport); List indicesToRemove = new LinkedList(); List testRemoveList = new LinkedList(list); for (E e : removals) { int index = testRemoveList.indexOf(e); if (index != -1) { indicesToRemove.add(Integer.valueOf(index)); testRemoveList.remove(index); } } int oldSize = list.size(); list.removeAll(removals); int newSize = list.size(); int removedCount = oldSize - newSize; assertEquals("Removed element count and number of removal indices.", removedCount, indicesToRemove.size()); assertEquals("Elements have been removed.", removedCount, listDataReport.eventCountRemove()); assertEquals("One event has been fired.", removedCount, listDataReport.eventCount()); // Check the indices fired by the ObservableList Iterator indexIterator = indicesToRemove.iterator(); for (ListDataEvent event : listDataReport.eventList()) { int index = indexIterator.next().intValue(); assertEquals("Proper index0 (removeAll).", index, event.getIndex0()); assertEquals("Proper index1 (removeAll).", index, event.getIndex1()); } } private static void testRetainAll(ObservableList list, List retains) { ListDataReport listDataReport = new ListDataReport(); list.addListDataListener(listDataReport); int oldSize = list.size(); list.retainAll(retains); int newSize = list.size(); int eventCount = oldSize - newSize; assertEquals("Elements have been removed.", eventCount, listDataReport.eventCountRemove()); assertEquals("One event has been fired.", eventCount, listDataReport.eventCount()); } private static void testSet(ObservableList list, int index) { ListDataReport listDataReport = new ListDataReport(); list.addListDataListener(listDataReport); if (index >= list.size()) { try { list.set(index, "newValue1"); fail("IndexOutOfBoundsException expected when removing index " + index); } catch (IndexOutOfBoundsException e) { // Do nothing; this is the expected behavior. } } else { list.set(index, "newValue1"); assertEquals("An element has been changed.", 1, listDataReport.eventCountChange()); assertEquals("One event has been fired.", 1, listDataReport.eventCount()); assertEquals("Proper index0 (first change).", index, listDataReport.lastEvent().getIndex0()); assertEquals("Proper index1 (first change).", index, listDataReport.lastEvent().getIndex1()); } if (index >= list.size()) { try { list.set(index, "newValue2"); fail("IndexOutOfBoundsException expected when removing index " + index); } catch (IndexOutOfBoundsException e) { // Do nothing; this is the expected behavior. } } else { list.set(index, "newValue2"); assertEquals("Another element has been changed.", 2, listDataReport.eventCountChange()); assertEquals("Another event has been fired.", 2, listDataReport.eventCount()); assertEquals("Proper index0 (second change).", index, listDataReport.lastEvent().getIndex0()); assertEquals("Proper index1 (second change).", index, listDataReport.lastEvent().getIndex1()); } } private static void testListIteratorAdd(ObservableList list, int iteratorIndex, int elementIndex) { ListDataReport listDataReport = new ListDataReport(); list.addListDataListener(listDataReport); ListIterator listIterator = list.listIterator(iteratorIndex); int relativeElementIndex = elementIndex - iteratorIndex; for (int i = 0; i < relativeElementIndex; i++) { listIterator.next(); } listIterator.add("Added by ListIterator"); assertEquals("An element has been added.", 1, listDataReport.eventCountAdd()); assertEquals("One event has been fired.", 1, listDataReport.eventCount()); assertEquals("Proper index0.", elementIndex, listDataReport.lastEvent().getIndex0()); assertEquals("Proper index1.", elementIndex, listDataReport.lastEvent().getIndex1()); } private static void testListIteratorRemove( ObservableList list, int iteratorIndex, int elementIndex) { ListDataReport listDataReport = new ListDataReport(); list.addListDataListener(listDataReport); ListIterator listIterator = list.listIterator(iteratorIndex); int relativeElementIndex = elementIndex - iteratorIndex; for (int i = 0; i <= relativeElementIndex && listIterator.hasNext(); i++) { listIterator.next(); } if (elementIndex < list.size()) { listIterator.remove(); assertEquals("An element has been removed.", 1, listDataReport.eventCountRemove()); assertEquals("One event has been fired.", 1, listDataReport.eventCount()); assertEquals("Proper index0.", elementIndex, listDataReport.lastEvent().getIndex0()); assertEquals("Proper index1.", elementIndex, listDataReport.lastEvent().getIndex1()); } } private static void testListIteratorSet( ObservableList list, int iteratorIndex, int elementIndex) { ListDataReport listDataReport = new ListDataReport(); list.addListDataListener(listDataReport); ListIterator listIterator = list.listIterator(iteratorIndex); int relativeElementIndex = elementIndex - iteratorIndex; for (int i = 0; i <= relativeElementIndex && listIterator.hasNext(); i++) { listIterator.next(); } if (elementIndex < list.size()) { listIterator.set("newValue1"); assertEquals("One event has been fired.", 1, listDataReport.eventCount()); assertEquals("An element has been removed.", 1, listDataReport.eventCountChange()); assertEquals("Proper index0.", elementIndex, listDataReport.lastEvent().getIndex0()); assertEquals("Proper index1.", elementIndex, listDataReport.lastEvent().getIndex1()); } } private static void testIteratorRemove( ObservableList list, int elementIndex) { ListDataReport listDataReport = new ListDataReport(); list.addListDataListener(listDataReport); Iterator iterator = list.iterator(); for (int i = 0; i <= elementIndex && iterator.hasNext(); i++) { iterator.next(); } if (elementIndex < list.size()) { iterator.remove(); assertEquals("An element has been removed.", 1, listDataReport.eventCountRemove()); assertEquals("One event has been fired.", 1, listDataReport.eventCount()); assertEquals("Proper index0.", elementIndex, listDataReport.lastEvent().getIndex0()); assertEquals("Proper index1.", elementIndex, listDataReport.lastEvent().getIndex1()); } } // Creating Observable Lists ********************************************* private static ArrayListModel createEmptyArrayListModel() { return new ArrayListModel(); } private static LinkedListModel createEmptyLinkedListModel() { return new LinkedListModel(); } private static ArrayListModel createSingleElementArrayListModel() { ArrayListModel list = new ArrayListModel(); list.add("One"); return list; } private static LinkedListModel createSingleElementLinkedListModel() { LinkedListModel list = new LinkedListModel(); list.add("One"); return list; } private static ArrayListModel createFilledArrayListModel() { ArrayListModel list = new ArrayListModel(); list.add("One"); list.add("Two"); list.add("Three"); list.add("Four"); list.add("Five"); list.add("Six"); return list; } private static LinkedListModel createFilledLinkedListModel() { LinkedListModel list = new LinkedListModel(); list.add("One"); list.add("Two"); list.add("Three"); list.add("Four"); list.add("Five"); list.add("Six"); return list; } } jgoodies-common-1.4.0/src/test/java/com/jgoodies/common/test/0000755000175000017500000000000011731046166022675 5ustar tonytonyjgoodies-common-1.4.0/src/test/java/com/jgoodies/common/test/event/0000755000175000017500000000000011731046166024016 5ustar tonytonyjgoodies-common-1.4.0/src/test/java/com/jgoodies/common/test/event/ListDataReport.java0000644000175000017500000001531111730624764027570 0ustar tonytony/* * Copyright (c) 2002-2012 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jgoodies.common.test.event; import java.util.LinkedList; import java.util.List; import java.util.ListIterator; import javax.swing.event.ListDataEvent; import javax.swing.event.ListDataListener; /** * A ListDataListener that stores the received ListDataEvents. * * @author Karsten Lentzsch * @version $Revision: 1.1 $ */ public final class ListDataReport implements ListDataListener { /** * Holds a list of all received ListDataEvents. */ private final List allEvents = new LinkedList(); /** * Holds a list of all received add ListDataEvents. */ private final List addEvents = new LinkedList(); /** * Holds a list of all received remove ListDataEvents. */ private final List removeEvents = new LinkedList(); /** * Holds a list of all received change ListDataEvents. */ private final List changeEvents = new LinkedList(); // Implementing the ListDataListener Interface *************************** /** * Sent after the indices in the index0,index1 * interval have been inserted in the data model. * The new interval includes both index0 and index1. * * @param evt a {@code ListDataEvent} encapsulating the * event information */ @Override public void intervalAdded(ListDataEvent evt) { allEvents.add(0, evt); addEvents.add(0, evt); } /** * Sent after the indices in the index0,index1 interval * have been removed from the data model. The interval * includes both index0 and index1. * * @param evt a {@code ListDataEvent} encapsulating the * event information */ @Override public void intervalRemoved(ListDataEvent evt) { allEvents.add(0, evt); removeEvents.add(0, evt); } /** * Sent when the contents of the list has changed in a way * that's too complex to characterize with the previous * methods. For example, this is sent when an item has been * replaced. Index0 and index1 bracket the change. * * @param evt a {@code ListDataEvent} encapsulating the * event information */ @Override public void contentsChanged(ListDataEvent evt) { allEvents.add(0, evt); changeEvents.add(0, evt); } // Public Report API ***************************************************** private ListDataEvent getEvent(int index) { return allEvents.get(index); } public ListDataEvent lastEvent() { return eventCount() > 0 ? getEvent(0) : null; } public ListDataEvent previousEvent() { return eventCount() > 1 ? getEvent(1) : null; } public List eventList() { return allEvents; } public int eventCount() { return allEvents.size(); } public int eventCountAdd() { return addEvents.size(); } public int eventCountRemove() { return removeEvents.size(); } public int eventCountChange() { return changeEvents.size(); } public boolean hasEvents() { return !allEvents.isEmpty(); } public void clearEventList() { allEvents.clear(); } // ************************************************************************ /** * Compares this report's event list with the event list * of the given object and ignores the source of the contained * ListDataEvents that may differ. * * @param o the object to compare with * @return true if equal, false if not * * @see java.util.AbstractList#equals(Object) */ @Override public boolean equals(Object o) { if (o == this) { return true; } if (!(o instanceof ListDataReport)) { return false; } ListIterator e1 = eventList().listIterator(); ListIterator e2 = ((ListDataReport) o).eventList().listIterator(); while (e1.hasNext() && e2.hasNext()) { ListDataEvent evt1 = e1.next(); ListDataEvent evt2 = e2.next(); if (!equalListDataEvents(evt1, evt2)) { return false; } } return !(e1.hasNext() || e2.hasNext()); } /** * Poor but valid implementation. Won't be used. * * @return this reports hash code */ @Override public int hashCode() { return eventList().size(); } /** * Checks and answers whether the two given ListDataEvents * have the same type and indices. The source may differ. */ private static boolean equalListDataEvents(ListDataEvent evt1, ListDataEvent evt2) { return evt1.getType() == evt2.getType() && evt1.getIndex0() == evt2.getIndex0() && evt1.getIndex1() == evt2.getIndex1(); } } jgoodies-common-1.4.0/src/test/java/com/jgoodies/common/AllCommonTests.java0000644000175000017500000000477211730624764025504 0ustar tonytony/* * Copyright (c) 2009-2012 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jgoodies.common; import org.junit.runner.RunWith; import org.junit.runners.Suite; import com.jgoodies.common.base.ObjectsTest; import com.jgoodies.common.base.PreconditionsTest; import com.jgoodies.common.base.StringsTest; import com.jgoodies.common.base.SystemUtilsTest; import com.jgoodies.common.collect.ObservableListTest; import com.jgoodies.common.format.FormatTest; import com.jgoodies.common.swing.MnemonicUtilsTest; /** * A test suite for all tests related to the JGoodies Common classes. * * @author Karsten Lentzsch * @version $Revision: 1.1 $ */ @RunWith(Suite.class) @Suite.SuiteClasses({ FormatTest.class, MnemonicUtilsTest.class, ObjectsTest.class, ObservableListTest.class, PreconditionsTest.class, StringsTest.class, SystemUtilsTest.class }) public final class AllCommonTests { // Just a suite definition class. } jgoodies-common-1.4.0/pom.xml0000644000175000017500000000227712003474132014672 0ustar tonytony 4.0.0 com.jgoodies jgoodies-common 1.4.0 jar JGoodies Common http://www.jgoodies.com/downloads/libraries.html The JGoodies Common library provides convenience code for other JGoodies libraries and applications. The BSD License http://www.opensource.org/licenses/bsd-license.html junit junit 4.8 test JGoodies http://www.jgoodies.com/ karsten Karsten Lentzsch JGoodies http://www.jgoodies.com/ +0100 Project owner Developer