Package com.tangosol.util.comparator
Class EntryComparator
- java.lang.Object
- 
- com.tangosol.util.Base
- 
- com.tangosol.util.comparator.SafeComparator
- 
- com.tangosol.util.comparator.EntryComparator
 
 
 
- 
- All Implemented Interfaces:
- ExternalizableLite,- PortableObject,- EntryAwareComparator,- QueryMapComparator,- Remote.Comparator,- Serializable,- Comparator
 
 public class EntryComparator extends SafeComparator Comparator implementation used to compare map entries. Depending on the comparison style this comparator will compare entries' values, entries' keys or, when the provided comparator is an instance ofQueryMapComparator, the entries themselves.- Author:
- gg 2002.12.14
- See Also:
- Serialized Form
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from class com.tangosol.util.BaseBase.LoggingWriter
 
- 
 - 
Field SummaryFields Modifier and Type Field Description static intCMP_AUTOIndicates that this EntryComparator should choose the comparison style based on the underying comparator type.static intCMP_ENTRYIndicates that entries that implementQueryMap.Entryinterface will be compared using thecompareEntries()method.static intCMP_KEYIndicates that this EntryComparator should compare the entries' keys.static intCMP_VALUEIndicates that this EntryComparator should compare the entries' values.protected intm_nStyleComparison style utilized by this EntryComparator.- 
Fields inherited from class com.tangosol.util.comparator.SafeComparatorINSTANCE, m_comparator, m_fNullFirst
 
- 
 - 
Constructor SummaryConstructors Constructor Description EntryComparator()Default constructor (for ExternalizableLite and PortableObject).EntryComparator(Comparator comparator)Construct an EntryComparator to compare entries' values using the provided Comparator object.EntryComparator(Comparator comparator, int nStyle)Construct an EntryComparator to compare entries using the provided Comparator object according to the specified comparison style.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompare(Object o1, Object o2)Compares two arguments for order.booleanequals(Object o)Determine if two EntryComparator objects are equal.intgetComparisonStyle()Obtain the comparison style value utilized by this EntryComparator.booleanisCompareEntry()Check whether or not this EntryComparator pass entries themselves for comparison to the underlyingcompareEntries()method.booleanisCompareKey()Check whether or not this EntryComparator uses entries' keys to pass for comparison to the underlying Comparator.booleanisCompareValue()Check whether or not this EntryComparator uses entries' values to pass for comparison to the underlying Comparator.voidreadExternal(PofReader in)Restore the contents of a user type instance by reading its state using the specified PofReader object.voidreadExternal(DataInput in)Restore the contents of this object by loading the object's state from the passed DataInput object.voidwriteExternal(PofWriter out)Save the contents of a POF user type instance by writing its state using the specified PofWriter object.voidwriteExternal(DataOutput out)Save the contents of this object by storing the object's state into the passed DataOutput object.- 
Methods inherited from class com.tangosol.util.comparator.SafeComparatorcompareEntries, compareSafe, compareSafe, getComparator, hashCode, INSTANCE, isKeyComparator, isKeyComparator, isNullFirst, toString
 - 
Methods inherited from class com.tangosol.util.Baseazzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mergeArray, mergeBooleanArray, mergeByteArray, mergeCharArray, mergeDoubleArray, mergeFloatArray, mergeIntArray, mergeLongArray, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
 - 
Methods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface java.util.ComparatorthenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
 - 
Methods inherited from interface com.tangosol.util.function.Remote.Comparatorreversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
 
- 
 
- 
- 
- 
Field Detail- 
CMP_AUTOpublic static final int CMP_AUTO Indicates that this EntryComparator should choose the comparison style based on the underying comparator type.- See Also:
- Constant Field Values
 
 - 
CMP_VALUEpublic static final int CMP_VALUE Indicates that this EntryComparator should compare the entries' values.- See Also:
- Constant Field Values
 
 - 
CMP_KEYpublic static final int CMP_KEY Indicates that this EntryComparator should compare the entries' keys.- See Also:
- Constant Field Values
 
 - 
CMP_ENTRYpublic static final int CMP_ENTRY Indicates that entries that implementQueryMap.Entryinterface will be compared using thecompareEntries()method.- See Also:
- Constant Field Values
 
 - 
m_nStyleprotected int m_nStyle Comparison style utilized by this EntryComparator. Valid values are any of the CMP_* constants.
 
