Example usage for java.lang CharSequence toString

List of usage examples for java.lang CharSequence toString

Introduction

In this page you can find the example usage for java.lang CharSequence toString.

Prototype

public String toString();

Source Link

Document

Returns a string containing the characters in this sequence in the same order as this sequence.

Usage

From source file:jp.co.ctc_g.jse.core.validation.util.Validators.java

/**
 * ?????????????????????/*from   ww w . j ava 2 s.c  o  m*/
 * ??{@link GenericValidator#maxLength(String, int)}?????
 * @param suspect 
 * @param size 
 * @return GenericValidator#maxLength(String, int)??
 */
public static boolean maxLength(CharSequence suspect, int size) {
    return GenericValidator.maxLength(suspect.toString(), size);
}

From source file:com.simiacryptus.mindseye.models.Hdf5Archive.java

private static void printTree(@Nonnull Hdf5Archive hdf5, CharSequence prefix, boolean printData,
        @Nonnull Logger log, @Nonnull String... path) {
    for (CharSequence datasetName : hdf5.getDataSets(path)) {
        @Nullable/*from   w ww .ja  va 2s  . co m*/
        Tensor tensor = hdf5.readDataSet(datasetName.toString(), path);
        log.info(String.format("%sDataset %s: %s", prefix, datasetName,
                Arrays.toString(tensor.getDimensions())));
        if (printData)
            log.info(String.format("%s%s", prefix, tensor.prettyPrint().replaceAll("\n", "\n" + prefix)));
        tensor.freeRef();
    }
    hdf5.getAttributes(path).forEach((k, v) -> {
        log.info((String.format("%sAttribute: %s => %s", prefix, k, v)));
    });
    for (String t : hdf5.getGroups(path).stream().map(CharSequence::toString).sorted(new Comparator<String>() {
        @Override
        public int compare(@Nonnull String o1, @Nonnull String o2) {
            @Nonnull
            String prefix = "layer_";
            @Nonnull
            Pattern digit = Pattern.compile("^\\d+$");
            if (digit.matcher(o1).matches() && digit.matcher(o2).matches())
                return Integer.compare(Integer.parseInt(o1), Integer.parseInt(o2));
            if (o1.startsWith(prefix) && o2.startsWith(prefix))
                return compare(o1.substring(prefix.length()), o2.substring(prefix.length()));
            else
                return o1.compareTo(o2);
        }
    }).collect(Collectors.toList())) {
        log.info(prefix + t);
        printTree(hdf5, prefix + "\t", printData, log, concat(path, t));
    }
}

From source file:jp.co.ctc_g.jse.core.validation.util.Validators.java

/**
 * <p>//ww  w.  jav a2  s  .  c o m
 * ?????????????????
 * <pre>
 * <code>
 * // ??3???
 * ^(?:1(?:5[012345678]|7[013456789]|9[012345678]|3[01234567]|1[0123456]|4[0123456]|2[01345]|0\d|6\d|8\d)|2(?:9[023456789]|0[12345678]|2[01234567]|6[01234567]|8[23456789]|1[0123456]|3\d|4\d|5\d|7\d)|6(?:2[012345679]|0[01234567]|8[0123459]|1\d|3\d|4\d|5\d|6\d|7\d|9\d)|5(?:4[012345679]|8[012345679]|0\d|1\d|2\d|3\d|5\d|6\d|7\d|9\d)|7(?:2[012356789]|4[012345679]|0\d|1\d|3\d|5\d|6\d|7\d|8\d|9\d)|4(?:9[012345678]|2[01245678]|0\d|1\d|3\d|4\d|5\d|6\d|7\d|8\d)|0(?:3[013456789]|0[1234567]|1\d|2\d|4\d|5\d|6\d|7\d|8\d|9\d)|9(?:0[01234567]|7[01234569]|1\d|2\d|3\d|4\d|5\d|6\d|8\d|9\d)|3(?:0\d|1\d|2\d|3\d|4\d|5\d|6\d|7\d|8\d|9\d)|8(?:0\d|1\d|2\d|3\d|4\d|5\d|6\d|7\d|8\d|9\d))$
 * </code>
 * </pre>
 * <pre>
 * <code>
 * // ??4???
 * ^\d{4}$
 * </code>
 * </pre>
 * </p>
 * @param suspect 
 * @param separator 
 * @return ???true
 */
public static boolean isZipCode(CharSequence suspect, String separator) {
    String target = suspect.toString();
    if (target.length() != (7 + separator.length())) {
        return false;
    }
    String zip1 = target.substring(0, 3);
    String sep = target.substring(3, 3 + separator.length());
    String zip2 = target.substring(3 + separator.length(), target.length());
    if (!ZIP1_PATTERN.matcher(zip1).matches()) {
        return false;
    }
    if (!separator.equals(sep)) {
        return false;
    }
    if (!ZIP2_PATTERN.matcher(zip2).matches()) {
        return false;
    }
    return true;
}

From source file:jp.co.ctc_g.jse.core.validation.util.Validators.java

/**
 * ??????????/*from ww  w  .  j a  va  2s  . co m*/
 * ??{@link GenericValidator#isDate(String, String, boolean)}?????
 * @param suspect 
 * @param datePattern ?????{@link SimpleDateFormat}?/????
 * @param strict ??????? ?<code>true</code>????????????????
 * @return GenericValidator#isDate(String, String, boolean)??
 */
public static boolean isDate(CharSequence suspect, String datePattern, boolean strict) {
    return GenericValidator.isDate(suspect.toString(), datePattern, strict);
}

From source file:com.openAtlas.bundleInfo.maker.PackageLite.java

private static String buildClassName(String str, CharSequence charSequence) {
    if (charSequence == null || charSequence.length() <= 0) {
        System.out.println("Empty class name in package " + str);
        return null;
    }/*ww w. j  a v a  2 s.c o  m*/
    String obj = charSequence.toString();
    char charAt = obj.charAt(0);
    if (charAt == '.') {
        return (str + obj).intern();
    }
    if (obj.indexOf(46) < 0) {
        StringBuilder stringBuilder = new StringBuilder(str);
        stringBuilder.append('.');
        stringBuilder.append(obj);
        return stringBuilder.toString().intern();
    } else if (charAt >= 'a' && charAt <= 'z') {
        return obj.intern();
    } else {
        System.out.println("Bad class name " + obj + " in package " + str);
        return null;
    }
}

From source file:jp.co.ctc_g.jse.core.validation.util.Validators.java

/**
 * ??????????????//  ww w  .  ja v  a 2s .  c o  m
 * @param suspect 
 * @param size 
 * @param encoding 
 * @return ???????true
 * @throws UnsupportedEncodingException 
 */
public static boolean equalsByteLength(CharSequence suspect, int size, String encoding)
        throws UnsupportedEncodingException {
    return suspect.toString().getBytes(encoding).length == size;
}

From source file:jp.co.ctc_g.jse.core.validation.util.Validators.java

/**
 * ?????????????????????//from w w w . j  av  a 2 s  .  c o m
 * @param suspect 
 * @param size 
 * @param encoding 
 * @return ??????????????true
 * @throws UnsupportedEncodingException 
 */
public static boolean minByteLength(CharSequence suspect, int size, String encoding)
        throws UnsupportedEncodingException {
    return suspect.toString().getBytes(encoding).length >= size;
}

From source file:jp.co.ctc_g.jse.core.validation.util.Validators.java

/**
 * ?????????????????????/*from w  ww  .  j  a v a2  s . c o m*/
 * @param suspect 
 * @param size 
 * @param encoding 
 * @return ??????????????true
 * @throws UnsupportedEncodingException 
 */
public static boolean maxByteLength(CharSequence suspect, int size, String encoding)
        throws UnsupportedEncodingException {
    return suspect.toString().getBytes(encoding).length <= size;
}

From source file:jp.co.ctc_g.jse.core.validation.util.Validators.java

/**
 * BigDecimal?????//  ww  w.j a v  a 2 s.c o m
 * @param suspect 
 * @param throwing true????????
 * @return 
 */
public static BigDecimal toBigDecimal(CharSequence suspect, boolean throwing) {
    BigDecimal value = null;
    try {
        value = new BigDecimal(suspect.toString());
    } catch (NumberFormatException e) {
        L.debug("??({})????????????????",
                new Object[] { suspect });
        if (throwing) {
            throw e;
        }
    }
    return value;
}

From source file:com.github.maven_nar.NarUtil.java

/**
 * Replaces target with replacement in string. For jdk 1.4 compatiblity.
 * //from  w  w  w .  ja  v a  2 s . c om
 * @param target
 * @param replacement
 * @param string
 * @return
 */
public static String replace(final CharSequence target, final CharSequence replacement, final String string) {
    return Pattern.compile(quote(target.toString())/*
                                                    * , Pattern.LITERAL jdk 1.4
                                                    */).matcher(string)
            .replaceAll(/* Matcher. jdk 1.4 */quoteReplacement(replacement.toString()));
}