Skip to content
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.

Commit

Permalink
bz-1007781: Editors should not contain file extension of assets
Browse files Browse the repository at this point in the history
  • Loading branch information
jervisliu committed Sep 18, 2013
1 parent cda2c33 commit 6566d9a
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 2 deletions.
Expand Up @@ -62,6 +62,30 @@ public FileSystem getFileSystem() {
public String getFileName() {
return path.getFileName();
}
@Override
public String getFileNameWithoutExtension() {
return removeExtension(path.getFileName());
}

public static String removeExtension(final String filename) {
if (filename == null) {
return null;
}
final int index = indexOfExtension(filename);
if (index == -1) {
return filename;
} else {
return filename.substring(0, index);
}
}

public static int indexOfExtension(final String filename) {
if (filename == null) {
return -1;
}
final int extensionPos = filename.lastIndexOf(".");
return extensionPos;
}

@Override
public String toURI() {
Expand Down
Expand Up @@ -21,6 +21,8 @@ public interface Path extends Comparable<Path> {
FileSystem getFileSystem();

String getFileName();

String getFileNameWithoutExtension();

String toURI();

Expand Down
Expand Up @@ -81,7 +81,32 @@ public FileSystem getFileSystem() {
public String getFileName() {
return fileName;
}


@Override
public String getFileNameWithoutExtension() {
return removeExtension(fileName);
}

public static String removeExtension(final String filename) {
if (filename == null) {
return null;
}
final int index = indexOfExtension(filename);
if (index == -1) {
return filename;
} else {
return filename.substring(0, index);
}
}

public static int indexOfExtension(final String filename) {
if (filename == null) {
return -1;
}
final int extensionPos = filename.lastIndexOf(".");
return extensionPos;
}

@Override
public String toURI() {
return uri;
Expand Down Expand Up @@ -124,5 +149,4 @@ public String toString() {
'}';
}
}

}
Expand Up @@ -50,6 +50,12 @@ public String toURI() {
public int compareTo( final Path o ) {
return 0;
}

@Override
public String getFileNameWithoutExtension() {
// TODO Auto-generated method stub
return null;
}
} );

final ObservablePath path = mock( ObservablePath.class );
Expand Down Expand Up @@ -102,6 +108,12 @@ public String toURI() {
public int compareTo( final Path o ) {
return 0;
}

@Override
public String getFileNameWithoutExtension() {
// TODO Auto-generated method stub
return null;
}
} );
final PlaceRequest somewhereTheSame = somewhere.clone();

Expand Down Expand Up @@ -161,6 +173,12 @@ public String toURI() {
public int compareTo( final Path o ) {
return 0;
}

@Override
public String getFileNameWithoutExtension() {
// TODO Auto-generated method stub
return null;
}
} );

final PlaceRequest somewhereElse = new PathPlaceRequest( new Path() {
Expand All @@ -183,6 +201,12 @@ public String toURI() {
public int compareTo( final Path o ) {
return 0;
}

@Override
public String getFileNameWithoutExtension() {
// TODO Auto-generated method stub
return null;
}
} );

//The first place
Expand Down

0 comments on commit 6566d9a

Please sign in to comment.