com.okworx.ilcd.validation.util.PrefixBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ilcd-validation Show documentation
Show all versions of ilcd-validation Show documentation
A Java library for performing technical validation of data in ILCD data format.
package com.okworx.ilcd.validation.util;
import org.apache.commons.lang3.StringUtils;
/**
* PrefixBuilder class.
*
* @author oliver.kusche
* @version $Id: $Id
*/
public class PrefixBuilder {
/**
* buildPrefix.
*
* @param pathToJar a {@link java.lang.String} object.
* @param resourcePath a {@link java.lang.String} object.
* @return a {@link java.lang.String} object.
*/
public static String buildPrefix(String pathToJar, String resourcePath) {
// build "jar:file:" + pathToJar + "!/" + resourcePath;
StringBuffer buf = new StringBuffer(buildPath(pathToJar, resourcePath));
if (StringUtils.isNotBlank(pathToJar) && StringUtils.isNotBlank(resourcePath) && !resourcePath.endsWith("/"))
buf.append("/");
return buf.toString();
}
/**
* buildPath.
*
* @param pathToJar a {@link java.lang.String} object.
* @param resourcePath a {@link java.lang.String} object.
* @return a {@link java.lang.String} object.
*/
public static String buildPath(String pathToJar, String resourcePath) {
// build "jar:file:" + pathToJar + "!/" + resourcePath;
StringBuffer buf = new StringBuffer();
if (!pathToJar.startsWith("file:"))
buf.append("jar:file:");
else
buf.append("jar:");
buf.append(pathToJar);
buf.append("!/");
buf.append(resourcePath);
return buf.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy