Example usage for java.lang Character isLetterOrDigit

List of usage examples for java.lang Character isLetterOrDigit

Introduction

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

Prototype

public static boolean isLetterOrDigit(int codePoint) 

Source Link

Document

Determines if the specified character (Unicode code point) is a letter or digit.

Usage

From source file:net.www_eee.portal.channels.ProxyChannel.java

/**
 * Add an <code>&lt;object&gt;</code> element to the channel
 * {@link net.www_eee.portal.Channel.ViewResponse#getContentContainerElement() content} creating an external resource
 * reference to the content at the given <code>proxiedFileURL</code> (link
 * {@linkplain #rewriteProxiedFileLink(Page.Request, URL, URI, boolean, boolean) rewritten} if necessary).
 * //  w ww .  j  av a 2s.  c o  m
 * @param pageRequest The {@link net.www_eee.portal.Page.Request Request} currently being processed.
 * @param viewResponse The {@link net.www_eee.portal.Channel.ViewResponse ViewResponse} currently being generated.
 * @param proxiedFileURL The {@linkplain #getProxiedFileURL(Page.Request, Channel.Mode, boolean) proxied file URL}.
 * @param contentType The {@link MimeType} of the proxied file.
 * @throws WWWEEEPortal.Exception If a problem occurred while determining the result.
 * @throws WebApplicationException If a problem occurred while determining the result.
 */
protected void renderResourceReferenceView(final Page.Request pageRequest, final ViewResponse viewResponse,
        final URL proxiedFileURL, final @Nullable MimeType contentType)
        throws WWWEEEPortal.Exception, WebApplicationException {
    final Element contentContainerElement = viewResponse.getContentContainerElement();
    final Document contentContainerDocument = DOMUtil.getDocument(contentContainerElement);

    final Element objectElement = DOMUtil.createElement(HTMLUtil.HTML_NS_URI, HTMLUtil.HTML_NS_PREFIX, "object",
            contentContainerElement, contentContainerDocument, true, true);

    final String[][] extraObjectClasses;
    if (contentType != null) {
        final String contentTypeString = contentType.toString();

        DOMUtil.createAttr(null, null, "type", contentTypeString, objectElement);

        final StringBuffer safeTypeClass = new StringBuffer();
        for (int i = 0; i < contentTypeString.length(); i++) {
            char c = contentTypeString.charAt(i);
            if (Character.isLetterOrDigit(c)) {
                safeTypeClass.append(c);
            } else {
                safeTypeClass.append('_');
            }
        }
        extraObjectClasses = new String[][] { new String[] { portal.getPortalID(), "channel",
                channelDef.getID(), "resource", "type", safeTypeClass.toString() } };

    } else {
        extraObjectClasses = null;
    }
    setIDAndClassAttrs(objectElement, Arrays.asList("proxy", "resource"), extraObjectClasses, null);

    final URI resourceURI = rewriteProxiedFileLink(pageRequest, proxiedFileURL, null, false, false).getKey();
    DOMUtil.createAttr(null, null, "data", resourceURI.toString(), objectElement);

    return;
}

From source file:gov.nih.nci.evs.browser.utils.DataUtils.java

public static String encodeTerm(String s) {
    if (s == null)
        return null;
    if (StringUtils.isAlphanumeric(s))
        return s;

    StringBuilder buf = new StringBuilder(s.length());
    for (int i = 0; i < s.length(); i++) {
        char c = s.charAt(i);
        if (Character.isLetterOrDigit(c)) {
            buf.append(c);//w w w .j  av  a 2s  .  c  om
        } else {
            buf.append("&#").append((int) c).append(";");
        }
    }
    return buf.toString();
}

From source file:com.jhh.hdb.sqlparser.MySemanticAnalyzer.java

/**
 * Returns whether the pattern is a regex expression (instead of a normal
 * string). Normal string is a string with all alphabets/digits and "_".
 *///from   www . ja  va 2s .c o  m
static boolean isRegex(String pattern, HiveConf conf) {
    String qIdSupport = HiveConf.getVar(conf, HiveConf.ConfVars.HIVE_QUOTEDID_SUPPORT);
    if ("column".equals(qIdSupport)) {
        return false;
    }
    for (int i = 0; i < pattern.length(); i++) {
        if (!Character.isLetterOrDigit(pattern.charAt(i)) && pattern.charAt(i) != '_') {
            return true;
        }
    }
    return false;
}

From source file:ths.commons.util.StringUtils.java

