/**
* Container for various file options.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class FileOption {
/**
* Creates new file options.
- *
+ *
* @param defaultMimeType
* The default MIME type of the file
*/
/**
* Returns the custom key. The custom key is only used when
* {@link #isInsert()} returns <code>true</code>.
- *
+ *
* @return The custom key
*/
public String getCustomKey() {
/**
* Sets the custom key. The custom key is only used when {@link #isInsert()}
* returns <code>true</code>.
- *
+ *
* @param customKey
* The custom key
*/
/**
* Returns whether the file should be inserted. If a file is not inserted, a
* custom key has to be specified for it.
- *
+ *
* @see #setCustomKey(String)
* @return <code>true</code> if the file should be inserted,
* <code>false</code> otherwise
/**
* Sets whether the file should be inserted. If a file is not inserted, a
* custom key has to be specified for it.
- *
+ *
* @param insert
* <code>true</code> if the file should be inserted,
* <code>false</code> otherwise
/**
* Sets the MIME type of the file. Setting the MIME type to
* <code>null</code> will set the MIME type to the default MIME type.
- *
+ *
* @param mimeType
* The MIME type of the file
*/
/**
* Returns the MIME type of the file. If no custom MIME type has been set,
* the default MIME type is returned.
- *
+ *
* @return The MIME type of the file
*/
public String getMimeType() {
/**
* Returns the name of the container this file should be put in.
- *
+ *
* @return The name of the container
*/
public String getContainer() {
/**
* Sets the name of the container this file should be put in.
- *
+ *
* @param container
* The name of the container
*/
/**
* Sets whether the file should have “$[EDITION+<i>n</i>]” tags replaced.
- *
+ *
* @param replaceEdition
* <code>true</code> to replace tags, <code>false</code> not
* to replace
/**
* Returns whether the file should have “$[EDITION+<i>n</i>]” tags
* replaced.
- *
+ *
* @return <code>true</code> if tags should be replaced,
* <code>false</code> otherwise
*/
/**
* Sets the range of editions that should be replaced.
- *
+ *
* @param editionRange
* The range editions to replace
*/
/**
* Returns the range of editions that should be replaced.
- *
+ *
* @return The range of editions to replace
*/
public int getEditionRange() {
/**
* Returns whether the options for this file have been modified, i.e. are
* not at their default values.
- *
+ *
* @return <code>true</code> if the options have been modified,
* <code>false</code> if they are at default values
*/
private Connection connection;
/**
- * Sets the hostname of the node. The default port for FCP2 connections (
- * {@link Node#DEFAULT_PORT}) is used.
+ * Sets the hostname of the node. The default port for FCP2 connections ({@link Node#DEFAULT_PORT})
+ * is used.
*
* @param hostname
* The hostname of the node
/**
* Interface for objects that want to be notified abount insert events.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public interface InsertListener extends EventListener {
/**
* Enumeration for the different error situations.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public static enum ErrorType {
/**
* Notifies a listener that an insert has started.
- *
+ *
* @param project
* The project that is now being inserted
*/
/**
* Notifies a listener that a project insert has generated a URI.
- *
+ *
* @param project
* The project being inserted
* @param uri
/**
* Notifies a listener that an insert has made some progress.
- *
+ *
* @param project
* The project being inserted
* @param succeeded
/**
* Notifies a listener that a project insert has finished.
- *
+ *
* @param project
* The project being inserted
* @param success
/*
- * jSite-0.7 -
+ * jSite-0.7 -
* Copyright (C) 2006 David Roden
*
* This program is free software; you can redistribute it and/or modify
/**
* Container for node information.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class Node extends de.todesbaum.util.freenet.fcp2.Node {
/**
* Creates a new node with the given hostname and the default port.
- *
+ *
* @see de.todesbaum.util.freenet.fcp2.Node#DEFAULT_PORT
* @param hostname
* The hostname of the new node
/**
* Creates a new node with the given hostname and port.
- *
+ *
* @param hostname
* The hostname of the new node
* @param port
/**
* Creates a new node with the given hostname, port, and name.
- *
+ *
* @param hostname
* The hostname of the new node
* @param port
/**
* Creates a new node that gets its settings from the given node.
- *
+ *
* @param node
* The node to copy
*/
/**
* Creates a new node from the given node, overwriting the name.
- *
+ *
* @param node
* The node to copy from
* @param name
/**
* Sets the name of the node.
- *
+ *
* @param name
* The name of the node
*/
/**
* Returns the name of the node.
- *
+ *
* @return The name of the node
*/
public String getName() {
/**
* Sets the hostname of the node.
- *
+ *
* @param hostname
* The hostname of the node
*/
/**
* Sets the port of the node.
- *
+ *
* @param port
* The port of the node
*/
/**
* Scans the local path of a project anychronously and returns the list of found
* files as an event.
- *
+ *
* @see Project#getLocalPath()
* @see FileScannerListener#fileScannerFinished(FileScanner)
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
/**
* Creates a new file scanner for the given project.
- *
+ *
* @param project
* The project whose files to scan
*/
/**
* Adds the given listener to the list of listeners.
- *
+ *
* @param fileScannerListener
* The listener to add
*/
/**
* Removes the given listener from the list of listeners.
- *
+ *
* @param fileScannerListener
* The listener to remove
*/
* <p>
* Scans all available files in the project’s local path and emits an event
* when finished.
- *
+ *
* @see FileScannerListener#fileScannerFinished(FileScanner)
*/
public void run() {
/**
* Returns whether there was an error scanning for files.
- *
+ *
* @return <code>true</code> if there was an error, <code>false</code>
* otherwise
*/
/**
* Returns the list of found files.
- *
+ *
* @return The list of found files
*/
public List<String> getFiles() {
/**
* Recursively scans a directory and adds all found files to the given list.
- *
+ *
* @param rootDir
* The directory to scan
* @param fileList
/**
* Listener interface for objects that want to be notified when scanning a
* project’s local path has finished.
- *
+ *
* @see FileScanner
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
/**
* Notifies a listener that scanning a project’s local path has finished.
- *
+ *
* @param fileScanner
* The file scanner that finished
*/
/*
- * jSite-0.7 -
+ * jSite-0.7 -
* Copyright (C) 2006 David Roden
*
* This program is free software; you can redistribute it and/or modify
/**
* Listener interface for objects that want to be notified if the node
* configuration changes.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public interface NodeManagerListener extends EventListener {
/**
* Notifies a listener that the node configuration was changed.
- *
+ *
* @param nodes
* The new list of nodes
*/
/**
* Maps i18n keys to translated texts, depending on a current locale.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class I18n {
/**
* Returns the currently set locale.
- *
+ *
* @return The current locale
*/
public static Locale getLocale() {
/**
* Sets the current locale.
- *
+ *
* @param locale
* The new current locale
*/
/**
* Returns the resource bundle for the current locale.
- *
+ *
* @return The resource bundle for the current locale
*/
public static ResourceBundle getResourceBundle() {
/**
* Returns the resource bundle for the given locale.
- *
+ *
* @param locale
* The locale to get the resource bundle for
* @return The resource bundle for the given locale
* Retrieves a translated text for the given i18n key. If the resource
* bundle for the current locale does not have a translation for the given
* key, the default locale is tried. If that fails, the key is returned.
- *
+ *
* @param key
* The key to get the translation for
* @return The translated value, or the key itself if not translation can be
/*
* jSite-remote - I18nContainer.java Copyright © 2007 David Roden
- *
+ *
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place - Suite 330, Boston, MA 02111-1307, USA.
/**
* Container that collects {@link Runnable}s that change the texts of GUI
* components when the current locale has changed.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class I18nContainer implements Iterable<Runnable> {
/**
* Returns the singleton instance.
- *
+ *
* @return The singleton instance
*/
public static I18nContainer getInstance() {
/**
* Registers an i18n runnable that is run when the current locale has
* changed.
- *
+ *
* @param i18nRunnable
* The runnable to register
*/
/**
* Registers a {@link Runnable} that changes texts when the current locale
* has changed and runs after {@link #i18nRunnables} have run.
- *
+ *
* @param i18nPostRunnable
* The runnable to register
*/
/*
- * jSite -
+ * jSite -
* Copyright (C) 2006 David Roden
*
* This program is free software; you can redistribute it and/or modify
/**
* Command-line interface for jSite.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class CLI implements InsertListener {
/**
* Creates a new command-line interface.
- *
+ *
* @param args
* The command-line arguments
*/
/**
* Returns the project with the given name.
- *
+ *
* @param name
* The name of the project
* @return The project, or <code>null</code> if no project could be found
/**
* Returns the node with the given name.
- *
+ *
* @param name
* The name of the node
* @return The node, or <code>null</code> if no node could be found
/**
* Inserts the given project.
- *
+ *
* @param currentProject
* The project to insert
* @return <code>true</code> if the insert finished successfully,
/**
* Creates a new command-line interface with the given arguments.
- *
+ *
* @param args
* The command-line arguments
*/
/*
- * todesbaum-lib -
+ * todesbaum-lib -
* Copyright (C) 2006 David Roden
*
* This program is free software; you can redistribute it and/or modify
/**
* A Client executes {@link Command}s over a {@link Connection} to a
* {@link Node} and delivers resulting {@link Message}s.
- *
+ *
* @author David Roden <droden@gmail.com>
* @version $Id$
*/
/**
* Creates a new client that operates on the specified connection.
- *
+ *
* @param connection
* The connection to operate on
*/
/**
* Creates a new client that operates on the specified connection and
* immediately executes the specified command.
- *
+ *
* @param connection
* The connection to operate on
* @param command
/**
* Returns whether this client catches all messages going over the
* connection.
- *
+ *
* @return <code>true</code> if the client catches all messages,
* <code>false</code> otherwise
*/
/**
* Sets whether this client catches all messages going over the connection.
- *
+ *
* @param catchAll
* <code>true</code> if the client should catch all messages,
* <code>false</code> otherwise
* Executes the specified command. This will also clear the queue of
* messages, discarding all messages that resulted from the previous command
* and have not yet been read.
- *
+ *
* @param command
* The command to execute
* @throws IOException
/**
* Executes the specified command and optionally clears the list of
* identifiers this clients listens to before starting the command.
- *
+ *
* @param command
* The command to execute
* @param removeExistingIdentifiers
* Returns the next message, waiting endlessly for it, if need be. If you
* are not sure whether a message will arrive, better use
* {@link #readMessage(long)} to only wait for a specific time.
- *
+ *
* @return The next message that resulted from the execution of the last
* command
* @see #readMessage(long)
* Returns the next message. If the message queue is currently empty, at
* least <code>maxWaitTime</code> milliseconds will be waited for a
* message to arrive.
- *
+ *
* @param maxWaitTime
* The minimum time to wait for a message, in milliseconds
* @return The message, or <code>null</code> if no message arrived in time
/**
* Returns whether the client is currently disconnected.
- *
+ *
* @return <code>true</code> if the client is disconnected,
* <code>false</code> otherwise
*/
/*
- * todesbaum-lib -
+ * todesbaum-lib -
* Copyright (C) 2006 David Roden
*
* This program is free software; you can redistribute it and/or modify
* takes care of that) and must not be sent afterwards.
* <p>
* The node can answer with the following messages: <code>NodeHello</code>.
- *
+ *
* @author David Roden <droden@gmail.com>
* @version $Id$
*/
* Returns the value of the <code>ExpectedVersion</code> parameter of this
* command. At the moment this value is not used by the node but in the
* future this may be used to enforce certain node versions.
- *
+ *
* @return The expected version
*/
public String getExpectedVersion() {
* Sets the value of the <code>ExpectedVersion</code> parameter of this
* command. At the moment this value is not used by the node but in the
* future this may be used to enforce certain node versions.
- *
+ *
* @param expectedVersion
* The expected version
*/
/**
* Returns the name of the client that is connecting.
- *
+ *
* @return The name of the client
*/
public String getName() {
/**
* Sets the name of the client that is connecting.
- *
+ *
* @param name
* The name of the client
*/
/*
- * todesbaum-lib -
+ * todesbaum-lib -
* Copyright (C) 2006 David Roden
*
* This program is free software; you can redistribute it and/or modify
/**
* Abstract base class for all put requests. It contains all parameters that put
* requests have in common.
- *
+ *
* @author David Roden <droden@gmail.com>
* @version $Id$
*/
/** The URI of this request. */
protected final String uri;
-
+
/** The client token of this request. */
protected String clientToken = null;
/**
* Creates a new put request with the specified name, identifier and URI.
- *
+ *
* @param name
* The name of this request
* @param identifier
/**
* Returns whether the node should not try to compress the data.
- *
+ *
* @return <code>true</code> if the node should <strong>not</strong> try
* to compress the data
*/
* archives like ZIP files. Otherwise the node will try to compress the file
* which -- depending on the size of the data -- might take a lot of time
* and memory.
- *
+ *
* @param dontCompress
* <code>true</code> if the node should <strong>not</strong>
* try to compress the data
/*
- * todesbaum-lib -
+ * todesbaum-lib -
* Copyright (C) 2006 David Roden
*
* This program is free software; you can redistribute it and/or modify
/**
* Abstract base class for all put requests that insert a directory.
- *
+ *
* @author David Roden <droden@gmail.com>
* @version $Id$
*/
/**
* Creates a new request with the specified name, identifier, and URI.
- *
+ *
* @param name
* The name of the request
* @param identifier
/**
* Returns the default name of the directory.
- *
+ *
* @return The default name of the directory
*/
public String getDefaultName() {
* requested without a filename. It's about the same as the
* <code>index.html</code> file that gets delivered if you only request a
* directory from a webserver.
- *
+ *
* @param defaultName
* The default name of the directory
*/
/*
- * todesbaum-lib -
+ * todesbaum-lib -
* Copyright (C) 2006 David Roden
*
* This program is free software; you can redistribute it and/or modify
* name of the {@link de.todesbaum.util.freenet.fcp2.Connection} connects). So
* when receiving messages from the node you should always be prepared for
* something you did not expect.
- *
+ *
* @author David Roden <droden@gmail.com>
* @version $Id$
*/
/**
* Creates a new command with the specified name and identifier.
- *
+ *
* @param name
* The name of the command
* @param identifier
/**
* Returns the name of this command.
- *
+ *
* @return The name of this command
*/
public String getCommandName() {
/**
* Return the identifier of this command.
- *
+ *
* @return The identifier of this command
*/
public String getIdentifier() {
* <strong>NOTE:</strong> Subclasses of Command <strong>must</strong> call
* <code>super.write(writer)</code> before or after writing their own
* parameters!
- *
+ *
* @param writer
* The stream to write the parameters to
* @throws IOException
* Returns whether this command has payload to send after the message.
* Subclasses need to return <code>true</code> here if they need to send
* payload after the message.
- *
+ *
* @return <code>true</code> if this command has payload to send,
* <code>false</code> otherwise
*/
* Returns the payload of this command as an {@link InputStream}. This
* method is never called if {@link #hasPayload()} returns
* <code>false</code>.
- *
+ *
* @return The payload of this command
*/
protected InputStream getPayload() {
/**
* Returns the length of the payload. This method is never called if
* {@link #hasPayload()} returns <code>false</code>.
- *
+ *
* @return The length of the payload
*/
protected long getPayloadLength() {
/*
- * todesbaum-lib -
+ * todesbaum-lib -
* Copyright (C) 2006 David Roden
*
* This program is free software; you can redistribute it and/or modify
/**
* A physical connection to a Freenet node.
- *
+ *
* @author David Roden <droden@gmail.com>
* @version $Id$
*/
/**
* Creates a new connection to the specified node with the specified name.
- *
+ *
* @param node
* The node to connect to
* @param name
/**
* Adds a listener that gets notified on connection events.
- *
+ *
* @param connectionListener
* The listener to add
*/
/**
* Removes a listener from the list of registered listeners. Only the first
* matching listener is removed.
- *
+ *
* @param connectionListener
* The listener to remove
* @see List#remove(java.lang.Object)
/**
* Notifies listeners about a received message.
- *
+ *
* @param message
* The received message
*/
/**
* Returns the name of the connection.
- *
+ *
* @return The name of the connection
*/
public String getName() {
/**
* Connects to the node.
- *
+ *
* @return <code>true</code> if the connection succeeded and the node
* returned a NodeHello message
* @throws IOException
/**
* Returns whether this connection is still connected to the node.
- *
+ *
* @return <code>true</code> if this connection is still valid,
* <code>false</code> otherwise
*/
/**
* Returns the NodeHello message the node sent on connection.
- *
+ *
* @return The NodeHello message of the node
*/
public Message getNodeHello() {
/**
* Executes the specified command.
- *
+ *
* @param command
* The command to execute
* @throws IllegalStateException
* The reader thread for this connection. This is essentially a thread that
* reads lines from the node, creates messages from them and notifies
* listeners about the messages.
- *
+ *
* @author David Roden <droden@gmail.com>
* @version $Id$
*/
/**
* Creates a new reader that reads from the specified input stream.
- *
+ *
* @param nodeInputStream
* The input stream to read from
*/
/*
- * todesbaum-lib -
+ * todesbaum-lib -
* Copyright (C) 2006 David Roden
*
* This program is free software; you can redistribute it and/or modify
/**
* Interface for clients that want to be notified when a message was received.
- *
+ *
* @author David Roden <droden@gmail.com>
* @version $Id$
*/
/**
* Notifies a client that a message was received.
- *
+ *
* @param connection
* The connection the message was received on
* @param message
/**
* Notifies a client that the connection to the node has been lost.
- *
+ *
* @param connection
* The connection that was lost
*/
/*
- * todesbaum-lib -
+ * todesbaum-lib -
* Copyright (C) 2006 David Roden
*
* This program is free software; you can redistribute it and/or modify
/**
* A {@link FileEntry} that sends its payload directly to the node, using the
* existing FCP connection.
- *
+ *
* @author David Roden <droden@gmail.com>
* @version $Id$
*/
/**
* Creates a new FileEntry with the specified name and content type that
* gets its data from the specified byte array.
- *
+ *
* @param filename
* The name of the file
* @param contentType
/**
* Creates a new FileEntry with the specified name and content type that
* gets its data from the specified input stream.
- *
+ *
* @param filename
* The name of the file
* @param contentType
/**
* Returns the input stream for the file's content.
- *
+ *
* @return The input stream for the file's content
*/
public InputStream getDataInputStream() {
/**
* Returns the length of this file's content.
- *
+ *
* @return The length of this file's content
*/
public long getDataLength() {
/*
- * todesbaum-lib -
+ * todesbaum-lib -
* Copyright (C) 2006 David Roden
*
* This program is free software; you can redistribute it and/or modify
/**
* A {@link FileEntry} that reads the content from a file on the disk.
- *
+ *
* @author David Roden <droden@gmail.com>
* @version $Id$
*/
/**
* Creates a new {@link FileEntry} with the specified name and content type
* that is read from the file specified by <code>localFilename</code>.
- *
+ *
* @param filename
* The name of the file
* @param contentType
/**
* Returns the name of the local file that holds the content for this file.
- *
+ *
* @return The name of the local file
*/
public String getLocalFilename() {
/*
- * todesbaum-lib -
+ * todesbaum-lib -
* Copyright (C) 2006 David Roden
*
* This program is free software; you can redistribute it and/or modify
* Abstract base class of file entries that are used in the
* {@link de.todesbaum.util.freenet.fcp2.ClientPutComplexDir} command to define
* the files of an insert.
- *
+ *
* @author David Roden <droden@gmail.com>
* @version $Id$
*/
* Creates a new file entry with the specified name and content type. The
* content type should be a standard MIME type with an additional charset
* specification for text-based types.
- *
+ *
* @param filename
* The name of the file
* @param contentType
* <code>disk</code>, or <code>redirect</code>. This method is
* implemented by the subclasses {@link DirectFileEntry},
* {@link DiskFileEntry}, and {@link RedirectFileEntry}, respectively.
- *
+ *
* @return The name of this entry's type
*/
public abstract String getName();
/**
* Returns the content type of this file.
- *
+ *
* @return The content type of this file
*/
public String getContentType() {
/**
* Returns the name of this file.
- *
+ *
* @return The name of this file
*/
public String getFilename() {
/*
- * todesbaum-lib -
+ * todesbaum-lib -
* Copyright (C) 2006 David Roden
*
* This program is free software; you can redistribute it and/or modify
* Implementation of the <code>GenerateSSK</code> command.
* <p>
* The node can answer with the following messages: <code>SSKKeypair</code>.
- *
+ *
* @author David Roden <droden@gmail.com>
* @version $Id$
*/
/*
- * todesbaum-lib -
+ * todesbaum-lib -
* Copyright (C) 2006 David Roden
*
* This program is free software; you can redistribute it and/or modify
* most of the messages also have an identifier which binds it to a specific
* command. Exceptions are among others <code>NodeHello</code>,
* <code>SSKKeypair</code>, and <code>EndListPersistentRequests</code>.
- *
+ *
* @author David Roden <droden@gmail.com>
* @version $Id$
* @see de.todesbaum.util.freenet.fcp2.Client
/**
* Creates a new message with the specified name.
- *
+ *
* @param name
* The name of this message
*/
/**
* Returns the identifier of this message.
- *
+ *
* @return The identifier
*/
public String getIdentifier() {
/**
* Sets the identifier of this message.
- *
+ *
* @param identifier
* The identifier of this message
*/
/**
* Returns the name of this message.
- *
+ *
* @return The name of this message
*/
public String getName() {
/**
* Tests whether this message contains the parameter with the specified key.
* Key names are compared ignoring case.
- *
+ *
* @param key
* The name of the parameter
* @return <code>true</code> if this parameter exists in this message,
* Returns all parameters of this message. The keys of the entries are all
* lower case so if you want to match the parameter names you have to watch
* out.
- *
+ *
* @return All parameters of this message
*/
public Set<Entry<String, String>> entrySet() {
/**
* Returns the value of the parameter with the name specified by
* <code>key</code>.
- *
+ *
* @param key
* The name of the parameter
* @return The value of the parameter
/**
* Stores the specified value as parameter with the name specified by
* <code>key</code>.
- *
+ *
* @param key
* The name of the parameter
* @param value
/**
* Returns the number of parameters in this message.
- *
+ *
* @return The number of parameters
*/
public int size() {
/**
* Returns a textual representation of this message, containing its name,
* the identifier, and the parameters.
- *
+ *
* @return A textual representation of this message
*/
public String toString() {
/*
- * todesbaum-lib -
+ * todesbaum-lib -
* Copyright (C) 2006 David Roden
*
* This program is free software; you can redistribute it and/or modify
/**
* Contains the hostname and port number of the Freenet node.
- *
+ *
* @author David Roden <droden@gmail.com>
* @version $Id$
*/
/**
* Creates a new node with the specified hostname and the default port
* number.
- *
+ *
* @param hostname
* The hostname of the node
* @see #DEFAULT_PORT
/**
* Creates a new node with the specified hostname and port number.
- *
+ *
* @param hostname
* The hostname of the node
* @param port
/**
* Returns the hostname of the node.
- *
+ *
* @return The hostname of the node
*/
public String getHostname() {
/**
* Returns the port number of the node.
- *
+ *
* @return The port number of the node
*/
public int getPort() {
/*
- * todesbaum-lib -
+ * todesbaum-lib -
* Copyright (C) 2006 David Roden
*
* This program is free software; you can redistribute it and/or modify
* is remembered as long as the node is running but not after restarts.
* <code>forever</code> finally means that a request persists until it is
* explicitely deleted.
- *
+ *
* @author David Roden <droden@gmail.com>
* @version $Id$
* @see de.todesbaum.util.freenet.fcp2.ModifyPersistentRequest
/**
* Private constructor that creates a persistence option with the specified
* name.
- *
+ *
* @param name
* The name of the persistence option.
*/
/**
* Returns the name of this persistence option.
- *
+ *
* @return The name of this persistence option
*/
public String getName() {
/**
* Returns a textual representation of this persistence option. The result
* is identical to calling {@link #getName()}.
- *
+ *
* @return The name of this persistence option
*/
public String toString() {
/*
- * todesbaum-lib -
+ * todesbaum-lib -
* Copyright (C) 2006 David Roden
*
* This program is free software; you can redistribute it and/or modify
* immediate mode large file downloads, not to disk), <code>updatable</code>
* (updatable site checks), <code>bulk</code> (large file downloads to disk),
* <code>prefetch</code>, <code>minimum</code>.
- *
+ *
* @author David Roden <droden@gmail.com>
* @version $Id$
*/
/**
* Creates a new priority class with the specified name and value.
- *
+ *
* @param name
* The name of the priority class
* @param value
/**
* Returns the name of this priority class.
- *
+ *
* @return The name of this priority class
*/
public String getName() {
/**
* Returns the value of this priority class.
- *
+ *
* @return The value of this priority class
*/
public int getValue() {
/*
- * todesbaum-lib -
+ * todesbaum-lib -
* Copyright (C) 2006 David Roden
*
* This program is free software; you can redistribute it and/or modify
/*
- * todesbaum-lib -
+ * todesbaum-lib -
* Copyright (C) 2006 David Roden
*
* This program is free software; you can redistribute it and/or modify
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place - Suite 330, Boston, MA 02111-1307, USA.
/*
* todesbaum-lib - Copyright (C) 2006 David Roden
- *
+ *
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place - Suite 330, Boston, MA 02111-1307, USA.
* so that clean-up code can be written with less code. All methods check that
* the given resource is not <code>null</code> before invoking the close()
* method of the respective type.
- *
+ *
* @author <a href="mailto:bombe@freenetproject.org">David ‘Bombe&squo;
* Roden</a>
* @version $Id$
/**
* Closes the given result set.
- *
+ *
* @param resultSet
* The result set to close
* @see ResultSet#close()
/**
* Closes the given statement.
- *
+ *
* @param statement
* The statement to close
* @see Statement#close()
/**
* Closes the given connection.
- *
+ *
* @param connection
* The connection to close
* @see Connection#close()
/**
* Closes the given server socket.
- *
+ *
* @param serverSocket
* The server socket to close
* @see ServerSocket#close()
/**
* Closes the given socket.
- *
+ *
* @param socket
* The socket to close
* @see Socket#close()
/**
* Closes the given input stream.
- *
+ *
* @param inputStream
* The input stream to close
* @see InputStream#close()
/**
* Closes the given output stream.
- *
+ *
* @param outputStream
* The output stream to close
* @see OutputStream#close()
/**
* Closes the given reader.
- *
+ *
* @param reader
* The reader to close
* @see Reader#close()
/**
* Closes the given writer.
- *
+ *
* @param writer
* The write to close
* @see Writer#close()
/*
- * todesbaum-lib -
+ * todesbaum-lib -
* Copyright (C) 2006 David Roden
*
* This program is free software; you can redistribute it and/or modify
* @version $Id$
*/
public class LineInputStream extends FilterInputStream {
-
+
private boolean skipLinefeed = false;
private StringBuffer lineBuffer = new StringBuffer();
}
return lineBuffer.toString();
}
-
+
}
/*
- * todesbaum-lib -
+ * todesbaum-lib -
* Copyright (C) 2006 David Roden
*
* This program is free software; you can redistribute it and/or modify
private Map<String, String> replacements = new HashMap<String, String>();
private StringBuffer ringBuffer = new StringBuffer();
-
+
/**
* @param out
*/
}
}
}
-
+
}
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place - Suite 330, Boston, MA 02111-1307, USA.
/**
* Copies input from an {@link InputStream} to an {@link OutputStream}.
- *
+ *
* @author <a href="mailto:droden@gmail.com">David Roden</a>
* @version $Id$
*/
/**
* Creates a new StreamCopier with the specified parameters and the default
* buffer size.
- *
+ *
* @param inputStream
* The {@link InputStream} to read from
* @param outputStream
/**
* Creates a new StreamCopier with the specified parameters and the default
* buffer size.
- *
+ *
* @param inputStream
* The {@link InputStream} to read from
* @param outputStream
* Copies the stream data. If the input stream is depleted before the
* requested number of bytes have been read an {@link EOFException} is
* thrown.
- *
+ *
* @throws EOFException
* if the input stream is depleted before the requested number
* of bytes has been read
/**
* Copies <code>length</code> bytes from the <code>inputStream</code> to
* the <code>outputStream</code>.
- *
+ *
* @param inputStream
* The input stream to read from
* @param outputStream
/**
* Copies <code>length</code> bytes from the <code>inputStream</code> to
* the <code>outputStream</code> using a buffer with the specified size
- *
+ *
* @param inputStream
* The input stream to read from
* @param outputStream
/*
- * todesbaum-lib -
+ * todesbaum-lib -
* Copyright (C) 2006 David Roden
*
* This program is free software; you can redistribute it and/or modify
-/* taken from freenet (http://www.freenetproject.org/) */
+/* taken from freenet (http://www.freenetproject.org/) */
package de.todesbaum.util.mime;
import java.util.HashMap;
* Holds the default MIME types.
*/
public class DefaultMIMETypes {
-
+
/** Default MIME type - what to set it to if we don't know any better */
public static final String DEFAULT_MIME_TYPE = "application/octet-stream";
-
+
/** MIME types: number -> name */
private static List<String> mimeTypesByNumber = new Vector<String>();
-
+
/** MIME types: name -> number */
private static Map<String, Short> mimeTypesByName = new HashMap<String, Short>();
-
+
/** MIME types by extension. One extension maps to one MIME type, but not necessarily
* the other way around. */
private static Map<String, Short> mimeTypesByExtension = new HashMap<String, Short>();
-
+
/** Primary extension by MIME type number. */
private static Map<Short, String> primaryExtensionByMimeNumber = new HashMap<Short, String>();
-
+
/**
* Add a MIME type, without any extensions.
* @param number The number of the MIME type for compression. This *must not change*
}
if(outExtension != null)
primaryExtensionByMimeNumber.put(t, outExtension);
-
+
}
/**
protected static synchronized void addMIMEType(short number, String type, String extensions, String outExtension) {
addMIMEType(number, type, extensions.split(" "), outExtension);
}
-
+
/**
* Get a known MIME type by number.
*/
return null;
return mimeTypesByNumber.get(x);
}
-
+
/**
* Get the number of a MIME type, or -1 if it is not in the table of known MIME
* types, in which case it will have to be sent uncompressed.
if(x != null) return x.shortValue();
return -1;
}
-
+
/* From toad's /etc/mime.types
- * cat /etc/mime.types | sed "/^$/d;/#/d" | tr --squeeze '\t' ' ' |
- * (y=0; while read x; do echo "$x" |
+ * cat /etc/mime.types | sed "/^$/d;/#/d" | tr --squeeze '\t' ' ' |
+ * (y=0; while read x; do echo "$x" |
* sed -n "s/^\([^ ]*\)$/addMIMEType\($y, \"\1\"\);/p;s/^\([^ (),]\+\) \(.*\)$/addMIMEType\($y, \"\1\", \"\2\"\);/p;"; y=$((y+1)); done)
*/
-
+
static {
addMIMEType((short) 0, "application/activemessage");
addMIMEType((short) 1, "application/andrew-inset", "ez");
addMIMEType((short) 686, "x-conference/x-cooltalk", "ice");
addMIMEType((short) 687, "x-world/x-vrml", "vrm vrml wrl");
}
-
+
/** Guess a MIME type from a filename */
public static String guessMIMEType(String arg) {
int x = arg.lastIndexOf('.');
if(typeNumber < 0) return null;
return primaryExtensionByMimeNumber.get(typeNumber);
}
-
+
public static String[] getAllMIMETypes() {
return mimeTypesByNumber.toArray(new String[mimeTypesByNumber.size()]);
}
/*
- * todesbaum-lib -
+ * todesbaum-lib -
* Copyright (C) 2006 David Roden
*
* This program is free software; you can redistribute it and/or modify
* @version $Id$
*/
public class SortedListModel extends AbstractListModel implements List {
-
+
private List elements = new ArrayList();
-
+
/**
* {@inheritDoc}
*/
/*
- * todesbaum-lib -
+ * todesbaum-lib -
* Copyright (C) 2006 David Roden
*
* This program is free software; you can redistribute it and/or modify
public TLabel(Icon image) {
super(image);
}
-
+
public TLabel(Icon image, int mnemonic, Component labelFor) {
super(image);
setDisplayedMnemonic(mnemonic);
/*
- * todesbaum-lib -
+ * todesbaum-lib -
* Copyright (C) 2006 David Roden
*
* This program is free software; you can redistribute it and/or modify
* @version $Id$
*/
public class TWizard extends JFrame implements WindowListener {
-
+
protected List<WizardListener> wizardListeners = new ArrayList<WizardListener>();
-
+
private Action previousAction;
private Action nextAction;
private Action quitAction;
private JPanel pagePanel;
private JLabel pageHeading;
private JLabel pageDescription;
-
+
protected void frameInit() {
super.frameInit();
setResizable(false);
addWindowListener(this);
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
createActions();
-
+
pageIcon = new JLabel();
pageIcon.setVerticalAlignment(SwingConstants.TOP);
pageHeading = new JLabel();
pageHeading.setFont(pageHeading.getFont().deriveFont(pageHeading.getFont().getSize() * 2.0f).deriveFont(Font.BOLD));
pageDescription = new JLabel();
-
+
JPanel contentPane = new JPanel(new BorderLayout(12, 12));
contentPane.setBorder(new EmptyBorder(12, 12, 12, 12));
-
+
JPanel topPanel = new JPanel(new BorderLayout(12, 12));
contentPane.add(topPanel, BorderLayout.PAGE_START);
-
+
topPanel.add(pageIcon, BorderLayout.LINE_START);
-
+
JPanel textPanel = new JPanel(new BorderLayout(12, 12));
topPanel.add(textPanel, BorderLayout.CENTER);
textPanel.add(pageHeading, BorderLayout.PAGE_START);
textPanel.add(pageDescription, BorderLayout.CENTER);
-
+
pagePanel = new JPanel(new BorderLayout(12, 12));
contentPane.add(pagePanel, BorderLayout.CENTER);
-
+
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.TRAILING, 12, 12));
buttonPanel.setBorder(new EmptyBorder(-12, -12, -12, -12));
buttonPanel.add(new JButton(previousAction));
buttonPanel.add(new JButton(nextAction));
buttonPanel.add(new JButton(quitAction));
contentPane.add(buttonPanel, BorderLayout.PAGE_END);
-
+
setContentPane(contentPane);
}
-
+
@Override
public void pack() {
super.pack();
setLocation((screenSize.width - getWidth()) / 2, (screenSize.height - getHeight()) / 2);
// System.out.println("resized to: " + getWidth() + "x" + getHeight());
}
-
+
private void createActions() {
previousAction = new AbstractAction("Previous") {
public void actionPerformed(ActionEvent actionEvent) {
actionPrevious();
}
};
-
+
nextAction = new AbstractAction("Next") {
public void actionPerformed(ActionEvent actionEvent) {
actionNext();
}
};
-
+
quitAction = new AbstractAction("Quit") {
public void actionPerformed(ActionEvent actionEvent) {
actionQuit();
}
};
}
-
+
public void addWizardListener(WizardListener wizardListener) {
wizardListeners.add(wizardListener);
}
-
+
public void removeWizardListener(WizardListener wizardListener) {
wizardListeners.remove(wizardListener);
}
-
+
protected void fireWizardPreviousPressed() {
for (WizardListener wizardListener: wizardListeners) {
wizardListener.wizardPreviousPressed(this);
}
}
-
+
protected void fireWizardNextPressed() {
for (WizardListener wizardListener: wizardListeners) {
wizardListener.wizardNextPressed(this);
}
}
-
+
protected void fireWizardQuitPressed() {
for (WizardListener wizardListener: wizardListeners) {
wizardListener.wizardQuitPressed(this);
}
}
-
+
public void setIcon(Icon icon) {
pageIcon.setIcon(icon);
}
-
+
public void setPage(TWizardPage page) {
setVisible(false);
pageHeading.setText(page.getHeading());
setTitle(page.getHeading());
setVisible(true);
}
-
+
public TWizardPage getPage() {
return (TWizardPage) pagePanel.getComponent(0);
}
-
+
public void setPreviousEnabled(boolean previousEnabled) {
previousAction.setEnabled(previousEnabled);
}
-
+
public void setPreviousName(String previousName) {
previousAction.putValue(Action.NAME, previousName);
}
-
+
public void setNextEnabled(boolean nextEnabled) {
nextAction.setEnabled(nextEnabled);
}
-
+
public void setNextName(String nextName) {
nextAction.putValue(Action.NAME, nextName);
}
-
+
public void setQuitEnabled(boolean quitEnabled) {
quitAction.setEnabled(quitEnabled);
}
-
+
public void setQuitName(String quitName) {
quitAction.putValue(Action.NAME, quitName);
}
-
+
protected void actionPrevious() {
fireWizardPreviousPressed();
}
protected void actionNext() {
fireWizardNextPressed();
}
-
+
protected void actionQuit() {
fireWizardQuitPressed();
}
-
+
//
// INTERFACE WindowListener
//
/*
- * todesbaum-lib -
+ * todesbaum-lib -
* Copyright (C) 2006 David Roden
*
* This program is free software; you can redistribute it and/or modify
/*
- * todesbaum-lib -
+ * todesbaum-lib -
* Copyright (C) 2006 David Roden
*
* This program is free software; you can redistribute it and/or modify
public void wizardNextPressed(TWizard wizard);
public void wizardPreviousPressed(TWizard wizard);
public void wizardQuitPressed(TWizard wizard);
-
+
}
/**
* SimpleXML is a helper class to construct XML trees in a fast and simple way. Construct a new XML tree by calling {@link #SimpleXML(String)} and
* append new nodes by calling {@link #append(String)}.
- *
+ *
* @author David Roden <droden@gmail.com>
* @version $Id:SimpleXML.java 221 2006-03-06 14:46:49Z bombe $
*/
/**
* Constructs a new XML node with the specified name.
- *
+ *
* @param name
* The name of the new node
*/
/**
* Returns the child node of this node with the specified name. If there are several child nodes with the specified name only the first node is
* returned.
- *
+ *
* @param nodeName
* The name of the child node
* @return The child node, or <code>null</code> if there is no child node with the specified name
* Returns the child node that is specified by the names. The first element of <code>nodeNames</code> is the name of the child node of this
* node, the second element of <code>nodeNames</code> is the name of a child node's child node, and so on. By using this method you can descend
* into an XML tree pretty fast.
- *
+ *
* <pre>
* SimpleXML deepNode = topNode.getNodes(new String[] { "person", "address", "number" });
* </pre>
- *
+ *
* @param nodeNames
* @return A node that is a deep child of this node, or <code>null</code> if the specified node does not eixst
*/
/**
* Returns all child nodes of this node.
- *
+ *
* @return All child nodes of this node
*/
public SimpleXML[] getNodes() {
/**
* Returns all child nodes of this node with the specified name. If there are no child nodes with the specified name an empty array is returned.
- *
+ *
* @param nodeName
* The name of the nodes to retrieve, or <code>null</code> to retrieve all nodes
* @return All child nodes with the specified name
/**
* Appends a new XML node with the specified name and returns the new node. With this method you can create deep structures very fast.
- *
+ *
* <pre>
* SimpleXML mouseNode = topNode.append("computer").append("bus").append("usb").append("mouse");
* </pre>
- *
+ *
* @param nodeName
* The name of the node to append as a child to this node
* @return The new node
/**
* Appends a new XML node with the specified name and value and returns the new node.
- *
+ *
* @param nodeName
* The name of the node to append
* @param nodeValue
/**
* Appends the node with all its child nodes to this node and returns the child node.
- *
+ *
* @param newChild
* The node to append as a child
* @return The child node that was appended
public void remove(SimpleXML child) {
children.remove(child);
}
-
+
public void remove(String childName) {
SimpleXML child = getNode(childName);
if (child != null) {
remove(child);
}
}
-
+
public void replace(String childName, String value) {
remove(childName);
append(childName, value);
}
-
+
public void replace(SimpleXML childNode) {
remove(childNode.getName());
append(childNode);
}
-
+
public void removeAll() {
children.clear();
}
/**
* Sets the value of this node.
- *
+ *
* @param nodeValue
* The new value of this node
* @return This node
/**
* Returns the name of this node.
- *
+ *
* @return The name of this node
*/
public String getName() {
/**
* Returns the value of this node.
- *
+ *
* @return The value of this node
*/
public String getValue() {
/**
* Creates a {@link Document} from this node and all its child nodes.
- *
+ *
* @return The {@link Document} created from this node
*/
public Document getDocument() {
/**
* Appends all children of this node to the specified {@link Element}. If a node has a value that is not <code>null</code> the value is
* appended as a text node.
- *
+ *
* @param rootElement
* The element to attach this node's children to
*/
/**
* Creates a SimpleXML node from the specified {@link Document}. The SimpleXML node of the document's top-level node is returned.
- *
+ *
* @param document
* The {@link Document} to create a SimpleXML node from
* @return The SimpleXML node created from the document's top-level node
/**
* Appends the child nodes of the specified {@link Document} to this node. Text nodes are converted into a node's value.
- *
+ *
* @param xmlDocument
* The SimpleXML node to append the child nodes to
* @param document
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
- *
+ *
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place - Suite 330, Boston, MA 02111-1307, USA.
/**
* Contains method to transform DOM XML trees to byte arrays and vice versa.
- *
+ *
* @author David Roden <droden@gmail.com>
* @version $Id:XML.java 221 2006-03-06 14:46:49Z bombe $
*/
/**
* Returns a document builder factory. If possible the cached instance will be returned.
- *
+ *
* @return A document builder factory
*/
private static DocumentBuilderFactory getDocumentBuilderFactory() {
/**
* Returns a document builder. If possible the cached instance will be returned.
- *
+ *
* @return A document builder
*/
private static DocumentBuilder getDocumentBuilder() {
/**
* Returns a transformer factory. If possible the cached instance will be returned.
- *
+ *
* @return A transformer factory
*/
private static TransformerFactory getTransformerFactory() {
/**
* Creates a new XML document.
- *
+ *
* @return A new XML document
*/
public static Document createDocument() {
/**
* Transforms the DOM XML document into a byte array.
- *
+ *
* @param document
* The document to transform
* @return The byte array containing the XML representation
/**
* Transforms the byte array into a DOM XML document.
- *
+ *
* @param data
* The byte array to parse
* @return The DOM XML document