/** * Builds the syntactic type depending on the current depth. * <p> * For instance, a current depth of 3 would return: * * <pre> * l(l(l(''))) * </pre> * * Note that the processor ignore the 'real' mime-type (the data is just * passed on), and thus uses '' as the innermost type. * @return */ private String getSyntacticType() { String syntacticType = LocalWorker.UNTYPED; for (int i = 0; i < getDepth(); i++) { syntacticType = "l(" + syntacticType + ")"; } return syntacticType; }
public void stateChanged(ChangeEvent e) { label.setText(makeHelp((Integer) spinner.getValue())); slicer.setDepth((Integer) spinner.getValue()); } }
protected SliceList getLocalWorker() { return new SliceList(); }
public void testXMLImport() { SliceList slicer = getLocalWorker(); slicer.setDepth(1337); Element e = slicer.provideXML(); SliceList slicer2 = getLocalWorker(); slicer2.consumeXML(e); assertEquals("Did not consume XML correctly", 1337, slicer2.getDepth()); }
public void testSettingDepth() { SliceList l = getLocalWorker(); l.setDepth(3); assertEquals(3, l.getDepth()); l.setDepth(1337); assertEquals(1337, l.getDepth()); // Below 1 should not work, should limit to 1 l.setDepth(0); assertEquals(1, l.getDepth()); l.setDepth(-1); assertEquals(1, l.getDepth()); l.setDepth(-20); assertEquals(1, l.getDepth()); l.setDepth(3); l.setDepth(2); assertEquals(2, l.getDepth()); }
public String[] inputTypes() { logger .error("Not supposed to call inputTypes() on LocalWorkerWithPorts instance"); return new String[] { getSyntacticType() , LocalWorker.STRING, LocalWorker.STRING}; }
private List runSlicer(SliceList slicer, List list, String fromString, String toString) throws TaskExecutionException { Map<String, DataThing> inputs = new HashMap<String, DataThing>(); inputs.put("inputlist", new DataThing(list)); inputs.put("fromindex", new DataThing(fromString)); inputs.put("toindex", new DataThing(toString)); Map out = slicer.execute(inputs); DataThing thing = (DataThing) out.get("outputlist"); List result = (List) thing.getDataObject(); return result; }
public void testXMLExport() throws DataConversionException { Element e = getLocalWorker().provideXML(); assertEquals(XScufl.XScuflNS, e.getNamespace()); assertEquals("extensions", e.getName()); Element slicelist = e.getChild("slicelist", XScufl.XScuflNS); assertNotNull("Element <slicelist> not found", slicelist); Attribute depth = slicelist.getAttribute("depth", XScufl.XScuflNS); assertNotNull("Attribute depth='' not found", depth); assertEquals(1, depth.getIntValue()); }
public List<OutputPort> outputPorts(LocalServiceProcessor processor) throws DuplicatePortNameException, PortCreationException { OutputPort port = new OutputPort(processor, OUTPUTLIST); port.setSyntacticType(getSyntacticType()); List<OutputPort> ports = new ArrayList<OutputPort>(); ports.add(port); return ports; }
/** * Export depth as <extensions><flattenlist depth="X" * /></extensions> */ public Element provideXML() { Element extensions = new Element(EXTENSIONS, XScufl.XScuflNS); Element sliceList = new Element(SLICELIST, XScufl.XScuflNS); sliceList.setAttribute(DEPTH, Integer.toString(getDepth()), XScufl.XScuflNS); extensions.addContent(sliceList); return extensions; }
/** * Extract the <slicelist depth="X" /> number from the <extensions> * element. */ public void consumeXML(Element element) { Element sliceList = element.getChild(SLICELIST, XScufl.XScuflNS); if (sliceList == null) { return; } Attribute depth = sliceList.getAttribute(DEPTH, XScufl.XScuflNS); if (depth == null) { return; } try { setDepth(depth.getIntValue()); } catch (DataConversionException ex) { logger.warn("Invalid depth: " + depth.getValue()); } }
public List<InputPort> inputPorts(LocalServiceProcessor processor) throws DuplicatePortNameException, PortCreationException { InputPort port = new InputPort(processor, INPUTLIST); port.setSyntacticType(getSyntacticType()); List<InputPort> ports = new ArrayList<InputPort>(); ports.add(port); InputPort fromIndexPort = new InputPort(processor, FROMINDEX); fromIndexPort.setSyntacticType(LocalWorker.STRING); ports.add(fromIndexPort); InputPort toIndexPort = new InputPort(processor, TOINDEX); toIndexPort.setSyntacticType(LocalWorker.STRING); ports.add(toIndexPort); return ports; }
new SpinnerNumberModel(slicer.getDepth(), 1, 100, 1); final JSpinner spinner = new JSpinner(range); panel.add(spinner, c);
public void testDefaultDepth() { assertEquals("Default value should be 1", 1, getLocalWorker().getDepth()); }