]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.export.core/src/org/simantics/export/core/impl/PublisherUtil.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.export.core / src / org / simantics / export / core / impl / PublisherUtil.java
1 package org.simantics.export.core.impl;\r
2 \r
3 \r
4 /**\r
5  * @author Tuukka Lehtonen\r
6  */\r
7 public class PublisherUtil {\r
8 \r
9     /**\r
10      * Returns either filePath as is or filePath suffixed by\r
11      * <code>endsWith</code> depending on whether <code>filePath</code> ends\r
12      * with <code>endsWith</code> or not.\r
13      * \r
14      * @param suffix\r
15      * @param ignoreCase\r
16      * @param filePath\r
17      * @return\r
18      */\r
19     public static String ensureEndsWith(boolean ignoreCase, String suffix, String filePath) {\r
20         int suffixLen = suffix.length();\r
21         int filePathLen = filePath.length();\r
22         if (suffixLen > filePathLen)\r
23             return filePath + suffix;\r
24         if (!filePath.regionMatches(ignoreCase, filePathLen - suffixLen, suffix, 0, suffixLen))\r
25             return filePath + suffix;\r
26         return filePath;\r
27     }\r
28 \r
29 }\r