com.abstractics.utils.converter
Class ConverterInsets
java.lang.Object
com.abstractics.utils.converter.ConverterInsets
- All Implemented Interfaces:
- ObjectConverter
- public class ConverterInsets
- extends java.lang.Object
- implements ObjectConverter
Converts the given object into a String via the toString()
method and then converts the String into a java.awt.Insets
object.
Insets contain 4 numbers generally used for padding and margin notation. A
number for top, right, bottom, and left are provided. This converter will
expect one of the following three formats for the String:
- A single integer ("4") - the same value is used for top, right, bottom,
and left values.
- Two integers, separated by a comma ("2,4") - The first number is used
for both top and bottom, the second number is used for left and right.
- Four integers, separated by commas ("2,5,3,1") - Each number is used for
the top, right, bottom, and left values, respectively.
Any other String value will result in an exception.
- Version:
- $Id: ConverterInsets.java,v 1.2 2006/03/15 05:37:30 andyman99 Exp $
- Author:
- Andrew Lawrence, Copyright 2006 Abstractics, L.L.C., Licensed under the Apache
License, Version 2.0
Method Summary |
java.lang.Object |
convert(java.lang.Object obj,
java.util.Locale locale)
|
java.lang.Class |
getClassToConvertTo()
Returns java.awt.Insets |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ConverterInsets
public ConverterInsets()
getClassToConvertTo
public java.lang.Class getClassToConvertTo()
- Returns
java.awt.Insets
- Specified by:
getClassToConvertTo
in interface ObjectConverter
- Returns:
- The class that this converter converts to
- See Also:
com.abstractics.xmlpanel.utils.stringtoobject.ObjectConverter#getClassToConvertTo()
convert
public java.lang.Object convert(java.lang.Object obj,
java.util.Locale locale)
throws ObjectConverterException
- Specified by:
convert
in interface ObjectConverter
- Parameters:
obj
- Object to be converted. Guaranteed not to be null and not to
already be an instanceof the Class returned by
ObjectConverter.getClassToConvertTo()
. Those conditions are checked
before the converter is even called.locale
- The locale that is asking for the conversion. This may or may
not be necessary for the conversion.
- Returns:
- The converted object - should NEVER return anything that is not
an instanceof the class returned by
ObjectConverter.getClassToConvertTo()
- Throws:
ObjectConverterException
- Throw this exception if the string cannot be converted, for
whatever reason.