Package org.marketcetera.util.l10n
Class MessageComparator
- java.lang.Object
-
- org.marketcetera.util.l10n.MessageComparator
-
public class MessageComparator extends Object
A comparator of two message meta-information holders.- Since:
- 0.6.0
- Version:
- $Id: MessageComparator.java 16154 2012-07-14 16:34:05Z colin $
- Author:
- tlerios@marketcetera.com
-
-
Field Summary
Fields Modifier and Type Field Description private MessageInfo[]mExtraDstInfoprivate MessageInfo[]mExtraSrcInfoprivate MessageInfoPair[]mMismatches
-
Constructor Summary
Constructors Modifier Constructor Description MessageComparator(Class<?> container)Creates a new comparator for the given container class and the fallback properties file deduced from the class's message provider.MessageComparator(Class<?> container, Locale locale)Creates a new comparator for the given container class and the properties file deduced from the class's message provider and the given locale.MessageComparator(List<MessageInfo> srcInfo, List<MessageInfo> dstInfo)Creates a new comparator for the given meta-information.MessageComparator(ContainerClassInfo classInfo)Creates a new comparator for the given container class meta-information and the properties file deduced from the container's message provider.privateMessageComparator(ContainerClassInfo classInfo, Locale locale)Creates a new comparator for the given container class meta-information and the properties file deduced from the container's message provider and the given locale.MessageComparator(MessageInfoProvider srcProvider, MessageInfoProvider dstProvider)Creates a new comparator for the given meta-information providers.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetDifferences()Returns a textual form of the differences between source and destination.MessageInfo[]getExtraDstInfo()Returns the receiver's list of destination meta-information that is absent from the source.MessageInfo[]getExtraSrcInfo()Returns the receiver's list of source meta-information that is absent from the destination.MessageInfoPair[]getMismatches()Returns the receiver's mismatches.booleanisMatch()Checks whether the receiver found no differences between source and destination.private HashMap<String,MessageInfo>toHashMap(List<MessageInfo> infoList)Converts the given meta-information list into a map, with the map keys being the message keys.
-
-
-
Field Detail
-
mMismatches
private MessageInfoPair[] mMismatches
-
mExtraSrcInfo
private MessageInfo[] mExtraSrcInfo
-
mExtraDstInfo
private MessageInfo[] mExtraDstInfo
-
-
Constructor Detail
-
MessageComparator
public MessageComparator(List<MessageInfo> srcInfo, List<MessageInfo> dstInfo)
Creates a new comparator for the given meta-information. For both parameters, the order of list elements is unimportant.- Parameters:
srcInfo- The source meta-information.dstInfo- The destination meta-information.
-
MessageComparator
public MessageComparator(MessageInfoProvider srcProvider, MessageInfoProvider dstProvider)
Creates a new comparator for the given meta-information providers.- Parameters:
srcProvider- The source meta-information provider.dstProvider- The destination meta-information provider.
-
MessageComparator
private MessageComparator(ContainerClassInfo classInfo, Locale locale) throws I18NException
Creates a new comparator for the given container class meta-information and the properties file deduced from the container's message provider and the given locale.- Parameters:
classInfo- The meta-information of a container class.locale- The locale. UseLocale.ROOTfor the fallback properties file.- Throws:
I18NException- Thrown if there is a problem obtaining the meta-information of the properties file.
-
MessageComparator
public MessageComparator(ContainerClassInfo classInfo) throws I18NException
Creates a new comparator for the given container class meta-information and the properties file deduced from the container's message provider.- Parameters:
classInfo- The meta-information of a container class.- Throws:
I18NException- Thrown if there is a problem obtaining the meta-information of the properties file.
-
MessageComparator
public MessageComparator(Class<?> container, Locale locale) throws I18NException
Creates a new comparator for the given container class and the properties file deduced from the class's message provider and the given locale.- Parameters:
container- The class.locale- The locale. UseLocale.ROOTfor the fallback properties file.- Throws:
I18NException- Thrown if there is a problem obtaining the meta-information of either the container or the properties file.
-
MessageComparator
public MessageComparator(Class<?> container) throws I18NException
Creates a new comparator for the given container class and the fallback properties file deduced from the class's message provider.- Parameters:
container- The class.- Throws:
I18NException- Thrown if there is a problem obtaining the meta-information of either the container or the properties file.
-
-
Method Detail
-
toHashMap
private HashMap<String,MessageInfo> toHashMap(List<MessageInfo> infoList)
Converts the given meta-information list into a map, with the map keys being the message keys.- Parameters:
infoList- The meta-information in list form.- Returns:
- The map.
-
getMismatches
public MessageInfoPair[] getMismatches()
Returns the receiver's mismatches. A mismatch occurs when two message keys are present in both source and destination, and both have known but different parameter counts.- Returns:
- The mismatches.
-
getExtraSrcInfo
public MessageInfo[] getExtraSrcInfo()
Returns the receiver's list of source meta-information that is absent from the destination.- Returns:
- The list.
-
getExtraDstInfo
public MessageInfo[] getExtraDstInfo()
Returns the receiver's list of destination meta-information that is absent from the source.- Returns:
- The list.
-
isMatch
public boolean isMatch()
Checks whether the receiver found no differences between source and destination.- Returns:
- True if so.
-
getDifferences
public String getDifferences()
Returns a textual form of the differences between source and destination.- Returns:
- The differences. This is the empty string if there are no differences.
-
-