Example usage for java.util Set equals

List of usage examples for java.util Set equals

Introduction

In this page you can find the example usage for java.util Set equals.

Prototype

boolean equals(Object o);

Source Link

Document

Compares the specified object with this set for equality.

Usage

From source file:ubic.pubmedgate.interactions.NormalizePairs.java

/**
 * Given a list of pairs and an XML reader to resolve them, create a connection matrix.
 * /*w  w w.j ava2s  . c  om*/
 * @param reader
 * @param pairs
 */
public NormalizeResult normalizePairsToMatrix(AirolaXMLReader reader, List<String> pairs,
        SLOutputReader SLReader, boolean writeOut, String name) throws Exception {
    // dump out pairs to HTML
    ShowSLErrors.writeExamples(reader, SLReader, pairs,
            Config.config.getString("whitetext.iteractions.results.folder") + name + ".html");

    // sort pairs by score (for AUC)
    pairs = SLReader.sortPairUsingScore(new LinkedList<String>(pairs));
    Collections.reverse(pairs);

    Map<String, String> results = new HashMap<String, String>();
    results.put("Input pair list size", pairs.size() + "");
    results.put("annotationSet", reader.getAnnotatorNameSet());

    Direction direction = Direction.ANYDIRECTION;
    boolean propigated = true;
    DoubleMatrix<String, String> dataMatrix = getConnectionMatrix(propigated, direction);

    BAMSDataLoader bamsLoader = new BAMSDataLoader();

    List<String> connectionRegionNames = dataMatrix.getRowNames();
    DoubleMatrix<String, String> predictedMatrix = new DenseDoubleMatrix<String, String>(
            connectionRegionNames.size(), connectionRegionNames.size());
    predictedMatrix.setRowNames(connectionRegionNames);
    predictedMatrix.setColumnNames(connectionRegionNames);

    Set<Resource> allTerms = resolveModel.getTerms(); // for speed
    Set<Resource> allConcepts = resolveModel.getConcepts(); // for speed

    int totalResolves = 0;
    int inMatrix = 0;
    int oneToManyMappings = 0;
    Set<String> uniqueConnections = new HashSet<String>();
    Set<String> uniqueRegions = new HashSet<String>();
    List<String> resovledPairs = new LinkedList<String>();

    Set<NormalizedConnection> normalizedPairs = new HashSet<NormalizedConnection>();
    int selfConnections = 0;
    int notInRowNames = 0;
    int pairsNotResolved = 0;
    int bothMatched = 0;
    int count = 0;
    List<Double> positiveRanks = new LinkedList<Double>();
    int totalDepth = 0;
    int pairsWithOneMatch = 0;

    for (String pair : pairs) {
        count++;
        boolean atLeast1Match = false;
        boolean atLeast1Normalization = false;

        // for testing
        // if ( count > 300 ) {
        // break;
        // }

        StopWatch s = new StopWatch();
        s.start();
        String regionA = reader.getPartnerAText(pair);
        String regionB = reader.getPartnerBText(pair);
        Set<String> regionAresolves = resolveModel.resolve(regionA, resolver, allTerms, allConcepts);

        log.info("Testing:" + regionA + " -> " + regionB + " " + count + " of " + pairs.size());

        // for speed only go forward if A resolved
        if (!regionAresolves.isEmpty()) {
            Set<String> regionBresolves = resolveModel.resolve(regionB, resolver, allTerms, allConcepts);

            if (!regionBresolves.isEmpty()) {
                log.info("Resolved:");
                log.info("   " + regionA + " -> " + regionAresolves.toString());
                log.info("   " + regionB + " -> " + regionBresolves.toString());
                totalResolves++;
                atLeast1Normalization = true;
                if (regionAresolves.size() > 1)
                    oneToManyMappings++;
                if (regionBresolves.size() > 1)
                    oneToManyMappings++;

                if (regionAresolves.equals(regionBresolves)) {
                    selfConnections++;
                    uniqueRegions.addAll(regionAresolves);
                    resovledPairs.add(pair);
                } else {
                    for (String resolvedA : regionAresolves) {
                        for (String resolvedB : regionBresolves) {
                            resovledPairs.add(pair);
                            uniqueRegions.add(resolvedA);
                            uniqueRegions.add(resolvedB);

                            totalDepth += bamsLoader.getParents(resolvedA).size();
                            totalDepth += bamsLoader.getParents(resolvedB).size();

                            if (dataMatrix.getRowNames().contains(resolvedA)
                                    && dataMatrix.getRowNames().contains(resolvedB)) {
                                if (resolvedA.equals(resolvedB)) { // also done at the set level
                                    selfConnections++;
                                } else {
                                    uniqueConnections.add(resolvedA + resolvedB);
                                    uniqueConnections.add(resolvedB + resolvedA);

                                    // a pair can match to more than one connection!! FIX - list
                                    NormalizedConnection c = new NormalizedConnection();
                                    c.regionA = resolvedA;
                                    c.regionB = resolvedB;
                                    c.pairID = pair;
                                    normalizedPairs.add(c);

                                    // put in connection matrix
                                    double currentValue = predictedMatrix.getByKeys(resolvedA, resolvedB);
                                    currentValue += 1;
                                    predictedMatrix.setByKeys(resolvedA, resolvedB, currentValue);
                                    predictedMatrix.setByKeys(resolvedB, resolvedA, currentValue);
                                    if (dataMatrix.getByKeys(resolvedA, resolvedB) == 1d) {
                                        atLeast1Match = true;
                                        positiveRanks.add((double) (resovledPairs.size()));
                                        inMatrix++;
                                    }
                                }
                            } else {
                                notInRowNames++;
                                log.info("Not in matrix but resolved");
                            }
                        }
                    }
                }
            }
        } // end if on region A resolve
        if (atLeast1Normalization) {
            bothMatched++;
        } else {
            pairsNotResolved++;
        }
        if (atLeast1Match) {
            pairsWithOneMatch++;
        }
    }

    results.put("PairsWithOneNormalize", bothMatched + "");
    results.put("PairsWithOneNormalize2", totalResolves + "");
    results.put("PairsWithOneMatch", pairsWithOneMatch + "");
    results.put("Unresolved pairs", pairsNotResolved + "");
    results.put("RP connected", "" + inMatrix);
    results.put("RP Self connections", "" + selfConnections);
    results.put("Not in BAMS", "" + notInRowNames);
    results.put("RP Unique normalized pairs (not counting self connects)", "" + (uniqueConnections.size() / 2));
    results.put("RP AUC", ROC.aroc(resovledPairs.size(), positiveRanks) + "");
    results.put("RP Resolved pairings", resovledPairs.size() + "");
    results.put("RP Average pair depth", (totalDepth / (double) resovledPairs.size()) + "");
    results.put("Unique regions", uniqueRegions.size() + "");
    results.put("One to many mapping rate", "" + ((double) oneToManyMappings / (2 * totalResolves)));
    results.put("Name", name);

    log.info("Pairs:" + pairs.size());
    log.info("Total resolves:" + totalResolves + " of " + pairs.size());
    log.info("connected in BAMS Matrix:" + inMatrix);
    log.info("Self connections:" + selfConnections);
    log.info("Not in BAMS ROWS:" + notInRowNames);
    log.info("Unresolved pairs:" + pairsNotResolved);

    log.info("Unique normalized pairs (not counting self connects):" + (uniqueConnections.size() / 2));

    if (writeOut)
        FileTools.stringsToFile(resovledPairs, reader.getNormalizedPairsFilename());

    // write out matrix, where??
    String matrixFileName = (Config.config.getString("whitetext.iteractions.results.folder") + name
            + ".matrix");
    Util.writeRTable(matrixFileName + ".txt", predictedMatrix);
    Util.writeImage(matrixFileName + ".png", predictedMatrix);

    NormalizeResult normResult = new NormalizeResult();
    normResult.normalizedPairs = normalizedPairs;
    normResult.statisticMap = results;
    normResult.name = name;

    return normResult;
}

