本文整理了Java中org.restlet.data.Protocol.valueOf()
方法的一些代码示例,展示了Protocol.valueOf()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Protocol.valueOf()
方法的具体详情如下:
包路径:org.restlet.data.Protocol
类名称:Protocol
方法名:valueOf
[英]Creates the protocol associated to a URI scheme name. If an existing constant exists then it is returned, otherwise a new instance is created.
[中]创建与URI方案名称关联的协议。如果现有常量存在,则返回该常量,否则将创建一个新实例。
代码示例来源:origin: org.restlet.osgi/org.restlet
/**
* Constructor.
*
* @param protocolName
* The connector protocol.
*/
public Client(String protocolName) {
this(Protocol.valueOf(protocolName));
}
代码示例来源:origin: DeviceConnect/DeviceConnect-Android
/**
* Constructor.
*
* @param protocolName
* The connector protocol.
*/
public Client(String protocolName) {
this(Protocol.valueOf(protocolName));
}
代码示例来源:origin: org.restlet/org.restlet
/**
* Constructor.
*
* @param protocolName
* The connector protocol.
*/
public Client(String protocolName) {
this(Protocol.valueOf(protocolName));
}
代码示例来源:origin: org.restlet.osgi/org.restlet
/**
* Returns the protocol associated with the scheme component.
*
* @return The protocol associated with the scheme component.
*/
public Protocol getSchemeProtocol() {
return Protocol.valueOf(getScheme());
}
代码示例来源:origin: org.restlet/org.restlet.ext.servlet
/**
* Returns the server protocol.
*
* @return The server protocol.
*/
@Override
public Protocol getProtocol() {
return Protocol.valueOf(getRequest().getScheme());
}
代码示例来源:origin: org.restlet/org.restlet
/**
* Returns the protocol associated with the scheme component.
*
* @return The protocol associated with the scheme component.
*/
public Protocol getSchemeProtocol() {
return Protocol.valueOf(getScheme());
}
代码示例来源:origin: org.restlet/org.restlet.ext.spring
/**
* Constructor.
*
* @param protocol
* The server's protocol such as "HTTP" or "HTTPS".
*/
public SpringServer(String protocol) {
super(new Context(), Protocol.valueOf(protocol), null);
}
代码示例来源:origin: com.noelios.restlet/com.noelios.restlet.ext.servlet
/**
* Returns the server protocol.
*
* @return The server protocol.
*/
@Override
public Protocol getProtocol() {
return Protocol.valueOf(getRequest().getScheme());
}
代码示例来源:origin: org.restlet/org.restlet.ext.spring
/**
* Constructor.
*
* @param protocol
* The server's protocol such as "HTTP" or "HTTPS".
* @param port
* The port number.
*/
public SpringServer(String protocol, int port) {
super(new Context(), Protocol.valueOf(protocol), port, null);
}
代码示例来源:origin: DeviceConnect/DeviceConnect-Android
/**
* Returns the protocol associated with the scheme component.
*
* @return The protocol associated with the scheme component.
*/
public Protocol getSchemeProtocol() {
return Protocol.valueOf(getScheme());
}
代码示例来源:origin: org.restlet/org.restlet.ext.spring
/**
* Constructor.
*
* @param protocol
* The server's protocol such as "HTTP" or "HTTPS".
* @param address
* The IP address.
* @param port
* The port number.
*/
public SpringServer(String protocol, String address, int port) {
super(new Context(), Protocol.valueOf(protocol), address, port, null);
}
代码示例来源:origin: org.restlet/org.restlet
/**
* Returns a protocol by its scheme. If the latter is unknown, instantiate a
* new protocol object.
*
* @param scheme
* the scheme of the desired protocol.
* @return a known protocol or a new instance.
*/
private Protocol getProtocol(String scheme) {
Protocol protocol = Protocol.valueOf(scheme);
if (protocol == null) {
protocol = new Protocol(scheme);
}
return protocol;
}
代码示例来源:origin: org.restlet.osgi/org.restlet
/**
* Returns a protocol by its scheme. If the latter is unknown, instantiate a
* new protocol object.
*
* @param scheme
* the scheme of the desired protocol.
* @return a known protocol or a new instance.
*/
private Protocol getProtocol(String scheme) {
Protocol protocol = Protocol.valueOf(scheme);
if (protocol == null) {
protocol = new Protocol(scheme);
}
return protocol;
}
代码示例来源:origin: org.restlet.osgi/org.restlet
/**
* Creates a reference string from its parts.
*
* @param scheme
* The scheme ("http", "https" or "ftp").
* @param hostName
* The host name or IP address.
* @param hostPort
* The host port (default ports are correctly ignored).
* @param path
* The path component for hierarchical identifiers.
* @param query
* The optional query component for hierarchical identifiers.
* @param fragment
* The optional fragment identifier.
* @return The reference as String.
*/
public static String toString(String scheme, String hostName,
Integer hostPort, String path, String query, String fragment) {
String host = hostName;
// Appends the host port number
if (hostPort != null) {
final int defaultPort = Protocol.valueOf(scheme).getDefaultPort();
if (hostPort != defaultPort) {
host = hostName + ':' + hostPort;
}
}
return toString(scheme, host, path, query, fragment);
}
代码示例来源:origin: DeviceConnect/DeviceConnect-Android
/**
* Creates a reference string from its parts.
*
* @param scheme
* The scheme ("http", "https" or "ftp").
* @param hostName
* The host name or IP address.
* @param hostPort
* The host port (default ports are correctly ignored).
* @param path
* The path component for hierarchical identifiers.
* @param query
* The optional query component for hierarchical identifiers.
* @param fragment
* The optional fragment identifier.
* @return The reference as String.
*/
public static String toString(String scheme, String hostName,
Integer hostPort, String path, String query, String fragment) {
String host = hostName;
// Appends the host port number
if (hostPort != null) {
final int defaultPort = Protocol.valueOf(scheme).getDefaultPort();
if (hostPort != defaultPort) {
host = hostName + ':' + hostPort;
}
}
return toString(scheme, host, path, query, fragment);
}
代码示例来源:origin: org.restlet/org.restlet.ext.spring
/**
* Sets the list of servers, either as protocol names, Protocol instances or
* Server instances.
*
* @param serversInfo
* The list of servers.
*/
public void setServersList(List<Object> serversInfo) {
for (final Object serverInfo : serversInfo) {
if (serverInfo instanceof String) {
getServers().add(Protocol.valueOf((String) serverInfo));
} else if (serverInfo instanceof Protocol) {
getServers().add((Protocol) serverInfo);
} else if (serverInfo instanceof Server) {
getServers().add((Server) serverInfo);
} else {
getLogger()
.warning(
"Unknown object found in the servers list. Only instances of String, org.restlet.data.Protocol and org.restlet.Server are allowed.");
}
}
}
代码示例来源:origin: org.restlet/org.restlet.ext.spring
/**
* Sets the list of clients, either as protocol names, Protocol instances or
* Client instances.
*
* @param clients
* The list of clients.
*/
public synchronized void setClientsList(List<Object> clients) {
for (final Object client : clients) {
if (client instanceof String) {
getClients().add(Protocol.valueOf((String) client));
} else if (client instanceof Protocol) {
getClients().add((Protocol) client);
} else if (client instanceof Client) {
getClients().add((Client) client);
} else {
getLogger()
.warning(
"Unknown object found in the clients list. Only instances of String, org.restlet.data.Protocol and org.restlet.Client are allowed.");
}
}
}
代码示例来源:origin: DeviceConnect/DeviceConnect-Android
/**
* Creates the protocol associated to a URI scheme name. If an existing
* constant exists then it is returned, otherwise a new instance is created.
*
* @param name
* The scheme name.
* @param version
* The version number.
* @return The associated protocol.
*/
public static Protocol valueOf(String name, String version) {
Protocol result = valueOf(name);
if (!version.equals(result.getVersion())) {
result = new Protocol(result.getSchemeName(), result.getName(),
result.getTechnicalName(), result.getDescription(),
result.getDefaultPort(), result.isConfidential(), version);
}
return result;
}
代码示例来源:origin: org.restlet.osgi/org.restlet
/**
* Creates the protocol associated to a URI scheme name. If an existing
* constant exists then it is returned, otherwise a new instance is created.
*
* @param name
* The scheme name.
* @param version
* The version number.
* @return The associated protocol.
*/
public static Protocol valueOf(String name, String version) {
Protocol result = valueOf(name);
if (!version.equals(result.getVersion())) {
result = new Protocol(result.getSchemeName(), result.getName(),
result.getTechnicalName(), result.getDescription(),
result.getDefaultPort(), result.isConfidential(), version);
}
return result;
}
代码示例来源:origin: org.restlet.jse/org.restlet.example
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
Client sdcClient = new Client(new Context(), Protocol.valueOf("SDC"));
Series<Parameter> parameters = sdcClient.getContext().getParameters();
parameters.add("keystorePath", "sdc.keystore");
parameters.add("keystorePassword", "password");
parameters.add("enabledCipherSuites", "TLS_RSA_WITH_AES_128_CBC_SHA");
parameters.add("sslProtocol", "TLSv1");
sdcClient.start();
System.out
.println("Press a key when the SDC agent is started and has established a tunnel...");
System.in.read();
Request request = new Request(Method.GET, "http://restlet.org");
request.setProtocol(Protocol.valueOf("SDC"));
request.setProxyChallengeResponse(new ChallengeResponse(ChallengeScheme
.valueOf("SDC"), "myUser@example.com", "myPassword"));
Response response = sdcClient.handle(request);
response.getEntity().write(System.out);
}
}
内容来源于网络,如有侵权,请联系作者删除!