diff --git a/src/main/com/ibm/icu/text/CharsetDetector.java b/src/main/com/ibm/icu/text/CharsetDetector.java index 867cabb66..e04665076 100644 --- a/src/main/com/ibm/icu/text/CharsetDetector.java +++ b/src/main/com/ibm/icu/text/CharsetDetector.java @@ -22,17 +22,16 @@ * The result of the detection operation is a list of possibly matching * charsets, or, for simple use, you can just ask for a Java Reader that * will will work over the input data. - *
+ ** Character set detection is at best an imprecise operation. The detection * process will attempt to identify the charset that best matches the characteristics * of the byte data, but the process is partly statistical in nature, and * the results can not be guaranteed to always be correct. - *
+ ** For best accuracy in charset detection, the input data should be primarily * in a single language, and a minimum of a few hundred bytes worth of plain text * in the language are needed. The detection process will attempt to * ignore html or xml style markup that could otherwise obscure the content. - *
* * stable ICU 3.4 */ @@ -105,8 +104,8 @@ public CharsetDetector setText(byte [] in) { * @param in the input text of unknown encoding * * @return This CharsetDetector - * - * @throws IOException + * + * @throws IOException if an I/O error occurs. * */ public CharsetDetector setText(InputStream in) throws IOException { @@ -222,8 +221,8 @@ public CharsetMatch[] detectAll() { * * @param declaredEncoding A declared encoding for the data, if available, * or null or an empty string if none is available. - * - * @return Reader to access the converted input data + * + * @return Reader to access the converted input data * */ public Reader getReader(InputStream in, String declaredEncoding) { @@ -256,8 +255,8 @@ public Reader getReader(InputStream in, String declaredEncoding) { * * @param declaredEncoding A declared encoding for the data, if available, * or null or an empty string if none is available. - * - * @return + * + * @return a String containing the converted input data * */ public String getString(byte[] in, String declaredEncoding) { diff --git a/src/main/com/ibm/icu/text/CharsetMatch.java b/src/main/com/ibm/icu/text/CharsetMatch.java index bf83b9686..898403ad3 100644 --- a/src/main/com/ibm/icu/text/CharsetMatch.java +++ b/src/main/com/ibm/icu/text/CharsetMatch.java @@ -62,8 +62,10 @@ public Reader getReader() { * * @return a String created from the converted input data. * + * @throws IOException if an IO error occurs. + * */ - public String getString() throws java.io.IOException { + public String getString() throws IOException { return getString(-1); } @@ -80,8 +82,10 @@ public String getString() throws java.io.IOException { * unlimited length. * @return a String created from the converted input data. * + * @throws IOException if an IO error occurs. + * */ - public String getString(int maxLength) throws java.io.IOException { + public String getString(int maxLength) throws IOException { String result; if (fInputStream != null) { StringBuilder sb = new StringBuilder(); diff --git a/src/main/com/mucommander/PlatformManager.java b/src/main/com/mucommander/PlatformManager.java index 9daf4868a..11370263c 100644 --- a/src/main/com/mucommander/PlatformManager.java +++ b/src/main/com/mucommander/PlatformManager.java @@ -50,10 +50,9 @@ public class PlatformManager { *~/Library/Preferences/trolCommander/
under MAC OS X.~/.trolcommander/
under all other OSes.* If the default preferences folder doesn't exist, this method will create it. - *
+ * * @return the path to the default trolCommander preferences folder. */ public static AbstractFile getDefaultPreferencesFolder() { @@ -68,10 +67,9 @@ public static AbstractFile getDefaultPreferencesFolder() { *~/Library/Preferences/trolCommander/
under MAC OS X.~/.trolcommander/
under all other OSes.* If the default preferences folder doesn't exist, this method will create it. - *
+ * * @return the path to the default trolCommander preferences folder. */ public static String getDefaultPreferencesFolderPath() { @@ -99,12 +97,11 @@ public static String getDefaultPreferencesFolderPath() { ** All modules that save user data to a file should do so in a file located in * the folder returned by this method. - *
** The value returned by this method can be set through {@link #setPreferencesFolder(File)}. * Otherwise, the {@link #getDefaultPreferencesFolder() default preference folder} will be * used. - *
+ * * @return the path to the user's preference folder. * @see #setPreferencesFolder(AbstractFile) */ @@ -121,7 +118,7 @@ public static AbstractFile getPreferencesFolder() { *
* If folder
is a file, its parent folder will be used instead. If it doesn't exist,
* this method will create it.
- *
* If folder
is a file, its parent folder will be used instead. If it doesn't exist,
* this method will create it.
- *
* If folder
is a file, its parent folder will be used instead. If it doesn't exist,
* this method will create it.
- *
* muCommander is considered up to date if:
* - the {@link com.mucommander.RuntimeConstants#VERSION local version} is
@@ -68,7 +68,7 @@
* versions of the current release, and those might be updated almost daily. Comparing dates
* makes it possible to automate the whole process without having to worry about out version
* numbers growing silly.
- *
* The date format is YYYYMMDD. - *
+ * * @return the date at which the latest version of muCommander has been released. */ public String getReleaseDate() {return releaseDate;} diff --git a/src/main/com/mucommander/adb/AdbUtils.java b/src/main/com/mucommander/adb/AdbUtils.java index 167b53d97..a46d3092f 100644 --- a/src/main/com/mucommander/adb/AdbUtils.java +++ b/src/main/com/mucommander/adb/AdbUtils.java @@ -60,8 +60,9 @@ public static Listpath
is not available.
*/
public static void setCredentialsFile(String path) throws FileNotFoundException {
- AbstractFile file;
+ AbstractFile file = FileFactory.getFile(path);
- if((file = FileFactory.getFile(path)) == null)
+ if (file == null) {
setCredentialsFile(new File(path));
- else
+ } else {
setCredentialsFile(file);
+ }
}
/**
@@ -148,8 +148,9 @@ public static void setCredentialsFile(File file) throws FileNotFoundException {
* @throws FileNotFoundException if path
is not available.
*/
public static void setCredentialsFile(AbstractFile file) throws FileNotFoundException {
- if(file.isBrowsable())
+ if (file.isBrowsable()) {
throw new FileNotFoundException("Not a valid file: " + file);
+ }
credentialsFile = file;
}
@@ -160,14 +161,14 @@ public static void setCredentialsFile(AbstractFile file) throws FileNotFoundExce
*/
public static void loadCredentials() throws Exception {
AbstractFile credentialsFile = getCredentialsFile();
- if(credentialsFile.exists()) {
+ if (credentialsFile.exists()) {
LOGGER.debug("Found credentials file: "+credentialsFile.getAbsolutePath());
// Parse the credentials file
new CredentialsParser().parse(credentialsFile);
LOGGER.debug("Credentials file loaded.");
+ } else {
+ LOGGER.debug("No credentials file found at " + credentialsFile.getAbsolutePath());
}
- else
- LOGGER.debug("No credentials file found at "+credentialsFile.getAbsolutePath());
}
/**
@@ -180,8 +181,9 @@ public static void loadCredentials() throws Exception {
*/
public static void writeCredentials(boolean forceWrite) throws IOException {
// Write credentials file only if changes were made to persistent entries since last write, or if write is forced
- if(!(forceWrite || saveNeeded))
+ if (!(forceWrite || saveNeeded)) {
return;
+ }
BackupOutputStream out = null;
try {
@@ -190,9 +192,11 @@ public static void writeCredentials(boolean forceWrite) throws IOException {
saveNeeded = false;
}
finally {
- if(out != null) {
- try {out.close();}
- catch(Exception e) {}
+ if (out != null) {
+ // TODO autoclosable
+ try {
+ out.close();
+ } catch(Exception e) {}
}
}
@@ -200,10 +204,11 @@ public static void writeCredentials(boolean forceWrite) throws IOException {
// 'group' and 'other'.
boolean fileSecured = !OsFamily.getCurrent().isUnixBased() || Chmod.chmod(credentialsFile, 0600); // rw-------
- if(fileSecured)
- LOGGER.debug("Credentials file saved successfully.");
- else
- LOGGER.warn("Credentials file could not be chmod!");
+ if (fileSecured) {
+ LOGGER.debug("Credentials file saved successfully.");
+ } else {
+ LOGGER.warn("Credentials file could not be chmod!");
+ }
}
@@ -252,14 +257,14 @@ public static Authenticator getAuthenticator() {
* @return a Vector of CredentialsMapping matching the given URL's scheme and host, best match at the first position
*/
private static ListVector
, preserving its position. If the
* vector contains no such object, it is added to the end of the vector.
*
- * @param vector the Vector
to replace/add the object to
+ * @param list the List
to replace/add the object to
* @param o the object to replace/add
*/
- private static void replaceVectorElement(ListBookmarks are simple name/location pairs: - *
An LRU (Least Recently Used) cache can contain a fixed number of items (the capacity). When capacity is reached, * the least recently used is removed. Each object retrieved with the {@link #get(Object) get()} method * makes the requested item the most recently used one. Similarly, each object inserted using the - * {@link #add(Object, Object) add()} method makes the added item the most recently used one.
+ * {@link #add(Object, Object) add()} method makes the added item the most recently used one. * *This LRUCache provides an optional feature : the ability to assign a time-to-live for each or part of the * items added. When the time-to-live of an item expires, the item is automatically removed from the cache and won't - * be returned by the {@link #get(Object) get()} method anymore.
+ * be returned by the {@link #get(Object) get()} method anymore. * *Implementation note: checking for expired items can be an expensive operation so it doesn't have * to be done as soon as the item has expired, the expired items can live a bit longer in the cache if necessary. @@ -42,7 +42,7 @@ *
null
if a value could not
@@ -126,7 +127,7 @@ public int getMissCount() {
* * The basic command syntax is fairly simple: *
"
characters are not removed from the resulting tokens.
- *
* * It's also possible to include keywords in a command: *
$p
is replaced by a file's parent's path.$j
is replaced by the path of the folder in which the JVM was started.
* Once a Command
instance has been retrieved, execution tokens can be retrieved through the
* {@link #getTokens(AbstractFile)} method. This will return a tokenized version of the command and replace any
* keyword by the corresponding file value . It's also possible to skip keyword replacement through the {@link #getTokens()} method.
- *
* A command's executable tokens are typically meant to be used with {@link com.mucommander.process.ProcessRunner#execute(String[],AbstractFile)} * in order to generate instances of {@link com.mucommander.process.AbstractProcess}. - *
+ * * @author Nicolas Rinaudo * @see CommandManager * @see com.mucommander.process.ProcessRunner @@ -130,7 +126,7 @@ public Command(String alias, String command, CommandType type, String displayNam *
* This is a convenience constructor and is strictly equivalent to calling
* {@link Command(String,String,CommandType,String) Command(}alias, command, {@link CommandType#NORMAL_COMMAND}, null)
.
- *
* This is a convenience constructor and is strictly equivalent to calling
* {@link Command(String,String,int,String) Command(}alias, command, type, null)
.
- *
* Returns true if command contains keywords referencing selected file, e.g. $f,$n,$p,$e,$b. * Returns false otherwise, e.g. $j, $xyz, etc. - *
* * @return whether this command contains keywords referencing selected file. */ @@ -467,7 +462,7 @@ public synchronized CommandType getType() { * Returns the command's display name. ** If it hasn't been set, returns this command's alias. - *
+ * * @return the command's display name. */ public synchronized String getDisplayName() { diff --git a/src/main/com/mucommander/command/CommandBuilder.java b/src/main/com/mucommander/command/CommandBuilder.java index 59183e1cf..bd966d2e8 100644 --- a/src/main/com/mucommander/command/CommandBuilder.java +++ b/src/main/com/mucommander/command/CommandBuilder.java @@ -25,12 +25,12 @@ * generate a list of commands - from instances loaded in memory or from a file, for example. * ImplementingCommandBuilder
allows classes to query these lists regardless of
* their source.
- *
+ *
*
* Instances of CommandBuilder
can rely on their methods to be called in the proper order,
* and on both their {@link #startBuilding()} and {@link #endBuilding()} methods to be called. Classes that
* interact with such instances must make sure this contract is respected.
- *
* A (fairly useless) implementation might look like: *
@@ -52,7 +52,7 @@ * - creating command 'open -a Safari $f' with alias 'openURL' * Done. *- * + * * @author Nicolas Rinaudo * @see CommandReader * @see CommandManager@buildCommands(CommandBuilder) diff --git a/src/main/com/mucommander/command/CommandManager.java b/src/main/com/mucommander/command/CommandManager.java index def5dcb31..52ea93791 100644 --- a/src/main/com/mucommander/command/CommandManager.java +++ b/src/main/com/mucommander/command/CommandManager.java @@ -517,6 +517,7 @@ public static void setAssociationFile(AbstractFile file) throws FileNotFoundExce * Its format is described {@link AssociationsXmlConstants here}. * * @throws IOException if an IO error occurs. + * @throws CommandException thrown when errors occur while building custom commands * @see #writeAssociations() * @see #getAssociationFile() * @see #setAssociationFile(String) @@ -534,6 +535,7 @@ public static void loadAssociations() throws IOException, CommandException { } finally { wereAssociationsModified = false; // Makes sure the input stream is closed. + // TODO use autoclosable if (in != null) { try { in.close(); diff --git a/src/main/com/mucommander/commons/collections/AlteredVector.java b/src/main/com/mucommander/commons/collections/AlteredVector.java index ea0c98246..f29139185 100644 --- a/src/main/com/mucommander/commons/collections/AlteredVector.java +++ b/src/main/com/mucommander/commons/collections/AlteredVector.java @@ -31,8 +31,8 @@ *
It is however not aware of modifications that are made to the contained objects themselves.
+ * + *It is however not aware of modifications that are made to the contained objects themselves. * * @author Maxence Bernard */ @@ -63,7 +63,7 @@ public AlteredVector(int initialCapacity) { * Adds the specified VectorChangeListener to the list of registered listeners. * *
Listeners are stored as weak references so {@link #removeVectorChangeListener(VectorChangeListener)} - * doesn't need to be called for listeners to be garbage collected when they're not used anymore.
+ * doesn't need to be called for listeners to be garbage collected when they're not used anymore. * * @param listener the VectorChangeListener to add to the list of registered listeners. * @see #removeVectorChangeListener(VectorChangeListener) @@ -90,8 +90,9 @@ public void removeVectorChangeListener(VectorChangeListener listener) { * @param nbAdded number of elements added */ private void fireElementsAddedEvent(int startIndex, int nbAdded) { - for(VectorChangeListener listener : listeners.keySet()) + for (VectorChangeListener listener : listeners.keySet()) { listener.elementsAdded(startIndex, nbAdded); + } } /** diff --git a/src/main/com/mucommander/commons/conf/Configuration.java b/src/main/com/mucommander/commons/conf/Configuration.java index 4661ab93a..611606d2d 100644 --- a/src/main/com/mucommander/commons/conf/Configuration.java +++ b/src/main/com/mucommander/commons/conf/Configuration.java @@ -28,9 +28,9 @@ * AConfiguration
instance's main goal is to act as a configuration data repository.
* Once created, it can be used to {@link #getVariable(String) retrieve}, {@link #removeVariable(String) delete}
* and {@link #setVariable(String,String) set} configuration variables.
- *
- * + * *
* Configuration variable names follow the same convention as Java System properties: a serie of strings
* separated by periods. By convention, all but the last string are called configuration sections, while
* the last one is the variable's name. When we refer to a variable's fully qualified name, we're talking
@@ -38,9 +38,9 @@
* For example, startup_folder.right.last_folder
is interpreted as a variable called
* last_folder
contained in a section called right
, itself contained in
* another section called startup_folder
.
- *
+ * *
* While the com.mucommander.commons.conf
really only handles one type of variables, strings, it offers
* tools to cast them as primitive Java types (int, long, float, double, boolean). This is done through the use
* of the various primitive types' class implementation parseXXX
method.
@@ -54,16 +54,16 @@
*
0
false
+ * *
* By default, configuration data is assumed to be in the standard muCommander file format (described in * {@link XmlConfigurationReader}). However, application writers can modify that to any format they want * through the {@link #setReaderFactory(ConfigurationReaderFactory) setReaderFactory} and * {@link #setWriterFactory(ConfigurationWriterFactory) setWriterFactory} methods. - *
- *+ * *
* While Configuration
provides read and write methods that accept streams as parameters, it's
* also possible to set the data source once and for all and let the API deal with the details. This can
* be achieved through the {@link #setSource(ConfigurationSource) setSource} method.
@@ -71,9 +71,9 @@
* common case of configuration sources, a local configuration file.
* For application writers who wish to be able to retrieve configuration files through a variety of file systems,
* we suggest creating a source using the com.mucommander.file
API.
- *
+ * *
* Classes that need to monitor the state of the configuration in order, for example, to react to changes * dynamically rather than wait for an application reboot can implement the {@link ConfigurationListener} * interface and register themselves through @@ -82,7 +82,7 @@ * Note that LISTENERS are stored as weak references, meaning that application writers must ensure that they keep * direct references to the listener instances they register if they do not want them to be garbaged collected * out of existence randomly. - *
+ * * @author Nicolas Rinaudo */ public class Configuration { @@ -120,11 +120,9 @@ public class Configuration { ** The resulting instance will use default {@link XmlConfigurationReader readers} and * {@link XmlConfigurationWriter writers}. - *
** Note that until the {@link #setSource(ConfigurationSource) setSource} method has been * invoked, calls to read or write methods without a stream parameter will fail. - *
*/ public Configuration() { } @@ -134,7 +132,7 @@ public Configuration() { ** The resulting instance will use the default {@link XmlConfigurationReader readers} and * {@link XmlConfigurationWriter writers}. - *
+ * * @param source where the resulting instance will look for its configuration data. */ public Configuration(ConfigurationSource source) { @@ -146,7 +144,7 @@ public Configuration(ConfigurationSource source) { ** Note that until the {@link #setSource(ConfigurationSource) setSource} method has been * invoked, calls to read or write methods without a stream parameter will fail. - *
+ * * @param reader factory for configuration readers. * @param writer factory for configuration writers. */ @@ -202,7 +200,7 @@ public ConfigurationSource getSource() { *
* In order to reset the configuration to its default reader factory, application writers can call this method
* with a null
parameter.
- *
* By default, this method will return an {@link XmlConfigurationReader XML reader} factory. * This can be modified by calling {@link #setReaderFactory(ConfigurationReaderFactory) setReaderFactory}. - *
+ * * @return the factory that is being used to create reader instances. * @see #setReaderFactory(ConfigurationReaderFactory) */ @@ -239,7 +237,7 @@ public ConfigurationReaderFactory getReaderFactory() { *
* In order to reset the configuration to its default writer factory, application writers can call
* this method will a null
parameter.
- *
* By default, this method will return an {@link XmlConfigurationWriter} factory. However, this * can be modified by calling {@link #setWriterFactory(ConfigurationWriterFactory) setWriterFactory}. - *
+ * * @return the factory that is being used to create writer instances. * @see #setWriterFactory(ConfigurationWriterFactory) */ @@ -292,7 +290,7 @@ synchronized void read(Reader in, ConfigurationReader reader) throws IOException ** This method will use the configuration reader set by {@link #setReaderFactory(ConfigurationReaderFactory)} if any, * or an {@link XmlConfigurationReader} instance if not. - *
+ * * @param in where to read the configuration from. * @throws ConfigurationException if a configuration error occurs. * @throws ConfigurationFormatException if a syntax error occurs in the configuration data. @@ -315,7 +313,7 @@ public void read(InputStream in) throws ConfigurationException, IOException { ** This method will use the configuration reader set by {@link #setReaderFactory(ConfigurationReaderFactory)} if any, * or an {@link XmlConfigurationReader} instance if not. - *
+ * * @param in where to read the configuration from. * @throws ConfigurationException if a configuration error occurs. * @throws ConfigurationFormatException if a syntax error occurs in the configuration data. @@ -335,7 +333,7 @@ public void read(Reader in) throws ConfigurationException, IOException { ** This method will use the input stream provided by {@link #setSource(ConfigurationSource)} if any, or * fail otherwise. - *
+ * * @param reader reader that will be used to interpret the content ofin
.
* @throws IOException if an I/O error occurs.
* @throws ConfigurationException if a configuration error occurs.
@@ -374,11 +372,11 @@ public void read(ConfigurationReader reader) throws IOException, ConfigurationEx
* If a reader has been specified through {@link #setReaderFactory(ConfigurationReaderFactory)}, it
* will be used to analyse the configuration. Otherwise, an {@link XmlConfigurationReader}
* instance will be used.
- *
+ *
* * If a configuration source has been specified through {@link #setSource(ConfigurationSource)}, it will be * used. Otherwise, this method will fail. - *
+ * * @throws IOException if an I/O error occurs. * @throws ConfigurationException if a configuration error occurs. * @throws SourceConfigurationException if no {@link ConfigurationSource} hasn't been set. @@ -402,7 +400,7 @@ public void read() throws ConfigurationException, IOException { * Writes the configuration to the specified {@link Writer}. ** This method will use {@link #getWriterFactory()} to create instances of configuration writer. - *
+ * * @param out where to write the configuration to. * @throws ConfigurationException if any error occurs. * @throws ConfigurationFormatException if a syntax error occurs in the configuration data. @@ -420,7 +418,7 @@ public void write(Writer out) throws ConfigurationException { ** If a configuration source was specified through {@link #setSource(ConfigurationSource)}, it will be used * to open an output stream. Otherwise, this method will fail. - *
+ * * @throws ConfigurationException if any error occurs. * @throws SourceConfigurationException if no {@link ConfigurationSource} has been set. * @throws ConfigurationFormatException if a syntax error occurs in the configuration data. @@ -503,7 +501,7 @@ private synchronized void build(ConfigurationBuilder builder, ConfigurationSecti *
* At the end of this call, fromVar
will have been deleted. Note that if fromVar
doesn't
* exist, but toVar
does, toVar
will be deleted.
- *
* This method might trigger as many as two {@link ConfigurationEvent events}: *
toVar
is set.fromVar
's value.
*/
@@ -524,11 +522,11 @@ public void renameVariable(String fromVar, String toVar) {
*
* This method will return false
if it didn't modify name
's value. Note that this doesn't
* mean the call failed, but that name
's value was already equal to value
.
- *
* If the value of the specified variable is actually modified, an {@link ConfigurationEvent event} will be passed * to all LISTENERS. - *
+ * * @param name fully qualified name of the variable to set. * @param value new value for the variable. * @returntrue
if this call resulted in a modification of the variable's value,
@@ -556,11 +554,11 @@ public synchronized boolean setVariable(String name, String value) {
* This method will return false
if it didn't modify name
's value. This, however, is not a
* way of indicating that the call failed: false
is only ever returned if the previous value is equal
* to the new value.
- *
+ *
* * If the value of the specified variable is actually modified, an {@link ConfigurationEvent event} will be passed * to all LISTENERS. - *
+ * * @param name fully qualified name of the variable to set. * @param value new value for the variable. * @returntrue
if this call resulted in a modification of the variable's value,
@@ -578,11 +576,11 @@ public boolean setVariable(String name, int value) {
* This method will return false
if it didn't modify name
's value. This, however, is not a
* way of indicating that the call failed: false
is only ever returned if the previous value is equal
* to the new value.
- *
+ *
* * If the value of the specified variable is actually modified, an {@link ConfigurationEvent event} will be passed to all * LISTENERS. - *
+ * * @param name fully qualified name of the variable to set. * @param value new value for the variable. * @param separator string used to separate each element of the list. @@ -601,11 +599,11 @@ public boolean setVariable(String name, Listfalse
if it didn't modify name
's value. This, however, is not
* a way of indicating that the call failed: false
is only ever returned if the previous value is equal
* to the new value.
- *
+ *
* * If the value of the specified variable is actually modified, an {@link ConfigurationEvent event} will be passed * to all LISTENERS. - *
+ * * @param name fully qualified name of the variable to set. * @param value new value for the variable. * @returntrue
if this call resulted in a modification of the variable's value,
@@ -621,11 +619,11 @@ public boolean setVariable(String name, Listfalse
if it didn't modify name
's value. This, however, is not a
* way of indicating that the call failed: false
is only ever returned if the previous value is equal
* to the new value.
- *
+ *
* * If the value of the specified variable is actually modified, an {@link ConfigurationEvent event} will be passed * to all LISTENERS. - *
+ * * @param name fully qualified name of the variable to set. * @param value new value for the variable. * @returntrue
if this call resulted in a modification of the variable's value,
@@ -643,11 +641,11 @@ public boolean setVariable(String name, boolean value) {
* This method will return false
if it didn't modify name
's value. This, however, is not a
* way of indicating that the call failed: false
is only ever returned if the previous value is equal
* to the new value.
- *
+ *
* * If the value of the specified variable is actually modified, an {@link ConfigurationEvent event} will be passed * to all LISTENERS. - *
+ * * @param name fully qualified name of the variable to set. * @param value new value for the variable. * @returntrue
if this call resulted in a modification of the variable's value,
@@ -665,11 +663,11 @@ public boolean setVariable(String name, long value) {
* This method will return false
if it didn't modify name
's value. This, however, is not a
* way of indicating that the call failed: false
is only ever returned if the previous value is equal
* to the new value.
- *
+ *
* * If the value of the specified variable is actually modified, an {@link ConfigurationEvent event} will be passed * to all LISTENERS. - *
+ * * @param name fully qualified name of the variable to set. * @param value new value for the variable. * @returntrue
if this call resulted in a modification of the variable's value,
@@ -809,7 +807,7 @@ private void prune(BufferedConfigurationExplorer explorer) {
* * If the variable was set, a configuration {@link ConfigurationEvent event} will be passed to * all registered LISTENERS. - *
+ * * @param name name of the variable to remove. * @return the variable's old value, ornull
if it wasn't set.
*/
@@ -835,7 +833,7 @@ public synchronized String removeVariable(String name) {
* * If the variable was set, a configuration {@link ConfigurationEvent event} will be passed to * all registered LISTENERS. - *
+ * * @param name name of the variable to remove. * @param separator character used to split the variable's value into a list. * @return the variable's old value, ornull
if it wasn't set.
@@ -849,7 +847,7 @@ public ValueList removeListVariable(String name, String separator) {
* * If the variable was set, a configuration {@link ConfigurationEvent event} will be passed to * all registered LISTENERS. - *
+ * * @param name name of the variable to remove. * @return the variable's old value, or0
if it wasn't set.
*/
@@ -862,7 +860,7 @@ public int removeIntegerVariable(String name) {
* * If the variable was set, a configuration {@link ConfigurationEvent event} will be passed to * all registered LISTENERS. - *
+ * * @param name name of the variable to remove. * @return the variable's old value, or0
if it wasn't set.
*/
@@ -875,7 +873,7 @@ public long removeLongVariable(String name) {
* * If the variable was set, a configuration {@link ConfigurationEvent event} will be passed to * all registered LISTENERS. - *
+ * * @param name name of the variable to remove. * @return the variable's old value, or0
if it wasn't set.
*/
@@ -888,7 +886,7 @@ public float removeFloatVariable(String name) {
* * If the variable was set, a configuration {@link ConfigurationEvent event} will be passed to * all registered LISTENERS. - *
+ * * @param name name of the variable to remove. * @return the variable's old value, or0
if it wasn't set.
*/
@@ -901,7 +899,7 @@ public double removeDoubleVariable(String name) {
* * If the variable was set, a configuration {@link ConfigurationEvent event} will be passed to * all registered LISTENERS. - *
+ * * @param name name of the variable to remove. * @return the variable's old value, orfalse
if it wasn't set.
*/
@@ -910,7 +908,7 @@ public boolean removeBooleanVariable(String name) {
}
/**
- * Remove all variables & sub-sections under the root section
+ * Remove all variables and sub-sections under the root section
*/
public void clear() {
root.clear();
@@ -925,7 +923,7 @@ public void clear() {
* If the variable isn't set, this method will set it to defaultValue
before
* returning it. If this happens, a configuration {@link ConfigurationEvent event} will
* be sent to all registered LISTENERS.
- *
+ *
* @param name name of the variable to retrieve.
* @param defaultValue value to use if name
is not set.
* @return the specified variable's value.
@@ -955,7 +953,7 @@ public synchronized String getVariable(String name, String defaultValue) {
* If the variable isn't set, this method will set it to defaultValue
before
* returning it. If this happens, a configuration {@link ConfigurationEvent event} will
* be sent to all registered LISTENERS.
- *
+ *
* @param name name of the variable to retrieve.
* @param defaultValue value to use if variable name
is not set.
* @param separator separator to use for defaultValue
if variable name
is not set.
@@ -973,7 +971,7 @@ public ValueList getVariable(String name, ListdefaultValue
before
* returning it. If this happens, a configuration {@link ConfigurationEvent event} will
* be sent to all registered LISTENERS.
- *
+ *
* @param name name of the variable to retrieve.
* @param defaultValue value to use if name
is not set.
* @return the specified variable's value.
@@ -991,7 +989,7 @@ public int getVariable(String name, int defaultValue) {
* If the variable isn't set, this method will set it to defaultValue
before
* returning it. If this happens, a configuration {@link ConfigurationEvent event} will
* be sent to all registered LISTENERS.
- *
+ *
* @param name name of the variable to retrieve.
* @param defaultValue value to use if name
is not set.
* @return the specified variable's value.
@@ -1009,7 +1007,7 @@ public long getVariable(String name, long defaultValue) {
* If the variable isn't set, this method will set it to defaultValue
before
* returning it. If this happens, a configuration {@link ConfigurationEvent event} will
* be sent to all registered LISTENERS.
- *
+ *
* @param name name of the variable to retrieve.
* @param defaultValue value to use if name
is not set.
* @return the specified variable's value.
@@ -1027,7 +1025,7 @@ public float getVariable(String name, float defaultValue) {
* If the variable isn't set, this method will set it to defaultValue
before
* returning it. If this happens, a configuration {@link ConfigurationEvent event} will
* be sent to all registered LISTENERS.
- *
+ *
* @param name name of the variable to retrieve.
* @param defaultValue value to use if name
is not set.
* @return the specified variable's value.
@@ -1044,7 +1042,7 @@ public boolean getVariable(String name, boolean defaultValue) {
* If the variable isn't set, this method will set it to defaultValue
before
* returning it. If this happens, a configuration {@link ConfigurationEvent event} will
* be sent to all registered LISTENERS.
- *
+ *
* @param name name of the variable to retrieve.
* @param defaultValue value to use if name
is not set.
* @return the specified variable's value.
diff --git a/src/main/com/mucommander/commons/conf/ConfigurationReaderFactory.java b/src/main/com/mucommander/commons/conf/ConfigurationReaderFactory.java
index b51d7f137..c396a510d 100644
--- a/src/main/com/mucommander/commons/conf/ConfigurationReaderFactory.java
+++ b/src/main/com/mucommander/commons/conf/ConfigurationReaderFactory.java
@@ -28,7 +28,7 @@
* public ConfigurationReader getReaderInstance() {return new MyReader();}
* }
*
- *
+ *
* @author Nicolas Rinaudo
* @see ConfigurationReader
*/
diff --git a/src/main/com/mucommander/commons/conf/ConfigurationSource.java b/src/main/com/mucommander/commons/conf/ConfigurationSource.java
index e1dae0e99..6f4586716 100644
--- a/src/main/com/mucommander/commons/conf/ConfigurationSource.java
+++ b/src/main/com/mucommander/commons/conf/ConfigurationSource.java
@@ -61,6 +61,8 @@ public interface ConfigurationSource {
/**
* Returns whether this source exists
* @return true if the source exists, false otherwise.
+ *
+ * @throws IOException if any I/O error occurs.
*/
boolean isExists() throws IOException;
}
diff --git a/src/main/com/mucommander/commons/conf/ConfigurationWriterFactory.java b/src/main/com/mucommander/commons/conf/ConfigurationWriterFactory.java
index c5cdb99d7..23059e4ef 100644
--- a/src/main/com/mucommander/commons/conf/ConfigurationWriterFactory.java
+++ b/src/main/com/mucommander/commons/conf/ConfigurationWriterFactory.java
@@ -30,7 +30,7 @@
* public ConfigurationWriter getWriterInstance() {return new MyWriter();}
* }
*
- *
+ *
* @author Nicolas Rinaudo
*/
public abstract class ConfigurationWriterFactory* The returned builder instance will serialize configuration events to the specified writer. - *
+ * * @param out where to write the configuration data. * @return an instance of {@link ConfigurationBuilder}. * @throws WriterConfigurationException if the factory wasn't properly configured. diff --git a/src/main/com/mucommander/commons/conf/XmlConfigurationReader.java b/src/main/com/mucommander/commons/conf/XmlConfigurationReader.java index 52661e59e..52e541c34 100644 --- a/src/main/com/mucommander/commons/conf/XmlConfigurationReader.java +++ b/src/main/com/mucommander/commons/conf/XmlConfigurationReader.java @@ -44,7 +44,7 @@ * will be excluded from section names. * * - * + * ** For example: *
@@ -64,7 +64,7 @@ *
some.section.var1
will be created with a value of value1
.some.section.var2
will be created with a value of value2
.section
and subsection
are both sections.name
is the variable's name.* Configuration data is stored in instances of {@link com.mucommander.commons.conf.Configuration}, which offers a set * of methods manipulate variables: @@ -38,18 +37,17 @@ * value. * * - *
*
* The com.mucommander.commons.conf
package offers various ways of loading and storing configuration.
- * The most obvious way is by using the {@link com.mucommander.commons.conf.Configuration#read(InputStream) read} and
- * {@link com.mucommander.commons.conf.Configuration#write(OutputStream) write} methods, but this has the disadvantage
+ * The most obvious way is by using the {@link com.mucommander.commons.conf.Configuration#read(java.io.Reader) read} and
+ * {@link com.mucommander.commons.conf.Configuration#write(java.io.Writer)) write} methods, but this has the disadvantage
* of forcing application writers to manage streams themselves.
* The preferred method is to create a dedicated {@link com.mucommander.commons.conf.ConfigurationSource} class and
* register it through {@link com.mucommander.commons.conf.Configuration#setSource(ConfigurationSource) setSource}.
* This allows an instance of {@link com.mucommander.commons.conf.Configuration} to know how to read from and write to
* its configuration file (or socket or any other medium that provides input and output streams).
- *
* The default configuration format is described in {@link com.mucommander.commons.conf.XmlConfigurationReader}. @@ -70,7 +68,7 @@ * {@link com.mucommander.commons.conf.Configuration#setReaderFactory(ConfigurationReaderFactory) setReaderFactory}. * * - *
+ * ** Classes that need to be notified when the configuration has changed can do so by: @@ -82,6 +80,5 @@ * addConfigurationLister}. * * - *
*/ package com.mucommander.commons.conf; \ No newline at end of file diff --git a/src/main/com/mucommander/commons/file/AbstractArchiveEntryFile.java b/src/main/com/mucommander/commons/file/AbstractArchiveEntryFile.java index 6b961b861..4c45c6cfc 100644 --- a/src/main/com/mucommander/commons/file/AbstractArchiveEntryFile.java +++ b/src/main/com/mucommander/commons/file/AbstractArchiveEntryFile.java @@ -50,7 +50,6 @@ *AbstractFile
is the superclass of all files.
*
* AbstractFile classes should never be instantiated directly. Instead, the {@link FileFactory} getFile
- * methods should be used to get a file instance from a path or {@link FileURL} location.
FileURL
contains are preserved, but properties are lost.
*
* The returned URL
uses this {@link AbstractFile} to access the associated resource, via the
- * underlying URLConnection
which delegates to this class.
URLConnection
which delegates to this class.
*
* It is important to note that this method is provided for interoperability purposes, for the sole purpose of
- * connecting to APIs that require a java.net.URL
.
java.net.URL
.
*
* @return a java.net.URL
referring to the same location as this FileURL
* @throws java.net.MalformedURLException if the java.net.URL could not parse the location of this FileURL
@@ -121,10 +121,10 @@ public URL getJavaNetURL() throws MalformedURLException {
* The returned name is the filename extracted from this file's FileURL
* as returned by {@link FileURL#getFilename()}. If the filename is null
(e.g. http://google.com), the
* FileURL
's host will be returned instead. If the host is null
(e.g. smb://), an empty
- * String will be returned. Thus, the returned name will never be null
.
null
.
*
* This method should be overridden if a special processing (e.g. URL-decoding) needs to be applied to the - * returned filename.
+ * returned filename. * * @return this file's name */ @@ -146,10 +146,11 @@ public String getName() { /** * Returns this file's extension,null
if this file's name doesn't have an extension.
*
- * A filename has an extension if and only if:
- * - it contains at least one .
character
- * - the last .
is not the last character of the filename
- * - the last .
is not the first character of the filename
+ * A filename has an extension if and only if:
+ * - it contains at least one .
character
+ * - the last .
is not the last character of the filename
+ * - the last .
is not the first character of the filename
*
* @return this file's extension, null
if this file's name doesn't have an extension
*/
@@ -171,7 +172,7 @@ public String getExtension() {
* the login and password parts. File implementations overridding this method should always return a path free of
* any login and password, so that it can safely be displayed to the end user or stored, without risking to
* compromise sensitive information.
- *
This implementation simply returns the value of {@link #getAbsolutePath()}, and thus should be overridden - * if canonical path resolution is available.
+ * if canonical path resolution is available. * * @return the canonical path to this file */ @@ -194,7 +195,7 @@ public String getCanonicalPath() { /** * Returns anAbstractFile
representing the canonical path of this file, or this
if the
- * absolute and canonical path of this file are identical.This default implementation returns the default separator "/", this method should be overridden if the path - * separator used by the file implementation is different.
+ * separator used by the file implementation is different. * * @return the path separator used by this file */ @@ -236,7 +237,7 @@ public String getSeparator() { * *This default implementation is solely based on the filename and returns true
if this
* file's name starts with '.'. This method should be overriden if the underlying filesystem has a notion
- * of hidden files.
* This default implementation returns the file whose URL has the same scheme as this one, same credentials (if any),
* and a path equal to /
.
- *
true
if this file is a root folder.
*
* This default implementation returns true
if this file's URL path is /
.
- *
true
if this file is a root folder
*/
@@ -303,11 +302,9 @@ public boolean isRoot() {
* for the Windows platform. Volumes may also have a meaning for certain network filesystems such as SMB, for which
* shares can be considered as volumes. Filesystems that don't have a notion of volume should return the
* {@link #getRoot() root folder}.
- *
* * This default implementation returns this file's {@link #getRoot() root folder}. This method should be overridden * if this is not adequate. - *
* * @return the volume on which this file is located. */ @@ -326,7 +323,7 @@ public AbstractFile getVolume() { * {@link java.io.InputStream#skip(long)} is used to position the stream to the specified offset, which on most *InputStream
implementations is very slow as it causes the bytes to be read and discarded.
* For this reason, file implementations that do not provide random read access may want to override this method
- * if a more efficient implementation can be provided.
+ * if a more efficient implementation can be provided.
*
* @param offset the offset in bytes from the beginning of the file, must be >0
* @throws IOException if this file cannot be read or is a folder.
@@ -359,18 +356,18 @@ public InputStream getInputStream(long offset) throws IOException {
* This method should be overridden by filesystems that do not offer a {@link #getOutputStream()}
* implementation, but that can take an InputStream
and use it to write the file.
* For this reason, it is recommended to use this method to write a file, rather than copying streams manually using
- * {@link #getOutputStream()}
The length
parameter is optional. Setting its value help certain protocols which need to know
* the length in advance. This is the case for instance for some HTTP-based protocols like Amazon S3, which require
* the Content-Length
header to be set in the request. Callers should thus set the length if it is
- * known.
Read and write operations are buffered, with a buffer of {@link #IO_BUFFER_SIZE} bytes. For performance * reasons, this buffer is provided by {@link BufferPool}. Thus, there is no need to surround the InputStream - * with a {@link java.io.BufferedInputStream}.
+ * with a {@link java.io.BufferedInputStream}. * - *Copy progress can optionally be monitored by supplying a {@link com.mucommander.commons.io.CounterInputStream}.
+ *Copy progress can optionally be monitored by supplying a {@link com.mucommander.commons.io.CounterInputStream}. * * @param in the InputStream to read from * @param append if true, data written to the OutputStream will be appended to the end of this file. If false, any @@ -412,16 +409,15 @@ public void copyStream(InputStream in, boolean append, long length) throws FileT *
If this file supports the {@link FileOperation#COPY_REMOTELY} file operation, an attempt to perform a
* {@link #copyRemotelyTo(AbstractFile) remote copy} of the file to the destination is made. If the operation isn't
* supported or wasn't successful, the file is copied manually, by transferring its contents to the destination
- * using {@link #copyRecursively(AbstractFile, AbstractFile)}.
+ * using {@link #copyRecursively(AbstractFile, AbstractFile)}.
* In that case, no clean up is performed if an error occurs in the midst of a transfer: files that have been copied
- * (even partially) are left in the destination.
+ * (even partially) are left in the destination.
* It is also worth noting that symbolic links are not copied to the destination when encountered: neither the link
- * nor the linked file is copied
If this file supports the {@link FileOperation#RENAME} file operation, an attempt to
* {@link #renameTo(AbstractFile) rename} the file to the destination is made. If the operation isn't supported
* or wasn't successful, the file is moved manually, by transferring its contents to the destination using
- * {@link #copyTo(AbstractFile)} and then deleting the source.
+ * {@link #copyTo(AbstractFile)} and then deleting the source.
* In that case, deletion of the source occurs only after all files have been successfully transferred.
* No clean up is performed if an error occurs in the midst of a transfer: files that have been copied
- * (even partially) are left in the destination.
+ * (even partially) are left in the destination.
* It is also worth noting that symbolic links are not moved to the destination when encountered: neither the link
- * nor the linked file is moved, and the symlink file is deleted.
This generic implementation simply creates a zero-byte file. {@link AbstractRWArchiveFile} implementations * may want to override this method so that it creates a valid archive with no entry. To illustrate, an empty Zip - * file with proper headers is 22-byte long.
+ * file with proper headers is 22-byte long. * * @throws IOException if the file could not be created, either because it already exists or because of an I/O error * @throws UnsupportedFileOperationException if this method relies on a file operation that is not supported @@ -547,7 +542,7 @@ public AbstractFile[] ls(FileFilter filter) throws IOException { *true
.
*
* This default implementation filters out files *after* they have been created. This method - * should be overridden if a more efficient implementation can be provided by subclasses.
+ * should be overridden if a more efficient implementation can be provided by subclasses. * * @param filter the FilenameFilter to be used to filter out files from the list, may benull
* @return the children files that this file contains
@@ -568,7 +563,7 @@ public AbstractFile[] ls(FilenameFilter filter) throws IOException {
* Implementation note: the default implementation of this method calls sequentially {@link #changePermission(int, int, boolean)}, * for each permission and access (that's a total 9 calls). This may affect performance on filesystems which need * to perform an I/O request to change each permission individually. In that case, and if the fileystem allows - * to change all permissions at once, this method should be overridden.
+ * to change all permissions at once, this method should be overridden. * * @param permissions new permissions for this file * @throws IOException if the permissions couldn't be changed, either because of insufficient permissions or because @@ -602,7 +597,6 @@ public void changePermissions(int permissions) throws IOException { *The first character triplet for 'user' access will always be added to the permissions. Then the 'group' and
* 'other' triplets will only be added if at least one of the user permission bits is supported, as tested with
@@ -615,7 +609,6 @@ public void changePermissions(int permissions) throws IOException {
* has read/write/executable permissions for all three 'user', 'group' and 'other' access types will return
* -rwxrwxrwx
true
is returned, this doesn't ensure that the file operation will succeed:
* additional conditions may be required for the operation to succeed and the corresponding method may throw an
* IOException
if those conditions are not met.
- *
*
* @param op a file operation
* @return true
if the specified file operation is supported by this filesystem.
@@ -701,8 +693,8 @@ public final boolean isBrowsable() {
/**
* Returns the name of the file without its extension.
*
- * A filename has an extension if and only if:
- * - it contains at least one .
character
+ *
A filename has an extension if and only if:
+ * - it contains at least one .
character
* - the last .
is not the last character of the filename
* - the last .
is not the first character of the filename
* If this file has no extension, its full name is returned.
@@ -760,7 +752,7 @@ public final String getCanonicalPath(boolean appendSeparator) {
/**
* Returns a child of this file, whose path is the concatenation of this file's path and the given relative path.
* Although this method does not enforce it, the specified path should be relative, i.e. should not start with
- * a separator.
+ * a separator.
* An IOException
may be thrown if the child file could not be instantiated but the returned file
* instance should never be null
.
*
@@ -800,7 +792,7 @@ public final AbstractFile getChildSilently(String relativePath) {
* This method never returns <null
.
*
*
Although {@link #getChild} can be used to retrieve a direct child file, this method should be favored because - * it allows to use this file instance as the parent of the returned child file.
+ * it allows to use this file instance as the parent of the returned child file. * * @param filename the name of the child file to be created * @return an AbstractFile representing the requested direct child file, never null @@ -984,7 +976,6 @@ public final boolean isParentOf(AbstractFile file) { * archive, as specified by {@link #isArchive()}. This is the case for files that were resolved as * {@link AbstractArchiveFile} instances based on their path, but that do not yet exist or were created as * directories. On the contrary, an existing archive will necessarily return a non-null value. - * * * @return the parent {@link AbstractArchiveFile} that contains this file */ @@ -1037,9 +1028,9 @@ public final Icon getIcon() { * file's contents and feeding the bytes to the givenMessageDigest
, until EOF is reached.
*
* The checksum is returned as an hexadecimal string, such as "6d75636f0a". The length of this string depends on - * the kind of algorithm.
+ * the kind of algorithm. * - *Note: this method does not reset the MessageDigest
after the checksum has been calculated.
Note: this method does not reset the MessageDigest
after the checksum has been calculated.
*
* @param algorithm the algorithm to use for calculating the checksum
* @return this file's checksum, as an hexadecimal string
@@ -1058,9 +1049,9 @@ public final String calculateChecksum(String algorithm) throws IOException, NoSu
* file's contents and feeding the bytes to the given MessageDigest
, until EOF is reached.
*
*
The checksum is returned as an hexadecimal string, such as "6d75636f0a". The length of this string depends on
- * the kind of MessageDigest
.
MessageDigest
.
*
- * Note: this method does not reset the MessageDigest
after the checksum has been calculated.
Note: this method does not reset the MessageDigest
after the checksum has been calculated.
*
* @param messageDigest the MessageDigest to use for calculating the checksum
* @return this file's checksum, as an hexadecimal string
@@ -1355,15 +1346,14 @@ public static boolean isFileOperationSupported(FileOperation op, Class extends
/**
* Returns the given filename's extension, null
if the filename doesn't have an extension.
*
- *
A filename has an extension if and only if:
- * - it contains at least one .
character
- * - the last .
is not the last character of the filename
- * - the last .
is not the first character of the filename
A filename has an extension if and only if:
+ * - it contains at least one .
character
+ * - the last .
is not the last character of the filename
+ * - the last .
is not the first character of the filename
*
*
* The returned extension (if any) is free of any extension separator character (.
). For instance,
* this method will return "ext"
for a file named "name.ext"
, not ".ext"
.
- *
null
if the filename doesn't have an extension
@@ -1386,7 +1376,7 @@ public static String getExtension(String filename) {
* A filename has an extension if and only if:
* - it contains at least one .
character
* - the last .
is not the last character of the filename
- * - the last .
is not the first character of the filename
.
is not the first character of the filename
*
* @return the file's base name - without its extension, if the filename doesn't have an extension returns the filename as received
*/
@@ -1407,7 +1397,7 @@ public String getBaseName() {
* reached.
*
* Important: this method does not close the InputStream
, and does not reset the
- * MessageDigest
after the checksum has been calculated.
MessageDigest
after the checksum has been calculated.
*
* @param in the InputStream for which to calculate the checksum
* @param messageDigest the MessageDigest to use for calculating the checksum
@@ -1437,7 +1427,6 @@ public static String calculateChecksum(InputStream in, MessageDigest messageDige
* * Unlike {@link #equalsCanonical(Object)}, this method is not allowed to perform I/O operations and block * the caller thread. - *
* * @param o the object to compare against this instance * @return Returnstrue
if the URL of this file and the specified one are equal
@@ -1459,13 +1448,13 @@ public boolean equals(Object o) {
* It is noteworthy that this method uses java.lang.String#equals(Object)
to compare paths, which
* in some rare cases may return false
for non-ascii/Unicode paths that have the same written
* representation but are not equal according to java.lang.String#equals(Object)
. Handling such cases
- * would require a locale-aware String comparison which is not an option here.
It is also worth noting that hostnames are not resolved, which means this method does not consider - * a hostname and its corresponding IP address as being equal.
+ * a hostname and its corresponding IP address as being equal. * *Unlike {@link #equals(Object)}, this method is allowed to perform I/O operations and block - * the caller thread.
+ * the caller thread. * * @param o the object to compare against this instance * @returntrue
if the canonical path of this file and the specified one are equal.
@@ -1516,7 +1505,7 @@ public String toString() {
*
* This {@link FileOperation#CHANGE_DATE file operation} may or may not be supported by the underlying filesystem * -- {@link #isFileOperationSupported(FileOperation)} can be called to find out if it is. If the operation isn't - * supported, a {@link UnsupportedFileOperation} will be thrown when this method is called.
+ * supported, a {@link UnsupportedFileOperation} will be thrown when this method is called. * * @param lastModified last modified date, in milliseconds since the epoch (00:00:00 GMT, January 1, 1970) * @throws IOException if the date couldn't be changed, either because of insufficient permissions or because of @@ -1562,7 +1551,7 @@ public String toString() { * out which bits are supported. * *This method may return permissions for which none of the bits are supported, but may never return
- * null
.
null
.
*
* @return this file's permissions, as a FilePermissions object
*/
@@ -1581,7 +1570,7 @@ public String toString() {
*
* This {@link FileOperation#CHANGE_PERMISSION file operation} may or may not be supported by the underlying filesystem * -- {@link #isFileOperationSupported(FileOperation)} can be called to find out if it is. If the operation isn't - * supported, a {@link UnsupportedFileOperation} will be thrown when this method is called.
+ * supported, a {@link UnsupportedFileOperation} will be thrown when this method is called. * * @param access see {@link PermissionTypes} for allowed values * @param permission see {@link PermissionAccesses} for allowed values @@ -1679,7 +1668,6 @@ public String toString() { ** An archive is a file container that can be {@link #isBrowsable() browsed}. Archive files may not be * {@link #isDirectory() directories}, and vice-versa. - *
. * * @returntrue
if this file is an archive.
*/
@@ -1710,7 +1698,7 @@ public String toString() {
*
* This {@link FileOperation#LIST_CHILDREN file operation} may or may not be supported by the underlying filesystem * -- {@link #isFileOperationSupported(FileOperation)} can be called to find out if it is. If the operation isn't - * supported, a {@link UnsupportedFileOperation} will be thrown when this method is called.
+ * supported, a {@link UnsupportedFileOperation} will be thrown when this method is called. * * @return the children files that this file contains * @throws IOException if this operation is not possible (file is not browsable) or if an error occurred. @@ -1725,7 +1713,7 @@ public String toString() { * *This {@link FileOperation#CREATE_DIRECTORY file operation} may or may not be supported by the underlying filesystem * -- {@link #isFileOperationSupported(FileOperation)} can be called to find out if it is. If the operation isn't - * supported, a {@link UnsupportedFileOperation} will be thrown when this method is called.
+ * supported, a {@link UnsupportedFileOperation} will be thrown when this method is called. * * @throws IOException if the directory could not be created, either because this file already exists or for any * other reason. @@ -1747,7 +1735,7 @@ public String toString() { * *This {@link FileOperation#READ_FILE file operation} may or may not be supported by the underlying filesystem * -- {@link #isFileOperationSupported(FileOperation)} can be called to find out if it is. If the operation isn't - * supported, a {@link UnsupportedFileOperation} will be thrown when this method is called.
+ * supported, a {@link UnsupportedFileOperation} will be thrown when this method is called. * * @return anInputStream
to read the contents of this file
* @throws IOException in any of the cases listed above
@@ -1815,7 +1803,7 @@ public String toString() {
*
* This {@link FileOperation#RANDOM_READ_FILE file operation} may or may not be supported by the underlying filesystem * -- {@link #isFileOperationSupported(FileOperation)} can be called to find out if it is. If the operation isn't - * supported, a {@link UnsupportedFileOperation} will be thrown when this method is called.
+ * supported, a {@link UnsupportedFileOperation} will be thrown when this method is called. * * @return aRandomAccessInputStream
to read the contents of this file with random access
* @throws IOException in any of the cases listed above
@@ -1858,7 +1846,7 @@ public String toString() {
*
* This {@link FileOperation#DELETE file operation} may or may not be supported by the underlying filesystem * -- {@link #isFileOperationSupported(FileOperation)} can be called to find out if it is. If the operation isn't - * supported, a {@link UnsupportedFileOperation} will be thrown when this method is called.
+ * supported, a {@link UnsupportedFileOperation} will be thrown when this method is called. * * @throws IOException if this file does not exist or could not be deleted * @throws UnsupportedFileOperationException if this operation is not supported by the underlying filesystem, @@ -1880,11 +1868,10 @@ public String toString() { *This {@link FileOperation#RENAME file operation} may or may not be supported by the underlying filesystem * -- {@link #isFileOperationSupported(FileOperation)} can be called to find out if it is. If the operation isn't - * supported, a {@link UnsupportedFileOperation} will be thrown when this method is called.
+ * supported, a {@link UnsupportedFileOperation} will be thrown when this method is called. * * @param destFile file to rename this file to * @throws IOException in any of the error cases listed above @@ -1901,7 +1888,7 @@ public String toString() { * file(s), without having the file's contents go through to the local process. This operation should only be * implemented if it offers a performance advantage over a regular client-driven copy like * {@link #copyTo(AbstractFile)}, or if {@link FileOperation#WRITE_FILE} is not supported (output streams cannot be - * retrieved) and thus a regular copy cannot succeed.. + * retrieved) and thus a regular copy cannot succeed. * *This method throws an {@link IOException} if the operation failed, for any of the following reasons: *
The behavior in the case of an error occurring in the midst of the transfer is unspecified: files that have - * been copied (even partially) may or may not be left in the destination.
+ * been copied (even partially) may or may not be left in the destination. * * @param destFile the destination file to copy this file to * @throws IOException in any of the error cases listed above @@ -1929,7 +1915,7 @@ public String toString() { * *This {@link FileOperation#GET_FREE_SPACE file operation} may or may not be supported by the underlying filesystem * -- {@link #isFileOperationSupported(FileOperation)} can be called to find out if it is. If the operation isn't - * supported, a {@link UnsupportedFileOperation} will be thrown when this method is called.
+ * supported, a {@link UnsupportedFileOperation} will be thrown when this method is called. * * @return the free space (in bytes) on the disk/volume where this file is,-1
if this information is
* not available.
@@ -1944,7 +1930,7 @@ public String toString() {
*
* This {@link FileOperation#GET_TOTAL_SPACE file operation} may or may not be supported by the underlying filesystem * -- {@link #isFileOperationSupported(FileOperation)} can be called to find out if it is. If the operation isn't - * supported, a {@link UnsupportedFileOperation} will be thrown when this method is called.
+ * supported, a {@link UnsupportedFileOperation} will be thrown when this method is called. * * @return the total space (in bytes) of the disk/volume where this file is * @throws IOException if an I/O error occurred diff --git a/src/main/com/mucommander/commons/file/DefaultSchemeHandler.java b/src/main/com/mucommander/commons/file/DefaultSchemeHandler.java index 18af9aa65..873bffee2 100644 --- a/src/main/com/mucommander/commons/file/DefaultSchemeHandler.java +++ b/src/main/com/mucommander/commons/file/DefaultSchemeHandler.java @@ -27,7 +27,6 @@ *
* The {@link #getRealm(FileURL)} implementation returns a URL with the same scheme and host (if any) as the specified
* URL, and a path set to "/"
. This behavior can be modified by overriding getRealm
.
- *
This parser can not only parse URLs but also local absolute paths and UNC paths. Upon parsing, these paths are - * turned into equivalent, fully qualified URLs.
+ * turned into equivalent, fully qualified URLs. * *@@ -46,7 +46,6 @@ *
C:\Windows\System32\
will be parsed and turned
* into a FileURL whose path separator is "\" and representation file://localhost/C:\Windows\System32\
@@ -59,7 +58,6 @@ *
\\Server\Volume\File
will be turned into a FileURL whose string
* representation is smb://Server/Volume/File
FileFactory
.
* This registration requires an implementation of {@link ProtocolProvider}, an instance of which will be passed to
* {@link #registerProtocol(String,ProtocolProvider) registerProtocol}.
- *
+ *
* * Built-in file protocols are: *
* In order to allow the com.mucommander.commons.file
API to access new archive formats, developers must create
* an implementation of {@link AbstractArchiveFile} that handles that format and register it to FileFactory
.
* This registration requires an implementation of {@link ArchiveFormatProvider}, an instance of which will be passed to
* {@link #registerArchiveFormat(ArchiveFormatProvider)}.
- *
* Built-in file file formats are: *
RAR
, registered to rar files.SEVENZIP
, registered to 7z files.* If a {@link ProtocolProvider} was already registered to the specified protocol, it will automatically be * unregistered. - *
+ * *
* The protocol
argument is expected to be the protocol identifier, without the trailing ://
.
* For example, the identifier of the HTTP protocol would be http
. This parameter's case is irrelevant,
* as it will be stored in all lower-case.
- *
* After this call, the various {@link #getFile(String) getFile} methods will be able to resolve files using the * specified protocol. - *
+ * ** Built-in file protocols are listed in {@link FileProtocols}. - *
* * @param protocol identifier of the protocol to register. * @param provider object used to create instances of files using the specified protocol. @@ -258,7 +257,7 @@ public static boolean isRegisteredProtocol(String protocol) { * *All objects returned by the iterator's nextElement()
method will be string instances. These can
* then be passed to {@link #getProtocolProvider(String) getProtocolProvider} to retrieve the associated
- * {@link ProtocolProvider}.
FileFactory.unregisterArchiveFormat(FileFactory.getArchiveFormatProvider("file.zip"))
* will unregister the (first, if any) Zip provider.
- *
*
* @param provider the ArchiveFormatProvider
to unregister.
* @see #getArchiveFormatProvider(String)
@@ -338,7 +336,7 @@ public static IteratorThis method does not throw any IOException but returns null
if the file could not be created.
This method does not throw any IOException but returns null
if the file could not be created.
*
* @param absPath the absolute path to the file
* @return null
if the given path is not absolute or incorrect (doesn't correspond to any file) or
@@ -356,7 +354,7 @@ public static AbstractFile getFile(String absPath) {
/**
* Returns an instance of AbstractFile for the given absolute path.
*
- *
This method does not throw any IOException but returns null
if the file could not be created.
This method does not throw any IOException but returns null
if the file could not be created.
*
* @param absPath the absolute path to the file
* @param throwException if set to true
, an IOException will be thrown if something went wrong during file creation
@@ -615,7 +613,7 @@ private static String getFilenameVariation(String filename) {
* extension will however always be preserved.
*
*
The returned file may be a {@link LocalFile} or a {@link AbstractArchiveFile} if the extension corresponds - * to a registered archive format.
+ * to a registered archive format. * * @param desiredFilename the desired filename for the temporary file. If a file with this name already exists * in the temp directory, the filename's prefix (name without extension) will be appended an ID, but the filename's @@ -687,7 +685,6 @@ public static boolean isArchiveFilename(String filename) { * {@link AbstractFile#isArchive()}. An {@link AbstractArchiveFile} instance that is not currently an archive * (either non-existent or a directory) will behave as a regular (non-archive) file. This allows file instances to * go from being an archive to not being an archive (and vice-versa), without having to re-resolve the file. - * */ public static AbstractFile wrapArchive(AbstractFile file) throws IOException { String filename = file.getName(); @@ -713,7 +710,7 @@ public static AbstractFile wrapArchive(AbstractFile file) throws IOException { * platform-dependent and as such may vary across platforms. * *It is noteworthy that the provider returned by this method is used by {@link com.mucommander.commons.file.AbstractFile#getIcon()} - * to create and return the icon.
+ * to create and return the icon. * * @return the default FileIconProvider implementation */ @@ -725,7 +722,7 @@ public static FileIconProvider getDefaultFileIconProvider() { * Sets the default {@link com.mucommander.commons.file.icon.FileIconProvider} implementation. * *It is noteworthy that the provider returned by this method is used by {@link com.mucommander.commons.file.AbstractFile#getIcon()} - * to create and return the icon.
+ * to create and return the icon. * * @param fip the new value for the default FileIconProvider */ diff --git a/src/main/com/mucommander/commons/file/icon/LocalFileIconProvider.java b/src/main/com/mucommander/commons/file/icon/LocalFileIconProvider.java index 46b3452d3..19b1f67a6 100644 --- a/src/main/com/mucommander/commons/file/icon/LocalFileIconProvider.java +++ b/src/main/com/mucommander/commons/file/icon/LocalFileIconProvider.java @@ -21,9 +21,7 @@ import com.mucommander.commons.file.AbstractFile; import com.mucommander.commons.file.FileFactory; -import com.mucommander.commons.file.impl.adb.AdbFile; import com.mucommander.commons.file.impl.local.LocalFile; -import com.mucommander.ui.icon.IconManager; import javax.swing.*; import java.awt.*; @@ -37,7 +35,7 @@ * requests for local file icons to {@link #getLocalFileIcon(com.mucommander.commons.file.impl.local.LocalFile, com.mucommander.commons.file.AbstractFile, java.awt.Dimension)}. * On the other hand, requests for non-local file icons are transformed to local ones, by creating a local temporary * file with the same name (best effort) and extension (guaranteed) as the non-local file, and passes on the file - * to {@link #getLocalFileIcon(com.mucommander.commons.file.impl.local.LocalFile, com.mucommander.commons.file.AbstractFile, java.awt.Dimension)}. + * to {@link #getLocalFileIcon(com.mucommander.commons.file.impl.local.LocalFile, com.mucommander.commons.file.AbstractFile, java.awt.Dimension)}. * * @author Maxence Bernard */ @@ -121,10 +119,10 @@ public Icon getFileIcon(AbstractFile originalFile, Dimension preferredResolution *The specified Dimension
is used as a hint at the preferred icon's resolution; there is
* absolutely no guarantee that the returned Icon
will indeed have this resolution. This dimension is
* only used to choose between different resolutions should more than one resolution be available, and return the
- * one that most closely matches the specified one.
+ * one that most closely matches the specified one.
* This method is not expected to perform any rescaling (either up or down), returned resolutions should only be
* 'native' icon resolutions. For example, if this provider is able to create icons both in 16x16 and 32x32
- * resolutions, and a 48x48 resolution is preferred, the 32x32 resolution should be favored for the returned icon.
true
if the underlying local filesystem uses drives assigned to letters
*/
public static boolean hasRootDrives() {
- return IS_WINDOWS
- || OsFamily.OS_2.isCurrent()
- || "\\".equals(SEPARATOR);
+ return IS_WINDOWS || OsFamily.OS_2.isCurrent() || "\\".equals(SEPARATOR);
}
@@ -472,10 +461,9 @@ public static AbstractFile[] getVolumes() {
// Add Mac OS X's /Volumes subfolders and not file roots ('/') since Volumes already contains a named link
// (like 'Hard drive' or whatever silly name the user gave his primary hard disk) to /
- if(OsFamily.MAC_OS_X.isCurrent()) {
+ if (OsFamily.MAC_OS_X.isCurrent()) {
addMacOSXVolumes(volumesV);
- }
- else {
+ } else {
// Add java.io.File's root folders
addJavaIoFileRoots(volumesV);
@@ -486,8 +474,9 @@ public static AbstractFile[] getVolumes() {
// Add home folder, if it is not already present in the list
AbstractFile homeFolder = getUserHome();
- if(!(homeFolder==null || volumesV.contains(homeFolder)))
+ if (!(homeFolder == null || volumesV.contains(homeFolder))) {
volumesV.add(homeFolder);
+ }
AbstractFile volumes[] = new AbstractFile[volumesV.size()];
volumesV.toArray(volumes);
@@ -529,21 +518,18 @@ private static void addMountEntries(Listnull
, creating a new
* {@link File} instance otherwise.
+ * @throws IOException if an I/O error occurs.
*/
protected UNCFile(FileURL fileURL, File file) throws IOException {
super(fileURL);
- if(file==null) {
+ if (file == null) {
absPath = SEPARATOR+SEPARATOR+fileURL.getHost()+fileURL.getPath().replace('/', '\\'); // Replace leading / char by \
// create the java.io.File instance and throw an exception if the path is not absolute.
file = new File(absPath);
- if(!file.isAbsolute())
+ if (!file.isAbsolute()) {
throw new IOException();
+ }
}
// the java.io.File instance was created by ls(), no need to re-create it or call the costly File#getAbsolutePath()
else {
@@ -104,8 +106,9 @@ protected UNCFile(FileURL fileURL, File file) throws IOException {
}
// Remove the trailing separator if present
- if(absPath.endsWith(SEPARATOR))
- absPath = absPath.substring(0, absPath.length()-1);
+ if (absPath.endsWith(SEPARATOR)) {
+ absPath = absPath.substring(0, absPath.length() - 1);
+ }
this.file = file;
this.permissions = new UNCFilePermissions(file);
@@ -262,6 +265,7 @@ public boolean isDirectory() {
* Implementation notes: the returned InputStream
uses a NIO {@link FileChannel} under the hood to
* benefit from InterruptibleChannel
and allow a thread waiting for an I/O to be gracefully interrupted
* using Thread#interrupt()
.
+ * @throws IOException if an I/O error occurs.
*/
@Override
public InputStream getInputStream() throws IOException {
@@ -272,6 +276,7 @@ public InputStream getInputStream() throws IOException {
* Implementation notes: the returned InputStream
uses a NIO {@link FileChannel} under the hood to
* benefit from InterruptibleChannel
and allow a thread waiting for an I/O to be gracefully interrupted
* using Thread#interrupt()
.
+ * @throws IOException if an I/O error occurs.
*/
@Override
public OutputStream getOutputStream() throws IOException {
@@ -282,6 +287,7 @@ public OutputStream getOutputStream() throws IOException {
* Implementation notes: the returned InputStream
uses a NIO {@link FileChannel} under the hood to
* benefit from InterruptibleChannel
and allow a thread waiting for an I/O to be gracefully interrupted
* using Thread#interrupt()
.
+ * @throws IOException if an I/O error occurs.
*/
@Override
public OutputStream getAppendOutputStream() throws IOException {
@@ -292,6 +298,7 @@ public OutputStream getAppendOutputStream() throws IOException {
* Implementation notes: the returned InputStream
uses a NIO {@link FileChannel} under the hood to
* benefit from InterruptibleChannel
and allow a thread waiting for an I/O to be gracefully interrupted
* using Thread#interrupt()
.
+ * @throws IOException if an I/O error occurs.
*/
@Override
public RandomAccessInputStream getRandomAccessInputStream() throws IOException {
@@ -302,6 +309,7 @@ public RandomAccessInputStream getRandomAccessInputStream() throws IOException {
* Implementation notes: the returned InputStream
uses a NIO {@link FileChannel} under the hood to
* benefit from InterruptibleChannel
and allow a thread waiting for an I/O to be gracefully interrupted
* using Thread#interrupt()
.
+ * @throws IOException if an I/O error occurs.
*/
@Override
public RandomAccessOutputStream getRandomAccessOutputStream() throws IOException {
@@ -310,10 +318,9 @@ public RandomAccessOutputStream getRandomAccessOutputStream() throws IOException
@Override
public void delete() throws IOException {
- boolean ret = file.delete();
-
- if(!ret)
+ if (!file.delete()) {
throw new IOException();
+ }
}
@@ -547,7 +554,7 @@ private int countIndexOf(String text, String search) {
/**
* Overridden to return the local volume on which this file is located. The returned volume is one of the volumes
- * returned by {@link #getVolumes()}.
+ * returned by {@link LocalFile#getVolumes()}.
*/
@Override
public AbstractFile getVolume() {
@@ -558,18 +565,16 @@ public AbstractFile getVolume() {
int bestDepth = -1;
int bestMatch = -1;
int depth;
- AbstractFile volume;
- String volumePath;
+
String thisPath = getAbsolutePath(true);
- for(int i=0; iRemarks: Each process has an associated error mode that indicates to the system how the application is going * to respond to serious errors. A child process inherits the error mode of its parent process. To retrieve the - * process error mode, use the GetErrorMode function. + * process error mode, use the GetErrorMode function. * Because the error mode is set for the entire process, you must ensure that multi-threaded applications do not set - * different error-mode flags. Doing so can lead to inconsistent error handling. + * different error-mode flags. Doing so can lead to inconsistent error handling. * The system does not make alignment faults visible to an application on all processor architectures. Therefore, * specifying SEM_NOALIGNMENTFAULTEXCEPT is not an error on such architectures, but the system is free to silently * ignore the request. @@ -197,7 +197,7 @@ boolean GetDiskFreeSpaceEx(String lpDirectoryName, /** * Moves an existing file or directory, including its children, with various move options. * - *
Warning: this method is NOT available on Windows 95, 98 and Me.
+ *Warning: this method is NOT available on Windows 95, 98 and Me. * * @param lpExistingFileName The current name of the file or directory on the local computer. If dwFlags specifies * MOVEFILE_DELAY_UNTIL_REBOOT, the file cannot exist on a remote share, because delayed operations are performed diff --git a/src/main/com/mucommander/commons/file/util/SymLinkUtils.java b/src/main/com/mucommander/commons/file/util/SymLinkUtils.java index 64ddcfe5a..beffdae35 100644 --- a/src/main/com/mucommander/commons/file/util/SymLinkUtils.java +++ b/src/main/com/mucommander/commons/file/util/SymLinkUtils.java @@ -63,9 +63,9 @@ public static boolean createSymlink(AbstractFile symLink, String target) { /** * - * @param symLink - * @param target - * @throws IOException + * @param symLink symlink path + * @param target target file/directory path + * @throws IOException if an I/O error occurs. * java.nio.file.AccessDeniedException * java.nio.file.FileAlreadyExistsException */ diff --git a/src/main/com/mucommander/commons/io/ByteCounter.java b/src/main/com/mucommander/commons/io/ByteCounter.java index 820c40894..af7a3c918 100644 --- a/src/main/com/mucommander/commons/io/ByteCounter.java +++ b/src/main/com/mucommander/commons/io/ByteCounter.java @@ -58,6 +58,7 @@ public ByteCounter(ByteCounter counter) { /** * Return the number of bytes which have been accounted for. + * @return the number of bytes which have been accounted for */ public synchronized long getByteCount() { if (addedCounter != null) {