From source file:com.evolveum.midpoint.repo.sql.helpers.OrgClosureManager.java

private void compareOrgClosureTables(List existingEntries, List recomputedEntries, boolean rebuild,
        OperationResult result) {//w w  w. ja v a2  s . c om
    Set<List> existing = convertEntries(existingEntries);
    Set<List> recomputed = convertEntries(recomputedEntries);
    if (!existing.equals(recomputed)) {
        String addendum;
        OperationResultStatus status;
        if (rebuild) {
            status = OperationResultStatus.HANDLED_ERROR;
            addendum = " The table has been recomputed and now it is OK.";
        } else {
            status = OperationResultStatus.FATAL_ERROR;
            addendum = " Please recompute the table as soon as possible.";
        }
        String m = "Closure table is not consistent with the repository. Expected size: " + recomputed.size()
                + " actual size: " + existing.size() + "." + addendum;
        result.recordStatus(status, m);
        LOGGER.info(m);
    } else {
        String m = "Closure table is OK (" + existing.size() + " entries)";
        result.recordStatus(OperationResultStatus.SUCCESS, m);
        LOGGER.info(m);
    }
}

From source file:com.gst.portfolio.loanproduct.domain.LoanProduct.java

public boolean update(final List<Charge> newProductCharges) {
    if (newProductCharges == null) {
        return false;
    }/*w  w  w  .j a  v  a2 s . c om*/

    boolean updated = false;
    if (this.charges != null) {
        final Set<Charge> currentSetOfCharges = new HashSet<>(this.charges);
        final Set<Charge> newSetOfCharges = new HashSet<>(newProductCharges);

        if (!currentSetOfCharges.equals(newSetOfCharges)) {
            updated = true;
            this.charges = newProductCharges;
        }
    } else {
        updated = true;
        this.charges = newProductCharges;
    }
    return updated;
}

