• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java URLEncoder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.extensions.surf.util.URLEncoder的典型用法代码示例。如果您正苦于以下问题:Java URLEncoder类的具体用法?Java URLEncoder怎么用?Java URLEncoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



URLEncoder类属于org.springframework.extensions.surf.util包,在下文中一共展示了URLEncoder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getDownloadAPIUrl

import org.springframework.extensions.surf.util.URLEncoder; //导入依赖的package包/类
/**
 * @param  node the node to construct the download URL for
 * @return For a content document, this method returns the URL to the /api/node/content
 *         API for the default content property
 *         <p>
 *         For a container node, this method returns an empty string
 *         </p>
 */
public String getDownloadAPIUrl(ScriptNode node)
{
    if (node.getIsDocument())
    {
       return MessageFormat.format(CONTENT_DOWNLOAD_API_URL, new Object[]{
               node.nodeRef.getStoreRef().getProtocol(),
               node.nodeRef.getStoreRef().getIdentifier(),
               node.nodeRef.getId(),
               URLEncoder.encode(node.getName())});
    }
    else
    {
        return "";
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:24,代码来源:ApplicationScriptUtils.java


示例2: getDownloadUrl

import org.springframework.extensions.surf.util.URLEncoder; //导入依赖的package包/类
/**
 * @return For a content document, this method returns the download URL to the content for
 *         the default content property (@see ContentModel.PROP_CONTENT)
 *         <p>
 *         For a container node, this method returns an empty string
 */
public String getDownloadUrl()
{
    if (getIsDocument() == true)
    {
       return MessageFormat.format(CONTENT_DOWNLOAD_URL, new Object[] {
                nodeRef.getStoreRef().getProtocol(),
                nodeRef.getStoreRef().getIdentifier(),
                nodeRef.getId(),
                URLEncoder.encode(getName()) });
    }
    else
    {
        return "";
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:22,代码来源:ScriptNode.java


示例3: getContentDispositionHeader

import org.springframework.extensions.surf.util.URLEncoder; //导入依赖的package包/类
protected String getContentDispositionHeader(FileInfo nodeInfo)
{
    String filename = nodeInfo.getName();
    StringBuilder sb = new StringBuilder();
    sb.append("attachment; filename=\"");
    for(int i = 0; i < filename.length(); i++)
    {
        char c = filename.charAt(i);
        if(isValidQuotedStringHeaderParamChar(c))
        {
            sb.append(c);
        }
        else
        {
            sb.append(" ");
        }
    }
    sb.append("\"; filename*=UTF-8''");
    sb.append(URLEncoder.encode(filename));
    return sb.toString();
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:22,代码来源:GetMethod.java


示例4: encode

import org.springframework.extensions.surf.util.URLEncoder; //导入依赖的package包/类
/**
 * <p>
 * encode string to share specific manner (all characters with code > 127 will be encoded in %u0... format)
 * </p>
 * 
 * @param value to encode
 * @return encoded value
 * @throws UnsupportedEncodingException
 */
public static String encode(String value) throws UnsupportedEncodingException
{
    StringBuilder result = new StringBuilder(value.length());

    for (int i = 0; i < value.length(); i++)
    {
        char c = value.charAt(i);
        if (c > 127)
        {
            result.append("%u0" + Integer.toHexString(c).toUpperCase());
        }
        else
        {
            if (c > 'a' && c < 'z' || c > 'A' && c < 'Z' || c == '/' || c == '@' || c == '+')
            {
                result.append(c);
            }
            else
            {
                result.append(URLEncoder.encode(c + ""));
            }
        }
    }
    return result.toString();
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:35,代码来源:ShareUtils.java


示例5: testChannelPut

import org.springframework.extensions.surf.util.URLEncoder; //导入依赖的package包/类
public void testChannelPut() throws Exception
{
    Channel channel1 = testHelper.createChannel(publishAnyType);
    Channel channel2 = testHelper.createChannel(publishAnyType);
    
    String name1 = channel1.getName();
    String name2 = channel2.getName();
    
    String newName = name1 + "Foo";
    JSONObject json = new JSONObject();
    json.put(NAME, newName);
    
    String jsonStr = json.toString();
    
    String channel1Url = MessageFormat.format(CHANNEL_URL, URLEncoder.encode(channel1.getId()));
    // Post JSON content.
    sendRequest(new PutRequest(channel1Url, jsonStr, JSON), 200);
    
    Channel renamedCH1 = channelService.getChannelById(channel1.getId());
    assertEquals("Channel1 was not renamed correctly!", newName, renamedCH1.getName());
    
    Channel renamedCH2 = channelService.getChannelById(channel2.getId());
    assertEquals("Channel2 name should not have changed!", name2, renamedCH2.getName());
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:25,代码来源:PublishingRestApiTest.java


示例6: checkJsonEvent

import org.springframework.extensions.surf.util.URLEncoder; //导入依赖的package包/类
private void checkJsonEvent(PublishingEvent event, JSONObject json) throws Exception
{
    String url = "api/publishing/events/" + URLEncoder.encode(event.getId());
    assertEquals(url, json.getString(URL));
    
    assertEquals(event.getStatus().name(), json.getString(STATUS));
    
    assertEquals(event.getComment(), json.optString(COMMENT));
    checkCalendar(event.getScheduledTime(), json.optJSONObject(SCHEDULED_TIME));
    assertEquals(event.getCreator(), json.getString(CREATOR));
    checkDate(event.getCreatedTime(), json.getJSONObject(CREATED_TIME));
    
    PublishingPackage pckg = event.getPackage();
    checkContainsNodes(pckg, json.getJSONArray(PUBLISH_NODES), true);
    checkContainsNodes(pckg, json.getJSONArray(UNPUBLISH_NODES), false);
    
    Channel channel = channelService.getChannelById(event.getChannelId());
    checkChannel(json.getJSONObject(CHANNEL), channel);
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:20,代码来源:PublishingRestApiTest.java


示例7: checkChannelType

import org.springframework.extensions.surf.util.URLEncoder; //导入依赖的package包/类
private void checkChannelType(JSONObject jsonType, ChannelType channelType) throws Exception
{
    check(ID, jsonType, channelType.getId());
    check(TITLE, jsonType, channelType.getId());
    
    String expUrl = "api/publishing/channel-types/"+URLEncoder.encode(channelType.getId());
    check(URL, jsonType, expUrl);
    check(CHANNEL_NODE_TYPE, jsonType, channelType.getChannelNodeType().toString());
    
    List<String> contentTypes = CollectionUtils.toListOfStrings(channelType.getSupportedContentTypes());
    checkStrings(jsonType.getJSONArray(SUPPORTED_CONTENT_TYPES), contentTypes);
    checkStrings(jsonType.getJSONArray(SUPPORTED_MIME_TYPES), channelType.getSupportedMimeTypes());
    
    check(CAN_PUBLISH, jsonType, channelType.canPublish());
    check(CAN_PUBLISH_STATUS_UPDATES, jsonType, channelType.canPublishStatusUpdates());
    check(CAN_UNPUBLISH, jsonType, channelType.canUnpublish());
    check(MAX_STATUS_LENGTH, jsonType, channelType.getMaximumStatusLength());

    //TODO Implement Icon URL
    check(ICON, jsonType, expUrl + "/icon");
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:22,代码来源:PublishingRestApiTest.java


示例8: startInvite

import org.springframework.extensions.surf.util.URLEncoder; //导入依赖的package包/类
private JSONObject startInvite(String inviteeFirstName, String inviteeLastName, String inviteeEmail, String inviteeSiteRole,
        String siteShortName, int expectedStatus)
        throws Exception
{
    this.inviteeEmailAddrs.add(inviteeEmail);

    // Inviter sends invitation to Invitee to join a Site
    String startInviteUrl = URL_INVITE + "/" + INVITE_ACTION_START
            + "?inviteeFirstName=" + inviteeFirstName + "&inviteeLastName="
            + inviteeLastName + "&inviteeEmail="
            + URLEncoder.encode(inviteeEmail) + "&siteShortName="
            + siteShortName + "&inviteeSiteRole=" + inviteeSiteRole
            + "&serverPath=" + "http://localhost:8081/share/"
            + "&acceptUrl=" + "page/accept-invite"
            + "&rejectUrl=" + "page/reject-invite";

    Response response = sendRequest(new GetRequest(startInviteUrl), expectedStatus);

    JSONObject result = new JSONObject(response.getContentAsString());

    return result;
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:23,代码来源:InviteServiceTest.java


示例9: testJobWithSpace

import org.springframework.extensions.surf.util.URLEncoder; //导入依赖的package包/类
public void testJobWithSpace() throws Exception
{
    String userName  = RandomStringUtils.randomNumeric(6);
    String userJob = "myJob" + RandomStringUtils.randomNumeric(2) + " myJob" + RandomStringUtils.randomNumeric(3);
    
    //we need to ecape a spaces for search
    String jobSearchString = userJob.replace(" ", "\\ ");
    
    createPerson(userName, "myTitle", "myFirstName", "myLastName", "myOrganisation",
            userJob, "[email protected]", "myBio", "images/avatar.jpg",
            Status.STATUS_OK);  
    
    // Get a person 
    Response response = sendRequest(new GetRequest(URL_PEOPLE + "?filter=" + URLEncoder.encode("jobtitle:" + jobSearchString)), 200);
    JSONObject res = new JSONObject(response.getContentAsString());
    assertEquals(1, res.getJSONArray("people").length());
    
    response = sendRequest(new GetRequest(URL_PEOPLE + "?filter=" + URLEncoder.encode("jobtitle:" + userJob)), 200);
    res = new JSONObject(response.getContentAsString());
    assertEquals(0, res.getJSONArray("people").length());
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:22,代码来源:PersonServiceTest.java


示例10: getWebdavUrl

import org.springframework.extensions.surf.util.URLEncoder; //导入依赖的package包/类
/**
 * Get the WebDavUrl for the specified nodeRef
 * 
 * @param nodeRef the node that the webdav URL (or null)
 * @return the URL of the node in webdav or "" if a URL cannot be built.
 */
public String getWebdavUrl(NodeRef nodeRef)
{
    String url = "";
    
    if (!enabled)
    {
        return url;
    }
    
    try
    {
        QName typeName = nodeService.getType(nodeRef);
        
        if (getIsContainer(typeName) || getIsDocument(typeName))
        {
            List<String> paths = fileFolderService.getNameOnlyPath(getRootNode().getNodeForCurrentTenant(), nodeRef);
            
            // build up the webdav url
            StringBuilder path = new StringBuilder(128);
            path.append("/" + WEBDAV_PREFIX);
            
            for (int i=0; i<paths.size(); i++)
            {
                path.append("/")
                    .append(URLEncoder.encode(paths.get(i)));
            }
            url = path.toString();
        }
    }
    catch (InvalidTypeException typeErr)
    {
        // cannot build path if file is a type such as a rendition
    }
    catch (FileNotFoundException nodeErr)
    {
        // cannot build path if file no longer exists, return default
    }
    return url;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:46,代码来源:WebDavServiceImpl.java


示例11: getUrl

import org.springframework.extensions.surf.util.URLEncoder; //导入依赖的package包/类
/**
 * @return For a content document, this method returns the URL to the content stream for the default content
 *         property (@see ContentModel.PROP_CONTENT)
 *         <p>
 *         For a container node, this method return the URL to browse to the folder in the web-client
 */
public String getUrl()
{
    if (getIsDocument() == true)
    {
        return MessageFormat.format(CONTENT_DEFAULT_URL, new Object[] { nodeRef.getStoreRef().getProtocol(),
                nodeRef.getStoreRef().getIdentifier(), nodeRef.getId(),
                URLEncoder.encode(getName())});
    }
    else
    {
        return MessageFormat.format(FOLDER_BROWSE_URL, new Object[] { nodeRef.getStoreRef().getProtocol(),
                nodeRef.getStoreRef().getIdentifier(), nodeRef.getId() });
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:21,代码来源:ScriptNode.java


示例12: getWebdavUrl

import org.springframework.extensions.surf.util.URLEncoder; //导入依赖的package包/类
/**
 * @return The WebDav cm:name based path to the content for the default content property
 *         (@see ContentModel.PROP_CONTENT)
 */
public String getWebdavUrl()
{
    String url = "";
    try
    {
        if (getIsContainer() || getIsDocument())
        {
            List<String> paths = this.services.getFileFolderService().getNameOnlyPath(null, getNodeRef());
            
            // build up the webdav url
            StringBuilder path = new StringBuilder(128);
            path.append("/webdav");
            
            // build up the path skipping the first path as it is the root folder
            for (int i=1; i<paths.size(); i++)
            {
                path.append("/")
                    .append(URLEncoder.encode(paths.get(i)));
            }
            url = path.toString();
        }
    }
    catch (InvalidTypeException typeErr)
    {
        // cannot build path if file is a type such as a rendition
    }
    catch (FileNotFoundException nodeErr)
    {
        // cannot build path if file no longer exists
    }
    return url;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:37,代码来源:ScriptNode.java


示例13: buildUrlParamString

import org.springframework.extensions.surf.util.URLEncoder; //导入依赖的package包/类
private String buildUrlParamString(Map<String, String> properties)
{
    StringBuilder params = new StringBuilder("?inviteId=");
    params.append(properties.get(WF_INSTANCE_ID));
    params.append("&inviteeUserName=");
    params.append(URLEncoder.encode(properties.get(wfVarInviteeUserName)));
    params.append("&siteShortName=");
    params.append(properties.get(wfVarResourceName));
    params.append("&inviteTicket=");
    params.append(properties.get(wfVarInviteTicket));
    return params.toString();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:13,代码来源:InviteNominatedSender.java


示例14: getUrl

import org.springframework.extensions.surf.util.URLEncoder; //导入依赖的package包/类
/**
 * @return Returns the URL to the content stream for the frozen state of the node from
 *         the default content property (@see ContentModel.PROP_CONTENT)
 */
@Override
public String getUrl()
{
    NodeRef nodeRef = this.version.getFrozenStateNodeRef();
    return MessageFormat.format(parent.CONTENT_GET_URL, new Object[] {
            nodeRef.getStoreRef().getProtocol(),
            nodeRef.getStoreRef().getIdentifier(),
            nodeRef.getId(),
            URLEncoder.encode(getName()) } );
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:15,代码来源:VersionHistoryNode.java


示例15: buildUrl

import org.springframework.extensions.surf.util.URLEncoder; //导入依赖的package包/类
private String buildUrl(String format)
{
   return MessageFormat.format(format, new Object[] {
             getNodeRef().getStoreRef().getProtocol(),
             getNodeRef().getStoreRef().getIdentifier(),
             getNodeRef().getId(),
             URLEncoder.encode(getName()) } );
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:9,代码来源:BaseContentNode.java


示例16: buildPropUrl

import org.springframework.extensions.surf.util.URLEncoder; //导入依赖的package包/类
private String buildPropUrl(String pformat)
{
    return MessageFormat.format(pformat, new Object[] {
             getNodeRef().getStoreRef().getProtocol(),
             getNodeRef().getStoreRef().getIdentifier(),
             getNodeRef().getId(),
             URLEncoder.encode(getName()),
             URLEncoder.encode(property.toString()) } );
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:10,代码来源:BaseContentNode.java


示例17: Person

import org.springframework.extensions.surf.util.URLEncoder; //导入依赖的package包/类
public Person(String name)
{
    this.name = name;
    String encName = URLEncoder.encode(name);
    this.email = encName + "@test.com";
    this.node = new NodeRef(testStore, encName);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:8,代码来源:InviteSenderTest.java


示例18: doGet

import org.springframework.extensions.surf.util.URLEncoder; //导入依赖的package包/类
/**
 * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 */
protected void doGet(HttpServletRequest req, HttpServletResponse res)
        throws ServletException, IOException
{
    String endpoint = null;
    StringBuilder args = new StringBuilder(32);
    
    Map<String, String[]> parameters = req.getParameterMap();
    for (Map.Entry<String, String[]> parameter : parameters.entrySet())
    {
        String[] values = parameter.getValue();
        int startIdx = 0;
        
        if (parameter.getKey().equals(PARAM_ENDPOINT) && values.length != 0)
        {
            endpoint = values[0];
            startIdx++;
        }
        
        for (int i = startIdx; i < values.length; i++)
        {
            if (args.length() != 0)
            {
                args.append("&");
            }
            args.append(parameter.getKey()).append('=').append(URLEncoder.encode(values[i]));
        }
    }
    
    if (endpoint == null || endpoint.length() == 0)
    {
        throw new IllegalArgumentException("endpoint argument not specified");
    }
    
    String url = endpoint + ((args.length() == 0) ? "" : "?" + args.toString());
    HTTPProxy proxy = new HTTPProxy(url, res);
    proxy.service();
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:41,代码来源:HTTPProxyServlet.java


示例19: buildUrl

import org.springframework.extensions.surf.util.URLEncoder; //导入依赖的package包/类
private static String buildUrl(WebScriptRequest req, Map<String, String> params, String hash)
{
    StringBuilder url = new StringBuilder(256);
    
    url.append(req.getServicePath());
    if (!params.isEmpty())
    {
        boolean first = true;
        for (String key: params.keySet())
        {
            String val = params.get(key);
            if (val != null && val.length() != 0)
            {
                url.append(first ? '?' : '&');
                url.append(key);
                url.append('=');
                url.append(URLEncoder.encode(val));
                first = false;
            }
        }
    }
    if (hash != null && hash.length() != 0)
    {
        url.append('#').append(hash);
    }
    
    return url.toString();
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:29,代码来源:NodeBrowserPost.java


示例20: setAttachment

import org.springframework.extensions.surf.util.URLEncoder; //导入依赖的package包/类
/**
 * Set attachment header
 * 
 * @param req WebScriptRequest
 * @param res WebScriptResponse
 * @param attach boolean
 * @param attachFileName String
 */
public void setAttachment(WebScriptRequest req, WebScriptResponse res, boolean attach, String attachFileName)
{
    if (attach == true)
    {
        String headerValue = "attachment";
        if (attachFileName != null && attachFileName.length() > 0)
        {
            if (logger.isDebugEnabled())
                logger.debug("Attaching content using filename: " + attachFileName);

            if (req == null)
            {
                headerValue += "; filename*=UTF-8''" + URLEncoder.encode(attachFileName)
                        + "; filename=\"" + filterNameForQuotedString(attachFileName) + "\"";
            }
            else
            {
                String userAgent = req.getHeader(HEADER_USER_AGENT);
                boolean isLegacy = (null != userAgent) && (userAgent.contains("MSIE 8") || userAgent.contains("MSIE 7"));
                if (isLegacy)
                {
                    headerValue += "; filename=\"" + URLEncoder.encode(attachFileName);
                }
                else
                {
                    headerValue += "; filename=\"" + filterNameForQuotedString(attachFileName) + "\"; filename*=UTF-8''"
                            + URLEncoder.encode(attachFileName);
                }
            }
        }
        
        // set header based on filename - will force a Save As from the browse if it doesn't recognize it
        // this is better than the default response of the browser trying to display the contents
        res.setHeader("Content-Disposition", headerValue);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:45,代码来源:ContentStreamer.java



注:本文中的org.springframework.extensions.surf.util.URLEncoder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JarResource类代码示例发布时间:2022-05-22
下一篇:
Java PermissionAdmin类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap