本文整理汇总了Java中org.apache.commons.httpclient.util.URIUtil.getName方法的典型用法代码示例。如果您正苦于以下问题:Java URIUtil.getName方法的具体用法?Java URIUtil.getName怎么用?Java URIUtil.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.httpclient.util.URIUtil
的用法示例。
在下文中一共展示了URIUtil.getName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getName
import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
public String getName() {
if(relPath!=null)
return relPath;
String escapedPath = httpUrl.getEscapedPath();
String escapedName =
URIUtil.getName(escapedPath.endsWith("/")
? escapedPath.substring(0, escapedPath.length() - 1)
: escapedPath);
try {
return URIUtil.decode(escapedName);
} catch (URIException e) {
return escapedName;
}
}
示例2: getName
import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
private static String getName(String uri) {
String escapedName = URIUtil.getName(
uri.endsWith("/") ? uri.substring(0, uri.length() - 1): uri);
try {
return URIUtil.decode(escapedName);
} catch (URIException e) {
return escapedName;
}
}
示例3: processParameters
import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
private void processParameters() throws MojoFailureException {
if (name != null) {
if (name.startsWith(OP_THEME_ARTIFACT_PREFIX)) {
if (artifactId == null) {
artifactId = name;
}
name = name.substring(OP_THEME_ARTIFACT_PREFIX_LENGTH);
} else {
if (artifactId == null) {
artifactId = OP_THEME_ARTIFACT_PREFIX + name;
}
}
}
// URL url = null;
if (theme != null) {
String str = theme.toLowerCase();
//url
if (str.startsWith("http://") || str.startsWith("https://")) {
try {
url = new URL(theme);
} catch (MalformedURLException e) {
throw new MojoFailureException("Not a valid url: " + theme, e);
}
if (name == null) {
String filename = URIUtil.getName(theme);
name = FilenameUtils.removeExtension(filename);
}
} else {
//groupId:artifactId:version[:packaging][:classifier]
String[] tokens = StringUtils.split(theme, ":");
if (tokens.length < 3 || tokens.length > 5) {
throw new MojoFailureException(
"Invalid theme artifact, you must specify groupId:artifactId:version[:packaging][:classifier] "
+ theme);
}
groupId = tokens[0];
artifactId = tokens[1];
version = tokens[2];
if (tokens.length >= 4) {
type = tokens[3];
}
if (tokens.length == 5) {
classifier = tokens[4];
} else {
classifier = null;
}
if (name == null) {
if (artifactId.startsWith(OP_THEME_ARTIFACT_PREFIX)) {
name = artifactId.substring(OP_THEME_ARTIFACT_PREFIX_LENGTH);
} else {
name = artifactId;
}
}
}
}
}
示例4: get
import org.apache.commons.httpclient.util.URIUtil; //导入方法依赖的package包/类
void get(String path, String filename)
{
filename = getLocalTragetFileName( path, filename);
try {
// The resource on the remote.
String src = checkUri(path);
// The file on the local.
String dest = (filename!=null)
? filename
: URIUtil.getName(src.endsWith("/")
? src.substring(0, src.length() - 1)
: src);
out.println("get " + src + " " + dest);
// For the overwrite operation;
String y = "y";
File file = new File(dest);
// Checking the local file.
if (file.exists()) {
// FIXME: interactive ?
out.print("Aleady exists. " +
"Do you want to overwrite it(y/n)? ");
BufferedReader in =
new BufferedReader(new InputStreamReader(System.in));
y = in.readLine();
}
if (y.trim().equalsIgnoreCase("y") ||
(y != null && y.length() == 0)) {
out.print("Downloading '" + src +
"' to '" + dest + "': ");
if (webdavResource.getMethod(src, file)) {
out.println("succeeded.");
} else {
out.println("failed.");
out.println(webdavResource.getStatusMessage());
}
}
}
catch (Exception ex) {
handleException(ex);
}
}