From source file:com.jskaleel.xml.JSONObject.java

/**
 * Determine if two JSONObjects are similar.
 * They must contain the same set of names which must be associated with
 * similar values./*from w w w .  j  av  a 2 s . c  o  m*/
 *
 * @param other The other JSONObject
 * @return true if they are equal
 */
public boolean similar(Object other) {
    try {
        if (!(other instanceof JSONObject)) {
            return false;
        }
        Set<String> set = this.keySet();
        if (!set.equals(((JSONObject) other).keySet())) {
            return false;
        }
        Iterator<String> iterator = set.iterator();
        while (iterator.hasNext()) {
            String name = iterator.next();
            Object valueThis = this.get(name);
            Object valueOther = ((JSONObject) other).get(name);
            if (valueThis instanceof JSONObject) {
                if (!((JSONObject) valueThis).similar(valueOther)) {
                    return false;
                }
            } else if (valueThis instanceof JSONArray) {
                if (!((JSONArray) valueThis).similar(valueOther)) {
                    return false;
                }
            } else if (!valueThis.equals(valueOther)) {
                return false;
            }
        }
        return true;
    } catch (Throwable exception) {
        return false;
    }
}

From source file:com.ggvaidya.scinames.model.Dataset.java

/**
 * Returns a Stream of all distinct names recognized at the end of this checklist.
 * /*  ww  w.j  av  a 2  s  .  c o m*/
 * For a checklist, this is every name in every row, plus names added by explicit
 * changes (which overrule the dataset), minus names removed by explicit changes.
 * 
 * For a dataset, it's (prevDataset's recognized names) + 
 * (names added by explicit and implicit changes) - (names removed by explicit
 * and implicit changes).
 * 
 * @param proj Required for filtering changes
 * @return A Stream of recognized names as at the end of this checklist.
 */
public Stream<Name> getRecognizedNames(Project proj) {
    // Start with names we explicitly add.
    Set<Name> addedNames = getChanges(proj).flatMap(ch -> ch.getToStream()).collect(Collectors.toSet());
    Set<Name> initialNames = new HashSet<>(addedNames);

    // If this is not a checklist, then pass through previously recognized names.
    if (prevDataset != null)
        initialNames.addAll(proj.getRecognizedNames(prevDataset));

    // Delete names we explicitly delete.
    Set<Name> deletedNames = getChanges(proj).flatMap(ch -> ch.getFromStream()).collect(Collectors.toSet());

    Set<Name> finalList = initialNames.stream().filter(n -> {
        // Filter out names that have been deleted, EXCEPT those that
        // have been explicitly added (such as in a lump or split).
        if (deletedNames.contains(n)) {
            if (addedNames.contains(n))
                return true; // don't filter
            else
                return false; // do filter
        } else
            return true; // don't filter
    }).collect(Collectors.toSet());

    // This should be the same as the names in a checklist!
    // Double-check!
    if (isChecklist() && !finalList.equals(getNamesInAllRows())) {
        // TODO: OKAY, so this is caused by the following scenario:
        //   - We explicitly rename "Osteocephalus vilmae" to "Hylomantis buckleyi" within a dataset
        //    - We do that because AmphibiaWeb *says* they are duplicates.
        //   - However, this dataset has rows for *both* vilmae and buckleyi.
        //   - So how?
        //      - We fix the discrepancy by recognizing all the names in the rows -- whether
        //        or not they're reflected in the changes.

        Set<Name> finalListButNotInRows = new HashSet<>(finalList);
        finalListButNotInRows.removeAll(getNamesInAllRows());

        Set<Name> rowNamesButNotFinalList = new HashSet<>(getNamesInAllRows());
        rowNamesButNotFinalList.removeAll(finalList);

        LOGGER.warning("Discrepency in calculating recognized names for " + this + ":\n"
                + "\t - Final list but not in rows: " + finalListButNotInRows + "\n"
                + "\t - Rows but not in final list: " + rowNamesButNotFinalList + "\n" + "\t - Name count: "
                + initialNames.size() + " + " + addedNames.size() + " - " + deletedNames.size() + " = "
                + (initialNames.size() + addedNames.size() - deletedNames.size()) + " (but should be "
                + finalList.size() + ")\n"
                + "Species in the rows but not in final count will be added to the list of recognized names.");

        finalList.addAll(rowNamesButNotFinalList);
    }

    return finalList.stream();
}

