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