當前位置: 首頁>>代碼示例>>Java>>正文


Java URIUtil.getName方法代碼示例

本文整理匯總了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;
  }
}
 
開發者ID:integrated,項目名稱:jakarta-slide-webdavclient,代碼行數:15,代碼來源:WebdavFile.java

示例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;
    }
}
 
開發者ID:integrated,項目名稱:jakarta-slide-webdavclient,代碼行數:10,代碼來源:WebdavResource.java

示例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;
                    }
                }
            }
        }
    }
 
開發者ID:opoo,項目名稱:opoopress,代碼行數:60,代碼來源:ThemeMojo.java

示例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);
    }
}
 
開發者ID:integrated,項目名稱:jakarta-slide-webdavclient,代碼行數:47,代碼來源:Client.java


注:本文中的org.apache.commons.httpclient.util.URIUtil.getName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。