/** * Return a filtered list of {@link CMAbstractCode codes} for the given list of codes and their * {@link CMAbstractCode#getInclude() includes}. Does not include {@link * CMAbstractCode#getDataUrl() external links} and {@link CMAbstractCode#getIeExpression() ie * specific links}. */ @Nonnull private static List<CMAbstractCode> getCodeListForHash( @Nullable List<? extends CMAbstractCode> codes, @Nullable List excludes, @Nonnull List<CMAbstractCode> results) { if (codes != null) { for (CMAbstractCode code : codes) { boolean excluded = excludes != null && excludes.contains(code); if (!excluded) { // get all included contents as well. Do not use includes of excluded contents. if (code.getInclude().size() != 0) { getCodeListForHash(code.getInclude(), excludes, results); } // only add resources that are not IeExcludes nor ExternalLinks boolean isIeExclude = code.getIeExpression().length() != 0; boolean isExternalLink = code.getDataUrl().length() != 0; if (!isIeExclude && !isExternalLink) { results.add(code); } } } } return results; }
/** * Check whether it's legal to add the {@link CMAbstractCode resource} with the given parameters. */ private static boolean shouldAddCode( CMAbstractCode code, boolean onlyIeExcludes, boolean onlyExternalLinks) { boolean add = Boolean.FALSE; // add code if both "only" parameters are false if (!onlyExternalLinks && !onlyIeExcludes) { add = Boolean.TRUE; } else { // add either all ieExcludes, or all externalLinks. Do not add ExternalLinks if it's also an // IeExclude. boolean isIeExclude = code.getIeExpression().length() != 0; boolean isExternalLink = code.getDataUrl().length() != 0; if (isIeExclude) { if (onlyIeExcludes) { add = Boolean.TRUE; } } else { if (isExternalLink && onlyExternalLinks) { add = Boolean.TRUE; } } } return add; }