Example usage for java.lang Character toString

List of usage examples for java.lang Character toString

Introduction

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

Prototype

public static String toString(int codePoint) 

Source Link

Document

Returns a String object representing the specified character (Unicode code point).

Usage

From source file:com.moz.fiji.schema.hbase.FijiManagedHBaseTableName.java

/**
 * Constructs using an HBase HTable name.
 *
 * @param hbaseTableName The HBase HTable name.
 * @return A new fiji-managed HBase table name.
 * @throws NotAFijiManagedTableException If the HBase table is not managed by fiji.
 */// ww  w .  j  ava2  s . co  m
public static FijiManagedHBaseTableName get(String hbaseTableName) throws NotAFijiManagedTableException {
    // Split it into components.
    String[] components = StringUtils.splitPreserveAllTokens(hbaseTableName, Character.toString(DELIMITER), 4);

    // Make sure the first component is 'fiji'.
    if (!components[0].equals(FIJI_COMPONENT)) {
        throw new NotAFijiManagedTableException(hbaseTableName, "Doesn't start with fiji name component.");
    }

    if (components.length == 3) {
        // It's a managed fiji meta/schema/system table.
        return new FijiManagedHBaseTableName(components[1], components[2]);
    } else if (components.length == 4) {
        // It's a user-space fiji table.
        return new FijiManagedHBaseTableName(components[1], components[2], components[3]);
    } else {
        // Wrong number of components... must not be a fiji table.
        throw new NotAFijiManagedTableException(hbaseTableName, "Invalid number of name components.");
    }
}

From source file:org.apache.axis2.databinding.utils.ConverterUtil.java

public static String convertToString(char i) {
    return Character.toString(i);
}

From source file:com.salesmanager.core.module.impl.application.currencies.GenericCurrencyModule.java

public String getFormatedAmount(BigDecimal amount) throws Exception {
    // TODO Auto-generated method stub
    NumberFormat nf = null;/*from www.j a va2 s.  co  m*/

    Locale locale = Locale.US;

    if (this.decimalPoint == ',') {
        locale = Locale.GERMAN;
    }

    nf = NumberFormat.getInstance(locale);

    nf.setMaximumFractionDigits(Integer.parseInt(Character.toString(decimalCount)));
    nf.setMinimumFractionDigits(Integer.parseInt(Character.toString(decimalCount)));

    return nf.format(amount);
}

From source file:com.ibm.stocator.fs.swift2d.systemtests.SwiftTestUtils.java

/**
 * Convert a byte to a character for printing. If the
 * byte value is < 32 -and hence unprintable- the byte is
 * returned as a two digit hex value//from   w  w  w . j  a v a  2 s.c o  m
 * @param b byte
 * @return the printable character string
 */
public static String toChar(byte b) {
    if (b >= 0x20) {
        return Character.toString((char) b);
    } else {
        return String.format("%02x", b);
    }
}

From source file:com.techcavern.pircbotz.Channel.java

protected void parseMode(String rawMode) {
    if (rawMode.contains(" ")) {
        //Mode contains arguments which are impossible to parse.
        //Could be a ban command (we shouldn't use this), channel key (should, but where), etc
        //Need to ask server
        modeStale = true;//from w  w  w. ja  v  a  2  s  . c om
        return;
    }

    //Parse mode by switching between removing and adding by the existance of a + or - sign
    boolean adding = true;
    for (char curChar : rawMode.toCharArray())
        if (curChar == '-')
            adding = false;
        else if (curChar == '+')
            adding = true;
        else if (adding)
            mode = mode + curChar;
        else
            mode = mode.replace(Character.toString(curChar), "");
}

From source file:net.sourceforge.pmd.lang.rule.properties.AbstractMultiValueProperty.java

@Override
protected void addAttributesTo(Map<PropertyDescriptorField, String> attributes) {
    super.addAttributesTo(attributes);
    attributes.put(PropertyDescriptorField.DELIMITER, Character.toString(multiValueDelimiter()));
}

From source file:org.andromda.cartridges.database.metafacades.ColumnLogicImpl.java

/**
 * @see org.andromda.cartridges.database.metafacades.NonForeignKeyColumn#getDummyLoadValue(int)
 *//*  w  ww .  java  2  s .  c  o m*/
