You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2021/12/11 15:53:58 UTC

[commons-vfs] branch master updated: Extract the layer separator character constant into LayeredFileName.LAYER_SEPARATOR.

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-vfs.git


The following commit(s) were added to refs/heads/master by this push:
     new 32ce5e7  Extract the layer separator character constant into LayeredFileName.LAYER_SEPARATOR.
     new f05c540  Merge branch 'master' of https://gitbox.apache.org/repos/asf/commons-vfs
32ce5e7 is described below

commit 32ce5e73642d3fe26bf1bf1dbdd50a69d44c59ef
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Dec 11 10:53:31 2021 -0500

    Extract the layer separator character constant into
    LayeredFileName.LAYER_SEPARATOR.
---
 .../org/apache/commons/vfs2/provider/LayeredFileName.java | 15 ++++++++++++---
 .../commons/vfs2/provider/LayeredFileNameParser.java      |  7 ++++---
 src/changes/changes.xml                                   |  3 +++
 3 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/LayeredFileName.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/LayeredFileName.java
index 0b90d84..c6540de 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/LayeredFileName.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/LayeredFileName.java
@@ -24,13 +24,22 @@ import org.apache.commons.vfs2.FileType;
  */
 public class LayeredFileName extends AbstractFileName {
 
+    /**
+     * The layer separator character '{@value #LAYER_SEPARATOR}'.
+     *
+     * @since 2.10.0
+     */
+    public static final char LAYER_SEPARATOR = '!';
+
+    static final char SCHEME_SEPARATOR = ':';
+    
     private final FileName outerUri;
 
     /**
      * Constructs a new instance.
      *
      * @param scheme The scheme.
-     * @param outerUri outer Uri.
+     * @param outerUri outer file name.
      * @param path the absolute path, maybe empty or null.
      * @param type the file type.
      */
@@ -42,9 +51,9 @@ public class LayeredFileName extends AbstractFileName {
     @Override
     protected void appendRootUri(final StringBuilder buffer, final boolean addPassword) {
         buffer.append(getScheme());
-        buffer.append(":");
+        buffer.append(SCHEME_SEPARATOR);
         buffer.append(getOuterName().getURI());
-        buffer.append("!");
+        buffer.append(LAYER_SEPARATOR);
     }
 
     /**
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/LayeredFileNameParser.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/LayeredFileNameParser.java
index d5560c2..7c878f7 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/LayeredFileNameParser.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/LayeredFileNameParser.java
@@ -27,6 +27,7 @@ import org.apache.commons.vfs2.FileType;
  * </p>
  */
 public class LayeredFileNameParser extends AbstractFileNameParser {
+
     private static final LayeredFileNameParser INSTANCE = new LayeredFileNameParser();
 
     /**
@@ -46,7 +47,7 @@ public class LayeredFileNameParser extends AbstractFileNameParser {
      */
     @Override
     public boolean encodeCharacter(final char ch) {
-        return super.encodeCharacter(ch) || ch == '!';
+        return super.encodeCharacter(ch) || ch == LayeredFileName.LAYER_SEPARATOR;
     }
 
     /**
@@ -59,10 +60,10 @@ public class LayeredFileNameParser extends AbstractFileNameParser {
         // Looking for <name>!<abspath> (staring at the end)
         final int maxlen = uri.length();
         int pos = maxlen - 1;
-        for (; pos > 0 && uri.charAt(pos) != '!'; pos--) {
+        for (; pos > 0 && uri.charAt(pos) != LayeredFileName.LAYER_SEPARATOR; pos--) {
         }
 
-        if (pos == 0 && uri.charAt(pos) != '!') {
+        if (pos == 0 && uri.charAt(pos) != LayeredFileName.LAYER_SEPARATOR) {
             // not ! found, so take the whole path a root
             // e.g. zip:/my/zip/file.zip
             pos = maxlen;
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index c6bd5bc..f64462f 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -93,6 +93,9 @@ The <action> type attribute can be add,update,fix,remove.
       <action type="add" dev="ggregory" due-to="Gary Gregory">
         Add RandomAccessMode.from(AccessMode) and toAccessModes().
       </action>
+      <action type="add" dev="ggregory" due-to="Gary Gregory">
+        Extract the layer separator character constant into LayeredFileName.LAYER_SEPARATOR.
+      </action>
       <!-- UDPATE -->
       <action type="update" dev="ggregory" due-to="Dependabot">
         Bump jakarta.mail from 1.6.7 to 2.0.1 #200.