Example usage for java.lang Character isUnicodeIdentifierPart

List of usage examples for java.lang Character isUnicodeIdentifierPart

Introduction

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

Prototype

public static boolean isUnicodeIdentifierPart(int codePoint) 

Source Link

Document

Determines if the specified character (Unicode code point) may be part of a Unicode identifier as other than the first character.

Usage

From source file:org.pentaho.di.core.Const.java

public static final String createName(String filename) {
    if (Const.isEmpty(filename)) {
        return filename;
    }// ww w  . j a  va  2  s.  com

    String pureFilename = filenameOnly(filename);
    if (pureFilename.endsWith(".ktr") || pureFilename.endsWith(".kjb") || pureFilename.endsWith(".xml")) {
        pureFilename = pureFilename.substring(0, pureFilename.length() - 4);
    }
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < pureFilename.length(); i++) {
        char c = pureFilename.charAt(i);
        if (Character.isUnicodeIdentifierPart(c)) {
            sb.append(c);
        } else if (Character.isWhitespace(c)) {
            sb.append(' ');
        } else if (c == '-') {
            sb.append(c);
        }
    }
    return sb.toString();
}

From source file:org.projectforge.common.CSVParser.java

public boolean isIdentifierPart(char ch) {
    return Character.isUnicodeIdentifierPart(ch);
}

From source file:org.projectforge.common.KeyValuePairParser.java

public boolean isIdentifierPart(final char ch) {
    return Character.isUnicodeIdentifierPart(ch);
}

From source file:org.tightblog.util.Utilities.java

/**
 * Removes non-alphanumerics from tags.//from   w  w  w .  j  av  a  2  s . c o m
 *
 * @param tag tag to strip invalid chars from
 * @param locale to determine lower-case, default if null
 * @return lower case tag with alphanumerics removed
 */
public static String normalizeTag(String tag, Locale locale) {
    if (tag == null) {
        throw new NullPointerException();
    }

    StringBuilder sb = new StringBuilder();
    char[] charArray = tag.toCharArray();
    for (char c : charArray) {

        // fast-path exclusions quotes and commas are obvious
        // percent sign and forward slashes problematic in URLs and frequently blocked by servers
        // 34 = ", 37 = %, 39 = ', 44 = comma, 47 = /
        if (c == 34 || c == 37 || c == 39 || c == 44 || c == 47) {
            continue;
        }

        if ((33 <= c && c <= 126) || Character.isUnicodeIdentifierPart(c)
                || Character.isUnicodeIdentifierStart(c)) {
            sb.append(c);
        }
    }
    tag = sb.toString();
    return locale == null ? tag.toLowerCase() : tag.toLowerCase(locale);
}