@Test public void testFilter() throws Exception { final String test = "3.yes,1.A;2.no,1.B;3.yes,1.C;3.yes,1.D;4.nope,1.E;"; GuacamoleReader reader = new FilteredGuacamoleReader(new ReaderGuacamoleReader(new StringReader(test)), new TestFilter()); GuacamoleInstruction instruction; instruction = reader.readInstruction(); assertNotNull(instruction); assertEquals("yes", instruction.getOpcode()); assertEquals(1, instruction.getArgs().size()); assertEquals("A", instruction.getArgs().get(0)); instruction = reader.readInstruction(); assertNotNull(instruction); assertEquals("yes", instruction.getOpcode()); assertEquals(1, instruction.getArgs().size()); assertEquals("C", instruction.getArgs().get(0)); instruction = reader.readInstruction(); assertNotNull(instruction); assertEquals("yes", instruction.getOpcode()); assertEquals(1, instruction.getArgs().size()); assertEquals("D", instruction.getArgs().get(0)); instruction = reader.readInstruction(); assertNull(instruction); }
@Override public GuacamoleInstruction readInstruction() throws GuacamoleException { GuacamoleInstruction filteredInstruction; do { GuacamoleInstruction unfilteredInstruction = reader.readInstruction(); if (unfilteredInstruction == null) return null; filteredInstruction = filter.filter(unfilteredInstruction); } while (filteredInstruction == null); return filteredInstruction; }
FilteredGuacamoleReader implements GuacamoleReader { @Override public GuacamoleInstruction readInstruction() throws GuacamoleException { GuacamoleInstruction filteredInstruction; do { GuacamoleInstruction unfilteredInstruction = reader.readInstruction(); if (unfilteredInstruction == null) return null; filteredInstruction = filter.filter(unfilteredInstruction); } while (filteredInstruction == null); return filteredInstruction; } }
FilteredGuacamoleReader implements GuacamoleReader { @Override public GuacamoleInstruction readInstruction() throws GuacamoleException { GuacamoleInstruction filteredInstruction; do { GuacamoleInstruction unfilteredInstruction = reader.readInstruction(); if (unfilteredInstruction == null) return null; filteredInstruction = filter.filter(unfilteredInstruction); } while (filteredInstruction == null); return filteredInstruction; } FilteredGuacamoleReader(GuacamoleReader reader, GuacamoleFilter filter); }
FilteredGuacamoleReader implements GuacamoleReader { @Override public GuacamoleInstruction readInstruction() throws GuacamoleException { GuacamoleInstruction filteredInstruction; do { GuacamoleInstruction unfilteredInstruction = reader.readInstruction(); if (unfilteredInstruction == null) return null; filteredInstruction = filter.filter(unfilteredInstruction); } while (filteredInstruction == null); return filteredInstruction; } FilteredGuacamoleReader(GuacamoleReader reader, GuacamoleFilter filter); @Override boolean available(); @Override char[] read(); @Override GuacamoleInstruction readInstruction(); }
FilteredGuacamoleReader implements GuacamoleReader { @Override public GuacamoleInstruction readInstruction() throws GuacamoleException { GuacamoleInstruction filteredInstruction; do { GuacamoleInstruction unfilteredInstruction = reader.readInstruction(); if (unfilteredInstruction == null) return null; filteredInstruction = filter.filter(unfilteredInstruction); } while (filteredInstruction == null); return filteredInstruction; } FilteredGuacamoleReader(GuacamoleReader reader, GuacamoleFilter filter); @Override boolean available(); @Override char[] read(); @Override GuacamoleInstruction readInstruction();  }