本文整理汇总了Java中org.restlet.data.Parameter类的典型用法代码示例。如果您正苦于以下问题:Java Parameter类的具体用法?Java Parameter怎么用?Java Parameter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Parameter类属于org.restlet.data包,在下文中一共展示了Parameter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: request
import org.restlet.data.Parameter; //导入依赖的package包/类
@Get("json")
public String request(final String entity)
{
try
{
final JSONObject answer = new JSONObject();
answer.put("version", RevisionHelper.getVerboseRevision());
answer.put("system_UUID", getSetting("system_UUID",""));
final Series<Parameter> ctxParams = getContext().getParameters();
final String hostId = ctxParams.getFirstValue("HOST_ID");
if (hostId != null)
answer.put("host",hostId);
return answer.toString();
}
catch (JSONException e)
{
e.printStackTrace();
return null;
}
}
示例2: request
import org.restlet.data.Parameter; //导入依赖的package包/类
@Get("json")
public String request(final String entity)
{
addAllowOrigin();
try
{
final JSONObject answer = new JSONObject();
answer.put("version", RevisionHelper.getVerboseRevision());
answer.put("system_UUID", getSetting("system_UUID",""));
final Series<Parameter> ctxParams = getContext().getParameters();
final String hostId = ctxParams.getFirstValue("HOST_ID");
if (hostId != null)
answer.put("host",hostId);
return answer.toString();
}
catch (JSONException e)
{
e.printStackTrace();
return null;
}
}
示例3: read
import org.restlet.data.Parameter; //导入依赖的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;
}
示例4: readFirstParameter
import org.restlet.data.Parameter; //导入依赖的package包/类
/**
* Reads the first parameter with the given name.
*
* @param name
* The parameter name to match.
* @return The parameter value.
* @throws IOException
*/
public Parameter readFirstParameter(String name) throws IOException {
Parameter result = null;
if (this.stream != null) {
Parameter param = readNextParameter();
while ((param != null) && (result == null)) {
if (param.getName().equals(name)) {
result = param;
}
param = readNextParameter();
}
this.stream.close();
}
return result;
}
示例5: getForm
import org.restlet.data.Parameter; //导入依赖的package包/类
/**
* The form, sent via POST or PUT, as a map. In the case of duplicate keys,
* only the last one will appear. Uploaded files will appear as instances of
* {@link FileParameter}. Other fields will be plain strings.
* <p>
* This value is cached locally.
*
* @return The form
*/
public Map<String, Object> getForm()
{
if( form == null )
{
form = new HashMap<String, Object>();
for( Parameter parameter : getFormAll() )
{
if( parameter instanceof FileParameter )
form.put( parameter.getName(), parameter );
else
form.put( parameter.getName(), parameter.getValue() );
}
}
return form;
}
示例6: initialize
import org.restlet.data.Parameter; //导入依赖的package包/类
@Override
protected void initialize()
{
if( request.getMethod().equals( Method.POST ) )
{
// Give the exposed file map a chance to consume the entity first
exposedFile.validateInitialized();
map.putAll( exposedFile.formFields );
if( request.isEntityAvailable() )
{
Form form = new Form( request.getEntity() );
for( Parameter parameter : form )
map.put( parameter.getName(), parameter.getValue() );
}
}
}
示例7: readValue
import org.restlet.data.Parameter; //导入依赖的package包/类
@Override
public LinkHeader readValue() throws IOException
{
LinkHeader linkHeader = readValueOnlyReference();
while( true )
{
if( !skipParameterSeparator() )
break;
Parameter parameter = readParameter();
if( parameter == null )
throw new IOException( "Invalid Link header. Parameter separator is not followed by a parameter." );
linkHeader.getParameters().put( parameter.getName(), parameter.getValue() );
}
return linkHeader;
}
示例8: list
import org.restlet.data.Parameter; //导入依赖的package包/类
@Override
public List<Car> list() {
Client client = new Client(new Context(), Protocol.HTTPS);
Series<Parameter> parameters = client.getContext().getParameters();
parameters.add("truststorePath", System.getProperty("javax.net.ssl.trustStore"));
ClientResource clientResource = new ClientResource("https://localhost:8043/api/cars/cars");
clientResource.setNext(client);
ChallengeResponse challenge = new ChallengeResponse(ChallengeScheme.HTTP_OAUTH_BEARER);
challenge.setRawValue(Request.getCurrent().getAttributes().getOrDefault("token", "").toString());
clientResource.setChallengeResponse(challenge);
CarServiceInterface carServiceInterface = clientResource.wrap(CarServiceInterface.class);
Car[] allCars = carServiceInterface.getAllCars();
try {
client.stop();
} catch (Exception e) {
throw new RuntimeException(e);
}
return asList(allCars);
}
示例9: createObjectWriter
import org.restlet.data.Parameter; //导入依赖的package包/类
@Override
protected ObjectWriter createObjectWriter() {
ObjectWriter writer = super.createObjectWriter();
for (SerializationFeature feature : SerializationFeature.values()) {
boolean hasDefault = DEFAULT_SERIALIZATION_FEATURES.contains(feature);
Parameter parameter = ContextUtils.getParameter(ContextUtils.getCurrentApplicationContext(), SERIALIZATION_FEATURE + feature.name());
if ((parameter != null) || hasDefault) {
if (ContextUtils.getParameterAsBoolean(parameter, feature.enabledByDefault() || hasDefault)) {
writer = writer.with(feature);
} else {
writer = writer.without(feature);
}
}
}
return writer;
}
示例10: createContext
import org.restlet.data.Parameter; //导入依赖的package包/类
protected Context createContext(Context parentContext, Element useConf)
{
Context appContext = parentContext.createChildContext();
String copy = DocumentLoader.getAttributeValue(useConf,"copy");
if (copy==null || "parameters".equals(copy) || "all".equals(copy)) {
for (Parameter param : parentContext.getParameters()) {
appContext.getParameters().add(param);
}
}
if (copy==null || "attributes".equals(copy) || "all".equals(copy)) {
for (String key : parentContext.getAttributes().keySet()) {
appContext.getAttributes().put(key,parentContext.getAttributes().get(key));
}
}
loadContext(appContext,useConf);
return appContext;
}
示例11: getResponseHeaders
import org.restlet.data.Parameter; //导入依赖的package包/类
/**
* Returns the modifiable list of response headers.
*
* @return The modifiable list of response headers.
*/
@Override
public Series<Parameter> getResponseHeaders() {
Series<Parameter> result = super.getResponseHeaders();
if (!this.responseHeadersAdded) {
if ((getHttpResponse() != null)
&& (getHttpResponse().getAllHeaders() != null)) {
for (Header header : getHttpResponse().getAllHeaders()) {
result.add(header.getName(), header.getValue());
}
}
this.responseHeadersAdded = true;
}
return result;
}
示例12: makeResponse
import org.restlet.data.Parameter; //导入依赖的package包/类
/**
* @param response The response to parse
* @return A HttpResponse object made by consuming the response of the
* given HttpMethod.
* @throws IOException when problems occur processing the body content
*/
@SuppressWarnings("unchecked")
private HttpResponse makeResponse(Response response) throws IOException {
HttpResponseBuilder builder = new HttpResponseBuilder();
Series<Parameter> headers = (Series<Parameter>) response.getAttributes().get("org.restlet.http.headers");
if (headers != null) {
for (Parameter param : headers) {
if (param.getName() != null) {
builder.addHeader(param.getName(), param.getValue());
}
}
}
Representation entity = Preconditions.checkNotNull(response.getEntity());
if (maxObjSize > 0 && entity != null && entity.getSize() > maxObjSize) {
return HttpResponse.badrequest("Exceeded maximum number of bytes - " + maxObjSize);
}
return builder.setHttpStatusCode(response.getStatus().getCode()).setResponse(toByteArraySafe(entity)).create();
}
示例13: getUserPrefs
import org.restlet.data.Parameter; //导入依赖的package包/类
/**
* @param req
* @return UserPrefs, if any are set for this request.
*/
private static UserPrefs getUserPrefs(Series<Parameter> req) {
Map<String, String> prefs = Maps.newHashMap();
Iterator<String> paramNames = req.getNames().iterator();
if (paramNames == null) {
return null;
}
while (paramNames.hasNext()) {
String paramName = paramNames.next();
if (paramName.startsWith(USERPREF_PARAM_PREFIX)) {
String prefName = paramName.substring(USERPREF_PARAM_PREFIX.length());
prefs.put(prefName, req.getFirstValue(paramName));
}
}
return new UserPrefs(prefs);
}
示例14: XlayerClient
import org.restlet.data.Parameter; //导入依赖的package包/类
public XlayerClient(URL serviceAddr) throws ConfigException {
serviceAddress = serviceAddr;
try {
serviceURI = serviceAddr.toURI();
} catch (Exception err) {
throw new ConfigException("Bad Service Address", err);
}
/*
* Not-so-super convincing timeout settings documented here:
* http://restlet.com/technical-resources/restlet-framework/javadocs/2.3
* /jse/engine/org/restlet/engine/connector/HttpClientHelper.html
*
* Hard to find complete info on timeouts for HTTP in restlet.
*/
serviceContext.getParameters().add(new Parameter("socketTimeout", SO_TIMEOUT_STRING));
serviceContext.getParameters().add(new Parameter("readTimeout", READ_TIMEOUT_STRING));
serviceContext.getParameters().add(new Parameter("socketConnectTimeoutMs", CONN_TIMEOUT_STRING));
}
示例15: getRequestHeaders
import org.restlet.data.Parameter; //导入依赖的package包/类
/**
* Returns the list of request headers.
*
* @return The list of request headers.
*/
@Override
@SuppressWarnings("unchecked")
public Series<Parameter> getRequestHeaders() {
if (this.requestHeaders == null) {
this.requestHeaders = new Form();
// Copy the headers from the request object
String headerName;
String headerValue;
for (final Enumeration<String> names = getRequest()
.getHeaderNames(); names.hasMoreElements();) {
headerName = names.nextElement();
for (final Enumeration<String> values = getRequest()
.getHeaders(headerName); values.hasMoreElements();) {
headerValue = values.nextElement();
this.requestHeaders.add(new Parameter(headerName,
headerValue));
}
}
}
return this.requestHeaders;
}