- 
 - 
Constructor Detail- 
EntryComparatorpublic EntryComparator() Default constructor (for ExternalizableLite and PortableObject).
 - 
EntryComparatorpublic EntryComparator(Comparator comparator) Construct an EntryComparator to compare entries' values using the provided Comparator object. The EntryComparator will choose the comparison style based on the specified comparator type: if the comparator is an instance of theKeyExtractor, the CMP_KEY style will be assumed; otherwise, the CMP_VALUE style is used.- Parameters:
- comparator- the comparator to use; if not specified the "natural" comparison of entries' values is used
 
 - 
EntryComparatorpublic EntryComparator(Comparator comparator, int nStyle) Construct an EntryComparator to compare entries using the provided Comparator object according to the specified comparison style. If the style is CMP_AUTO then the comparator type is checked: if the comparator is an instance of theKeyExtractor, the CMP_KEY style will be assumed; otherwise, the CMP_VALUE style is used.- Parameters:
- comparator- the comparator to use; if not specified the "natural" comparison is used
- nStyle- the comparison style to use; valid values are any of the CMP_* constants
 
 
- 
 - 
Method Detail- 
comparepublic int compare(Object o1, Object o2) Compares two arguments for order. The arguments must beMap.Entryobjects. Depending on the comparison style, this method will pass either the entries' values, keys or the entries themselves to the underlying Comparator.- Specified by:
- comparein interface- Comparator
- Overrides:
- comparein class- SafeComparator
- Parameters:
- o1- the first object to be compared
- o2- the second object to be compared
- Returns:
- a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second
 
 - 
equalspublic boolean equals(Object o) Determine if two EntryComparator objects are equal.- Specified by:
- equalsin interface- Comparator
- Overrides:
- equalsin class- SafeComparator
- Parameters:
- o- the other object
- Returns:
- true if the passed object is equal to this
 
 - 
getComparisonStylepublic int getComparisonStyle() Obtain the comparison style value utilized by this EntryComparator. The returned value should be one of the CMP_* constants.- Returns:
- the comparison style value
 
 - 
isCompareValuepublic boolean isCompareValue() Check whether or not this EntryComparator uses entries' values to pass for comparison to the underlying Comparator.- Returns:
- true iff entries' values are used for comparison
 
 - 
isCompareKeypublic boolean isCompareKey() Check whether or not this EntryComparator uses entries' keys to pass for comparison to the underlying Comparator.- Returns:
- true iff entries' keys are used for comparison
 
 - 
isCompareEntrypublic boolean isCompareEntry() Check whether or not this EntryComparator pass entries themselves for comparison to the underlyingcompareEntries()method.- Returns:
- true iff entries themselves are used for comparison
 
 - 
readExternalpublic void readExternal(DataInput in) throws IOException Restore the contents of this object by loading the object's state from the passed DataInput object.- Specified by:
- readExternalin interface- ExternalizableLite
- Overrides:
- readExternalin class- SafeComparator
- Parameters:
- in- the DataInput stream to read data from in order to restore the state of this object
- Throws:
- IOException- if an I/O exception occurs
- NotActiveException- if the object is not in its initial state, and therefore cannot be deserialized into
 
 - 
writeExternalpublic void writeExternal(DataOutput out) throws IOException Save the contents of this object by storing the object's state into the passed DataOutput object.- Specified by:
- writeExternalin interface- ExternalizableLite
- Overrides:
- writeExternalin class- SafeComparator
- Parameters:
- out- the DataOutput stream to write the state of this object to
- Throws:
- IOException- if an I/O exception occurs
 
 - 
readExternalpublic void readExternal(PofReader in) throws IOException Restore the contents of a user type instance by reading its state using the specified PofReader object.- Specified by:
- readExternalin interface- PortableObject
- Overrides:
- readExternalin class- SafeComparator
- Parameters:
- in- the PofReader from which to read the object's state
- Throws:
- IOException- if an I/O error occurs
 
 - 
writeExternalpublic void writeExternal(PofWriter out) throws IOException Save the contents of a POF user type instance by writing its state using the specified PofWriter object.- Specified by:
- writeExternalin interface- PortableObject
- Overrides:
- writeExternalin class- SafeComparator
- Parameters:
- out- the PofWriter to which to write the object's state
- Throws:
- IOException- if an I/O error occurs
 
 
- 
 
-