org.apache.commons.lang3.ArrayUtils#lastIndexOf ( )源码实例Demo

下面列出了org.apache.commons.lang3.ArrayUtils#lastIndexOf ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: uyuni   文件: SmtpMail.java
private boolean verifyAddress(InternetAddress addr) {
    log.debug("verifyAddress called ...");
    boolean retval = true;
    String domain = addr.getAddress();
    int domainStart = domain.indexOf('@');
    if (domainStart > -1 && domainStart + 1 < domain.length()) {
        domain = domain.substring(domainStart + 1);

    }
    if (log.isDebugEnabled()) {
        log.debug("Restricted domains: " +
                StringUtils.join(restrictedDomains, " | "));
        log.debug("disallowedDomains domains: " +
                StringUtils.join(disallowedDomains, " | "));
    }
    if (restrictedDomains != null && restrictedDomains.length > 0) {
        if (ArrayUtils.lastIndexOf(restrictedDomains, domain) == -1) {
            log.warn("Address " + addr.getAddress() +
                    " not in restricted domains list");
            retval = false;
        }
    }

    if (retval &&  disallowedDomains != null && disallowedDomains.length > 0) {
        if (ArrayUtils.lastIndexOf(disallowedDomains, domain) > -1) {
            log.warn("Address " + addr.getAddress() + " in disallowed domains list");
            retval = false;
        }
    }
    log.debug("verifyAddress returning: " + retval);
    return retval;
}
 
源代码2 项目: hbase   文件: TableName.java
/**
 * @param fullName byte array to look into
 * @param offset within said array
 * @param length within said array
 * @throws IllegalArgumentException if fullName equals old root or old meta.
 */
public static TableName valueOf(byte[] fullName, int offset, int length)
    throws IllegalArgumentException {
  Preconditions.checkArgument(offset >= 0, "offset must be non-negative but was %s", offset);
  Preconditions.checkArgument(offset < fullName.length, "offset (%s) must be < array length (%s)",
      offset, fullName.length);
  Preconditions.checkArgument(length <= fullName.length,
      "length (%s) must be <= array length (%s)", length, fullName.length);
  for (TableName tn : tableCache) {
    final byte[] tnName = tn.getName();
    if (Bytes.equals(tnName, 0, tnName.length, fullName, offset, length)) {
      return tn;
    }
  }

  int namespaceDelimIndex = ArrayUtils.lastIndexOf(fullName, (byte) NAMESPACE_DELIM,
      offset + length - 1);

  if (namespaceDelimIndex < offset) {
    return createTableNameIfNecessary(
        ByteBuffer.wrap(NamespaceDescriptor.DEFAULT_NAMESPACE_NAME),
        ByteBuffer.wrap(fullName, offset, length));
  } else {
    return createTableNameIfNecessary(
        ByteBuffer.wrap(fullName, offset, namespaceDelimIndex),
        ByteBuffer.wrap(fullName, namespaceDelimIndex + 1, length - (namespaceDelimIndex + 1)));
  }
}
 
源代码3 项目: systemds   文件: PlanSelectionFuseCostBasedV2.java
private static long getNumSkipPlans(boolean[] plan) {
	int pos = ArrayUtils.lastIndexOf(plan, true);
	return UtilFunctions.pow(2, plan.length-pos-1);
}
 
源代码4 项目: systemds   文件: PlanSelectionFuseCostBasedV2.java
private static long getNumSkipPlans(boolean[] plan) {
	int pos = ArrayUtils.lastIndexOf(plan, true);
	return UtilFunctions.pow(2, plan.length-pos-1);
}
 
源代码5 项目: hbase   文件: TableName.java
/**
 * Check passed byte array, "tableName", is legal user-space table name.
 * @return Returns passed <code>tableName</code> param
 * @throws IllegalArgumentException if passed a tableName is null or
 * is made of other than 'word' characters or underscores: i.e.
 * <code>[\p{IsAlphabetic}\p{Digit}.-:]</code>. The ':' is used to delimit the namespace
 * from the table name and can be used for nothing else.
 *
 * Namespace names can only contain 'word' characters
 * <code>[\p{IsAlphabetic}\p{Digit}]</code> or '_'
 *
 * Qualifier names can only contain 'word' characters
 * <code>[\p{IsAlphabetic}\p{Digit}]</code> or '_', '.' or '-'.
 * The name may not start with '.' or '-'.
 *
 * Valid fully qualified table names:
 * foo:bar, namespace=&gt;foo, table=&gt;bar
 * org:foo.bar, namespace=org, table=&gt;foo.bar
 */
public static byte [] isLegalFullyQualifiedTableName(final byte[] tableName) {
  if (tableName == null || tableName.length <= 0) {
    throw new IllegalArgumentException("Name is null or empty");
  }

  int namespaceDelimIndex = ArrayUtils.lastIndexOf(tableName, (byte) NAMESPACE_DELIM);
  if (namespaceDelimIndex < 0){
    isLegalTableQualifierName(tableName);
  } else {
    isLegalNamespaceName(tableName, 0, namespaceDelimIndex);
    isLegalTableQualifierName(tableName, namespaceDelimIndex + 1, tableName.length);
  }
  return tableName;
}