/**
 * <p>Checks if the CharSequence contains only Unicode letters, digits
 * or space ({@code ' '}).</p>//from   w  w  w. ja v a 2s  . c  o  m
 *
 * <p>{@code null} will return {@code false}.
 * An empty CharSequence (length()=0) will return {@code true}.</p>
 *
 * <pre>
 * StringUtils.isAlphanumericSpace(null)   = false
 * StringUtils.isAlphanumericSpace("")     = true
 * StringUtils.isAlphanumericSpace("  ")   = true
 * StringUtils.isAlphanumericSpace("abc")  = true
 * StringUtils.isAlphanumericSpace("ab c") = true
 * StringUtils.isAlphanumericSpace("ab2c") = true
 * StringUtils.isAlphanumericSpace("ab-c") = false
 * </pre>
 *
 * @param cs  the CharSequence to check, may be null
 * @return {@code true} if only contains letters, digits or space,
 *  and is non-null
 * @since 3.0 Changed signature from isAlphanumericSpace(String) to isAlphanumericSpace(CharSequence)
 */
public static boolean isAlphanumericSpace(CharSequence cs) {
    if (cs == null) {
        return false;
    }
    int sz = cs.length();
    for (int i = 0; i < sz; i++) {
        if ((Character.isLetterOrDigit(cs.charAt(i)) == false) && (cs.charAt(i) != ' ')) {
            return false;
        }
    }
    return true;
}

From source file:com.sjdf.platform.xss.StringUtils.java

/**
 * <p>//w w w .  j  ava 2 s .  co  m
 * Checks if the CharSequence contains only Unicode letters or digits.
 * </p>
 * <p/>
 * <p>
 * {@code null} will return {@code false}. An empty CharSequence
 * (length()=0) will return {@code false}.
 * </p>
 * <p/>
 * <pre>
 * StringUtils.isAlphanumeric(null)   = false
 * StringUtils.isAlphanumeric("")     = false
 * StringUtils.isAlphanumeric("  ")   = false
 * StringUtils.isAlphanumeric("abc")  = true
 * StringUtils.isAlphanumeric("ab c") = false
 * StringUtils.isAlphanumeric("ab2c") = true
 * StringUtils.isAlphanumeric("ab-c") = false
 * </pre>
 *
 * @param cs the CharSequence to check, may be null
 * @return {@code true} if only contains letters or digits, and is non-null
 * @since 3.0 Changed "" to return false and not true
 */
public static boolean isAlphanumeric(CharSequence cs) {
    if (cs == null || cs.length() == 0) {
        return false;
    }
    int sz = cs.length();
    for (int i = 0; i < sz; i++) {
        if (!Character.isLetterOrDigit(cs.charAt(i))) {
            return false;
        }
    }
    return true;
}

From source file:org.apache.commons.lang3.StringUtils.java

/**
 * <p>Checks if the CharSequence contains only Unicode letters or digits.</p>
 *
 * <p>{@code null} will return {@code false}.
 * An empty CharSequence (length()=0) will return {@code false}.</p>
 *
 * <pre>// w  w  w. j  a  v a2s .com
 * StringUtils.isAlphanumeric(null)   = false
 * StringUtils.isAlphanumeric("")     = false
 * StringUtils.isAlphanumeric("  ")   = false
 * StringUtils.isAlphanumeric("abc")  = true
 * StringUtils.isAlphanumeric("ab c") = false
 * StringUtils.isAlphanumeric("ab2c") = true
 * StringUtils.isAlphanumeric("ab-c") = false
 * </pre>
 *
 * @param cs  the CharSequence to check, may be null
 * @return {@code true} if only contains letters or digits,
 *  and is non-null
 * @since 3.0 Changed signature from isAlphanumeric(String) to isAlphanumeric(CharSequence)
 * @since 3.0 Changed "" to return false and not true
 */
public static boolean isAlphanumeric(CharSequence cs) {
    if (cs == null || cs.length() == 0) {
        return false;
    }
    int sz = cs.length();
    for (int i = 0; i < sz; i++) {
        if (Character.isLetterOrDigit(cs.charAt(i)) == false) {
            return false;
        }
    }
    return true;
}

From source file:com.sjdf.platform.xss.StringUtils.java

/**
 * <p>//ww  w  .j a v a  2 s.c o  m
 * Checks if the CharSequence contains only Unicode letters, digits or space
 * ({@code ' '}).
 * </p>
 * <p/>
 * <p>
 * {@code null} will return {@code false}. An empty CharSequence
 * (length()=0) will return {@code true}.
 * </p>
 * <p/>
 * <pre>
 * StringUtils.isAlphanumericSpace(null)   = false
 * StringUtils.isAlphanumericSpace("")     = true
 * StringUtils.isAlphanumericSpace("  ")   = true
 * StringUtils.isAlphanumericSpace("abc")  = true
 * StringUtils.isAlphanumericSpace("ab c") = true
 * StringUtils.isAlphanumericSpace("ab2c") = true
 * StringUtils.isAlphanumericSpace("ab-c") = false
 * </pre>
 *
 * @param cs the CharSequence to check, may be null
 * @return {@code true} if only contains letters, digits or space, and is
 * non-null
 * @since 3.0 Changed signature from isAlphanumericSpace(String) to
 * isAlphanumericSpace(CharSequence)
 */
