This repository was archived by the owner on Feb 9, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +51
-26
lines changed
uberfire-api/src/main/java/org/uberfire Expand file tree Collapse file tree 2 files changed +51
-26
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2012 JBoss Inc
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+ * use this file except in compliance with the License. You may obtain a copy of
6+ * the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+ * License for the specific language governing permissions and limitations under
14+ * the License.
15+ */
16+ package org .uberfire .workbench .type ;
17+
18+ import org .uberfire .backend .vfs .Path ;
19+
20+ public final class FileNameUtil {
21+
22+ public static String removeExtension ( final Path path ,
23+ final ResourceTypeDefinition type ) {
24+ if ( path == null ) {
25+ return null ;
26+ }
27+ final String fileName = path .getFileName ();
28+ if ( type == null ) {
29+ return fileName ;
30+ }
31+ final int index = indexOfExtension ( type ,
32+ fileName );
33+ if ( index == -1 ) {
34+ return fileName ;
35+ } else {
36+ return fileName .substring ( 0 ,
37+ index );
38+ }
39+ }
40+
41+ private static int indexOfExtension ( final ResourceTypeDefinition type ,
42+ final String fileName ) {
43+ if ( fileName == null ) {
44+ return -1 ;
45+ }
46+ final String suffix = ( type .getSuffix () == null ? "" : type .getSuffix () );
47+ final int extensionPos = fileName .lastIndexOf ( "." + suffix );
48+ return extensionPos ;
49+ }
50+
51+ }
You can’t perform that action at this time.
0 commit comments