本文整理汇总了Java中org.restlet.util.Series类的典型用法代码示例。如果您正苦于以下问题:Java Series类的具体用法?Java Series怎么用?Java Series使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Series类属于org.restlet.util包,在下文中一共展示了Series类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: request
import org.restlet.util.Series; //导入依赖的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.util.Series; //导入依赖的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: parse
import org.restlet.util.Series; //导入依赖的package包/类
/**
* Parses a post into a given entries series.
*
* @param entries
* The target entries series.
* @param post
* The posted form.
*/
public static void parse(Series<FormData> entries, Representation post) {
if (post != null) {
if (post.isAvailable()) {
FormReader fr = null;
try {
fr = new FormReader(post);
} catch (IOException ioe) {
Context.getCurrentLogger().warn("Unable to create a form reader. Parsing aborted.", ioe);
}
if (fr != null) {
fr.addEntries(entries);
}
} else {
throw new IllegalStateException(
"The Web form cannot be parsed as no fresh content is available. If this entity has been already read once, caching of the entity is required");
}
}
}
示例4: parseRequest
import org.restlet.util.Series; //导入依赖的package包/类
/**
* Parses an authenticate header into a list of challenge request. The
* header is {@link HeaderConstants#HEADER_WWW_AUTHENTICATE}.
*
* @param header
* The HTTP header value to parse.
* @param httpHeaders
* The current response HTTP headers.
* @return The list of parsed challenge request.
*/
public static List<ChallengeRequest> parseRequest(Response response,
String header, Series<Header> httpHeaders) {
List<ChallengeRequest> result = new ArrayList<ChallengeRequest>();
if (header != null) {
result = new ChallengeRequestReader(header).readValues();
for (ChallengeRequest cr : result) {
// Give a chance to the authenticator helper to do further
// parsing
AuthenticatorHelper helper = Engine.getInstance().findHelper(
cr.getScheme(), true, false);
if (helper != null) {
helper.parseRequest(cr, response, httpHeaders);
} else {
Context.getCurrentLogger().warn(
"Couldn't find any helper support the "
+ cr.getScheme() + " challenge scheme.");
}
}
}
return result;
}
示例5: processHeaders
import org.restlet.util.Series; //导入依赖的package包/类
/**
* Updates the request method based on specific header.
*
* @param request
* The request to update.
*/
@SuppressWarnings("unchecked")
private void processHeaders(Request request) {
final TunnelService tunnelService = getTunnelService();
if (tunnelService.isMethodTunnel()) {
// get the headers
Series<Header> extraHeaders = (Series<Header>) request
.getAttributes().get(HeaderConstants.ATTRIBUTE_HEADERS);
if (extraHeaders != null) {
// look for the new value of the method
final String newMethodValue = extraHeaders.getFirstValue(
getTunnelService().getMethodHeader(), true);
if (newMethodValue != null
&& newMethodValue.trim().length() > 0) {
// set the current method to the new method
request.setMethod(Method.valueOf(newMethodValue));
}
}
}
}
示例6: getRequestHeaders
import org.restlet.util.Series; //导入依赖的package包/类
@Override
public Series<Header> getRequestHeaders() {
final Series<Header> result = super.getRequestHeaders();
if (!this.requestHeadersAdded) {
final Iterable<Map.Entry<String, String>> headers = getNettyRequest().headers();
for (Map.Entry<String, String> header : headers) {
result.add(header.getKey(), header.getValue());
}
this.requestHeadersAdded = true;
}
return result;
}
示例7: getCookies
import org.restlet.util.Series; //导入依赖的package包/类
/**
* Returns the cookies provided by the client.
*
* @return The cookies provided by the client.
*/
@Override
public Series<Cookie> getCookies() {
Series<Cookie> result = super.getCookies();
if (!this.cookiesAdded) {
String cookieValues = getHeaders().getValues(HeaderConstants.HEADER_COOKIE);
if (cookieValues != null) {
new CookieReader(cookieValues).addValues(result);
}
this.cookiesAdded = true;
}
return result;
}
示例8: getHeaders
import org.restlet.util.Series; //导入依赖的package包/类
@Override
public Series<Header> getHeaders() {
final Series<Header> result = super.getHeaders();
if (!this.headersAdded) {
Entry<CharSequence, CharSequence> header = null;
for (Iterator<Entry<CharSequence, CharSequence>> headers = getNettyRequest().headers()
.iteratorCharSequence(); headers.hasNext();) {
header = headers.next();
result.add(header.getKey().toString(), header.getValue().toString());
}
getAttributes().put(HeaderConstants.ATTRIBUTE_HEADERS,
result);
this.headersAdded = true;
}
return result;
}
示例9: getCookies
import org.restlet.util.Series; //导入依赖的package包/类
/**
* Returns the cookies provided by the client.
*
* @return The cookies provided by the client.
*/
@Override
public Series<Cookie> getCookies() {
Series<Cookie> result = super.getCookies();
if (!this.cookiesAdded) {
String cookieValues = getHttpCall().getRequestHeaders().getValues(HeaderConstants.HEADER_COOKIE);
if (cookieValues != null) {
new CookieReader(cookieValues).addValues(result);
}
this.cookiesAdded = true;
}
return result;
}
示例10: Call
import org.restlet.util.Series; //导入依赖的package包/类
/**
* Constructor.
*/
public Call() {
this.hostDomain = null;
this.hostPort = -1;
this.clientAddress = null;
this.clientPort = -1;
this.confidential = false;
this.method = null;
this.protocol = null;
this.reasonPhrase = "";
this.requestHeaders = new Series<>(Header.class);
this.requestUri = null;
this.responseHeaders = new Series<Header>(Header.class);
this.serverAddress = null;
this.serverPort = -1;
this.statusCode = 200;
this.userPrincipal = null;
this.version = null;
}
示例11: addExtensionHeaders
import org.restlet.util.Series; //导入依赖的package包/类
/**
* Adds extension headers if they are non-standard headers.
*
* @param existingHeaders
* The headers to update.
* @param additionalHeaders
* The headers to add.
*/
public static void addExtensionHeaders(Series<Header> existingHeaders,
Series<Header> additionalHeaders) {
if (additionalHeaders != null) {
for (Header param : additionalHeaders) {
if (STANDARD_HEADERS.contains(param.getName())) {
// Standard headers that can't be overridden
Context.getCurrentLogger()
.warn(
"Addition of the standard header \""
+ param.getName()
+ "\" is not allowed. Please use the equivalent property in the Restlet API.");
} else if (UNSUPPORTED_STANDARD_HEADERS.contains(param
.getName())) {
Context.getCurrentLogger()
.warn(
"Addition of the standard header \""
+ param.getName()
+ "\" is discouraged as a future version of the Restlet API will directly support it.");
existingHeaders.add(param);
} else {
existingHeaders.add(param);
}
}
}
}
示例12: addGeneralHeaders
import org.restlet.util.Series; //导入依赖的package包/类
/**
* Adds the general headers from the {@link Message} to the {@link Series}.
*
* @param message
* The source {@link Message}.
* @param headers
* The target headers {@link Series}.
*/
public static void addGeneralHeaders(Message message, Series<Header> headers) {
addHeader(HeaderConstants.HEADER_CACHE_CONTROL,
CacheDirectiveWriter.write(message.getCacheDirectives()),
headers);
if (message.getDate() == null) {
message.setDate(new Date());
}
addHeader(HeaderConstants.HEADER_DATE,
DateWriter.write(message.getDate()), headers);
addHeader(HeaderConstants.HEADER_VIA,
RecipientInfoWriter.write(message.getRecipientsInfo()), headers);
addHeader(HeaderConstants.HEADER_WARNING,
WarningWriter.write(message.getWarnings()), headers);
}
示例13: addNotModifiedEntityHeaders
import org.restlet.util.Series; //导入依赖的package包/类
/**
* Adds the entity headers based on the {@link Representation} to the {@link Series} when a 304 (Not Modified)
* status is returned.
*
* @param entity
* The source entity {@link Representation}.
* @param headers
* The target headers {@link Series}.
*/
public static void addNotModifiedEntityHeaders(Representation entity,
Series<Header> headers) {
if (entity != null) {
if (entity.getTag() != null) {
HeaderUtils.addHeader(HeaderConstants.HEADER_ETAG,
TagWriter.write(entity.getTag()), headers);
}
if (entity.getLocationRef() != null) {
HeaderUtils.addHeader(HeaderConstants.HEADER_CONTENT_LOCATION,
entity.getLocationRef().getTargetRef().toString(),
headers);
}
}
}
示例14: getContentLength
import org.restlet.util.Series; //导入依赖的package包/类
/**
* Returns the content length of the request entity if know, {@link Representation#UNKNOWN_SIZE} otherwise.
*
* @return The request content length.
*/
public static long getContentLength(Series<Header> headers) {
long contentLength = Representation.UNKNOWN_SIZE;
if (headers != null) {
// Extract the content length header
for (Header header : headers) {
if (header.getName().equalsIgnoreCase(
HeaderConstants.HEADER_CONTENT_LENGTH)) {
try {
contentLength = Long.parseLong(header.getValue());
} catch (NumberFormatException e) {
contentLength = Representation.UNKNOWN_SIZE;
}
}
}
}
return contentLength;
}
示例15: createContentType
import org.restlet.util.Series; //导入依赖的package包/类
/**
* Creates a content type.
*
* @param mediaType
* The media type name.
* @param parameters
* The parameters parsed.
* @return The content type.
*/
private ContentType createContentType(StringBuilder mediaType,
Series<Parameter> parameters) {
// Attempt to extract the character set
CharacterSet characterSet = null;
if (parameters != null) {
String charSet = parameters.getFirstValue("charset");
if (charSet != null) {
parameters.removeAll("charset");
characterSet = new CharacterSet(charSet);
}
return new ContentType(new MediaType(mediaType.toString(),
parameters), characterSet);
}
return new ContentType(new MediaType(mediaType.toString()), null);
}