]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - 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
diff --git a/bundles/org.simantics.export.core/src/org/simantics/export/core/impl/PublisherUtil.java b/bundles/org.simantics.export.core/src/org/simantics/export/core/impl/PublisherUtil.java
new file mode 100644 (file)
index 0000000..b2ae02a
--- /dev/null
@@ -0,0 +1,29 @@
+package org.simantics.export.core.impl;\r
+\r
+\r
+/**\r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class PublisherUtil {\r
+\r
+    /**\r
+     * Returns either filePath as is or filePath suffixed by\r
+     * <code>endsWith</code> depending on whether <code>filePath</code> ends\r
+     * with <code>endsWith</code> or not.\r
+     * \r
+     * @param suffix\r
+     * @param ignoreCase\r
+     * @param filePath\r
+     * @return\r
+     */\r
+    public static String ensureEndsWith(boolean ignoreCase, String suffix, String filePath) {\r
+        int suffixLen = suffix.length();\r
+        int filePathLen = filePath.length();\r
+        if (suffixLen > filePathLen)\r
+            return filePath + suffix;\r
+        if (!filePath.regionMatches(ignoreCase, filePathLen - suffixLen, suffix, 0, suffixLen))\r
+            return filePath + suffix;\r
+        return filePath;\r
+    }\r
+\r
+}\r