org.kaazing.gateway.util.Utils类的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(90)

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

Utils介绍

暂无

代码示例

代码示例来源:origin: kaazing/gateway

static long getWsInactivityTimeout(String value) {
  long wsInactivityTimeout = DEFAULT_WS_INACTIVITY_TIMEOUT_MILLIS;
  if (value != null) {
    long val = Utils.parseTimeInterval(value, MILLISECONDS);
    if (val > 0) {
      wsInactivityTimeout = val;
    }
  }
  return wsInactivityTimeout;
}

代码示例来源:origin: kaazing/gateway

@Override
public boolean matches(Object arg) {
  return (arg instanceof ByteBuffer) &&
      asString((ByteBuffer) arg).matches(pattern);
}

代码示例来源:origin: kaazing/gateway

/**
 * Converts a data size specified in bytes (all digits), kilobytes (digits followed by k or K)
 * or megabytes (digits followed by m or M), values like 1048, 64k, 10M.
 * @param dataSizeValue   data size
 * @return - data size converted to int number of bytes
 */
public static int parseDataSize(String dataSizeValue) {
  return parseDataSize(dataSizeValue, "dataSize");
}

代码示例来源:origin: kaazing/gateway

jsonOptions.put(key, Utils.asCommaSeparatedString(asList((String[]) value)));
} else {
  jsonOptions.put(key, value);

代码示例来源:origin: kaazing/gateway

/**
 * Gets the value of a static int field (static final constant), given its fully qualified name.
 * The owner class can be a (public static) inner class provided the physical name is used
 * (e.g. "my.package.MyClass$MyInnerClass.INT_FIELD").
 * @param fullyQualifiedFieldName
 * @return the value of the field
 * @throws ClassNotFoundException
 * @throws NoSuchFieldException
 * @throws IllegalAccessException
 * @throws IllegalArgumentException - if the given name is invalid
 */
public static int loadStaticInt(String fullyQualifiedFieldName)
 throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException {
  int lastDotPos = fullyQualifiedFieldName.lastIndexOf('.');
  // Name must contain "." but not as first or last character
  if (lastDotPos <= 0 || lastDotPos + 1 >= fullyQualifiedFieldName.length()) {
    throw new IllegalArgumentException(fullyQualifiedFieldName);
  }
  String className = fullyQualifiedFieldName.substring(0, lastDotPos);
  String fieldName = fullyQualifiedFieldName.substring(lastDotPos + 1);
  Class<?> clazz = loadClass(className);
  Field field = clazz.getField(fieldName);
  int mode = field.getInt(clazz);
  return mode;
}

代码示例来源:origin: kaazing/gateway

private boolean validateUpstreamOrDownstreamURI(URI wsURI, URI uri) {
  if (!Arrays.asList("http", "https").contains(uri.getScheme())) {
    return false;
  }
  if (!Utils.sameOrEquals(wsURI.getHost(), uri.getHost())) {
    return false;
  }
  if (!WseUtils.pathPrefixMatches(wsURI, uri)) {
    return false;
  }
  return true;
}

代码示例来源:origin: kaazing/gateway

jsonOptions.put("ssl.ciphers", Utils.asCommaSeparatedString(asList(sslCiphers)));
  jsonOptions.put(key, Utils.asCommaSeparatedString(asList((String[]) value)));
} else {
  jsonOptions.put(key, value);

代码示例来源:origin: kaazing/gateway

Class<?> principalClass = Utils.loadClass(principalClassName);
    Class<?> userPrincipalClass = Utils.loadClass(principal.getValue());

代码示例来源:origin: kaazing/gateway

@Override
public boolean equals(Object obj) {
  if (obj == null || !(obj instanceof WsMessage)) {
    return false;
  }
  WsMessage that = (WsMessage) obj;
  return (that.getKind() == this.getKind() && that.fin == this.fin &&
      Utils.sameOrEquals(this.buf == null ? null : this.buf.buf(),
          that.buf == null ? null : that.buf.buf())); // IoBufferEx has no equals method
}

代码示例来源:origin: kaazing/gateway

static int getHttpKeepaliveTimeout(String httpKeepaliveTimeoutValue) {
  int httpKeepaliveTimeout = DEFAULT_HTTP_KEEPALIVE_TIMEOUT;
  if (httpKeepaliveTimeoutValue != null) {
    long val = Utils.parseTimeInterval(httpKeepaliveTimeoutValue, SECONDS);
    if (val > 0) {
      httpKeepaliveTimeout = (int) val;
    }
  }
  return httpKeepaliveTimeout;
}

代码示例来源:origin: kaazing/gateway

@Deprecated // Use asString now it's been fixed to use UTF-8 CharSet
public static String asStringUTF8(ByteBuffer buf) {
  return asString(buf);
}

代码示例来源:origin: kaazing/gateway

static int getWsMaximumMessageSize(String wsMaxMessageSizeValue) {
  int wsMaxMessageSize = DEFAULT_WEBSOCKET_MAXIMUM_MESSAGE_SIZE;
  if (wsMaxMessageSizeValue != null) {
    wsMaxMessageSize = Utils.parseDataSize(wsMaxMessageSizeValue);
  }
  return wsMaxMessageSize;
}

代码示例来源:origin: kaazing/gateway

jsonOptions.put(key, Utils.asCommaSeparatedString(asList((String[]) value)));
} else {
  jsonOptions.put(key, value);

代码示例来源:origin: kaazing/gateway

Class<?> untypedClass;
try {
  untypedClass = org.kaazing.gateway.util.Utils.loadClass(className);
  if ( !(Principal.class.isAssignableFrom(untypedClass)) ) {
    String message = className + " is not of type Principal";

代码示例来源:origin: kaazing/gateway

public static long parseTimeInterval(String timeIntervalValue, TimeUnit outputUnit) {
  return parseTimeInterval(timeIntervalValue, outputUnit, 0);
}

代码示例来源:origin: kaazing/gateway

@Override
public String toString() {
  return String.valueOf(getKind()) + ':' + ' ' +
      "status=" + status + ", reason=" + Utils.asString(reason);
}

代码示例来源:origin: kaazing/gateway

/**
 * Get a property which is a number of bytes expressed either as an integer (number of bytes) or an integer followed by K
 * (number of kilobytes) or an integer followed by M (for megabytes). Examples: 1048, 64k, 10M
 */
public static int getOptionalDataSizeProperty(ServiceProperties properties, String propertyName, int defaultValue) {
  String value = getOptionalProperty(properties, propertyName, Integer.toString(defaultValue));
  return Utils.parseDataSize(value);
}

代码示例来源:origin: kaazing/gateway

String cipherString = Utils.asCommaSeparatedString(asList(sslCiphers));
if (cipherString != null && cipherString.length() > 0) {
  jsonOptions.put("ssl.ciphers", cipherString);
  jsonOptions.put(key, Utils.asCommaSeparatedString(asList((String[]) value)));
} else {
  jsonOptions.put(key, value);

代码示例来源:origin: kaazing/gateway

/**
 * @param timeIntervalValue - The value to be parsed
 * @param outputUnit        - The value will be converted to this unit
 * @param defaultValue      - The default value in seconds
 * @return
 */
public static long parseTimeInterval(String timeIntervalValue, TimeUnit outputUnit, long defaultValue) {
  return parseTimeInterval(timeIntervalValue, outputUnit, String.valueOf(defaultValue) + "seconds");
}

代码示例来源:origin: kaazing/gateway

public static String asString(Map<ByteBuffer, ByteBuffer> headers) {
  if (headers == null) {
    return null;
  }
  Iterator<Entry<ByteBuffer, ByteBuffer>> i = headers.entrySet().iterator();
  if (! i.hasNext()) {
    return "{}";
  }
  StringBuilder sb = new StringBuilder();
  sb.append('{');
  for (;;) {
    Entry<ByteBuffer, ByteBuffer> e = i.next();
    ByteBuffer key = e.getKey();
    ByteBuffer value = e.getValue();
    sb.append(key   == headers ? "(this Map)" : asString(key));
    sb.append('=');
    sb.append(value == headers ? "(this Map)" : asString(value));
    if (! i.hasNext()) {
      return sb.append('}').toString();
    }
    sb.append(", ");
  }
}

相关文章