本文整理汇总了Java中javax.websocket.Extension.getParameters方法的典型用法代码示例。如果您正苦于以下问题:Java Extension.getParameters方法的具体用法?Java Extension.getParameters怎么用?Java Extension.getParameters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.websocket.Extension
的用法示例。
在下文中一共展示了Extension.getParameters方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateExtensionHeaders
import javax.websocket.Extension; //导入方法依赖的package包/类
private static List<String> generateExtensionHeaders(List<Extension> extensions) {
List<String> result = new ArrayList<String>(extensions.size());
for (Extension extension : extensions) {
StringBuilder header = new StringBuilder();
header.append(extension.getName());
for (Extension.Parameter param : extension.getParameters()) {
header.append(';');
header.append(param.getName());
String value = param.getValue();
if (value != null && value.length() > 0) {
header.append('=');
header.append(value);
}
}
result.add(header.toString());
}
return result;
}
示例2: getExtensionResponse
import javax.websocket.Extension; //导入方法依赖的package包/类
@Override
public Extension getExtensionResponse() {
Extension result = new WsExtension(NAME);
List<Extension.Parameter> params = result.getParameters();
if (!serverContextTakeover) {
params.add(new WsExtensionParameter(SERVER_NO_CONTEXT_TAKEOVER, null));
}
if (serverMaxWindowBits != -1) {
params.add(new WsExtensionParameter(SERVER_MAX_WINDOW_BITS,
Integer.toString(serverMaxWindowBits)));
}
if (!clientContextTakeover) {
params.add(new WsExtensionParameter(CLIENT_NO_CONTEXT_TAKEOVER, null));
}
if (clientMaxWindowBits != -1) {
params.add(new WsExtensionParameter(CLIENT_MAX_WINDOW_BITS,
Integer.toString(clientMaxWindowBits)));
}
return result;
}
示例3: append
import javax.websocket.Extension; //导入方法依赖的package包/类
private static void append(StringBuilder sb, Extension extension) {
if (extension == null || extension.getName() == null || extension.getName().length() == 0) {
return;
}
sb.append(extension.getName());
for (Extension.Parameter p : extension.getParameters()) {
sb.append(';');
sb.append(p.getName());
if (p.getValue() != null) {
sb.append('=');
sb.append(p.getValue());
}
}
}
示例4: doTestParseExtensionHeaderSimple
import javax.websocket.Extension; //导入方法依赖的package包/类
private void doTestParseExtensionHeaderSimple(String header) {
// Simple test
List<Extension> result = new ArrayList<Extension>();
Util.parseExtensionHeader(result, header);
Assert.assertEquals(1, result.size());
Extension ext = result.get(0);
Assert.assertEquals("ext", ext.getName());
List<Parameter> params = ext.getParameters();
Assert.assertEquals(2, params.size());
Parameter paramA = params.get(0);
Assert.assertEquals("a", paramA.getName());
Assert.assertEquals("1", paramA.getValue());
Parameter paramB = params.get(1);
Assert.assertEquals("b", paramB.getName());
Assert.assertEquals("2", paramB.getValue());
}
示例5: generateExtensionHeaders
import javax.websocket.Extension; //导入方法依赖的package包/类
private static List<String> generateExtensionHeaders(List<Extension> extensions) {
List<String> result = new ArrayList<String>(extensions.size());
for (Extension extension : extensions) {
StringBuilder header = new StringBuilder();
header.append(extension.getName());
for (Extension.Parameter param : extension.getParameters()) {
header.append(';');
header.append(param.getName());
String value = param.getValue();
if (value != null && value.length() > 0) {
header.append('=');
header.append(value);
}
}
result.add(header.toString());
}
return result;
}
示例6: getExtensionResponse
import javax.websocket.Extension; //导入方法依赖的package包/类
@Override
public Extension getExtensionResponse() {
Extension result = new WsExtension(NAME);
List<Extension.Parameter> params = result.getParameters();
if (!serverContextTakeover) {
params.add(new WsExtensionParameter(SERVER_NO_CONTEXT_TAKEOVER, null));
}
if (serverMaxWindowBits != -1) {
params.add(new WsExtensionParameter(SERVER_MAX_WINDOW_BITS, Integer.toString(serverMaxWindowBits)));
}
if (!clientContextTakeover) {
params.add(new WsExtensionParameter(CLIENT_NO_CONTEXT_TAKEOVER, null));
}
if (clientMaxWindowBits != -1) {
params.add(new WsExtensionParameter(CLIENT_MAX_WINDOW_BITS, Integer.toString(clientMaxWindowBits)));
}
return result;
}
示例7: append
import javax.websocket.Extension; //导入方法依赖的package包/类
private static void append(StringBuilder sb, Extension extension) {
if (extension == null || extension.getName() == null || extension.getName().length() == 0) {
return;
}
sb.append(extension.getName());
for (Extension.Parameter p : extension.getParameters()) {
sb.append(';');
sb.append(p.getName());
if (p.getValue() != null) {
sb.append('=');
sb.append(p.getValue());
}
}
}
示例8: generateExtensionHeaders
import javax.websocket.Extension; //导入方法依赖的package包/类
private List<String> generateExtensionHeaders(List<Extension> extensions) {
List<String> result = new ArrayList<String>(extensions.size());
for (Extension extension : extensions) {
StringBuilder header = new StringBuilder();
header.append(extension.getName());
for (Extension.Parameter param : extension.getParameters()) {
header.append(';');
header.append(param.getName());
String value = param.getValue();
if (value != null && value.length() > 0) {
header.append('=');
header.append(value);
}
}
}
return result;
}
示例9: doTestParseExtensionHeaderMultiple
import javax.websocket.Extension; //导入方法依赖的package包/类
private void doTestParseExtensionHeaderMultiple(String header) {
// Simple test
List<Extension> result = new ArrayList<Extension>();
Util.parseExtensionHeader(result, header);
Assert.assertEquals(3, result.size());
Extension ext = result.get(0);
Assert.assertEquals("ext", ext.getName());
List<Parameter> params = ext.getParameters();
Assert.assertEquals(2, params.size());
Parameter paramA = params.get(0);
Assert.assertEquals("a", paramA.getName());
Assert.assertEquals("1", paramA.getValue());
Parameter paramB = params.get(1);
Assert.assertEquals("b", paramB.getName());
Assert.assertEquals("2", paramB.getValue());
Extension ext2 = result.get(1);
Assert.assertEquals("ext2", ext2.getName());
List<Parameter> params2 = ext2.getParameters();
Assert.assertEquals(2, params2.size());
Parameter paramC = params2.get(0);
Assert.assertEquals("c", paramC.getName());
Assert.assertNull(paramC.getValue());
Parameter paramD = params2.get(1);
Assert.assertEquals("d", paramD.getName());
Assert.assertEquals("xyz", paramD.getValue());
Extension ext3 = result.get(2);
Assert.assertEquals("ext3", ext3.getName());
List<Parameter> params3 = ext3.getParameters();
Assert.assertEquals(0, params3.size());
}
示例10: initParameters
import javax.websocket.Extension; //导入方法依赖的package包/类
private static Map<String, String> initParameters(Extension extension) {
List<Extension.Parameter> parameters = extension.getParameters();
Map<String, String> result = new LinkedCaseInsensitiveMap<String>(parameters.size(), Locale.ENGLISH);
for (Extension.Parameter parameter : parameters) {
result.put(parameter.getName(), parameter.getValue());
}
return result;
}