當前位置: 首頁>>代碼示例>>Java>>正文


Java Chars.indexOf方法代碼示例

本文整理匯總了Java中com.google.common.primitives.Chars.indexOf方法的典型用法代碼示例。如果您正苦於以下問題:Java Chars.indexOf方法的具體用法?Java Chars.indexOf怎麽用?Java Chars.indexOf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.primitives.Chars的用法示例。


在下文中一共展示了Chars.indexOf方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: escape

import com.google.common.primitives.Chars; //導入方法依賴的package包/類
static String escape(String s) {
  StringBuilder builder = new StringBuilder();
  int len = s.length();
  for (int i = 0; i < len; i++) {
    char c = s.charAt(i);

    int index = Chars.indexOf(SPECIAL_CHARS, c);
    if (index != -1) {
      builder.append(ESCAPED_SPECIAL_CHARS[index]);
    } else if (isControlChar(c)) {
      String hex = Integer.toHexString(c);
      builder.append("\\u");
      for (int j = 4; j > hex.length(); j--) {
        builder.append('0');
      }
      builder.append(hex);
    } else {
      builder.append(c);
    }
  }
  return builder.toString();
}
 
開發者ID:JetBrains,項目名稱:mapper,代碼行數:23,代碼來源:JsonUtil.java

示例2: indexOf

import com.google.common.primitives.Chars; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 *
 * @throws NullPointerException
 *             if the wrapped array was <code>null</code>.
 */
@Override
public int indexOf(Object o) {
	// Will make the method fail if array is null.
	if (size() < 1) {
		return -1;
	}
	if (o instanceof Character) {
		return Chars.indexOf(array, ((Character) o).charValue());
	}
	return -1;
}
 
開發者ID:eclipse,項目名稱:xtext-lib,代碼行數:18,代碼來源:Conversions.java

示例3: toDecimal

import com.google.common.primitives.Chars; //導入方法依賴的package包/類
public long toDecimal(String string) {
	long result = 0;
	long pow = 1;
	for (int i = 0; i < string.length(); i++) {
		char charAt = string.charAt(string.length() - i - 1);
		int indexOf = Chars.indexOf(this.digits, charAt);
		checkArgument(indexOf >= 0, "%s is not a valid character in %s",
				charAt, this.digits);
		result = checkedAdd(result, checkedMultiply(indexOf, pow));
		pow = checkedMultiply(pow, numDigits);
	}
	return result;
}
 
開發者ID:pfichtner,項目名稱:jcrunch,代碼行數:14,代碼來源:NumberSystem.java

示例4: setCode

import com.google.common.primitives.Chars; //導入方法依賴的package包/類
public synchronized static void setCode(String code) {
    // For each codon state, set the amino acid state
    for (int i = 0; i < CODON_STATES; i++) {
        if (code.charAt(i) == '*') {
            CODONS_TO_AMINO_ACIDS[i] = UNKNOWN_STATE; // stop codon
        } else {
            CODONS_TO_AMINO_ACIDS[i] = Chars.indexOf(AMINO_ACIDS, code.charAt(i)); // INSTANCE.getAminoAcidIndexByChar(code.charAt(i));
        }
    }

    // For each amino acid state, set all possible translating codon states
    for (int i = 0; i < AMINO_ACID_STATES; i++) {
        List<Integer> codonStates = Lists.newArrayList();

        // Search for this amino acid in the genetic code string
        int pos = 0;
        while (true) {
            pos = code.indexOf(AMINO_ACIDS[i], pos);
            if (pos == -1) {
                break;
            } else {
                codonStates.add(pos);
            }
            pos++;
        }
        AMINO_ACIDS_TO_CODONS[i] = Ints.toArray(codonStates);
    }

    SENSE_CODONS = getInstance().setSenseCodons();

    /*
    System.out.printf("swmutsel.utils.GeneticCode - Stop codons: ");
    for (int i = 0; i < CODON_STATES; i++) if (INSTANCE.isUnknownAminoAcidState(INSTANCE.getAminoAcidIndexFromCodonIndex(i))) System.out.printf("%s ", INSTANCE.getCodonTLA(i));
    System.out.println();
    System.out.printf("swmutsel.utils.GeneticCode - Methionine codon(s): ");
    for (int i : INSTANCE.getCodonIndexFromAminoAcidIndex(INSTANCE.getAminoAcidIndexByChar('M'))) System.out.printf("%s ", INSTANCE.getCodonTLA(i));
    System.out.println();
    */
}
 
開發者ID:tamuri,項目名稱:swmutsel,代碼行數:40,代碼來源:GeneticCode.java

示例5: getNucleotideIndexByChar

import com.google.common.primitives.Chars; //導入方法依賴的package包/類
public int getNucleotideIndexByChar(char c) {
    return Chars.indexOf(NUCLEOTIDES, c);
}
 
開發者ID:tamuri,項目名稱:swmutsel,代碼行數:4,代碼來源:GeneticCode.java

示例6: getAminoAcidIndexByChar

import com.google.common.primitives.Chars; //導入方法依賴的package包/類
public int getAminoAcidIndexByChar(char c) {
    return Chars.indexOf(AMINO_ACIDS, c);
}
 
開發者ID:tamuri,項目名稱:swmutsel,代碼行數:4,代碼來源:GeneticCode.java

示例7: isUnescapedSpecialChar

import com.google.common.primitives.Chars; //導入方法依賴的package包/類
static boolean isUnescapedSpecialChar(char ch) {
  return Chars.indexOf(UNESCAPED_SPECIAL_CHARS, ch) != -1;
}
 
開發者ID:JetBrains,項目名稱:mapper,代碼行數:4,代碼來源:JsonUtil.java


注:本文中的com.google.common.primitives.Chars.indexOf方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。