Example usage for java.lang StringBuffer setCharAt

List of usage examples for java.lang StringBuffer setCharAt

Introduction

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

Prototype

@Override
public synchronized void setCharAt(int index, char ch) 

Source Link

Usage

From source file:com.github.DroidPHP.Utils.ConfParser.java

public static String filterValue(String mString) {
    StringBuffer sb = new StringBuffer(mString);

    if (mString.startsWith("\"") || mString.startsWith("'")) {
        sb.setCharAt(0, ' ');

    }//  w w w. j av a2s. c om
    if (mString.endsWith("\"") || mString.endsWith("'")) {
        sb.deleteCharAt(mString.length() - 1);

    }
    mString = null;

    return sb.toString().trim();

}

From source file:Main.java

/**
 * Replaces Windows 1252 characters with their Unicode equivalents.
 * @param buffer the buffer to be edited 
 *//*from   w w  w  . j  a va 2 s .  c o  m*/
public static void fixWin1252(StringBuffer buffer) {
    for (int i = 0; i < buffer.length(); i++) {
        char ch = buffer.charAt(i);
        if ('\u0080' <= ch && ch <= '\u009F')
            buffer.setCharAt(i, win1252_80_9f[ch - '\u0080']);
    }
}

From source file:com.yunmel.syncretic.utils.commons.StrUtils.java

/**
 * ?//w  w  w.  j a v  a2s.  c o  m
 * @param str
 * @return
 */
public static String firstCharToUpper(String str) {
    StringBuffer sb = new StringBuffer(str);
    sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
    return sb.toString();
}

From source file:com.yunmel.syncretic.utils.commons.StrUtils.java

/**
 * ??//w ww. j  a v a  2 s  .  c  om
 * @param str
 * @return
 */
public static String firstCharToLower(String str) {
    StringBuffer sb = new StringBuffer(str);
    sb.setCharAt(0, Character.toLowerCase(sb.charAt(0)));
    return sb.toString();
}

From source file:com.util.ConvertJspToStringHtml.java

private static String ASCII2Unicode(String ascii) {
    StringBuffer unicode = new StringBuffer(ascii);
    int code;/*from ww  w.  ja va  2s  . c  o  m*/
    for (int i = 0; i < ascii.length(); i++) {
        code = (int) ascii.charAt(i);
        if ((0xA1 <= code) && (code <= 0xFB)) {
            unicode.setCharAt(i, (char) (code + 0xD60));
        }
    }
    return unicode.toString();
}

From source file:ju.ehealthservice.graphs.RespRateGraphImage.java

public static boolean save(String fileName, String img) {
    try {//from www  . java2  s .com
        StringBuffer data = new StringBuffer(img);
        data = new StringBuffer(data.substring(23));
        int c = 0;
        for (int i = 0; i < data.length(); i++) {
            if (data.charAt(i) == ' ') {
                c++;
                data.setCharAt(i, '+');
            }
        }
        byte[] imageByteArray = Base64.decodeBase64(data.toString());
        String ID = fileName.substring(0, fileName.indexOf('_'));
        String path = Constants.GRAPH_REPOSITORY_PATH + ID + "\\RespRate\\";
        fileName = fileName + ".jpg";
        FileOutputStream imageOutFile = new FileOutputStream(path + fileName);
        imageOutFile.write(imageByteArray);
        imageOutFile.close();
        return true;
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}

From source file:ju.ehealthservice.graphs.ECGGraphImage.java

public static boolean save(String fileName, String img) {
    try {/*from w w w.j  ava2 s  .  c  om*/
        StringBuffer data = new StringBuffer(img);
        data = new StringBuffer(data.substring(23));
        int c = 0;
        for (int i = 0; i < data.length(); i++) {
            if (data.charAt(i) == ' ') {
                c++;
                data.setCharAt(i, '+');
            }
        }
        byte[] imageByteArray = Base64.decodeBase64(data.toString());
        String ID = fileName.substring(0, fileName.indexOf('_'));
        String path = Constants.GRAPH_REPOSITORY_PATH + ID + "\\ECG\\";
        fileName = fileName + ".jpg";
        FileOutputStream imageOutFile = new FileOutputStream(path + fileName);
        imageOutFile.write(imageByteArray);
        imageOutFile.close();
        return true;
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}

From source file:org.kuali.rice.edl.impl.components.WorkflowDocumentState.java

public static void addActions(Document dom, Element documentState, List actions) {
    Element actionsPossible = EDLXmlUtils.getOrCreateChildElement(documentState, "actionsPossible", true);
    Iterator it = actions.iterator();
    while (it.hasNext()) {
        String action = it.next().toString();
        Element actionElement = dom.createElement(action);
        // if we use string.xsl we can avoid doing this here
        // (unless for some reason we decide we want different titles)
        if (!Character.isUpperCase(action.charAt(0))) {
            StringBuffer sb = new StringBuffer(action);
            sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
            action = sb.toString();//w ww.ja  va  2 s . c o m
        }
        actionElement.setAttribute("title", action);
        actionsPossible.appendChild(actionElement);
    }

    Element annotatable = EDLXmlUtils.getOrCreateChildElement(documentState, "annotatable", true);
    annotatable.appendChild(dom.createTextNode(String.valueOf(isAnnotatable(actions))));
}

From source file:Main.java

private static String convertStringToTime(String oldTime) {
    if (oldTime == null || oldTime.length() == 0) {
        return "00h00m00s";
    }/* w w  w . ja  v  a2  s . c om*/

    boolean hasHours = (oldTime.indexOf('h') != -1);
    boolean hasMinutes = (oldTime.indexOf('m') != -1);
    StringBuffer rtn = new StringBuffer(oldTime);

    // Delete the seconds fields and replace other chars with colons
    rtn.deleteCharAt(oldTime.indexOf('s'));

    if (hasMinutes) {
        rtn.setCharAt(oldTime.indexOf('m'), ':');
    } else {
        rtn.insert(0, "00:");
    }

    if (hasHours) {
        rtn.setCharAt(oldTime.indexOf('h'), ':');
    } else {
        rtn.insert(0, "00:");
    }

    StringTokenizer st = new StringTokenizer(rtn.toString(), ":");
    int index = 1;
    String hh = "00";
    String mm = "00";
    String ss = "00";

    while (st.hasMoreTokens()) {
        String toke = st.nextToken();

        switch (index) {
        case 1:
            if (toke.length() < 2) {
                hh = "0" + toke;
            } else {
                hh = toke;
            }
            break;

        case 2:
            if (toke.length() < 2) {
                mm = "0" + toke;
            } else {
                mm = toke;
            }
            break;

        case 3:
            if (toke.length() < 2) {
                ss = "0" + toke;
            } else {
                ss = toke;
            }
            break;
        }

        index++;
    }

    return hh + "h" + mm + "m" + ss + "s";
}

From source file:org.openadaptor.core.AbstractTestIDataProcessor.java

protected static JSONObject generateJSON(Object[] names, Object[] values) {
    StringBuffer sb = new StringBuffer("{");
    for (int i = 0; i < names.length; i++) {
        sb.append('"').append(names[i]).append('"');
        sb.append(":").append('"').append(values[i]).append('"');
        sb.append(",");
    }// ww w .ja va  2  s.  c o m
    sb.setCharAt(sb.length() - 1, '}');
    try {
        return new JSONObject(sb.toString());
    } catch (JSONException je) {
        throw new RuntimeException(je);
    }
}