public static boolean isAlphanumericSpace(CharSequence cs) {
    if (cs == null) {
        return false;
    }
    int sz = cs.length();
    for (int i = 0; i < sz; i++) {
        if (!Character.isLetterOrDigit(cs.charAt(i)) && cs.charAt(i) != ' ') {
            return false;
        }
    }
    return true;
}

From source file:org.apache.commons.lang3.StringUtils.java

/**
 * <p>Checks if the CharSequence contains only Unicode letters, digits
 * or space ({@code ' '}).</p>//from  w w w.j  av a2  s . c om
 *
 * <p>{@code null} will return {@code false}.
 * An empty CharSequence (length()=0) will return {@code true}.</p>
 *
 * <pre>
 * StringUtils.isAlphanumericSpace(null)   = false
 * StringUtils.isAlphanumericSpace("")     = true
 * StringUtils.isAlphanumericSpace("  ")   = true
 * StringUtils.isAlphanumericSpace("abc")  = true
 * StringUtils.isAlphanumericSpace("ab c") = true
 * StringUtils.isAlphanumericSpace("ab2c") = true
 * StringUtils.isAlphanumericSpace("ab-c") = false
 * </pre>
 *
 * @param cs  the CharSequence to check, may be null
 * @return {@code true} if only contains letters, digits or space,
 *  and is non-null
 * @since 3.0 Changed signature from isAlphanumericSpace(String) to isAlphanumericSpace(CharSequence)
 */
public static boolean isAlphanumericSpace(CharSequence cs) {
    if (cs == null) {
        return false;
    }
    int sz = cs.length();
    for (int i = 0; i < sz; i++) {
        if (Character.isLetterOrDigit(cs.charAt(i)) == false && cs.charAt(i) != ' ') {
            return false;
        }
    }
    return true;
}

From source file:com.cohort.util.String2.java

/** 
 * This converts "camelCase99String" to "Camel Case 99 String"
 * //from   w  ww  .  j  ava 2 s  .  c  o m
 * @param s the camel case string.
 * @return the string with spaces before capital letters.
 *   null returns null.
 *   "" returns "".
 */
public static String camelCaseToTitleCase(String s) {

    //change 
    //  but don't space out an acronym, e.g., E T O P O
    //  and don't split hyphenated words, e.g.,   Real-Time
    if (s == null)
        return null;
    int n = s.length();
    if (n <= 1)
        return s;
    StringBuilder sb = new StringBuilder(n + 10);
    sb.append(Character.toUpperCase(s.charAt(0)));
    for (int i = 1; i < n; i++) {
        char chi1 = s.charAt(i - 1);
        char chi = s.charAt(i);
        if (Character.isLetter(chi)) {
            if (chi1 == Character.toLowerCase(chi1) && Character.isLetterOrDigit(chi1)
                    && chi != Character.toLowerCase(chi))
                sb.append(' ');
        } else if (Character.isDigit(chi)) {
            if (chi1 == Character.toLowerCase(chi1) && Character.isLetter(chi1))
                sb.append(' ');
        }
        sb.append(chi);
    }
    return sb.toString();
}

From source file:gdv.xport.feld.Bezeichner.java

private static String toShortcut(final String input) {
    StringBuilder converted = new StringBuilder();
    char[] chars = input.toCharArray();
    for (int i = 0; i < chars.length; i++) {
        switch (chars[i]) {
        case '\u00c4':
            converted.append("Ae");
            break;
        case '\u00d6':
            converted.append("Oe");
            break;
        case '\u00dc':
            converted.append("Ue");
            break;
        case '\u00e4':
            converted.append("ae");
            break;
        case '\u00f6':
            converted.append("oe");
            break;
        case '\u00fc':
            converted.append("ue");
            break;
        case '\u00df':
            converted.append("ss");
            break;
        default:/*from   w  ww . ja v a  2 s  .co  m*/
            if (Character.isLetterOrDigit(chars[i])) {
                converted.append(chars[i]);
            }
            break;
        }
    }
    String word = converted.toString();
    if (word.endsWith("datum")) {
        return word.substring(0, word.length() - 2);
    }
    if ("Waehrungseinheiten".equals(word)) {
        return "WE";
    }
    return WordUtils.capitalize(word);
}