Example usage for java.lang Character Character

List of usage examples for java.lang Character Character

Introduction

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

Prototype

@Deprecated(since = "9")
public Character(char value) 

Source Link

Document

Constructs a newly allocated Character object that represents the specified char value.

Usage

From source file:org.opencms.util.CmsDataTypeUtil.java

/**
 * Formats the given data into a string value.<p>
 * /*w w  w .j a  v a  2s.com*/
 * @param data the data to format
 * 
 * @return a string representation of the given data
 */
public static String format(char data) {

    return new Character(data).toString();
}

From source file:com.jdom.junit.utils.AbstractFixture.java

/**
 * Get a randomized value./*from   w  w w .  j  a  va2  s . c om*/
 * 
 * @param value
 *            the value to randomize
 * @param salt
 *            the randomizer to use
 * @return the randomized value
 */
public static Character getSaltedValue(Character value, int salt) {
    Character retValue;

    if (salt == 0) {
        retValue = value;
    } else {
        retValue = new Character(String.valueOf(salt).charAt(0));
    }

    return retValue;
}

From source file:org.sipfoundry.sipxconfig.common.DataCollectionUtilTest.java

public void testMove() throws Exception {
    List<Character> list = new ArrayList<Character>();
    for (char c = 'a'; c < 'd'; c++) {
        list.add(c);/* ww  w  .  jav a 2s .c o m*/
    }

    assertEquals(0, DataCollectionUtil.move(list, 0, -1));
    assertEquals(0, DataCollectionUtil.move(list, 0, -2));
    assertEquals(0, DataCollectionUtil.move(list, 1, -1));
    assertEquals(new Character('b'), list.get(0));
    assertEquals(new Character('a'), list.get(1));
    assertEquals(2, DataCollectionUtil.move(list, 0, 3));
    assertEquals(new Character('b'), list.get(2));
    assertEquals(2, DataCollectionUtil.move(list, 0, 2));
    assertEquals(new Character('a'), list.get(2));
    assertEquals(new Character('b'), list.get(1));
    assertEquals(new Character('c'), list.get(0));
}

From source file:org.apache.zeppelin.file.HDFSFileInterpreter.java

private String listOne(String path, OneFileStatus fs) {
    if (args.flags.contains(new Character('l'))) {
        StringBuilder sb = new StringBuilder();
        sb.append(listPermission(fs) + "\t");
        sb.append(((fs.replication == 0) ? "-" : fs.replication) + "\t ");
        sb.append(fs.owner + "\t");
        sb.append(fs.group + "\t");
        if (args.flags.contains(new Character('h'))) { //human readable
            sb.append(humanReadableByteCount(fs.length) + "\t\t");
        } else {/*from   w w w. j av  a 2 s  . c  o  m*/
            sb.append(fs.length + "\t");
        }
        sb.append(listDate(fs) + "GMT\t");
        sb.append((path.length() == 1) ? path + fs.pathSuffix : path + '/' + fs.pathSuffix);
        return sb.toString();
    }
    return fs.pathSuffix;
}

From source file:org.pdfsam.console.business.dto.commands.AbstractParsedCommand.java

/**
 * @param outputPdfVersion//ww w.  jav a2 s.c  o  m
 *        the outputPdfVersion to set
 */
public void setOutputPdfVersion(char outputPdfVersion) {
    this.outputPdfVersion = new Character(outputPdfVersion);
}

From source file:org.tmjee.miniwiki.radeox.filter.ListFilter.java

/**
 * Adds a list to a buffer/* w  w  w . ja  v a 2s . c om*/
 *
 * @param buffer The buffer to write to
 * @param reader Input is read from this Reader
 */
private void addList(StringBuffer buffer, BufferedReader reader) throws IOException {
    char[] lastBullet = new char[0];
    String line = null;
    while ((line = reader.readLine()) != null) {
        // no nested list handling, trim lines:
        line = line.trim();
        if (line.length() == 0) {
            continue;
        }

        int bulletEnd = line.indexOf(' ');
        if (bulletEnd < 1) {
            continue;
        }
        if (line.charAt(bulletEnd - 1) == '.') {
            bulletEnd--;
        }
        char[] bullet = line.substring(0, bulletEnd).toCharArray();
        // Logger.log("found bullet: ('" + new String(lastBullet) + "') '" + new String(bullet) + "'");
        // check whether we find a new list
        int sharedPrefixEnd;
        for (sharedPrefixEnd = 0;; sharedPrefixEnd++) {
            if (bullet.length <= sharedPrefixEnd || lastBullet.length <= sharedPrefixEnd
                    || +bullet[sharedPrefixEnd] != lastBullet[sharedPrefixEnd]) {
                break;
            }
        }

        for (int i = sharedPrefixEnd; i < lastBullet.length; i++) {
            //Logger.log("closing " + lastBullet[i]);
            buffer.append(closeList.get(new Character(lastBullet[i]))).append("\n");
        }

        for (int i = sharedPrefixEnd; i < bullet.length; i++) {
            //Logger.log("opening " + bullet[i]);
            buffer.append(openList.get(new Character(bullet[i]))).append("\n");
        }
        buffer.append("<li>");
        buffer.append(line.substring(line.indexOf(' ') + 1));
        buffer.append("</li>\n");
        lastBullet = bullet;
    }

    for (int i = lastBullet.length - 1; i >= 0; i--) {
        //Logger.log("closing " + lastBullet[i]);
        buffer.append(closeList.get(new Character(lastBullet[i])));
    }
}

