当前位置: 首页>>代码示例>>Java>>正文


Java Form类代码示例

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


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

示例1: obtainCredentials

import org.restlet.data.Form; //导入依赖的package包/类
/**
 * Obtain credentials from the request.
 *
 * @return the credential
 */
protected Credential obtainCredentials() {
    final UsernamePasswordCredential c = new UsernamePasswordCredential();
    final WebRequestDataBinder binder = new WebRequestDataBinder(c);
    final RestletWebRequest webRequest = new RestletWebRequest(getRequest());

    final Form form = new Form(getRequest().getEntity());
    logFormRequest(form);

    if (!form.isEmpty()) {
        binder.bind(webRequest);
        return c;
    }
    LOGGER.trace("Failed to bind the request to credentials. Resulting form is empty");
    return null;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:21,代码来源:TicketResource.java

示例2: logFormRequest

import org.restlet.data.Form; //导入依赖的package包/类
/**
 * Log the form request.
 *
 * @param form the form
 */
private void logFormRequest(final Form form) {
    if (LOGGER.isDebugEnabled()) {
        final Set<String> pairs = new HashSet<>();
        for (final String name : form.getNames()) {
            final StringBuilder builder = new StringBuilder();
            builder.append(name);
            builder.append(": ");
            if (!"password".equalsIgnoreCase(name)) {
                builder.append(form.getValues(name));
            } else {
                builder.append("*****");
            }
            pairs.add(builder.toString());
        }
        LOGGER.debug(StringUtils.join(pairs, ", "));
    }
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:23,代码来源:TicketResource.java

示例3: logFormRequest

import org.restlet.data.Form; //导入依赖的package包/类
private void logFormRequest(final Form form) {
    if (LOGGER.isDebugEnabled()) {
        final Set<String> pairs = new HashSet<String>();
        for (final String name : form.getNames()) {
            final StringBuilder builder = new StringBuilder();
            builder.append(name);
            builder.append(": ");
            if (!"password".equalsIgnoreCase(name)) {
                builder.append(form.getValues(name));
            } else {
                builder.append("*****");
            }
            pairs.add(builder.toString());
        }
        LOGGER.debug(StringUtils.join(pairs, ", "));
    }
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:18,代码来源:TicketResource.java

示例4: request

import org.restlet.data.Form; //导入依赖的package包/类
@Get("json")
public String request(final String entity) throws JSONException
{
    QueryParser qp = new QueryParser();
    Form parameters = getRequest().getResourceRef().getQueryAsForm();
    qp.parseQuery(parameters);
    
    List<String> fields = Arrays.asList(new String[]{"country_geoip"});
 
    final JSONObject answer = new JSONObject();
    final JSONArray countries = new JSONArray(queryDB("upper(msim.country)", "t.mobile_network_id", "mccmnc2name msim ON msim.uid", qp));
    final JSONArray provider = new JSONArray(queryDB("mprov.name", "t.mobile_provider_id", "provider mprov ON mprov.uid", qp));
    final JSONArray providerN = new JSONArray(queryDB("prov.name", "t.provider_id", "provider prov ON prov.uid", qp));
    
    
    
    answer.put("country_mobile", countries);
    answer.put("provider_mobile", provider);
    answer.put("provider", providerN);
    
    return answer.toString();
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:23,代码来源:ChoicesResource.java

示例5: getRepresentation

import org.restlet.data.Form; //导入依赖的package包/类
@Get("csv")
public Object getRepresentation() {

    if (ds == null) {
        getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
        return null;
    }

    if (!ds.getStatus().isInitialized()) {
        getResponse().setStatus(Status.SUCCESS_ACCEPTED);
        return "Initializing...";
    }

    Form queryForm = getRequest().getOriginalRef().getQueryAsForm();
    char delimiter = queryForm.getFirstValue("delimiter", ",").charAt(0);

    return new CsvRepresentation(getStats(), true, delimiter);
}
 
开发者ID:itesla,项目名称:ipst,代码行数:19,代码来源:ITeslaStatsResource.java

示例6: subsetColumns

import org.restlet.data.Form; //导入依赖的package包/类
@Override
protected ColumnDescriptor[] subsetColumns(ColumnDescriptor[] columns, Form queryForm) {
    ColumnDescriptor[] cols = super.subsetColumns(columns, queryForm);

    for (int i=0;i<cols.length;i++) {
        ColumnDescriptor cd = cols[i];
        if (cd.getName().endsWith("_PP") && !(cd instanceof FunctionalColumn)) {
            cols[i] = new StrictlyPositive(cd.getName().substring(0, cd.getName().length()-1));
        } else if (cd.getName().endsWith("_PN") && !(cd instanceof FunctionalColumn)) {
            cols[i] = new StrictlyNegative(cd.getName().substring(0, cd.getName().length()-1));
        } else if (cd.getName().endsWith("_IP") && !(cd instanceof FunctionalColumn)) {
            cols[i] = new CurrentPowerRatio(cd.getName().substring(0, cd.getName().length()-3));
        }
    }

    return cols;
}
 
开发者ID:itesla,项目名称:ipst,代码行数:18,代码来源:ITeslaDataResource.java

示例7: postFormData

import org.restlet.data.Form; //导入依赖的package包/类
@Post
public void postFormData(final Representation entity) {
    ExtensionTokenManager tokenManager = getTokenManager();
    if (tokenManager.authenticationRequired()) {
        getResponse().setStatus(Status.CLIENT_ERROR_UNAUTHORIZED);
    } else {
        Form form = new Form(entity);
        final String emailAddress = form.getFirstValue(FORM_INPUT_EMAIL_ADDRESS);
        if (StringUtils.isNotBlank(emailAddress)) {
            TestEmailNotifier testNotifier = (TestEmailNotifier) getContext().getAttributes()
                    .get(EmailExtensionConstants.CONTEXT_ATTRIBUTE_KEY_TEST_NOTIFIER);
            testNotifier.setEmailAddress(emailAddress);
            testNotifier.run();
            testNotifier.setEmailAddress("");
        }
    }
}
 
开发者ID:blackducksoftware,项目名称:hub-email-extension,代码行数:18,代码来源:EmailTestServerResource.java

示例8: getEasyJson

import org.restlet.data.Form; //导入依赖的package包/类
public   Map<String,Object>  getEasyJson(Form form){
	 Map<String,Object> returnMap= new HashMap<String, Object>();
	List<Map<String,Object>> list= new  ArrayList<Map<String,Object>>();
	 Map<String,Object> map= new HashMap<String, Object>();
	 map.put("name", 123);
	 map.put("picUrl", "www.baidu.com");
	 list.add(map);
	 list.add(map);
	 list.add(map);
	 returnMap.put("ret", 0);
	 returnMap.put("test", "ok");
	 returnMap.put("data", list);
	 for(Entry<String, Object> entry : map.entrySet()){
           String strkey = entry.getKey();
           Object strval = entry.getValue();
       }
	 return returnMap;
}
 
开发者ID:jialiuyang,项目名称:appBack,代码行数:19,代码来源:Yun15Method.java

示例9: writeRequest

import org.restlet.data.Form; //导入依赖的package包/类
@Override
public boolean writeRequest(Object requestObject, Request request) throws ResourceException
{
   if (requestObject instanceof Form)
   {
      // Form as query parameters
      if (request.getMethod().equals(Method.GET))
         request.getResourceRef().setQuery(((Form)requestObject).getQueryString());
      else
         request.setEntity(((Form)requestObject).getWebRepresentation(CharacterSet.UTF_8));

      return true;
   }

   return false;
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:17,代码来源:FormRequestWriter.java

示例10: parse

import org.restlet.data.Form; //导入依赖的package包/类
/**
 * Parses a post into a given form.
 * 
 * @param form
 *            The target form.
 * @param post
 *            The posted form.
 * @param decode
 *            Indicates if the parameters should be decoded.
 */
public static void parse(Form form, Representation post, boolean decode) {
    if (post != null) {
        if (post.isAvailable()) {
            FormReader fr = null;

            try {
                fr = new FormReader(post, decode);
            } catch (IOException ioe) {
                Context.getCurrentLogger().log(Level.WARNING,
                        "Unable to create a form reader. Parsing aborted.",
                        ioe);
            }

            if (fr != null) {
                fr.addParameters(form);
            }
        } else {
            Context.getCurrentLogger()
                    .log(Level.FINE,
                            "The form wasn't changed as the given representation isn't available.");
        }
    }
}
 
开发者ID:DeviceConnect,项目名称:DeviceConnect-Android,代码行数:34,代码来源:FormUtils.java

示例11: read

import org.restlet.data.Form; //导入依赖的package包/类
/**
 * Reads all the parameters.
 * 
 * @return The form read.
 * @throws IOException
 *             If the parameters could not be read.
 */
public Form read() throws IOException {
    Form result = new Form();

    if (this.stream != null) {
        Parameter param = readNextParameter();

        while (param != null) {
            result.add(param);
            param = readNextParameter();
        }

        this.stream.close();
    }

    return result;
}
 
开发者ID:DeviceConnect,项目名称:DeviceConnect-Android,代码行数:24,代码来源:FormReader.java

示例12: requestToken

import org.restlet.data.Form; //导入依赖的package包/类
/**
     * Handles the {@link Post} request. The client MUST use the HTTP "POST"
     * method when making access token requests. (3.2. Token Endpoint)
     * 
     * @param input
     *            HTML form formated token request per oauth-v2 spec.
     * @return JSON response with token or error.<br>
     * 			※Local OAuth ではResultRepresentation型のポインタを返す。<br>
     * 			getResult()=trueならアクセストークンが含まれている。アクセストークンはgetText()で取得する。<br>
     * 			getResult()=falseならエラー。アクセストークンは取得できない。<br>
     */
    public static Representation requestToken(Representation input)
            throws OAuthException, JSONException {
        getLogger().fine("Grant request");
        final Form params = new Form(input);

        final GrantType grantType = getGrantType(params);
        switch (grantType) {
        case authorization_code:
            getLogger().info("Authorization Code Grant");
            return doAuthCodeFlow(params);
//        case password:
//        	getLogger().info("Resource Owner Password Credentials Grant");
//            return doPasswordFlow(params);
//        case client_credentials:
//        	getLogger().info("Client Credentials Grantt");
//            return doClientFlow(params);
//        case refresh_token:
//        	getLogger().info("Refreshing an Access Token");
//            return doRefreshFlow(params);
        default:
            getLogger().warning("Unsupported flow: " + grantType);
            throw new OAuthException(OAuthError.unsupported_grant_type,
                    "Flow not supported", null);
        }
    }
 
开发者ID:DeviceConnect,项目名称:DeviceConnect-Android,代码行数:37,代码来源:AccessTokenServerResource.java

示例13: getGrantType

import org.restlet.data.Form; //导入依赖的package包/类
/**
 * Get request parameter "grant_type".
 * 
 * @param params
 * @return
 * @throws OAuthException
 */
protected static GrantType getGrantType(Form params) throws OAuthException {
    String typeString = params.getFirstValue(GRANT_TYPE);
    getLogger().info("Type: " + typeString);
    try {
        GrantType type = Enum.valueOf(GrantType.class, typeString);
        getLogger().fine("Found flow - " + type);
        return type;
    } catch (IllegalArgumentException iae) {
        throw new OAuthException(OAuthError.unsupported_grant_type,
                "Unsupported flow", null);
    } catch (NullPointerException npe) {
        throw new OAuthException(OAuthError.invalid_request,
                "No grant_type parameter found.", null);
    }
}
 
开发者ID:DeviceConnect,项目名称:DeviceConnect-Android,代码行数:23,代码来源:AccessTokenServerResource.java

示例14: getClient

import org.restlet.data.Form; //导入依赖的package包/类
/**
 * Get request parameter "client_id".
 * 
 * @param params
 * @return
 * @throws OAuthException
 */
protected static Client getClient(Form params) throws OAuthException {
    // check clientId:
    String clientId = params.getFirstValue(CLIENT_ID);
    if (clientId == null || clientId.isEmpty()) {
        getLogger().warning("Could not find client ID");
        throw new OAuthException(OAuthError.invalid_request,
                "No client_id parameter found.", null);
    }
    Client client = clients.findById(clientId);
    getLogger().fine("Client = " + client);
    if (client == null) {
    	getLogger().warning("Need to register the client : " + clientId);
        throw new OAuthException(OAuthError.invalid_request,
                "Need to register the client : " + clientId, null);
    }

    return client;
}
 
开发者ID:DeviceConnect,项目名称:DeviceConnect-Android,代码行数:26,代码来源:OAuthServerResource.java

示例15: doInit

import org.restlet.data.Form; //导入依赖的package包/类
/**
 * Initializes the resource, and delegates to the <code>handleInit()</code>
 * entry point in the executable.
 */
@Override
protected void doInit() throws ResourceException
{
	super.doInit();
	setAnnotated( false );

	if( attributes.isSourceViewable() )
	{
		Request request = getRequest();
		Form query = request.getResourceRef().getQueryAsForm();
		if( TRUE.equals( query.getFirstValue( SOURCE ) ) )
			// Bypass doInit delegation
			return;
	}

	DelegatedResourceConversationService conversationService = new DelegatedResourceConversationService( this, null, null, attributes.getDefaultCharacterSet() );
	enter( attributes.getEntryPointNameForInit(), true, conversationService );
}
 
开发者ID:tliron,项目名称:prudence,代码行数:23,代码来源:DelegatedResource.java


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