From source file:com.liferay.portal.security.ldap.internal.exportimport.LDAPUserImporterImpl.java

protected void importGroups(LDAPImportContext ldapImportContext, Attributes userAttributes, User user)
        throws Exception {

    Properties groupMappings = ldapImportContext.getGroupMappings();

    String groupMappingsUser = groupMappings.getProperty("user");

    Set<Long> newUserGroupIds = new LinkedHashSet<>();

    LDAPServerConfiguration ldapServerConfiguration = _ldapServerConfigurationProvider
            .getConfiguration(ldapImportContext.getCompanyId(), ldapImportContext.getLdapServerId());

    if (Validator.isNotNull(groupMappingsUser) && ldapServerConfiguration.groupSearchFilterEnabled()) {

        String baseDN = ldapServerConfiguration.baseDN();

        StringBundler sb = new StringBundler(9);

        sb.append(StringPool.OPEN_PARENTHESIS);
        sb.append(StringPool.AMPERSAND);

        String groupSearchFilter = ldapServerConfiguration.groupSearchFilter();

        LDAPUtil.validateFilter(groupSearchFilter, "LDAPServerConfiguration.groupSearchFilter");

        sb.append(groupSearchFilter);/*from  w ww . j  av  a 2  s.com*/

        sb.append(StringPool.OPEN_PARENTHESIS);
        sb.append(groupMappingsUser);
        sb.append(StringPool.EQUAL);

        Binding binding = _portalLDAP.getUser(ldapImportContext.getLdapServerId(),
                ldapImportContext.getCompanyId(), user.getScreenName(), user.getEmailAddress());

        String fullUserDN = binding.getNameInNamespace();

        sb.append(escapeValue(fullUserDN));

        sb.append(StringPool.CLOSE_PARENTHESIS);
        sb.append(StringPool.CLOSE_PARENTHESIS);

        byte[] cookie = new byte[0];

        while (cookie != null) {
            List<SearchResult> searchResults = new ArrayList<>();

            String groupMappingsGroupName = GetterUtil.getString(groupMappings.getProperty("groupName"));

            groupMappingsGroupName = StringUtil.toLowerCase(groupMappingsGroupName);

            cookie = _portalLDAP.searchLDAP(ldapImportContext.getCompanyId(),
                    ldapImportContext.getLdapContext(), cookie, 0, baseDN, sb.toString(),
                    new String[] { groupMappingsGroupName }, searchResults);

            for (SearchResult searchResult : searchResults) {
                String fullGroupDN = searchResult.getNameInNamespace();

                newUserGroupIds = importGroup(ldapImportContext, fullGroupDN, user, newUserGroupIds);
            }
        }
    } else {
        Properties userMappings = ldapImportContext.getUserMappings();

        String userMappingsGroup = userMappings.getProperty("group");

        if (Validator.isNull(userMappingsGroup)) {
            if (_log.isInfoEnabled()) {
                _log.info("Skipping group import because no mappings for LDAP "
                        + "groups were specified in user mappings " + userMappings);
            }

            return;
        }

        Attribute userGroupAttribute = userAttributes.get(userMappingsGroup);

        if (userGroupAttribute == null) {
            return;
        }

        for (int i = 0; i < userGroupAttribute.size(); i++) {
            String fullGroupDN = (String) userGroupAttribute.get(i);

            newUserGroupIds = importGroup(ldapImportContext, fullGroupDN, user, newUserGroupIds);
        }
    }

    addUserGroupsNotAddedByLDAPImport(user.getUserId(), newUserGroupIds);

    Set<Long> oldUserGroupIds = new LinkedHashSet<>();

    List<UserGroup> oldUserGroups = _userGroupLocalService.getUserUserGroups(user.getUserId());

    for (UserGroup oldUserGroup : oldUserGroups) {
        oldUserGroupIds.add(oldUserGroup.getUserGroupId());
    }

    if (!oldUserGroupIds.equals(newUserGroupIds)) {
        long[] userGroupIds = ArrayUtil.toLongArray(newUserGroupIds);

        _userGroupLocalService.setUserUserGroups(user.getUserId(), userGroupIds);
    }
}