From source file:com.github.xbn.array.primitive.ObjectArrayFromPrimitive.java

/**
   <p>Get a {@code java.lang.Object} array from an array of {@code char}-s.</p>
        /*from   ww  w  .j a  v  a  2s .  c  o  m*/
 * @return  If {@code prmtv_array} is<ul>
 <li>{@code null}: {@code null}</li>
 <li>non-{@code null} and has no elements: <code>org.apache.commons.lang3.{@link org.apache.commons.lang3.ArrayUtils ArrayUtils}.{@link org.apache.commons.lang3.ArrayUtils#EMPTY_OBJECT_ARRAY EMPTY_OBJECT_ARRAY}</code></li>
 <li>Otherwise: A new {@code Object} array containing all elements in {@code prmtv_array}.</li>
   </ul>
 * @see  #get(boolean[], NullContainer, String) get(b[])
 */
public static final Object[] get(char[] prmtv_array, NullContainer nnull, String cntrName_forNullBad) {
    if (prmtv_array == null) {
        IndexableUtil.crashIfContainerIsNullAndThatIsBad(nnull, cntrName_forNullBad);
        return null;
    }

    if (prmtv_array.length == 0) {
        return ArrayUtils.EMPTY_OBJECT_ARRAY;
    }

    Character[] ao = new Character[prmtv_array.length];
    for (int i = 0; i < prmtv_array.length; i++) {
        ao[i] = new Character(prmtv_array[i]);
    }

    return ao;
}

From source file:org.xwiki.batchimport.BatchImportService.java

/**
 * Fills in the passed configuration from the request. Used to be able to chain read methods on the same
 * configuration, only overwriting the settings contained in the request (leaving the rest unchanged).
 * //  w w  w  .j  av  a 2 s  . c o  m
 * @see #readConfigurationFromRequest()
 */
@SuppressWarnings("unchecked")
public BatchImportConfiguration readConfigurationFromRequest(BatchImportConfiguration config) {
    XWikiRequest request = getRequest();

    String separatorValue = request.getParameter("batchimportseparator");
    // only take into account if it's not empty and it's exactly one
    if (!StringUtils.isEmpty(separatorValue) && separatorValue.length() == 1) {
        config.setCsvSeparator(new Character(separatorValue.charAt(0)));
    }

    try {
        String attachmentRef = request.getParameter("batchimportattachmentref");
        if (!StringUtils.isEmpty(attachmentRef)) {
            AttachmentReferenceResolver<String> refResolver = cm.lookup(AttachmentReferenceResolver.class,
                    "current");
            config.setAttachmentReference(refResolver.resolve(attachmentRef));
        }
    } catch (ComponentLookupException cle) {
        LOGGER.warn("Could not parse attachment reference from request parameters", cle);
    }

    String type = request.getParameter("batchimporttype");
    if (!StringUtils.isEmpty(type)) {
        config.setType(type);
    }

    String hasheader = request.getParameter("batchimporthasheader");
    if (!StringUtils.isEmpty(hasheader)) {
        config.setHeaderRow(Boolean.parseBoolean(hasheader));
    }

    String mappingClass = request.getParameter("batchimportmappingclass");
    if (!StringUtils.isEmpty(mappingClass)) {
        config.setMappingClassName(mappingClass);
    }

    for (Map.Entry<String, String[]> parameter : ((Map<String, String[]>) request.getParameterMap())
            .entrySet()) {
        if (parameter.getKey().startsWith(MAPPING_PARAM_PREFIX) && parameter.getValue().length > 0
                && !StringUtils.isEmpty(parameter.getValue()[0])) {
            config.addFieldMapping(parameter.getKey().substring(MAPPING_PARAM_PREFIX.length()),
                    parameter.getValue()[0]);
        }
    }

    String defaultSpace = request.getParameter("batchimportdefaultspace");
    if (!StringUtils.isEmpty(defaultSpace)) {
        config.setDefaultSpace(defaultSpace);
    }

    String emptyDocNamePrefix = request.getParameter("batchimportemptydocnameprefix");
    if (!StringUtils.isEmpty(emptyDocNamePrefix)) {
        config.setEmptyDocNamePrefix(emptyDocNamePrefix);
    }

    String localeLanguage = request.getParameter("batchimportlocalelanguage");
    if (!StringUtils.isEmpty(localeLanguage)) {
        config.setLocale(localeLanguage);
    }

    String defaultDateFormat = request.getParameter("batchimportdefaultdateformat");
    if (!StringUtils.isEmpty(defaultDateFormat)) {
        config.setDefaultDateFormat(defaultDateFormat);
    }

    String overwrite = request.getParameter("batchimportoverwrite");
    if (!StringUtils.isEmpty(overwrite)) {
        config.setOverwrite(overwrite);
    }

    String docNameDeduplication = request.getParameter("batchimportdocnamededuplication");
    if (!StringUtils.isEmpty(docNameDeduplication)) {
        config.setDocNameDeduplication(docNameDeduplication);
    }

    String listSeparator = request.getParameter("batchimportlistseparator");
    if (!StringUtils.isEmpty(listSeparator)) {
        config.setListSeparator(listSeparator.charAt(0));
    }

    return config;
}

From source file:org.radeox.filter.ListFilter.java

/**
 * Adds a list to a buffer// w w w  . j  av  a  2  s.  co m
 * 
 * @param buffer
 *        The buffer to write to
 * @param reader
 *        Input is read from this Reader
 */
private void addList(StringBuffer buffer, BufferedReader reader) throws IOException {
    char[] lastBullet = new char[0];
    String line = null;
    boolean goneUp = false;
    while ((line = reader.readLine()) != null) {
        // no nested list handling, trim lines:
        line = line.trim();
        if (line.length() == 0) {
            continue;
        }

        // if the line doesn't contain a space ignore it. (it shouldn't have
        // matched!)
        int bulletEnd = line.indexOf(' ');
        if (bulletEnd < 1) {
            continue;
        }
        if (line.charAt(bulletEnd - 1) == '.') {
            bulletEnd--;
        }
        char[] bullet = line.substring(0, bulletEnd).toCharArray();
        // Logger.log("found bullet: ('" + new String(lastBullet) + "') '" +
        // new String(bullet) + "'");
        // check whether we find a new list
        int sharedPrefixEnd;
        for (sharedPrefixEnd = 0;; sharedPrefixEnd++) {
            if (bullet.length <= sharedPrefixEnd || lastBullet.length <= sharedPrefixEnd
                    || +bullet[sharedPrefixEnd] != lastBullet[sharedPrefixEnd]) {
                break;
            }
        }

        goneUp = false;

        for (int i = sharedPrefixEnd; i < lastBullet.length; i++) {
            // Logger.log("closing " + lastBullet[i]);
            if (lastBullet[i] != '.') {
                buffer.append("</li>").append(closeList.get(new Character(lastBullet[i]))).append("\n");
            }

        }

        for (int i = sharedPrefixEnd; i < bullet.length; i++) {
            // Logger.log("opening " + bullet[i]);
            if (bullet[i] != '.') {
                buffer.append(openList.get(new Character(bullet[i]))).append("<li>");
            }
            goneUp = true;
        }
        if (!goneUp) {
            buffer.append("</li>\n<li>");
        }

        buffer.append(line.substring(line.indexOf(' ') + 1));

        lastBullet = bullet;
    }

    for (int i = lastBullet.length - 1; i >= 0; i--) {
        // Logger.log("closing " + lastBullet[i]);
        if (lastBullet[i] != '.') {
            buffer.append("</li>").append(closeList.get(new Character(lastBullet[i])));
        }
    }
    buffer.append('\n');
}

From source file:org.jamwiki.db.WikiPreparedStatement.java

/**
 * Sets the designated parameter to the given Java character value. The
 * driver converts this to an SQL CHAR value when it sends it to the database.
 *
 * @param parameterIndex The first parameter is 1, the second is 2, ...
 * @param x The parameter value.//from   w w w  .  j a va2 s.com
 * @throws Exception If a parameter is invalid.
 */
public void setChar(int parameterIndex, char x) throws Exception {
    this.verifyParams(parameterIndex);
    this.paramTypes[parameterIndex - 1] = Types.CHAR;
    this.params[parameterIndex - 1] = new Character(x);
}