Example usage for java.lang Character DASH_PUNCTUATION

List of usage examples for java.lang Character DASH_PUNCTUATION

Introduction

In this page you can find the example usage for java.lang Character DASH_PUNCTUATION.

Prototype

byte DASH_PUNCTUATION

To view the source code for java.lang Character DASH_PUNCTUATION.

Click Source Link

Document

General category "Pd" in the Unicode specification.

Usage

From source file:CharUtils.java

/**
 * Evict dashes from a string./*from  www .j  a va2  s.  c  o  m*/
 * 
 * @param s
 *            String from which to evict dashes.
 * 
 * @return String with dashes evicted.
 */

public static String evictDashes(String s) {
    StringBuffer result = new StringBuffer();

    for (int i = 0; i < s.length(); i++) {
        if (Character.getType(s.charAt(i)) != Character.DASH_PUNCTUATION) {
            result.append(s.charAt(i));
        }
    }

    return result.toString();
}

From source file:org.apache.orc.impl.mask.RedactMaskFactory.java

/**
 * Given a UTF code point, find the replacement codepoint
 * @param codepoint a UTF character//from w w w .  j  av  a2  s . c o  m
 * @return the replacement codepoint
 */
int getReplacement(int codepoint) {
    switch (Character.getType(codepoint)) {
    case Character.UPPERCASE_LETTER:
        return UPPPER_REPLACEMENT;
    case Character.LOWERCASE_LETTER:
        return LOWER_REPLACEMENT;
    case Character.TITLECASE_LETTER:
    case Character.MODIFIER_LETTER:
    case Character.OTHER_LETTER:
        return OTHER_LETTER_REPLACEMENT;
    case Character.NON_SPACING_MARK:
    case Character.ENCLOSING_MARK:
    case Character.COMBINING_SPACING_MARK:
        return MARK_REPLACEMENT;
    case Character.DECIMAL_DIGIT_NUMBER:
        return DIGIT_CP_REPLACEMENT;
    case Character.LETTER_NUMBER:
    case Character.OTHER_NUMBER:
        return OTHER_NUMBER_REPLACEMENT;
    case Character.SPACE_SEPARATOR:
    case Character.LINE_SEPARATOR:
    case Character.PARAGRAPH_SEPARATOR:
        return SEPARATOR_REPLACEMENT;
    case Character.MATH_SYMBOL:
    case Character.CURRENCY_SYMBOL:
    case Character.MODIFIER_SYMBOL:
    case Character.OTHER_SYMBOL:
        return SYMBOL_REPLACEMENT;
    case Character.DASH_PUNCTUATION:
    case Character.START_PUNCTUATION:
    case Character.END_PUNCTUATION:
    case Character.CONNECTOR_PUNCTUATION:
    case Character.OTHER_PUNCTUATION:
        return PUNCTUATION_REPLACEMENT;
    default:
        return OTHER_REPLACEMENT;
    }
}