From source file:com.tesora.dve.tools.aitemplatebuilder.AiTemplateBuilder.java

/**
 * Check if the relationship is compatible with all user-specified ranges
 * (if any)./*from  ww  w  .j a  v  a 2s.  co m*/
 */
private boolean isBaseRangeCompatible(final Relationship relationship) throws PEException {
    final Set<TableColumn> leftColumns = findBaseRangeColumns(relationship.getLHS());
    final Set<TableColumn> rightColumns = findBaseRangeColumns(relationship.getRHS());

    return (((leftColumns == null) || leftColumns.equals(relationship.getLeftColumns()))
            && ((rightColumns == null) || rightColumns.equals(relationship.getRightColumns())));
}

From source file:dk.netarkivet.harvester.indexserver.distribute.IndexRequestClient.java

/**
 * Check the reply message is valid./*from w  ww . jav  a  2 s  .  com*/
 * @param jobSet The requested set of jobs
 * @param msg The message received
 * @throws ArgumentNotValid On wrong parameters in replied message.
 * @throws IOFailure on trouble in communication or invalid reply types.
 * @throws IllegalState if message is not OK.
 */
private void checkMessageValid(Set<Long> jobSet, NetarkivetMessage msg)
        throws IllegalState, IOFailure, ArgumentNotValid {
    //Read and check reply
    if (msg == null) {
        throw new IOFailure(
                "Timeout waiting for reply of index request " + "for jobs " + StringUtils.conjoin(",", jobSet));
    }
    if (!msg.isOk()) {
        throw new IllegalState("Reply message not ok. Message is: '" + msg.getErrMsg()
                + "' in index request for jobs " + StringUtils.conjoin(",", jobSet));
    }
    if (!(msg instanceof IndexRequestMessage)) {
        throw new IOFailure("Unexpected type of reply message: '" + msg.getClass().getName()
                + "' in index request for jobs " + StringUtils.conjoin(",", jobSet));
    }
    IndexRequestMessage reply = (IndexRequestMessage) msg;
    Set<Long> foundJobs = reply.getFoundJobs();
    if (foundJobs == null) {
        throw new ArgumentNotValid("Missing parameter foundjobs in reply to" + " index request for jobs "
                + StringUtils.conjoin(",", jobSet));
    }

    //FoundJobs should always be a subset
    if (!jobSet.containsAll(foundJobs)) {
        throw new ArgumentNotValid("foundJobs is not a subset of requested " + "jobs. Requested: "
                + StringUtils.conjoin(",", jobSet) + ". Found: " + StringUtils.conjoin(",", foundJobs));
    }

    if (jobSet.equals(foundJobs)) {
        //Files should only be present if jobSet=foundJobs
        if (reply.isIndexIsStoredInDirectory()) {
            List<RemoteFile> files;
            files = reply.getResultFiles();
            if (files == null) {
                throw new ArgumentNotValid("Missing files in reply to" + " index request for jobs "
                        + StringUtils.conjoin(",", jobSet));
            }
        } else {
            RemoteFile file = reply.getResultFile();
            if (file == null) {
                throw new ArgumentNotValid("Missing file in reply to" + " index request for jobs "
                        + StringUtils.conjoin(",", jobSet));
            }
        }
    }
}

From source file:io.fabric8.git.internal.GitDataStoreImpl.java

