javax.websocket.Extension.getParameters()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(10.6k)|赞(0)|评价(0)|浏览(143)

本文整理了Java中javax.websocket.Extension.getParameters()方法的一些代码示例,展示了Extension.getParameters()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Extension.getParameters()方法的具体详情如下:
包路径:javax.websocket.Extension
类名称:Extension
方法名:getParameters

Extension.getParameters介绍

[英]The extension parameters for this extension in the order they appear in the http headers.
[中]此扩展的扩展参数在http标头中的显示顺序。

代码示例

代码示例来源:origin: spring-projects/spring-framework

private static Map<String, String> initParameters(Extension extension) {
  List<Extension.Parameter> parameters = extension.getParameters();
  Map<String, String> result = new LinkedCaseInsensitiveMap<>(parameters.size(), Locale.ENGLISH);
  for (Extension.Parameter parameter : parameters) {
    result.put(parameter.getName(), parameter.getValue());
  }
  return result;
}

代码示例来源:origin: org.glassfish.tyrus/tyrus-core

/**
 * {@inheritDoc}
 * <p/>
 * Please note the TODO. {@link
 * ExtendedExtension#onExtensionNegotiation(ExtensionContext, List)}
 */
@Override
public List<Parameter> onExtensionNegotiation(ExtensionContext context,
                       List<Parameter> requestedParameters) {
  return extendedExtension
      .onExtensionNegotiation(context, requestedExtension.getParameters());
}

代码示例来源:origin: eclipse-ee4j/tyrus

/**
 * {@inheritDoc}
 * <p/>
 * Please note the TODO. {@link
 * ExtendedExtension#onExtensionNegotiation(ExtensionContext, List)}
 */
@Override
public List<Parameter> onExtensionNegotiation(ExtensionContext context,
                       List<Parameter> requestedParameters) {
  return extendedExtension
      .onExtensionNegotiation(context, requestedExtension.getParameters());
}

代码示例来源:origin: org.apache.tomcat/tomcat7-websocket

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;
}

代码示例来源:origin: org.glassfish.tyrus/tyrus-core

/**
 * Returns defined representation for HTTP headers.
 *
 * @param extension {@link Extension} instance.
 * @return String containing {@link Extension} representation as defined in RFC 6455.
 */
static String toString(Extension extension) {
  final StringBuilder sb = new StringBuilder();
  sb.append(extension.getName());
  final List<Parameter> extensionParameters = extension.getParameters();
  if (extensionParameters != null && !extensionParameters.isEmpty()) {
    for (Extension.Parameter p : extensionParameters) {
      sb.append("; ");
      sb.append(TyrusParameter.toString(p));
    }
  }
  return sb.toString();
}

代码示例来源:origin: codefollower/Tomcat-Research

private List<String> generateExtensionHeaders(List<Extension> extensions) {
  List<String> result = new ArrayList<>(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;
}

代码示例来源:origin: org.jboss.web/jbossweb

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);
      }
    }
    result.add(header.toString());
  }
  return result;
}

代码示例来源:origin: org.apache.tomcat/tomcat-websocket

private static List<String> generateExtensionHeaders(List<Extension> extensions) {
  List<String> result = new ArrayList<>(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;
}

代码示例来源:origin: org.apache.tomcat.embed/tomcat-embed-websocket

private static List<String> generateExtensionHeaders(List<Extension> extensions) {
  List<String> result = new ArrayList<>(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;
}

代码示例来源:origin: eclipse-ee4j/tyrus

/**
 * Returns defined representation for HTTP headers.
 *
 * @param extension {@link Extension} instance.
 * @return String containing {@link Extension} representation as defined in RFC 6455.
 */
static String toString(Extension extension) {
  final StringBuilder sb = new StringBuilder();
  sb.append(extension.getName());
  final List<Parameter> extensionParameters = extension.getParameters();
  if (extensionParameters != null && !extensionParameters.isEmpty()) {
    for (Extension.Parameter p : extensionParameters) {
      sb.append("; ");
      sb.append(TyrusParameter.toString(p));
    }
  }
  return sb.toString();
}

代码示例来源:origin: org.springframework/spring-websocket

private static Map<String, String> initParameters(Extension extension) {
  List<Extension.Parameter> parameters = extension.getParameters();
  Map<String, String> result = new LinkedCaseInsensitiveMap<>(parameters.size(), Locale.ENGLISH);
  for (Extension.Parameter parameter : parameters) {
    result.put(parameter.getName(), parameter.getValue());
  }
  return result;
}

代码示例来源:origin: Red5/red5-plugins

private static List<Transformation> createTransformations(List<Extension> negotiatedExtensions) {
  TransformationFactory factory = TransformationFactory.getInstance();
  LinkedHashMap<String, List<List<Extension.Parameter>>> extensionPreferences = new LinkedHashMap<>();
  // Result will likely be smaller than this
  List<Transformation> result = new ArrayList<>(negotiatedExtensions.size());
  for (Extension extension : negotiatedExtensions) {
    List<List<Extension.Parameter>> preferences = extensionPreferences.get(extension.getName());
    if (preferences == null) {
      preferences = new ArrayList<>();
      extensionPreferences.put(extension.getName(), preferences);
    }
    preferences.add(extension.getParameters());
  }
  for (Map.Entry<String, List<List<Extension.Parameter>>> entry : extensionPreferences.entrySet()) {
    Transformation transformation = factory.create(entry.getKey(), entry.getValue(), true);
    if (transformation != null) {
      result.add(transformation);
    }
  }
  return result;
}

代码示例来源:origin: apache/servicemix-bundles

private static Map<String, String> initParameters(Extension extension) {
  List<Extension.Parameter> parameters = extension.getParameters();
  Map<String, String> result = new LinkedCaseInsensitiveMap<>(parameters.size(), Locale.ENGLISH);
  for (Extension.Parameter parameter : parameters) {
    result.put(parameter.getName(), parameter.getValue());
  }
  return result;
}

代码示例来源:origin: org.apache.tomcat.embed/tomcat-embed-websocket

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());
    }
  }
}

代码示例来源:origin: org.apache.tomcat/tomcat7-websocket

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());
    }
  }
}

代码示例来源:origin: org.jboss.web/jbossweb

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());
    }
  }
}

代码示例来源:origin: org.apache.tomcat/tomcat-websocket

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());
    }
  }
}

代码示例来源:origin: Red5/red5-plugins

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());
    }
  }
}

代码示例来源:origin: org.apache.tomcat.embed/tomcat-embed-websocket

@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;
}

代码示例来源:origin: org.apache.tomcat/tomcat-websocket

@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;
}

相关文章