/**
* A “ClientPut” requests inserts a single file into freenet, either uploading
* it directly with this messge ({@link UploadFrom#direct}), uploading it from
- * disk ({@link UploadFrom#disk}) or by creating a redirect to another URI ({@link UploadFrom#redirect}).
+ * disk ({@link UploadFrom#disk}) or by creating a redirect to another URI (
+ * {@link UploadFrom#redirect}).
*
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
/**
* Creates a new “ClientPut” message that inserts a file to the given URI.
- * Depending on <code>uploadFrom</code> the file data has to be supplied
- * in different ways: If <code>uploadFrom</code> is
- * {@link UploadFrom#direct}, use
- * {@link #setPayloadInputStream(java.io.InputStream)} to supply the input
- * data. If <code>uploadFrom</code> is {@link UploadFrom#disk}, use
+ * Depending on <code>uploadFrom</code> the file data has to be supplied in
+ * different ways: If <code>uploadFrom</code> is {@link UploadFrom#direct},
+ * use {@link #setPayloadInputStream(java.io.InputStream)} to supply the
+ * input data. If <code>uploadFrom</code> is {@link UploadFrom#disk}, use
* {@link #setFilename(String)} to supply the file to upload. You have to
* test your direct-disk access (see {@link TestDDARequest},
* {@link TestDDAReply}, {@link TestDDAResponse}, {@link TestDDAComplete})
* before using this option! If <code>uploadFrom</code> is
- * {@link UploadFrom#redirect}, use {@link #setTargetURI(String)} to set
- * the target URI of the redirect.
+ * {@link UploadFrom#redirect}, use {@link #setTargetURI(String)} to set the
+ * target URI of the redirect.
*
* @param uri
* The URI to insert to
* already been compressed.
*
* @param dontCompress
- * <code>true</code> to skip compression of the data in the
- * node, <code>false</code> to allow compression
+ * <code>true</code> to skip compression of the data in the node,
+ * <code>false</code> to allow compression
*/
public void setDontCompress(boolean dontCompress) {
setField("DontCompress", String.valueOf(dontCompress));
*/
public void addFileEntry(FileEntry fileEntry) {
Map<String, String> fields = fileEntry.getFields();
- for (Entry<String, String> fieldEntry: fields.entrySet()) {
+ for (Entry<String, String> fieldEntry : fields.entrySet()) {
setField("Files." + fileIndex + "." + fieldEntry.getKey(), fieldEntry.getValue());
}
fileIndex++;
* {@inheritDoc}
* <p>
* Do not call this method to add input streams! The input streams, if any,
- * will be taken directly from the {@link FileEntry}s and the stream you
- * set here will be overridden!
+ * will be taken directly from the {@link FileEntry}s and the stream you set
+ * here will be overridden!
*/
@Override
public void setPayloadInputStream(InputStream payloadInputStream) {
* already been compressed.
*
* @param dontCompress
- * <code>true</code> to skip compression of the data in the
- * node, <code>false</code> to allow compression
+ * <code>true</code> to skip compression of the data in the node,
+ * <code>false</code> to allow compression
*/
public void setDontCompress(boolean dontCompress) {
setField("DontCompress", String.valueOf(dontCompress));
/**
* Sets the length of data of the optional payload. If you call this method
- * you also have to call {@link #setPayloadInputStream(java.io.InputStream)}!
+ * you also have to call {@link #setPayloadInputStream(java.io.InputStream)}
+ * !
*
* @param dataLength
* The length of data in the payload input stream
*
* @param field
* The name of the field to check for
- * @return <code>true</code> if the message has a field with the given
- * name, <code>false</code> otherwise
+ * @return <code>true</code> if the message has a field with the given name,
+ * <code>false</code> otherwise
*/
public boolean hasField(String field) {
return fields.containsKey(field);
*
* @param field
* The name of the field
- * @return The value of the field, or <code>null</code> if there is no
- * such field
+ * @return The value of the field, or <code>null</code> if there is no such
+ * field
*/
public String getField(String field) {
return fields.get(field);
/**
* Writes this message to the given output stream. If the message has a
- * payload (i.e. {@link #payloadInputStream} is not <code>null</code>)
- * the payload is written to the given output stream after the message as
- * well. That means that this method can only be called once because on the
- * second invocation the payload input stream could not be read (again).
+ * payload (i.e. {@link #payloadInputStream} is not <code>null</code>) the
+ * payload is written to the given output stream after the message as well.
+ * That means that this method can only be called once because on the second
+ * invocation the payload input stream could not be read (again).
*
* @param outputStream
* The output stream to write the message to
*/
public void write(OutputStream outputStream) throws IOException {
writeLine(outputStream, name);
- for (Entry<String, String> fieldEntry: fields.entrySet()) {
+ for (Entry<String, String> fieldEntry : fields.entrySet()) {
writeLine(outputStream, fieldEntry.getKey() + "=" + fieldEntry.getValue());
}
writeLine(outputStream, "EndMessage");
}
/**
- * Tries to parse the given string into an int, returning <code>-1</code>
- * if the string can not be parsed.
+ * Tries to parse the given string into an int, returning <code>-1</code> if
+ * the string can not be parsed.
*
* @param value
* The string to parse
/**
* Copies as many bytes as possible (i.e. until {@link InputStream#read()}
- * returns <code>-1</code>) from the source input stream to the
- * destination output stream.
+ * returns <code>-1</code>) from the source input stream to the destination
+ * output stream.
*
* @param source
* The input stream to read from
/**
* Copies <code>length</code> bytes from the source input stream to the
- * destination output stream. If <code>length</code> is <code>-1</code>
- * as much bytes as possible will be copied (i.e. until
+ * destination output stream. If <code>length</code> is <code>-1</code> as
+ * much bytes as possible will be copied (i.e. until
* {@link InputStream#read()} returns <code>-1</code> to signal the end of
* the stream).
*
/**
* Copies <code>length</code> bytes from the source input stream to the
- * destination output stream. If <code>length</code> is <code>-1</code>
- * as much bytes as possible will be copied (i.e. until
+ * destination output stream. If <code>length</code> is <code>-1</code> as
+ * much bytes as possible will be copied (i.e. until
* {@link InputStream#read()} returns <code>-1</code> to signal the end of
* the stream).
*
* @param name
* The name of the file
* @param contentType
- * The content type of the file, or <code>null</code> to let
- * the node auto-detect it
+ * The content type of the file, or <code>null</code> to let the
+ * node auto-detect it
* @param length
* The length of the file
* @param dataInputStream
* @param filename
* The name of the file on disk
* @param contentType
- * The content type of the file, or <code>null</code> to let
- * the node auto-detect it
+ * The content type of the file, or <code>null</code> to let the
+ * node auto-detect it
* @param length
* The length of the file, or <code>-1</code> to not specify a
* size
* @param name
* The name of the file
* @param contentType
- * The content type of the file, or <code>null</code> to
- * let the node auto-detect it
+ * The content type of the file, or <code>null</code> to let
+ * the node auto-detect it
* @param length
* The length of the file
* @param inputStream
* @param filename
* The name of the on-disk file
* @param contentType
- * The content type of the file, or <code>null</code> to
- * let the node auto-detect it
+ * The content type of the file, or <code>null</code> to let
+ * the node auto-detect it
* @param length
* The length of the file
*/
/**
* Creates a “GetNode” command that returns the request noderef of the node,
* including private and volatile data, if requested. If any of the Boolean
- * parameters are <code>null</code> the parameter is ignored and the
- * node’s default value is used.
+ * parameters are <code>null</code> the parameter is ignored and the node’s
+ * default value is used.
*
* @param giveOpennetRef
* <code>true</code> to request the opennet noderef,
/**
* Creates a new “ListPeer” request that returns information about the node
- * specified by <code>nodeIdentifier</code>. <code>nodeIdentifier</code>
- * can be of several formats: The node’s name, its identity, or its IP
- * address and port (connection with a ‘:’).
+ * specified by <code>nodeIdentifier</code>. <code>nodeIdentifier</code> can
+ * be of several formats: The node’s name, its identity, or its IP address
+ * and port (connection with a ‘:’).
*
* @param nodeIdentifier
* The identifier of the node to get details about
* @param identifier
* The identifier of the request
* @param withMetadata
- * If <code>true</code> metadata of the peers is included in
- * the reply
+ * If <code>true</code> metadata of the peers is included in the
+ * reply
* @param withVolatile
- * if <code>true</code> volatile data of the peers is included
- * in the reply
+ * if <code>true</code> volatile data of the peers is included in
+ * the reply
*/
public ListPeers(String identifier, boolean withMetadata, boolean withVolatile) {
super("ListPeers");
*
* @param field
* The name of the field
- * @return The value of the field, or <code>null</code> if there is no
- * such field
+ * @return The value of the field, or <code>null</code> if there is no such
+ * field
*/
public String getVolatile(String field) {
return getField("volatile." + field);
/**
* Returns the data length of the request.
*
- * @return The data length of the request, or <code>-1</code> if the
- * length could not be parsed
+ * @return The data length of the request, or <code>-1</code> if the length
+ * could not be parsed
*/
public long getDataLength() {
return FcpUtils.safeParseLong(getField("DataLength"));
* <code>-1</code> is returned each block is tried forever.
*
* @return The maximum number of retries for failed blocks, or
- * <code>-1</code> for unlimited retries, or <code>-2</code> if
- * the number of retries could not be parsed
+ * <code>-1</code> for unlimited retries, or <code>-2</code> if the
+ * number of retries could not be parsed
*/
public int getMaxRetries() {
return FcpUtils.safeParseInt(getField("MaxRetries"));
/**
* Returns whether this request has started.
*
- * @return <code>true</code> if the request has started,
- * <code>false</code> otherwise
+ * @return <code>true</code> if the request has started, <code>false</code>
+ * otherwise
*/
public boolean isStarted() {
return Boolean.valueOf(getField("Started"));
*/
public int getFileCount() {
int fileCount = -1;
- while (getField("Files." + ++fileCount + ".UploadFrom") != null) { /*
- * do
- * nothing.
- */
+ while (getField("Files." + ++fileCount + ".UploadFrom") != null) {
+ /* do nothing. */
}
return fileCount;
}
* Returns whether the request was removed from the global queue.
*
* @return <code>true</code> if the request was removed from the global
- * queue, <code>false</code> if it was removed from the
- * client-local queue
+ * queue, <code>false</code> if it was removed from the client-local
+ * queue
*/
public boolean isGlobal() {
return Boolean.valueOf(getField("Global"));
/**
* Returns the error code.
*
- * @return The error code, or <code>-1</code> if the error code could not
- * be parsed
+ * @return The error code, or <code>-1</code> if the error code could not be
+ * parsed
*/
public int getCode() {
return FcpUtils.safeParseInt(getField("Code"));
/**
* Returns some extra description of the error.
*
- * @return Extra description of the error, or <code>null</code> if there
- * is none
+ * @return Extra description of the error, or <code>null</code> if there is
+ * none
*/
public String getExtraDescription() {
return getField("ExtraDescription");
/**
* Returns the code of the error.
*
- * @return The code of the error, or <code>-1</code> if the error code
- * could not be parsed
+ * @return The code of the error, or <code>-1</code> if the error code could
+ * not be parsed
*/
public int getCode() {
return FcpUtils.safeParseInt(getField("Code"));
public int[] getComplexErrorCodes() {
Map<String, String> allFields = getFields();
List<Integer> errorCodeList = new ArrayList<Integer>();
- for (Entry<String, String> field: allFields.entrySet()) {
+ for (Entry<String, String> field : allFields.entrySet()) {
String fieldKey = field.getKey();
if (fieldKey.startsWith("Errors.")) {
int nextDot = fieldKey.indexOf('.', 7);
}
int[] errorCodes = new int[errorCodeList.size()];
int errorIndex = 0;
- for (int errorCode: errorCodeList) {
+ for (int errorCode : errorCodeList) {
errorCodes[errorIndex++] = errorCode;
}
return errorCodes;
* @param directory
* The directory you want to access files in
* @param wantReadDirectory
- * <code>true</code> if you want to read files from the
- * directory
+ * <code>true</code> if you want to read files from the directory
* @param wantWriteDirectory
- * <code>true</code> if you want to write files to the
- * directory
+ * <code>true</code> if you want to write files to the directory
*/
public TestDDARequest(String directory, boolean wantReadDirectory, boolean wantWriteDirectory) {
super("TestDDARequest");
* @param directory
* The directory from the {@link TestDDARequest} command
* @param readContent
- * The read content, or <code>null</code> if you did not
- * request read access
+ * The read content, or <code>null</code> if you did not request
+ * read access
*/
public TestDDAResponse(String directory, String readContent) {
super("TestDDAResponse");
/**
* The “URIGenerated” message signals the client that an URI was generated for a
- * {@link ClientPut} (or {@link ClientPutDiskDir} or {@link ClientPutComplexDir})
- * request.
+ * {@link ClientPut} (or {@link ClientPutDiskDir} or {@link ClientPutComplexDir}
+ * ) request.
*
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
* @param fatal
* <code>true</code> if this request failed fatally,
* <code>false</code> otherwise
- *
*/
void setFatal(boolean fatal) {
this.fatal = fatal;