/** * Returns whether the content can be resent to the output stream * if the request must be retried. The default is false. */ public boolean isResendable() { return super.isResendable(); } /**
public SearchHandle() { super(); super.setFormat(Format.XML); }
StructuredQueryXMLWriter(StructuredQueryDefinition[] queries) { super(); super.setResendable(true); super.setFormat(Format.XML); this.queries = queries; } @Override
/** * Zero-argument constructor. */ public OutputStreamHandle() { super(); super.setResendable(false); } /**
@SuppressWarnings("unchecked") @Override public <T extends JSONReadHandle> T export(T handle) { if (!(handle instanceof BaseHandle)) { throw new IllegalArgumentException("cannot export with handle that doesn't extend base"); } String planAst = getAst(); // TODO: move to a method of BaseHandle? @SuppressWarnings("rawtypes") BaseHandle baseHandle = (BaseHandle) handle; @SuppressWarnings("rawtypes") Class as = baseHandle.receiveAs(); if (InputStream.class.isAssignableFrom(as)) { baseHandle.receiveContent(new ByteArrayInputStream(planAst.getBytes())); } else if (Reader.class.isAssignableFrom(as)) { baseHandle.receiveContent(new StringReader(planAst)); } else if (byte[].class.isAssignableFrom(as)) { baseHandle.receiveContent(planAst.getBytes()); } else if (String.class.isAssignableFrom(as)) { baseHandle.receiveContent(planAst); } else { throw new IllegalArgumentException("cannot export with handle that doesn't accept content as byte[], input stream, reader, or string"); } return handle; } @Override
public UrisHandle() { super(); super.setMimetype("text/uri-list"); }
private <T extends AbstractReadHandle> String getRowFormat(T rowHandle) { if (rowHandle == null) { throw new IllegalArgumentException("Must specify a handle to iterate over the rows"); } if (!(rowHandle instanceof BaseHandle)) { throw new IllegalArgumentException("Cannot iterate rows with invalid handle having class "+rowHandle.getClass().getName()); } BaseHandle<?,?> baseHandle = (BaseHandle<?,?>) rowHandle; Format handleFormat = baseHandle.getFormat(); switch (handleFormat) { case JSON: case UNKNOWN: return "json"; case XML: return "xml"; default: throw new IllegalArgumentException("Must use JSON or XML format to iterate rows instead of "+handleFormat.name()); } } private RESTServiceResultIterator makeRequest(
/** * Specifies whether the content can be resent to the output stream * if the request must be retried. */ public void setResendable(boolean resendable) { super.setResendable(resendable); } /**
public SearchHandle() { super(); super.setFormat(Format.XML); }
StructuredQueryXMLWriter(StructuredQueryDefinition[] queries) { super(); super.setResendable(true); super.setFormat(Format.XML); this.queries = queries; } @Override
/** * Specifies whether the content can be resent to the output stream * if the request must be retried. */ @Override public void setResendable(boolean resendable) { super.setResendable(resendable); } /**
/** * Returns whether the content can be resent to the output stream * if the request must be retried. The default is false. */ @Override public boolean isResendable() { return super.isResendable(); } /**
protected JacksonBaseHandle() { super(); super.setFormat(Format.JSON); }
/** * Zero-argument constructor. */ public OutputStreamHandle() { super(); super.setResendable(false); } /**
static private <T> T withFormat(T handle, Format format, Class<T> as) { if (handle != null) { if (!(handle instanceof BaseHandle)) { throw new IllegalArgumentException( "cannot set format on handle of "+handle.getClass().getName() ); } ((BaseHandle) handle).setFormat(format); } return handle; }
@Override public void setHandle(JSONWriteHandle handle) { if (handle == null) { throw new IllegalArgumentException("Must specify handle for reading raw plan"); } if (!(handle instanceof BaseHandle)) { throw new IllegalArgumentException( "Cannot provide raw plan definition with invalid handle having class "+handle.getClass().getName() ); } ((BaseHandle) handle).setFormat(Format.JSON); this.handle = handle; } @Override
/** * Zero-argument constructor. */ public GSONHandle() { super(); super.setFormat(Format.JSON); setResendable(true); } /**
public TuplesHandle() { super(); super.setFormat(Format.XML); try { jc = JAXBContext.newInstance(TuplesBuilder.Tuples.class); unmarshaller = jc.createUnmarshaller(); } catch (JAXBException e) { throw new MarkLogicBindingException(e); } }
/** * Zero-argument constructor. */ public XMLEventReaderHandle() { super(); super.setFormat(Format.XML); setResendable(false); } /**
/** * Zero-argument constructor. */ public JacksonHandle() { super(); super.setFormat(Format.JSON); setResendable(true); } /**