private PullPolicyResult doPullInternal(GitContext context, CredentialsProvider credentialsProvider,
        boolean allowVersionDelete) {
    PullPolicyResult pullResult = pullPushPolicy.doPull(context, getCredentialsProvider(), allowVersionDelete);
    if (pullResult.getLastException() == null) {
        if (pullResult.localUpdateRequired()) {
            versionCache.invalidateAll();
            notificationRequired = true;
        }/*from  www .  j  a va2  s .  c o m*/
        Set<String> pullVersions = pullResult.getVersions();
        if (!pullVersions.isEmpty() && !pullVersions.equals(versions)) {
            versions.clear();
            versions.addAll(pullVersions);
            versionCache.invalidateAll();
            notificationRequired = true;
        }
        if (pullResult.remoteUpdateRequired()) {
            doPushInternal(context, credentialsProvider);
        }
    }
    return pullResult;
}

From source file:org.adl.datamodels.datatypes.InteractionValidatorImpl.java

/**
 * Compares two valid data model elements for equality.
 * //from w w  w .j  av a  2 s. com
 * @param iFirst  The first value being compared.
 * 
 * @param iSecond The second value being compared.
 * 
 * @param iDelimiters The common set of delimiters associated with the
 * values being compared.
 * 
 * @return <code>true</code> if the two values are equal, otherwise
 *         <code>false</code>.
 */
