001 002 package lrs.visitor; 003 import lrs.*; 004 import logic.*; 005 006 /** 007 * Removes the leading consecutive multiple of an integer from the host. 008 */ 009 public class RemLeadMods implements IAlgo { 010 011 public static RemLeadMods Singleton = new RemLeadMods(); 012 private RemLeadMods(){} 013 014 /** 015 * @param host 016 * @param param 017 * @return 018 */ 019 public Object emptyCase(LRStruct host, Object... param) { 020 return (null); // Nothing to remove. 021 } 022 023 /** 024 * Removes leading multiples of param from host. 025 * @param host the LRS to filter. 026 * @param param the factor to be filtered 027 * @return 028 */ 029 public Object nonEmptyCase(final LRStruct host, final Object... param) { 030 BooleanFactory.Singleton.makeBoolean(((Integer) host.getFirst()) > ((Integer) param[0])). 031 execute( new IBooleanAlgo() { 032 public Object trueCase(IBoolean h, Object... inp) { 033 host.removeFront (); 034 return host.execute (RemLeadMods.this, param); 035 } 036 public Object falseCase(IBoolean h, Object... inp) { 037 return null; 038 } 039 }); 040 041 042 // if (((Integer) host.getFirst ()).intValue () % ((Integer)param[0]).intValue () == 0) 043 // { 044 // host.removeFront (); 045 // host.execute (this, param[0]); 046 // } 047 return (host.getFirst ()); // 048 } 049 } 050