/** * Returns a list of resource URIs that contain the given pattern(s). This is * useful to obtain, e.g., all KEGG resources this term points to. * * @param patterns * an arbitrary number of patterns, e.g., * {@code http://idenifiers.org/kegg.reaction/R.*}, {@code .*kegg.*} or just {@code kegg} that * are matched to all resources using an OR-operation, i.e., * if just one of the patterns matches a resource, this resource will * appear in the returned list. * @return A list of all resources that contain the given pattern. This list * can be empty, but never {@code null}. The order of the resources * in that list will be identical to the order in this {@link CVTerm}. * @see Pattern * @see Matcher#find() * */ public List<String> filterResources(String... patterns) { Pattern pattern; Pattern[] patternList = new Pattern[patterns.length]; for (int i = 0; i < patternList.length; i++) { pattern = Pattern.compile(patterns[i]); patternList[i] = pattern; } return filterResources(patternList); }
/** * Returns a list of CVTerm having the given qualifier and * where the URI contains the given pattern. The pattern can only be plain text. * * @param qualifier the qualifier. * @param pattern a plain text pattern. * @return a list of CVTerm having the given qualifier and * where the URI matches the given pattern. */ public List<String> filterCVTerms(Qualifier qualifier, String pattern) { List<String> l = new ArrayList<String>(); for (CVTerm c : filterCVTerms(qualifier)) { l.addAll(c.filterResources(pattern)); } return l; }
if (cvt.isBiologicalQualifier() && (cvt.getBiologicalQualifierType() == qualifier)) { return pattern != null ? cvt.filterResources(pattern) .size() > 0 : true; } else if (cvt.isModelQualifier() && cvt.getModelQualifierType() == qualifier) { return pattern != null ? cvt.filterResources(pattern) .size() > 0 : true; return cvt.filterResources(pattern).size() > 0;
@Override public List<String> filterCVTerms(CVTerm.Qualifier qualifier, boolean recursive, String... patterns) { List<String> l = new ArrayList<String>(); for (CVTerm c : filterCVTerms(qualifier)) { l.addAll(c.filterResources(patterns)); } if (recursive) { TreeNode child; for (int i = 0; i < getChildCount(); i++) { child = getChildAt(i); if (child instanceof SBase) { l.addAll( ((SBase) child).filterCVTerms(qualifier, recursive, patterns)); } } } return l; }