001package org.biojava.bio.seq.filter; 002 003import org.biojava.bio.seq.FeatureFilter; 004import org.biojava.bio.seq.FilterUtils; 005import org.biojava.utils.walker.Visitor; 006 007/** 008 * Base-class for visitors that re-write a filter tree. 009 * 010 * <p> 011 * This filter transformer will just duplicate a tree, using the same leaf 012 * instances, and re-creating all logical filters, like And and ByDescendant. 013 * </p> 014 * 015 * @author Matthew Pocock 016 */ 017public class FilterTransformer 018implements Visitor { 019 public FeatureFilter featureFilter(FeatureFilter filter) { 020 return filter; 021 } 022 023 public FeatureFilter and(FeatureFilter.And and, 024 FeatureFilter c1, 025 FeatureFilter c2) 026 { 027 return FilterUtils.and(c1, c2); 028 } 029 030 public FeatureFilter or(FeatureFilter.Or or, 031 FeatureFilter c1, 032 FeatureFilter c2) 033 { 034 return FilterUtils.or(c1, c2); 035 } 036 037 public FeatureFilter not(FeatureFilter.Not not, FeatureFilter c) { 038 return FilterUtils.not(c); 039 } 040 041 public FeatureFilter byParent(FeatureFilter.ByParent parent, FeatureFilter c) { 042 return FilterUtils.byParent(c); 043 } 044 045 public FeatureFilter byAncestor(FeatureFilter.ByAncestor ancestor, FeatureFilter c) { 046 return FilterUtils.byAncestor(c); 047 } 048 049 public FeatureFilter onlyChildren(FeatureFilter.OnlyChildren child, FeatureFilter c) { 050 return FilterUtils.onlyChildren(c); 051 } 052 053 public FeatureFilter onlyDescendants(FeatureFilter.OnlyDescendants desc, FeatureFilter c) { 054 return FilterUtils.onlyDescendants(c); 055 } 056 057 public FeatureFilter byChild(FeatureFilter.ByChild child, FeatureFilter c) { 058 return FilterUtils.byChild(c); 059 } 060 061 public FeatureFilter byDescendant(FeatureFilter.ByDescendant desc, FeatureFilter c) { 062 return FilterUtils.byDescendant(c); 063 } 064}