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. - *

    + * * @param folder path to the folder in which trolCommander will look for its preferences. * @throws IOException if an IO error occurs. * @see #getPreferencesFolder() @@ -135,7 +132,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. - *

    + * * @param path path to the folder in which trolCommander will look for its preferences. * @throws IOException if an IO error occurs. * @see #getPreferencesFolder() @@ -157,7 +154,7 @@ public static void setPreferencesFolder(String path) throws IOException { *

    * If folder is a file, its parent folder will be used instead. If it doesn't exist, * this method will create it. - *

    + * * @param folder path to the folder in which trolCommander will look for its preferences. * @throws IOException if an IO error occurs. * @see #getPreferencesFolder() diff --git a/src/main/com/mucommander/VersionChecker.java b/src/main/com/mucommander/VersionChecker.java index 9e97eebbd..697de8ec7 100644 --- a/src/main/com/mucommander/VersionChecker.java +++ b/src/main/com/mucommander/VersionChecker.java @@ -56,7 +56,7 @@ * } * catch(Exception e) {System.err.println("An error occured.");} * - *

    + * *

    * 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. - *

    + * * @author Maxence Bernard, Nicolas Rinaudo */ public class VersionChecker extends DefaultHandler { @@ -200,7 +200,7 @@ public boolean isNewVersionAvailable() { * Returns the date at which the latest version of muCommander has been released. *

    * 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 List getDevices() { /** * - * @param serial - * @return + * @param serial the device serial number + * + * @return device name (or null if unknown) */ public static String getDeviceName(String serial) { if (lastDeviceNames == null || !lastDeviceNames.containsKey(serial)) { diff --git a/src/main/com/mucommander/auth/CredentialsManager.java b/src/main/com/mucommander/auth/CredentialsManager.java index 1765b3698..cdf2edd88 100644 --- a/src/main/com/mucommander/auth/CredentialsManager.java +++ b/src/main/com/mucommander/auth/CredentialsManager.java @@ -51,7 +51,6 @@ * application is started. *
  • volatile credentials: lost when the application terminates.
  • * - *

    * * @author Maxence Bernard */ @@ -123,12 +122,13 @@ private static AbstractFile getCredentialsFile() throws IOException { * @throws FileNotFoundException if path 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 List getMatchingCredentialsV(FileURL location) { - List matchesV = new Vector<>(); + List matchesV = new ArrayList<>(); findMatches(location, volatileCredentialMappings, matchesV); findMatches(location, persistentCredentialMappings, matchesV); // Find the best match and move it at the first position in the vector int bestMatchIndex = getBestMatchIndex(location, matchesV); - if(bestMatchIndex!=-1) { + if (bestMatchIndex >= 0) { matchesV.add(0, matchesV.remove(bestMatchIndex)); } @@ -282,8 +287,9 @@ private static List getMatchingCredentialsV(FileURL location public static void addCredentials(CredentialsMapping credentialsMapping) { // Do not add if the credentials are empty - if(credentialsMapping.getCredentials().isEmpty()) + if (credentialsMapping.getCredentials().isEmpty()) { return; + } boolean persist = credentialsMapping.isPersistent(); @@ -291,12 +297,11 @@ public static void addCredentials(CredentialsMapping credentialsMapping) { LOGGER.trace("before, persistentCredentials="+ persistentCredentialMappings); LOGGER.trace("before, volatileCredentials="+ volatileCredentialMappings); - if(persist) { - replaceVectorElement(persistentCredentialMappings, credentialsMapping); + if (persist) { + replaceListElement(persistentCredentialMappings, credentialsMapping); volatileCredentialMappings.remove(credentialsMapping); - } - else { - replaceVectorElement(volatileCredentialMappings, credentialsMapping); + } else { + replaceListElement(volatileCredentialMappings, credentialsMapping); persistentCredentialMappings.removeElement(credentialsMapping); } @@ -322,8 +327,9 @@ public static void authenticate(FileURL location, CredentialsMapping credentials FileURL realm = credentialsMapping.getRealm(); Set propertyKeys = realm.getPropertyNames(); for (String key : propertyKeys) { - if(location.getProperty(key) == null) + if (location.getProperty(key) == null) { location.setProperty(key, realm.getProperty(key)); + } } } @@ -343,10 +349,9 @@ private static void authenticateImplicit(FileURL location) { LOGGER.trace("called, fileURL="+ location +" containsCredentials="+ location.containsCredentials()); CredentialsMapping creds[] = getMatchingCredentials(location); - if(creds.length>0) { + if (creds.length > 0) { authenticate(location, creds[0]); - } - else { + } else { Credentials guestCredentials = location.getGuestCredentials(); if(guestCredentials!=null) { authenticate(location, new CredentialsMapping(guestCredentials, location.getRealm(), false)); @@ -364,12 +369,11 @@ private static void authenticateImplicit(FileURL location) { * @param matches the Vector where matching CredentialsMapping instances will be added */ private static void findMatches(FileURL location, List credentials, List matches) { - for(CredentialsMapping tempCredentialsMapping: credentials) { + for (CredentialsMapping tempCredentialsMapping: credentials) { FileURL tempRealm = tempCredentialsMapping.getRealm(); - if(location.schemeEquals(tempRealm) - && location.portEquals(tempRealm) - && location.hostEquals(tempRealm)) + if (location.schemeEquals(tempRealm) && location.portEquals(tempRealm) && location.hostEquals(tempRealm)) { matches.add(tempCredentialsMapping); + } } LOGGER.trace("returning matches="+matches); @@ -389,8 +393,9 @@ private static void findMatches(FileURL location, List crede * @return the CredentialsMapping instance that best matches the given location, -1 if the given matches Vector is empty. */ private static int getBestMatchIndex(FileURL location, List matches) { - if(matches.size()==0) + if (matches.isEmpty()) { return -1; + } // Splits the provided location's path into an array of folder tokens (e.g. "/home/maxence" -> ["home","maxence"]) String path = location.getPath(); @@ -412,14 +417,15 @@ private static int getBestMatchIndex(FileURL location, List // Compares the location's path against all the one of all CredentialsMapping instances int nbMatches = matches.size(); - for(int i=0; i // /var/log and /usr -> nbMatchingToken = 0 st = new StringTokenizer(tempPath, "/\\"); nbMatchingToken = 0; - for(int j=0; jmaxTokens) { @@ -451,15 +458,16 @@ private static int getBestMatchIndex(FileURL location, List * Replaces any object that's equal to the given one in the Vector, 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(List vector, CredentialsMapping o) { - int index = vector.indexOf(o); - if(index==-1) - vector.add(o); - else - vector.set(index, o); + private static void replaceListElement(List list, CredentialsMapping o) { + int index = list.indexOf(o); + if (index < 0) { + list.add(o); + } else { + list.set(index, o); + } } /** @@ -498,7 +506,6 @@ public static AlteredVector getPersistentCredentialMappings( * @author Maxence Bernard */ private static class CredentialsManagerAuthenticator implements Authenticator { - public void authenticate(FileURL fileURL) { CredentialsManager.authenticateImplicit(fileURL); } diff --git a/src/main/com/mucommander/bookmark/Bookmark.java b/src/main/com/mucommander/bookmark/Bookmark.java index d06aa69f5..35109d2cc 100644 --- a/src/main/com/mucommander/bookmark/Bookmark.java +++ b/src/main/com/mucommander/bookmark/Bookmark.java @@ -22,14 +22,14 @@ /** * Represents a bookmark. *

    Bookmarks are simple name/location pairs: - *

      - *
    • The name is a String describing the bookmark.
    • - *
    • - * The location should designate a path or file URL. The designated location may not exist or may not even be - * a valid path or URL, so it is up to classes that call {@link #getLocation()} to deal with it appropriately. - *
    • - *
    - *

    + *
      + *
    • The name is a String describing the bookmark.
    • + *
    • + * The location should designate a path or file URL. The designated location may not exist or may not even be + * a valid path or URL, so it is up to classes that call {@link #getLocation()} to deal with it appropriately. + *
    • + *
    + * * @author Maxence Bernard */ public class Bookmark implements Cloneable { diff --git a/src/main/com/mucommander/cache/LRUCache.java b/src/main/com/mucommander/cache/LRUCache.java index 9e63500d1..31cb726de 100644 --- a/src/main/com/mucommander/cache/LRUCache.java +++ b/src/main/com/mucommander/cache/LRUCache.java @@ -29,11 +29,11 @@ *

    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 @@ *

  • as soon as an item has expired, it cannot be returned by {@link #get(Object) get()}. *
  • when cache capacity is reached (cache is full) and a new item needs to be added, any expired item must be * immediately removed. This prevents least recently used items from being removed unnecessarily. - *

    + * * * @author Maxence Bernard */ @@ -73,6 +73,7 @@ public LRUCache(int capacity) { /** * Returns the maximum number of items this cache can contain. + * @return the maximum number of items this cache can contain */ public int getCapacity() { return capacity; @@ -111,7 +112,7 @@ public int getMissCount() { *
      *
    • the given key doesn't exist *
    • the cached value corresponding to the key has expired - *

    + * * * @param key the cached item's key * @return the cached value corresponding to the specified key, or null if a value could not @@ -126,7 +127,7 @@ public int getMissCount() { *
      *
    • any object with a past expiration date will be removed< *
    • if no expired item could be removed, the least recently used item will be removed - *

    + * * * @param key the key for the object to store * @param value the value to cache @@ -154,6 +155,8 @@ public synchronized void add(K key, V value) { * Returns the current size of this cache, i.e. the number of cached elements it contains. *
    Note: Some items that have expired and have not yet been removed might be accounted for * in the returned size. + * + * @return the current size of this cache */ public abstract int size(); diff --git a/src/main/com/mucommander/command/Command.java b/src/main/com/mucommander/command/Command.java index 4fbec3e8d..c18eb6397 100644 --- a/src/main/com/mucommander/command/Command.java +++ b/src/main/com/mucommander/command/Command.java @@ -37,7 +37,6 @@ * {@link CommandType#INVISIBLE_COMMAND invisible} (invisible and mutable) or {@link CommandType#NORMAL_COMMAND} (visible and mutable). *
  • * - *

    *

    * The basic command syntax is fairly simple: *

      @@ -46,7 +45,6 @@ *
    • Non-escaped space characters are used as token separators.
    • *
    * It is important to remember that " characters are not removed from the resulting tokens. - *

    *

    * It's also possible to include keywords in a command: *

      @@ -57,16 +55,14 @@ *
    • $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). - *

    + * * @param alias alias of the command. * @param command command that will be executed. */ @@ -143,7 +139,7 @@ public Command(String alias, String command) { *

    * This is a convenience constructor and is strictly equivalent to calling * {@link Command(String,String,int,String) Command(}alias, command, type, null). - *

    + * * @param alias alias of the command. * @param command command that will be executed. * @param type type of the command. @@ -339,7 +335,6 @@ else if(j != files.length - 1) *

    * 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. * Implementing CommandBuilder 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 @@ *
  • one or more elements has been removed *
  • an element has been changed * - *

    - *

    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 @@ * A Configuration 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. - *

    - *

    + * *

    Naming conventions

    + *

    * 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.
    - *

    - *

    + * *

    Variable types

    + *

    * 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 @@ *

  • Double: 0
  • *
  • Boolean: false
  • * - *

    - *

    + * *

    Configuration file format

    + *

    * 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. - *

    - *

    + * *

    Configuration data location

    + *

    * 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. - *

    - *

    + * *

    Monitoring configuration changes

    + *

    * 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. - *

    + * * @param f factory that will be used to create reader instances. * @see #getReaderFactory() */ @@ -217,7 +215,7 @@ public void setReaderFactory(ConfigurationReaderFactory f) { *

    * 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. - *

    + * * @param f factory that will be used to create writer instances. * @see #getWriterFactory() */ @@ -254,7 +252,7 @@ public void setWriterFactory(ConfigurationWriterFactory f) { *

    * 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 of in. * @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}: *

      @@ -511,7 +509,7 @@ private synchronized void build(ConfigurationBuilder builder, ConfigurationSecti *
    • One when toVar is set.
    • *
    * The removal event will always be triggered first. - *

    + * * @param fromVar fully qualified name of the variable to rename. * @param toVar fully qualified name of the variable that will receive 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. * @return true 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. * @return true 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, List value, String separator) { * 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. * @return true if this call resulted in a modification of the variable's value, @@ -621,11 +619,11 @@ public boolean setVariable(String name, List value, String separator) { * 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. * @return true 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. * @return true 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. * @return true 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, or null 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, or null 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, or 0 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, or 0 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, or 0 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, or 0 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, or false 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, List defaultValue, String sepa * 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. @@ -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 { @@ -67,7 +67,7 @@ protected String getRootElementName() { * Creates an instance of {@link ConfigurationBuilder}. *

    * 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 @@
      *   
  • A variable called some.section.var1 will be created with a value of value1.
  • *
  • A variable called some.section.var2 will be created with a value of value2.
  • * - *

    + * * @author Nicolas Rinaudo * @see XmlConfigurationWriter */ diff --git a/src/main/com/mucommander/commons/conf/XmlConfigurationWriter.java b/src/main/com/mucommander/commons/conf/XmlConfigurationWriter.java index 61590322c..db94792fe 100644 --- a/src/main/com/mucommander/commons/conf/XmlConfigurationWriter.java +++ b/src/main/com/mucommander/commons/conf/XmlConfigurationWriter.java @@ -66,6 +66,7 @@ public XmlConfigurationWriter getWriterInstance(Writer out) { /** * Creates a new instance of XML configuration writer. * @param out where to write the configuration data. + * @param rootElementName the name of root element */ protected XmlConfigurationWriter(Writer out, String rootElementName) { this.rootElementName = rootElementName; diff --git a/src/main/com/mucommander/commons/conf/package-info.java b/src/main/com/mucommander/commons/conf/package-info.java index 47e8a25f6..c0057bb89 100644 --- a/src/main/com/mucommander/commons/conf/package-info.java +++ b/src/main/com/mucommander/commons/conf/package-info.java @@ -8,7 +8,6 @@ *
  • 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. * * - *

    *

    Loading and storing configuration

    *

    * 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). - *

    + * *

    Changing the default configuration format

    *

    * 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}. * * - *

    + * *

    Listening to the configuration

    *

    * 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 @@ *
  • {@link ROArchiveEntryFile}: represents an entry inside a read-only archive
  • *
  • {@link RWArchiveEntryFile}: represents an entry inside a {@link AbstractArchiveFile#isWritable() read-write} archive
  • * - *

    * * @see AbstractArchiveFile * @see ArchiveEntry diff --git a/src/main/com/mucommander/commons/file/AbstractArchiveFile.java b/src/main/com/mucommander/commons/file/AbstractArchiveFile.java index 9010fb827..580a89505 100644 --- a/src/main/com/mucommander/commons/file/AbstractArchiveFile.java +++ b/src/main/com/mucommander/commons/file/AbstractArchiveFile.java @@ -206,16 +206,18 @@ ArchiveEntryTree getArchiveEntryTree() { * @throws UnsupportedFileOperationException if {@link FileOperation#READ_FILE} operations are not supported by the * underlying file protocol. */ - protected AbstractFile[] ls(AbstractArchiveEntryFile entryFile, FilenameFilter filenameFilter, FileFilter fileFilter) throws IOException, UnsupportedFileOperationException { + protected AbstractFile[] ls(AbstractArchiveEntryFile entryFile, FilenameFilter filenameFilter, FileFilter fileFilter) throws IOException { // Make sure the entries tree is created and up-to-date checkEntriesTree(); - if(!entryFile.isBrowsable()) + if (!entryFile.isBrowsable()) { throw new IOException(); + } DefaultMutableTreeNode matchNode = entryTreeRoot.findEntryNode(entryFile.getEntry().getPath()); - if(matchNode==null) + if (matchNode == null) { throw new IOException(); + } return ls(matchNode, entryFile, filenameFilter, fileFilter); } @@ -226,7 +228,7 @@ protected AbstractFile[] ls(AbstractArchiveEntryFile entryFile, FilenameFilter f * @throws UnsupportedFileOperationException if {@link FileOperation#READ_FILE} operations are not supported by the * underlying file protocol. */ - private AbstractFile[] ls(DefaultMutableTreeNode treeNode, AbstractFile parentFile, FilenameFilter filenameFilter, FileFilter fileFilter) throws IOException, UnsupportedFileOperationException { + private AbstractFile[] ls(DefaultMutableTreeNode treeNode, AbstractFile parentFile, FilenameFilter filenameFilter, FileFilter fileFilter) throws IOException { AbstractFile files[]; int nbChildren = treeNode.getChildCount(); @@ -491,7 +493,7 @@ public AbstractFile[] ls() throws IOException, UnsupportedFileOperationException @Override public AbstractFile[] ls(FilenameFilter filter) throws IOException, UnsupportedFileOperationException { // Delegate to the ancestor if this file isn't actually an archive - if(!isArchive()) + if (!isArchive()) return super.ls(filter); // Make sure the entries tree is created and up-to-date @@ -511,10 +513,11 @@ public AbstractFile[] ls(FilenameFilter filter) throws IOException, UnsupportedF * underlying file protocol. */ @Override - public AbstractFile[] ls(FileFilter filter) throws IOException, UnsupportedFileOperationException { + public AbstractFile[] ls(FileFilter filter) throws IOException { // Delegate to the ancestor if this file isn't actually an archive - if(!isArchive()) + if (!isArchive()) { return super.ls(filter); + } // Make sure the entries tree is created and up-to-date checkEntriesTree(); diff --git a/src/main/com/mucommander/commons/file/AbstractFile.java b/src/main/com/mucommander/commons/file/AbstractFile.java index b4438a0db..f40acd66e 100644 --- a/src/main/com/mucommander/commons/file/AbstractFile.java +++ b/src/main/com/mucommander/commons/file/AbstractFile.java @@ -44,7 +44,7 @@ * 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.

    + * methods should be used to get a file instance from a path or {@link FileURL} location. * * @see com.mucommander.commons.file.FileFactory * @see com.mucommander.commons.file.impl.ProxyFile @@ -102,10 +102,10 @@ public FileURL getURL() { * Thus, any credentials this 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.

    + * underlying 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.

    + * connecting to APIs that require a 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.

    + * String will be returned. Thus, the returned name will never be 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. - *

    + * * * @return the absolute path to this file */ @@ -184,7 +185,7 @@ public String getAbsolutePath() { * Returns the canonical path to this file, resolving any symbolic links or '..' and '.' occurrences. * *

    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 an AbstractFile representing the canonical path of this file, or this if the - * absolute and canonical path of this file are identical.
    + * absolute and canonical path of this file are identical.
    * Note that the returned file may or may not exist, for example if this file is a symlink to a file that doesn't * exist. * @@ -222,7 +223,7 @@ public AbstractFile getCanonicalFile() { * Returns the path separator used by this file. * *

    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.

    + * of hidden files. * * @return true if this file is hidden */ @@ -268,7 +269,6 @@ public boolean isExecutable() { *

    * This default implementation returns the file whose URL has the same scheme as this one, same credentials (if any), * and a path equal to /. - *

    * * @return the root folder that contains this file */ @@ -283,7 +283,6 @@ public AbstractFile getRoot() { * Returns true if this file is a root folder. *

    * This default implementation returns true if this file's URL path is /. - *

    * * @return 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()}

    + * {@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.

    + * 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 *

  • the destination file (or one of its children) can not be written
  • *
  • an I/O error occurred
  • * - *

    * *

    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

    + * nor the linked file is copied * * @param destFile the destination file to copy this file to * @throws IOException in any of the error cases listed above @@ -460,17 +456,16 @@ public final void copyTo(AbstractFile destFile) throws IOException { *
  • the destination file (or one of its children) can not be written
  • *
  • an I/O error occurred
  • * - *

    * *

    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.

    + * nor the linked file is moved, and the symlink file is deleted. * * @param destFile the destination file to move this file to * @throws IOException in any of the error cases listed above @@ -506,7 +501,7 @@ public final void moveTo(AbstractFile destFile) throws IOException { * *

    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 be null * @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 { *
  • 'w' if this file has write permission, '-' otherwise *
  • 'x' if this file has executable permission, '-' otherwise * - *

    * *

    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

  • . * - *

    * * @return a string representation of this file's permissions */ @@ -672,7 +665,6 @@ public void deleteRecursively() throws IOException { * Note that even if 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 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 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.

    + * the kind of 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, Classnull 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". - *

    * * @param filename a filename, not a full path * @return the given filename's extension, 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

    + * - the last . 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 Returns true 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.

    + * 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 * @return true 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. - *

    . * * @return true 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 an InputStream 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 a RandomAccessInputStream 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() { *
  • the destination file can not be written
  • *
  • an I/O error occurred
  • * - *

    * *

    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: *

      @@ -1911,10 +1898,9 @@ public String toString() { *
    • the destination file (or one of its children) can not be written
    • *
    • an I/O error occurred
    • *
    - *

    * *

    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. - *

    * * @see com.mucommander.commons.file.FileURL#getDefaultHandler() * @see com.mucommander.commons.file.SchemeHandler diff --git a/src/main/com/mucommander/commons/file/DefaultSchemeParser.java b/src/main/com/mucommander/commons/file/DefaultSchemeParser.java index 6ee651e8a..e44a6abb3 100644 --- a/src/main/com/mucommander/commons/file/DefaultSchemeParser.java +++ b/src/main/com/mucommander/commons/file/DefaultSchemeParser.java @@ -32,7 +32,7 @@ * can be turned on or off in the constructor, allowing this parser to be used with most schemes. * *

    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. * *

    Local paths

    *

    @@ -46,7 +46,6 @@ *

  • Under a Unix-style OS (Linux, Mac OS X, Solaris...), C:\Windows\System32\ will be parsed and turned * into a FileURL whose path separator is "\" and representation file://localhost/C:\Windows\System32\
  • * - *

    * *

    UNC paths

    *

    @@ -59,7 +58,6 @@ *

  • On any other kind of OS, \\Server\Volume\File will be turned into a FileURL whose string * representation is smb://Server/Volume/File
  • * - *

    * * @see PathCanonizer * @author Maxence Bernard diff --git a/src/main/com/mucommander/commons/file/FileFactory.java b/src/main/com/mucommander/commons/file/FileFactory.java index d8804ae90..4ae79c778 100644 --- a/src/main/com/mucommander/commons/file/FileFactory.java +++ b/src/main/com/mucommander/commons/file/FileFactory.java @@ -44,7 +44,7 @@ * an implementation of {@link AbstractFile} that handles that protocol and register it to 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: *

      @@ -56,14 +56,14 @@ *
    • {@link FileProtocols#NFS NFS}.
    • *
    • {@link FileProtocols#SMB SMB}.
    • *
    - *

    + * *

    Archive formats

    *

    * 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: *

      @@ -77,7 +77,7 @@ *
    • RAR, registered to rar files.
    • *
    • SEVENZIP, registered to 7z files.
    • *
    - *

    + * * @author Maxence Bernard, Nicolas Rinaudo */ public class FileFactory { @@ -175,19 +175,18 @@ private FileFactory() { *

    * 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}.

    + * {@link ProtocolProvider}. * * @return an iterator on all known protocol names. */ @@ -283,7 +282,6 @@ public static void registerArchiveFormat(ArchiveFormatProvider provider) { * {@link #getArchiveFormatProvider(String)} with a known archive filename to retrieve the provider instance. * For example, 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 Iterator archiveFormats() { /** * 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 * @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.

    + * resolutions, and a 48x48 resolution is preferred, the 32x32 resolution should be favored for the returned icon. * * @param localFile the LocalFile instance for which an icon is requested * @param originalFile the AbstractFile for which an icon was originally requested diff --git a/src/main/com/mucommander/commons/file/impl/ftp/FTPFile.java b/src/main/com/mucommander/commons/file/impl/ftp/FTPFile.java index 8c9520306..67cdb1b37 100644 --- a/src/main/com/mucommander/commons/file/impl/ftp/FTPFile.java +++ b/src/main/com/mucommander/commons/file/impl/ftp/FTPFile.java @@ -706,7 +706,7 @@ public void changePermissions(int permissions) throws IOException { boolean success = connHandler.ftpClient.sendSiteCommand("CHMOD "+Integer.toOctalString(permissions)+" "+absPath); LOGGER.info("server reply: {}", connHandler.ftpClient.getReplyString()); - if(!success) { + if (!success) { int replyCode = connHandler.ftpClient.getReplyCode(); // If server reported that the command is not supported, mark it in the ConnectionHandler so that @@ -794,7 +794,7 @@ public AbstractFile getCanonicalFile() { // create the canonical file instance and cache it if (canonicalFile == null) { // getLink() returns the raw symlink target which can either be an absolute or a relative path. If the path is - // relative, preprend the absolute path of the symlink's parent folder. + // relative, prepared the absolute path of the symlink's parent folder. String symlinkTargetPath = file.getLink(); if (!symlinkTargetPath.startsWith("/")) { String parentPath = fileURL.getParent().getPath(); @@ -1251,7 +1251,7 @@ private void checkServerReply() throws IOException { * All IOException raised by FTPClient should be checked by this method so that socket errors are properly detected. */ private void checkSocketException(IOException e) { - if(((e instanceof FTPConnectionClosedException) || (e instanceof SocketException) || (e instanceof SocketTimeoutException)) && isConnected()) { + if (((e instanceof FTPConnectionClosedException) || (e instanceof SocketException) || (e instanceof SocketTimeoutException)) && isConnected()) { LOGGER.info("socket exception detected, closing connection", e); closeConnection(); } @@ -1443,8 +1443,6 @@ public FTPFilePermissions(org.apache.commons.net.ftp.FTPFile file) { public boolean getBitValue(int access, int type) { int fAccess; - int fPermission; - if (access == USER_ACCESS) { fAccess = org.apache.commons.net.ftp.FTPFile.USER_ACCESS; } else if (access == GROUP_ACCESS) { @@ -1455,6 +1453,7 @@ public boolean getBitValue(int access, int type) { return false; } + int fPermission; if (type == READ_PERMISSION) { fPermission = org.apache.commons.net.ftp.FTPFile.READ_PERMISSION; } else if (type == WRITE_PERMISSION) { diff --git a/src/main/com/mucommander/commons/file/impl/local/LocalFile.java b/src/main/com/mucommander/commons/file/impl/local/LocalFile.java index 98fd88a24..aceccf9a3 100644 --- a/src/main/com/mucommander/commons/file/impl/local/LocalFile.java +++ b/src/main/com/mucommander/commons/file/impl/local/LocalFile.java @@ -35,10 +35,6 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.nio.file.attribute.AclEntry; -import java.nio.file.attribute.AclFileAttributeView; -import java.nio.file.attribute.BasicFileAttributes; -import java.nio.file.attribute.DosFileAttributeView; import java.nio.file.attribute.FileOwnerAttributeView; import java.nio.file.attribute.PosixFileAttributes; import java.nio.file.attribute.UserPrincipal; @@ -48,9 +44,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.mucommander.commons.file.AbstractFile; import com.mucommander.commons.file.FileFactory; import com.mucommander.commons.file.FileOperation; @@ -191,8 +184,9 @@ protected LocalFile(FileURL fileURL, File file) throws IOException { String path = fileURL.getPath(); // Remove the leading '/' for Windows-like paths - if(USES_ROOT_DRIVES) + if (USES_ROOT_DRIVES) { path = path.substring(1, path.length()); + } // create the java.io.File instance and throw an exception if the path is not absolute. file = new File(path); @@ -214,7 +208,7 @@ protected LocalFile(FileURL fileURL, File file) throws IOException { // Remove the leading '/' for Windows-like paths if (USES_ROOT_DRIVES) { absPath = absPath.substring(1, absPath.length()); - } + } } this.file = file; @@ -234,10 +228,7 @@ protected LocalFile(FileURL fileURL, File file) throws IOException { */ public static AbstractFile getUserHome() { String userHomePath = System.getProperty("user.home"); - if(userHomePath==null) - return null; - - return FileFactory.getFile(userHomePath); + return userHomePath == null ? null : FileFactory.getFile(userHomePath); } /** @@ -252,7 +243,7 @@ public static AbstractFile getUserHome() { */ public long[] getVolumeInfo() throws IOException { // Under Java 1.6 and up, use the (new) java.io.File methods - if(JavaVersion.JAVA_1_6.isCurrentOrHigher()) { + if (JavaVersion.JAVA_1_6.isCurrentOrHigher()) { return new long[] { getTotalSpace(), getFreeSpace() @@ -403,9 +394,9 @@ else if(!freeSpace.equals("")) // dfInfo[1] = struct.f_bfree * (long)struct.f_frsize; // } } - } - finally { - if(br!=null) + } finally { + // TODO use autoclose + if (br!=null) try { br.close(); } catch(IOException e) {} } @@ -446,9 +437,7 @@ public boolean guessRemovableDrive() { * @return 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(List v) { try { br = new BufferedReader(new InputStreamReader(new FileInputStream("/proc/mounts"))); - StringTokenizer st; String line; - AbstractFile file; - String mountPoint, fsType; - boolean knownFS; + // read each line in file and parse it while ((line=br.readLine())!=null) { line = line.trim(); // split line into tokens separated by " \t\n\r\f" // tokens are: device, mount_point, fs_type, attributes, fs_freq, fs_passno - st = new StringTokenizer(line); + StringTokenizer st = new StringTokenizer(line); st.nextToken(); - mountPoint = st.nextToken().replace("\\040", " "); - fsType = st.nextToken(); - knownFS = false; + String mountPoint = st.nextToken().replace("\\040", " "); + String fsType = st.nextToken(); + boolean knownFS = false; for (String fs : KNOWN_UNIX_FS) { if (fs.equals(fsType)) { // this is really known physical FS @@ -553,21 +539,20 @@ private static void addMountEntries(List v) { } if (knownFS) { - file = FileFactory.getFile(mountPoint); - if(file!=null && !v.contains(file)) + AbstractFile file = FileFactory.getFile(mountPoint); + if (file != null && !v.contains(file)) { v.add(file); + } } } - } - catch(Exception e) { + } catch(Exception e) { logger.warn("Error parsing /proc/mounts entries", e); - } - finally { - if(br != null) { + } finally { + // TODO use autoclose + if (br != null) { try { br.close(); - } - catch(IOException e) {} + } catch(IOException e) {} } } } @@ -596,8 +581,8 @@ private static void addMacOSXVolumes(List v) { v.add(0, folder); } else { v.add(folder); + } } - } } } catch(IOException e) { logger.warn("Can't get /Volumes subfolders", e); @@ -659,7 +644,7 @@ public boolean isSystem() { // if GetFileAttributes() fails we try FindFirstFile() as fallback // such a case would be pagefile.sys - if(attributes == Kernel32API.INVALID_FILE_ATTRIBUTES) { + if (attributes == Kernel32API.INVALID_FILE_ATTRIBUTES) { Kernel32API.FindFileHandle findFileHandle = null; Kernel32API.WIN32_FIND_DATA findFileData = new Kernel32API.WIN32_FIND_DATA(); @@ -696,7 +681,7 @@ public void changeDate(long lastModified) throws IOException { if (!file.setLastModified(lastModified)) { throw new IOException(); - } + } } @Override @@ -758,7 +743,7 @@ public void changePermission(int access, int permission, boolean enabled) throws if (!success) { throw new IOException(); - } + } } // private String getOwnerPosix() { // Path path = Paths.get(file.toURI()); @@ -1111,12 +1096,11 @@ public AbstractFile[] ls(FilenameFilter filenameFilter) throws IOException { int nbFiles = files.length; AbstractFile children[] = new AbstractFile[nbFiles]; - FileURL childURL; for(int i=0; i bestDepth) { bestDepth = depth; bestMatch = i; @@ -1383,18 +1367,18 @@ public void write(byte b[], int off, int len) throws IOException { public void setLength(long newLength) throws IOException { long currentLength = getLength(); - if(newLength==currentLength) + if (newLength == currentLength) { return; + } long currentPos = channel.position(); - if(newLengthnewLength) channel.position(newLength); - } - else { + } else { // Expand the file by positionning the offset at the new EOF and writing a byte, and reposition the // offset to where it was channel.position(newLength-1); // Note: newLength cannot be 0 diff --git a/src/main/com/mucommander/commons/file/impl/local/UNCFile.java b/src/main/com/mucommander/commons/file/impl/local/UNCFile.java index 10993d596..3eba22409 100644 --- a/src/main/com/mucommander/commons/file/impl/local/UNCFile.java +++ b/src/main/com/mucommander/commons/file/impl/local/UNCFile.java @@ -86,17 +86,19 @@ protected UNCFile(FileURL fileURL) throws IOException { /** * Creates a new instance of UNCFile, using the given {@link File} if not null, 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; ibestDepth) { bestDepth = depth; @@ -578,8 +583,9 @@ else if(thisPath.startsWith(volumePath)) { } } - if(bestMatch!=-1) + if (bestMatch >= 0) { return volumes[bestMatch]; + } // If no volume matched this file (shouldn't normally happen), return the root folder return getRoot(); @@ -598,7 +604,7 @@ else if(thisPath.startsWith(volumePath)) { */ public long[] getVolumeInfo() throws IOException { // Under Java 1.6 and up, use the (new) java.io.File methods - if(JavaVersion.JAVA_1_6.isCurrentOrHigher()) { + if (JavaVersion.JAVA_1_6.isCurrentOrHigher()) { return new long[] { getTotalSpace(), getFreeSpace() @@ -623,7 +629,7 @@ protected long[] getNativeVolumeInfo() throws IOException { try { // Use the Kernel32 DLL if it is available - if(Kernel32.isAvailable()) { + if (Kernel32.isAvailable()) { // Retrieves the total and free space information using the GetDiskFreeSpaceEx function of the // Kernel32 API. LongByReference totalSpaceLBR = new LongByReference(); diff --git a/src/main/com/mucommander/commons/file/util/Kernel32API.java b/src/main/com/mucommander/commons/file/util/Kernel32API.java index fcaf3c134..1aeda3476 100644 --- a/src/main/com/mucommander/commons/file/util/Kernel32API.java +++ b/src/main/com/mucommander/commons/file/util/Kernel32API.java @@ -76,9 +76,9 @@ public interface Kernel32API extends StdCallLibrary { * *

    Remarks: 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) {