@Override
public boolean compare(String iFirst, String iSecond, List<DMDelimiter> iDelimiters) {
    boolean equal = true;

    // SCORM defined separators
    String comma = "\\[,\\]";

    // Lang code validator
    LangStringValidator langValidator = new LangStringValidator();

    // Real Range validator
    RealRangeValidator realValidator = new RealRangeValidator();

    // URI validator for maximum of 250 elements
    URIValidator uriValidator = new URIValidator(250, "short_identifier_type");

    int idx = -1;

    // Swith on the mInteractionType member to determine the type
    // being compared.
    switch (mInteractionType) {
    case MULTIPLE_CHOICE: {
        String choices1[] = iFirst.split(comma);
        String choices2[] = iSecond.split(comma);

        Set<String> set1 = new HashSet<String>();
        Set<String> set2 = new HashSet<String>();

        for (String element : choices1) {
            set1.add(element);
        }

        for (String element : choices2) {
            set2.add(element);
        }

        equal = set1.equals(set2);

        break;
    }
    case FILL_IN: {
        // Assume default delimiters
        boolean caseMatters = false;
        boolean orderMatters = true;

        // Extract each part of the match_text
        String matchText1[] = iFirst.split(comma);
        String matchText2[] = iSecond.split(comma);

        // If the lengths are not equal, we're done
        if (matchText1.length == matchText2.length) {
            if (iDelimiters != null) {
                // Loop across all delimiters looking for order_matters and
                // case_matters
                for (int i = 0; i < iDelimiters.size(); i++) {
                    DMDelimiter del = iDelimiters.get(i);

                    if (del.mDescription.mName.equals("order_matters")) {
                        // Is this the default?
                        if (del.mValue != null) {
                            orderMatters = false;
                        }
                    } else if (del.mDescription.mName.equals("case_matters")) {
                        // Is this the default?
                        if (del.mValue != null) {
                            caseMatters = true;
                        }
                    }
                }
            }

            String matchString1 = null;
            String matchString2 = null;

            String langString1 = "en";
            String langString2 = "en";

            // If order matters, just loop over the array
            if (orderMatters) {
                for (int i = 0; i < matchText1.length && equal; i++) {
                    // Look for the 'lang' delimiter in first value
                    if (matchText1[i].startsWith("{lang=")) {
                        // Find the closing '}'
                        idx = matchText1[i].indexOf('}');
                        if (idx != -1) {
                            matchString1 = matchText1[i].substring(idx + 1);
                            langString1 = matchText1[i].substring(6, idx);
                        } else {
                            langString1 = "en";
                            matchString1 = matchText1[i];
                        }
                    } else {
                        langString1 = "en";
                        matchString1 = matchText1[i];
                    }

                    // Look for the 'lang' delimiter in second value
                    if (matchText2[i].startsWith("{lang=")) {
                        // Find the closing '}'
                        idx = matchText2[i].indexOf('}');
                        if (idx != -1) {
                            matchString2 = matchText2[i].substring(idx + 1);
                            langString2 = matchText2[i].substring(6, idx);
                        } else {
                            langString2 = "en";
                            matchString2 = matchText2[i];
                        }
                    } else {
                        langString2 = "en";
                        matchString2 = matchText2[i];
                    }

                    // Make sure the lang codes are equal
                    equal = langValidator.compare(langString1, langString2, (List<DMDelimiter>) null);

                    if (equal) {
                        // Compare case?
                        if (caseMatters) {
                            equal = matchString1.equals(matchString2);
                        } else {
                            equal = matchString1.equalsIgnoreCase(matchString2);
                        }
                    } else {
                        equal = false;
                    }
                }
            } else {
                List<Boolean> matched = new ArrayList<Boolean>();

                // set all matched to 'not matched'
                for (@SuppressWarnings("unused")
                String element : matchText1) {
                    matched.add(false);
                }

                boolean found = false;

                // Loop across all strings, looking for matches
                for (int i = 0; i < matchText1.length && equal; i++) {
                    matchString1 = null;
                    matchString2 = null;

                    langString1 = "en";
                    langString2 = "en";

                    // Look for the 'lang' delimiter in first value
                    if (matchText1[i].startsWith("{lang=")) {
                        // Find the closing '}'
                        idx = matchText1[i].indexOf('}');
                        if (idx != -1) {
                            matchString1 = matchText1[i].substring(idx + 1);
                            langString1 = matchText1[i].substring(6, idx);
                        } else {
                            langString1 = "en";
                            matchString1 = matchText1[i];
                        }
                    } else {
                        langString1 = "en";
                        matchString1 = matchText1[i];
                    }

                    found = false;
                    for (int j = 0; j < matchText2.length && !found; j++) {

                        // Look for the 'lang' delimiter in second value
                        if (matchText2[j].startsWith("{lang=")) {
                            // Find the closing '}'
                            idx = matchText2[j].indexOf('}');
                            if (idx != -1) {
                                matchString2 = matchText2[j].substring(idx + 1);
                                langString2 = matchText2[j].substring(6, idx);
                            } else {
                                langString2 = "en";
                                matchString2 = matchText2[j];
                            }
                        } else {
                            langString2 = "en";
                            matchString2 = matchText2[j];
                        }

                        // Check if the lang codes are equal
                        equal = langValidator.compare(langString1, langString2, null);

                        if (equal) {
                            // Compare case?
                            if (caseMatters) {
                                found = matchString1.equals(matchString2);
                            } else {
                                found = matchString1.equalsIgnoreCase(matchString2);
                            }
                        }

                        if (found) {
                            boolean used = matched.get(j).booleanValue();

                            // Make sure this value was not used before
                            if (!used) {
                                // Remember that we've matched this string
                                matched.set(j, true);
                            } else {
                                // Keep looking for a match
                                found = false;
                            }
                        }
                    }

                    if (!found) {
                        // Did not find a match, we're done
                        equal = false;
                    }
                }
            }
        } else {
            equal = false;
        }

        break;
    }
    case LONG_FILL_IN: {
        // Assume default delimiters
        boolean caseMatters = false;

        if (iDelimiters != null) {
            // Loop across all delimiters looking for case_matters
            for (int i = 0; i < iDelimiters.size(); i++) {
                DMDelimiter del = iDelimiters.get(i);

                if (del.mDescription.mName.equals("case_matters")) {
                    // Is this the default?
                    if (del.mValue != null) {
                        caseMatters = true;
                    }
                }
            }
        }

        // Compare case?
        if (caseMatters) {
            equal = iFirst.equals(iSecond);
        } else {
            equal = iFirst.equalsIgnoreCase(iSecond);
        }

        break;
    }
    case LIKERT: {
        // Check if the URIs are equal
        equal = uriValidator.compare(iFirst, iSecond, null);

        break;
    }
    case MATCHING: {
        // Check to see if we can accept two empty strings
        if (mAllowEmpty && (iFirst.trim().equals("") || iSecond.trim().equals(""))) {
            equal = iFirst.trim().equals(iSecond.trim());

            // We're done
            break;
        }

        String pairs1[] = iFirst.split(comma);
        String pairs2[] = iSecond.split(comma);

        // If the lengths are not equal, we're done
        if (pairs1.length == pairs2.length) {
            List<Boolean> matched = new ArrayList<Boolean>();

            // set all matched pairs to 'not matched'
            for (@SuppressWarnings("unused")
            String element : pairs1) {
                matched.add(false);
            }

            boolean found = false;

            // Loop across all pairs, looking for matches
            for (int i = 0; i < pairs1.length && equal; i++) {
                idx = pairs1[i].indexOf("[.]");

                String source1 = pairs1[i].substring(0, idx);
                String target1 = pairs1[i].substring(idx + 3, pairs1[i].length());

                found = false;
                for (int j = 0; j < pairs2.length && !found; j++) {
                    idx = pairs2[i].indexOf("[.]");

                    String source2 = pairs2[i].substring(0, idx);
                    String target2 = pairs2[i].substring(idx + 3, pairs2[i].length());

                    // Compare the sources
                    found = uriValidator.compare(source1, source2, null);

                    if (found) {
                        // Compare the targets
                        found = uriValidator.compare(target1, target2, null);
                    }

                    if (found) {
                        boolean used = matched.get(j).booleanValue();

                        // Make sure this pair was not used before
                        if (!used) {
                            // Remember that we've matched this pair
                            matched.set(j, true);
                        } else {
                            // Keep looking for a match
                            found = false;
                        }
                    }
                }

                if (!found) {
                    // Did not find a match, we're done
                    equal = false;
                }
            }
        } else {
            equal = false;
        }

        break;
    }
    case PERFORMANCE: {
        // Check to see if we can accept two empty strings
        if (mAllowEmpty && (iFirst.trim().equals("") || iSecond.trim().equals(""))) {
            equal = iFirst.trim().equals(iSecond.trim());

            // We're done
            break;
        }

        // Extract the array of records
        String records1[] = iFirst.split(comma);
        String records2[] = iSecond.split(comma);

        boolean orderMatters = true;

        // If the lengths are not equal, we're done
        if (records1.length == records2.length) {
            if (iDelimiters != null) {
                // Loop across all delimiters looking for order_matters 
                for (int i = 0; i < iDelimiters.size(); i++) {
                    DMDelimiter del = iDelimiters.get(i);

                    if (del.mDescription.mName.equals("order_matters")) {
                        // Is this the default?
                        if (del.mValue != null) {
                            orderMatters = false;
                        }
                    }
                }
            }

            // If order matters, loop across all records
            if (orderMatters) {
                for (int i = 0; i < records1.length && equal; i++) {
                    // Simply compare the records
                    equal = records1[i].equals(records2[i]);
                }
            } else {
                List<Boolean> matched = new ArrayList<Boolean>();

                // set all matched records to 'not matched'
                for (@SuppressWarnings("unused")
                String element : records1) {
                    matched.add(false);
                }

                boolean found = false;

                // Loop across all pairs, looking for matches
                for (int i = 0; i < records1.length && equal; i++) {
                    found = false;
                    for (int j = 0; j < records2.length && !found; j++) {
                        // Compare the records
                        found = records1[i].equals(records2[j]);

                        if (found) {
                            boolean used = matched.get(j).booleanValue();

                            // Make sure this record was not used before
                            if (!used) {
                                // Remember that we've matched this record
                                matched.set(j, true);
                            } else {
                                // Keep looking for a match
                                found = false;
                            }
                        }
                    }

                    if (!found) {
                        // Did not find a match, we're done
                        equal = false;
                    }
                }
            }
        } else {
            equal = false;
        }

        break;
    }
    case SEQUENCING: {
        // Extract each part of the sequence
        String seq1[] = iFirst.split(comma);
        String seq2[] = iSecond.split(comma);

        // If the lengths are not equal, we're done
        if (seq1.length == seq2.length) {
            for (int i = 0; i < seq1.length && equal; i++) {
                equal = uriValidator.compare(seq1[i], seq2[i], null);
            }
        } else {
            equal = false;
            break;
        }

        break;
    }
    case NUMERIC: {
        if (mElement.equals("cmi.interactions.n.correct_responses.n.pattern")) {
            String minString1 = null;
            String maxString1 = null;

            String minString2 = null;
            String maxString2 = null;

            idx = iFirst.indexOf("[:]");

            if (idx != -1) {
                minString1 = iFirst.substring(0, idx);
                maxString1 = iFirst.substring(idx + 3);
            }

            idx = iSecond.indexOf("[:]");
            if (idx != -1) {
                minString2 = iSecond.substring(0, idx);
                maxString2 = iSecond.substring(idx + 3);
            }

            if (StringUtils.isNotBlank(minString1) || StringUtils.isNotBlank(minString2)) {
                equal = realValidator.compare(minString1, minString2, null);
            }

            if (equal) {
                if (StringUtils.isNotBlank(maxString1) || StringUtils.isNotBlank(maxString2)) {
                    equal = realValidator.compare(maxString1, maxString2, null);
                }
            }
        } else {
            equal = realValidator.compare(iFirst, iSecond, null);
        }

        break;
    }
    default: {
        break;
    }
    }

    return equal;
}