本文整理汇总了Java中org.simpleframework.http.Path类的典型用法代码示例。如果您正苦于以下问题:Java Path类的具体用法?Java Path怎么用?Java Path使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Path类属于org.simpleframework.http包,在下文中一共展示了Path类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: formatRequest
import org.simpleframework.http.Path; //导入依赖的package包/类
/** Format the HTTP request path as a multiline string. */
public String formatRequest(Request request) {
Query query = request.getQuery();
// poss. optimization, but how to use it?:
boolean persistent = request.isKeepAlive();
Path path = request.getPath();
String directory = path.getDirectory();
String name = path.getName();
String[] segments = path.getSegments();
return "Query: " + query + (persistent ? " (persistent)\n" : "\n")
+ "Path: " + path + " (" + segments.length + " segments)\n"
+ "Directory: " + directory + "\n"
+ "Name: " + name + "\n";
}
开发者ID:coil-lighting,项目名称:udder,代码行数:17,代码来源:HttpServiceContainer.java
示例2: getPathParameter
import org.simpleframework.http.Path; //导入依赖的package包/类
@Test
public void getPathParameter() {
Request request = mock(Request.class);
Path path = mock(Path.class);
when(path.getPath()).thenReturn("/first-name/John/last-name/Doe");
when(request.getPath()).thenReturn(path);
Route route = new Route("/first-name/:firstName/last-name/:lastName");
SimpleHttpRequest req = new SimpleHttpRequest(request, null, route, null);
assertEquals("John", req.getPathParameter("firstName"));
assertEquals("Doe", req.getPathParameter("lastName"));
assertNull(req.getPathParameter("nonExistentPathParam"));
}
开发者ID:lantunes,项目名称:fixd,代码行数:17,代码来源:TestSimpleHttpRequest.java
示例3: handle
import org.simpleframework.http.Path; //导入依赖的package包/类
public void handle(Request request, Response response) {
Path path = request.getPath();
String action = path.getDirectory()+path.getName();
String result = "";
log.debug("Request: "+action);
// Handle request
if(action.equals("/listLoadBalancer")) result = listLoadBalancer();
else if(action.equals("/addAutoScalePolicy")) result = addAutoScalePolicy(request);
else if(action.equals("/removeAutoScalePolicy")) result = removeAutoScalePolicy(request);
else result = "Not Supported";
// Handle response
try {
PrintStream body = response.getPrintStream();
long time = System.currentTimeMillis();
response.setValue("Content-Type", "text/javascript");
response.setValue("Server", "AutoScaleAPI/1.0");
response.setDate("Date", time);
response.setDate("Last-Modified", time);
body.println(result);
body.close();
} catch(Exception e) {
log.error("Could not connect to cloudstack api",e);
}
}
开发者ID:hlipala,项目名称:autoscaling,代码行数:32,代码来源:ApiServer.java
示例4: getPath
import org.simpleframework.http.Path; //导入依赖的package包/类
public Path getPath() {
return header.getPath();
}
开发者ID:blobrobotics,项目名称:bstation,代码行数:4,代码来源:MockProxyRequest.java
示例5: getPath
import org.simpleframework.http.Path; //导入依赖的package包/类
public Path getPath() {
return new AddressParser(target).getPath();
}
开发者ID:blobrobotics,项目名称:bstation,代码行数:4,代码来源:MockRequest.java
示例6: createCommand
import org.simpleframework.http.Path; //导入依赖的package包/类
/** Return a Command object bearing a payload relevant to the given route,
* or die trying and throw an exception. Never return null.
*
* Example command-line test query:
* curl --data "state={\"r\":1.0,\"g\":0.5,\"b\":0.25}" localhost:8080/mixer0/layer0
*/
public Command createCommand(Request request)
throws UnsupportedEncodingException,
RoutingException,
CommandParserException,
SoftenedException, // generic wrapper for a boon JSON parser exception
ClassCastException // sometimes a Boon JSON parser exception in disguise
{
Query query = request.getQuery();
Path path = request.getPath();
String route = path.toString();
Class stateClass = this.commandMap.get(route);
if (stateClass == null) {
throw new RoutingException("No route for path: " + route);
} else {
String rawState = query.get("state");
if (rawState == null) {
throw new CommandParserException("The 'state' request param is required for " + route);
} else {
String json = URLDecoder.decode(rawState, "UTF-8");
if (json == null) {
throw new CommandParserException("Failed to URL-decode a raw JSON string for " + route);
} else {
// This works fine, but the JsonFactory for some reason wants a
// Class<T>, not a plain class. Causes an unchecked conversion warning.
Object state = JsonFactory.fromJson(json, stateClass);
if (state == null) {
throw new CommandParserException(
"Failed to deserialize a JSON command of length "
+ json.length() + " for " + route);
} else if (state.getClass() == stateClass) {
return new Command(route, state);
} else {
throw new CommandParserException(
"Failed to convert a command of length "
+ json.length() + " for " + route + " into a "
+ stateClass.getSimpleName() + ".");
}
}
}
}
}
开发者ID:coil-lighting,项目名称:udder,代码行数:54,代码来源:HttpServiceContainer.java
示例7: getPath
import org.simpleframework.http.Path; //导入依赖的package包/类
/**
* This is used to retrieve the path of this URI. The path part
* is the most fundamental part of the URI. This will return
* the value of the path. If there is no path part then this
* will return <code>/</code> to indicate the root.
* <p>
* The <code>Path</code> object returned by this will contain
* no path parameters. The path parameters are available using
* the <code>Address</code> methods. The reason that this does not
* contain any of the path parameters is so that if the path is
* needed to be converted into an OS specific path then the path
* parameters will not need to be separately parsed out.
*
* @return the path that this URI contains, this value will not
* contain any back references such as "./" and "../" or any
* path parameters
*/
public Path getPath(){
if(normal == null) {
String text = path.toString();
if(text == null) {
normal = new PathParser("/");
}
if(normal == null){
normal = new PathParser(text);
}
}
return normal;
}
开发者ID:blobrobotics,项目名称:bstation,代码行数:31,代码来源:AddressParser.java
示例8: setPath
import org.simpleframework.http.Path; //导入依赖的package包/类
/**
* This will set the path to whatever value it is given. If the
* value is null then this <code>Address.toString</code> method
* will not contain the path, that is if path is null then it will
* be interpreted as <code>/</code>.
* <p>
* This will reset the parameters this URI has. If the value
* given to this method has embedded parameters these will form
* the parameters of this URI. The value given may not be the
* same value that the <code>getPath</code> produces. The path
* will have all back references and parameters stripped.
*
* @param path the path that this URI is to be set with
*/
public void setPath(Path path) {
if(path != null){
normal = path;
}else {
setPath("/");
}
}
开发者ID:blobrobotics,项目名称:bstation,代码行数:22,代码来源:AddressParser.java
示例9: getPath
import org.simpleframework.http.Path; //导入依赖的package包/类
/**
* This is used to retrive the path of this URI. The path part is the most
* fundemental part of the URI. This will return the value of the path. If
* there is no path part then this will return <code>/</code> to indicate
* the root.
* <p>
* The <code>Path</code> object returned by this will contain no path
* parameters. The path parameters are available using the
* <code>Address</code> methods. The reason that this does not contain any
* of the path parameters is so that if the path is needed to be converted
* into ab OS specific path then the path parameters will not need to be
* separately parsed out.
*
* @return the path that this URI contains, this value will not contain any
* back references such as "./" and "../" or any path parameters
*/
@Override
public Path getPath() {
String text = this.path.toString();
if (text == null) {
this.normal = new PathParser("/");
}
if (this.normal == null) {
this.normal = new PathParser(text);
}
return this.normal;
}
开发者ID:TehSomeLuigi,项目名称:someluigis-peripherals,代码行数:29,代码来源:AddressParser.java
示例10: setPath
import org.simpleframework.http.Path; //导入依赖的package包/类
/**
* This will set the path to whatever value it is given. If the value is
* null then this <code>Address.toString</code> method will not contain the
* path, that is if path is null then it will be interpreted as
* <code>/</code>.
* <p>
* This will reset the parameters this URI has. If the value given to this
* method has embedded parameters these will form the parameters of this
* URI. The value given may not be the same value that the
* <code>getPath</code> produces. The path will have all back references and
* parameters stripped.
*
* @param path
* the path that this URI is to be set with
*/
public void setPath(Path path) {
if (path != null) {
this.normal = path;
} else {
this.setPath("/");
}
}
开发者ID:TehSomeLuigi,项目名称:someluigis-peripherals,代码行数:23,代码来源:AddressParser.java
示例11: getPath
import org.simpleframework.http.Path; //导入依赖的package包/类
/**
* This is used to acquire the path as extracted from the
* the HTTP request URI. The <code>Path</code> object that is
* provided by this method is immutable, it represents the
* normalized path only part from the request URI.
*
* @return this returns the normalized path for the request
*/
Path getPath();
开发者ID:blobrobotics,项目名称:bstation,代码行数:10,代码来源:Header.java
示例12: getPath
import org.simpleframework.http.Path; //导入依赖的package包/类
/**
* This is used to acquire the path as extracted from the
* the HTTP request URI. The <code>Path</code> object that is
* provided by this method is immutable, it represents the
* normalized path only part from the request URI.
*
* @return this returns the normalized path for the request
*/
public Path getPath() {
return getAddress().getPath();
}
开发者ID:blobrobotics,项目名称:bstation,代码行数:12,代码来源:RequestConsumer.java
示例13: getPath
import org.simpleframework.http.Path; //导入依赖的package包/类
/**
* This is used to acquire the path as extracted from the HTTP
* request URI. The <code>Path</code> object that is provided by
* this method is immutable, it represents the normalized path
* only part from the request uniform resource identifier.
*
* @return this returns the normalized path for the request
*/
public Path getPath() {
return header.getPath();
}
开发者ID:blobrobotics,项目名称:bstation,代码行数:12,代码来源:RequestMessage.java
示例14: getPath
import org.simpleframework.http.Path; //导入依赖的package包/类
/**
* This is used to acquire the path as extracted from the the HTTP request
* URI. The <code>Path</code> object that is provided by this method is
* immutable, it represents the normalized path only part from the request
* URI.
*
* @return this returns the normalized path for the request
*/
Path getPath();
开发者ID:TehSomeLuigi,项目名称:someluigis-peripherals,代码行数:10,代码来源:Header.java
示例15: getPath
import org.simpleframework.http.Path; //导入依赖的package包/类
/**
* This is used to acquire the path as extracted from the the HTTP request
* URI. The <code>Path</code> object that is provided by this method is
* immutable, it represents the normalized path only part from the request
* URI.
*
* @return this returns the normalized path for the request
*/
@Override
public Path getPath() {
return this.getAddress().getPath();
}
开发者ID:TehSomeLuigi,项目名称:someluigis-peripherals,代码行数:13,代码来源:RequestConsumer.java
示例16: getPath
import org.simpleframework.http.Path; //导入依赖的package包/类
/**
* This is used to acquire the path as extracted from the HTTP request URI.
* The <code>Path</code> object that is provided by this method is
* immutable, it represents the normalized path only part from the request
* uniform resource identifier.
*
* @return this returns the normalized path for the request
*/
@Override
public Path getPath() {
return this.header.getPath();
}
开发者ID:TehSomeLuigi,项目名称:someluigis-peripherals,代码行数:13,代码来源:RequestMessage.java
注:本文中的org.simpleframework.http.Path类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论