protected String handleGetDummyLoadValue(int index) {

    String dummyLoadValue = null;

    final ClassifierFacade metaType = getType();
    final String type = metaType.getFullyQualifiedName(true);

    if ("datatype::String".equals(type)) {

        dummyLoadValue = getName() + '-' + index;

    } else if ("datatype::boolean".equals(type)) {

        dummyLoadValue = String.valueOf((index % 2) == 0);

    } else if ("datatype::int".equals(type) || "datatype::Integer".equals(type)
            || "datatype::short".equalsIgnoreCase(type) || "datatype::long".equalsIgnoreCase(type)) {

        dummyLoadValue = String.valueOf(index);

    } else if ("datatype::float".equalsIgnoreCase(type) || "datatype::double".equalsIgnoreCase(type)) {

        dummyLoadValue = String.valueOf(index) + ".555";

    } else if ("datatype::char".equals(type) || "datatype::Character".equals(type)) {

        dummyLoadValue = Character.toString((char) index);

    } else if ("datatype::Date".equals(type) || "datatype::DateTime".equals(type)) {

        dummyLoadValue = DATE_FORMATTER.format(new Date());

    } else if (metaType.isEnumeration()) {

        List literals = new ArrayList(getType().getAttributes());
        AttributeFacade literal = (AttributeFacade) literals.get(index % literals.size());

        dummyLoadValue = literal.getName();

    } else {

        dummyLoadValue = "\'error\'";

    }

    final String maxLengthString = getColumnLength();
    int maxLength = 0;
    int dummyValueLength = dummyLoadValue.length();

    try {

        maxLength = Integer.parseInt(maxLengthString);

    } catch (Exception ex) {

        maxLength = 0;

    }

    if ((maxLength > 0) && (dummyValueLength > maxLength)) {

        int startIndex = dummyLoadValue.length() - maxLength;

        dummyLoadValue = dummyLoadValue.substring(startIndex);

    }

    if (needsQuotes(metaType)) {

        dummyLoadValue = '\'' + dummyLoadValue + '\'';

    }

    return dummyLoadValue;

}

From source file:com.evolveum.midpoint.repo.sql.query2.hqm.HibernateQuery.java

public String createAlias(String name, boolean entity) {
    String prefix;//from  ww w.  java  2  s.c om

    //we want to skip 'R' prefix for entity definition names (a bit of hack)
    int prefixIndex = entity ? 1 : 0;
    prefix = Character.toString(name.charAt(prefixIndex)).toLowerCase();

    int index = 2;
    String alias = prefix;
    while (hasAlias(alias)) {
        alias = prefix + Integer.toString(index);
        index++;

        if (index > LIMIT) {
            throw new IllegalStateException("Alias index for '" + name + "' is more than " + LIMIT
                    + "? This probably should not happen.");
        }
    }

    return alias;
}

From source file:org.egov.infra.utils.NumberToWord.java

