Class Overview
An IndexedComparator which compares two String charsets. The comparison
follows the rules outlined in DataFlavor.selectBestTextFlavor. In order
to ensure that non-Unicode, non-ASCII, non-default charsets are sorted
in alphabetical order, charsets are not automatically converted to their
canonical forms.
Summary
Protected Methods |
int
|
compareCharsets(String charset1, String charset2)
Compares charsets.
|
static
String
|
getEncoding(String charset)
Returns encoding for the specified charset according to the
following rules:
- If the charset is
null , then null will
be returned.
|
[Expand]
Inherited Methods |
From class
sun.awt.datatransfer.DataTransferer.IndexedComparator
|
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this object.
|
boolean
|
equals(Object obj)
Indicates whether some other object is "equal to" this one.
|
void
|
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
final
Class<?>
|
getClass()
Returns the runtime class of this Object .
|
int
|
hashCode()
Returns a hash code value for the object.
|
final
void
|
notify()
Wakes up a single thread that is waiting on this object's
monitor.
|
final
void
|
notifyAll()
Wakes up all threads that are waiting on this object's monitor.
|
String
|
toString()
Returns a string representation of the object.
|
final
void
|
wait()
Causes the current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object.
|
final
void
|
wait(long timeout, int nanos)
Causes the current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object, or
some other thread interrupts the current thread, or a certain
amount of real time has elapsed.
|
final
void
|
wait(long timeout)
Causes the current thread to wait until either another thread invokes the
notify() method or the
notifyAll() method for this object, or a
specified amount of time has elapsed.
|
|
From interface
java.util.Comparator
abstract
int
|
compare(T o1, T o2)
Compares its two arguments for order.
|
abstract
boolean
|
equals(Object obj)
Indicates whether some other object is "equal to" this
comparator.
|
|
Public Constructors
public
DataTransferer.CharsetComparator
()
public
DataTransferer.CharsetComparator
(boolean order)
Public Methods
public
int
compare
(Object obj1, Object obj2)
Compares two String objects. Returns a negative integer, zero,
or a positive integer as the first charset is worse than, equal to,
or better than the second.
Parameters
obj1
| the first charset to be compared |
obj2
| the second charset to be compared |
Returns
- a negative integer, zero, or a positive integer as the
first argument is worse, equal to, or better than the
second.
Protected Methods
protected
int
compareCharsets
(String charset1, String charset2)
Compares charsets. Returns a negative integer, zero, or a positive
integer as the first charset is worse than, equal to, or better than
the second.
Charsets are ordered according to the following rules:
- All unsupported charsets are equal.
- Any unsupported charset is worse than any supported charset.
- Unicode charsets, such as "UTF-16", "UTF-8", "UTF-16BE" and
"UTF-16LE", are considered best.
- After them, platform default charset is selected.
- "US-ASCII" is the worst of supported charsets.
- For all other supported charsets, the lexicographically less
one is considered the better.
Parameters
charset1
| the first charset to be compared |
charset2
| the second charset to be compared. |
Returns
- a negative integer, zero, or a positive integer as the
first argument is worse, equal to, or better than the
second.
protected
static
String
getEncoding
(String charset)
Returns encoding for the specified charset according to the
following rules:
- If the charset is
null
, then null
will
be returned.
- Iff the charset specifies an encoding unsupported by this JRE,
UNSUPPORTED_CHARSET
will be returned.
- If the charset specifies an alias name, the corresponding
canonical name will be returned iff the charset is a known
Unicode, ASCII, or default charset.
Returns
- an encoding for this charset.