XFlows implements Iterable<XFlow> { public ListIterator<XFlow> iterator(final String projectName, final String owner) { return new ListIterator<XFlow>() { Map<String, String> params = new HashMap<String, String>(); @Override protected List<XFlow> list() { ArrayList<XFlow> xFlows = new ArrayList<XFlow>(); String lastMarker = params.get("marker"); if (params.containsKey("marker") && lastMarker.length() == 0) { return null; } if (owner != null) { params.put("owner", owner); } String resource = ResourceBuilder.buildXFlowsResource(projectName); try { ListXFlowsResponse resp = odps.getRestClient().request(ListXFlowsResponse.class, resource, "GET", params); for (XFlowModel model : resp.xFlows) { XFlow t = new XFlow(model, projectName, odps); xFlows.add(t); } params.put("marker", resp.marker); } catch (OdpsException e) { throw new RuntimeException(e.getMessage(), e); } return xFlows; } }; } XFlows(Odps odps); XFlow get(String name); XFlow get(String name, String projectName); boolean exists(String name); boolean exists(String name, String projectName); ListIterator<XFlow> iterator(final String projectName, final String owner); void create(XFlowModel model); void create(XFlowModel model, String projectName); void delete(String name); void delete(String name, String projectName); void update(XFlowModel model); void update(XFlowModel model, String projectName); @Override Iterator<XFlow> iterator(); Iterator<XFlow> iterator(String projectName); Instance execute(XFlowInstance xFlowInstance); Instance execute(XFlowInstance xFlowInstance, String project); Map<String, XResult> getXResults(Instance xInstance); String getXSource(Instance xInstance); XFlowInstance getXFlowInstance(Instance instance); boolean isXFlowInstance(Instance instance);  }
@Test public void testIterator() throws OdpsException { XFlows xflows = odps.xFlows(); long cnt = 0; for (XFlow xflow : xflows) { System.out.println(xflow.getName()); System.out.println(xflow.getSourceXml()); ++cnt; if (cnt > 2) { break; } } }