public static String translateToWord(String value) {

    if (!isUnsignedNumber(value))
        throw new ApplicationRuntimeException("Provided value is not a valid number");

    StringBuilder numberInWords = new StringBuilder();
    long number = Long.parseLong(value);
    if (number == ZEROS || value.length() > 12) {
        numberInWords.append(getWord(number));
    }//from w  ww.java 2  s  .co  m

    Long subNum;
    String numericPart = Long.toString(number);
    while (number > 0 && numericPart.length() < 13) {
        numericPart = Long.toString(number);
        long place = getPlace(numericPart);

        if (place == HUNDREDCRORES || place == THOUSANDCRORES || place == TENTHOUSANDCRORES) {
            subNum = Long.parseLong(Character.toString(numericPart.charAt(0)));
            numberInWords.append(getWord(subNum));
            if (place == HUNDREDCRORES) {
                number -= subNum * HUNDREDCRORES;
                if (number == 0) {
                    numberInWords.append(HUNDRED_CRORES);
                } else {
                    numberInWords.append(HUNDRED);
                }
            } else if (place == THOUSANDCRORES) {
                number -= subNum * THOUSANDCRORES;
                if (number == 0) {
                    numberInWords.append(THOUSAND_CRORES);
                } else {
                    numberInWords.append(THOUSAND);
                }
            } else {
                numberInWords.setLength(0);
                subNum = Long.parseLong(Character.toString(numericPart.charAt(0)) + numericPart.charAt(1));
                number -= subNum * THOUSANDCRORES;
                if (subNum >= 21 && (subNum % 10) != 0 && number == 0) {
                    numberInWords.append(getWord(Long.parseLong(String.valueOf(numericPart.charAt(0))) * 10))
                            .append(WHITESPACE).append(getWord(subNum % 10)).append(THOUSAND_CRORES);
                } else if (number == 0) {
                    numberInWords.append(getWord(Long.parseLong(String.valueOf(numericPart.charAt(0))) * 10))
                            .append(THOUSAND_CRORES);
                } else {
                    numberInWords.append(getWord(Long.parseLong(String.valueOf(numericPart.charAt(0))) * 10))
                            .append(WHITESPACE).append(getWord(subNum % 10)).append(THOUSAND);
                }
            }

        } else if (place == TENS || place == TENTHOUSANDS || place == TENLAKHS || place == TENCRORES) {
            subNum = Long
                    .parseLong(String.valueOf(numericPart.charAt(0)) + String.valueOf(numericPart.charAt(1)));

            if (subNum >= 21 && (subNum % 10) != 0) {
                numberInWords.append(getWord(Long.parseLong(String.valueOf(numericPart.charAt(0))) * 10))
                        .append(WHITESPACE).append(getWord(subNum % 10));
            } else {
                numberInWords.append(getWord(subNum));
            }

            if (place == TENS) {
                number = 0;
            } else if (place == TENTHOUSANDS) {
                number -= subNum * THOUSANDS;
                numberInWords.append(THOUSAND);
            } else if (place == TENLAKHS) {
                number -= subNum * LAKHS;
                numberInWords.append(LAKH);
            } else if (place == TENCRORES) {
                number -= subNum * CRORES;
                numberInWords.append(CRORE);
            }
        } else {
            subNum = Long.parseLong(String.valueOf(numericPart.charAt(0)));
            numberInWords.append(getWord(subNum));
            if (place == UNITS) {
                number = 0;
            } else if (place == HUNDREDS) {
                number -= subNum * HUNDREDS;
                numberInWords.append(HUNDRED);
            } else if (place == THOUSANDS) {
                number -= subNum * THOUSANDS;
                numberInWords.append(THOUSAND);
            } else if (place == LAKHS) {
                number -= subNum * LAKHS;
                numberInWords.append(LAKH);
            } else if (place == CRORES) {
                number -= subNum * CRORES;
                numberInWords.append(CRORE);
            }
        }
    }
    return numberInWords.toString();
}

From source file:com.btobits.automator.fix.quickfix.bridge.FixConnectivity.java

public void sendRawMessage(final SessionID sessionID, final String inMessage, final boolean inValidate,
        final FillHeaderTrailer appropriateHeaderTrailer) throws Exception {

    final String replaced = inMessage.replaceAll("/u0001", Character.toString('\u0001'));

    //        if (fixVersion==null) {
    //            fixVersion = MessageUtils.getStringField(replaced, FixUtils.TYPE);
    //        }/* w ww .  jav a2 s.c  o  m*/

    final Session session = getSession(sessionID);
    //        if (appropriateHeaderTrailer) {
    //            // target and sender takes from fixSend task
    //            session = getSession(inSenderCompID, inTargetCompID, fixVersion);
    //        } else {
    //            // default values
    //            // target and sender takes from raw messages
    ////            session = getSession(senderFromRawMes, targetFromRawMes, fixVersion);
    //            session = getSession(inSenderCompID, inTargetCompID, fixVersion);
    //        }

    // validate message
    if (inValidate) {
        try {
            final Message ourMessage = MessageUtils2.parse(session, replaced);
            if (sessionID.isFIXT()) {
                MessageUtils2.validate(ourMessage, sessionID, session.getDataDictionaryProvider(),
                        session.getTargetDefaultApplicationVersionID());
            } else {
                MessageUtils2.validate(ourMessage, session.getDataDictionary());
            }
        } catch (final Exception e) {
            log.error("validation: got generic exception: " + e, e);
            throw new Exception("Validation failed: " + e, e);
        }
    }
    boolean resultSending = false;
    System.out.println("Send fix message [" + replaced + "].");
    switch (appropriateHeaderTrailer) {
    case NONE:
        resultSending = session.sendAsRaw(replaced);
        break;
    case ONLYREQ:
        resultSending = session.sendAsRaw(MessageUtils2.parse(session, replaced), false);
        break;
    case FULL:
        resultSending = session.sendAsRaw(MessageUtils2.parse(session, replaced), true);
        break;
    }
    if (!resultSending) {
        throw new Exception("Write to FIX network layer was not successful");
    }
}