Example usage for java.lang StringBuffer deleteCharAt

List of usage examples for java.lang StringBuffer deleteCharAt

Introduction

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

Prototype

@Override
public synchronized StringBuffer deleteCharAt(int index) 

Source Link

Usage

From source file:com.delmar.station.web.action.WFDetailAction.java

private String convertCargoCompanyId(String orgIds) {

    if (orgIds == null || orgIds.length() <= 0) {
        return "";
    }/*from  w ww. j  av a 2 s.  co  m*/
    HttpServletRequest request = ServletActionContext.getRequest();
    List<UserorgAccess> userorgListStr = (List<UserorgAccess>) request.getSession()
            .getAttribute("userorgaccessList");

    if (orgIds.equals(""))
        return "";

    StringBuffer cargoCompanyIds = new StringBuffer();
    orgIds = "," + orgIds + ",";
    for (UserorgAccess userorgaccess : userorgListStr) {
        if (orgIds.indexOf("," + userorgaccess.getOrgId().toString() + ",") > -1)
            cargoCompanyIds.append(userorgaccess.getOrg().getValue() + ",");
    }

    if (cargoCompanyIds.length() > 0)
        cargoCompanyIds.deleteCharAt(cargoCompanyIds.length() - 1);

    return cargoCompanyIds.toString();
}

From source file:my.home.model.datasource.AutoCompleteItemDataSourceImpl.java

@Override
public void getAutoCompleteItems(Context context, String currentInput) {
    if (!mLoadSuccess) {
        BusProvider.getRestBusInstance().post(new MGetAutoCompleteItemEvent(new ArrayList()));
        return;/*from  www .  j  a v a 2 s. c om*/
    }

    boolean in_msg_or_time_ind_state = false;
    boolean in_msg_or_time_state = false;
    boolean in_if_state = false;
    boolean in_if_then_state = false;
    boolean in_while_state = false;
    String leftString = "";
    String lastString = "";
    String lastPreMsg = "";
    String lastState = "";
    StringBuffer cmdBuffer = new StringBuffer();
    StringBuffer inputBuffer = new StringBuffer(currentInput);
    String curState = mInitState;
    while (inputBuffer.length() > 0) {
        if (in_msg_or_time_ind_state) {
            if (inputBuffer.toString().startsWith(mMessageSeq) || inputBuffer.toString().startsWith(mTimeSeq)) {
                in_msg_or_time_ind_state = false;
            }
            cmdBuffer.append(inputBuffer.charAt(0));
            inputBuffer.deleteCharAt(0);
            continue;
        }
        boolean found = false;
        String tempInput = inputBuffer.toString();
        if (!mLinks.containsKey(curState)) {
            BusProvider.getRestBusInstance().post(new MGetAutoCompleteItemEvent(new ArrayList()));
            return;
        }
        for (String nextState : mLinks.get(curState)) {
            if (!in_if_state && !in_while_state) {
                if (nextState.equals("then") || nextState.equals("compare") || nextState.equals("logical"))
                    continue;
            }
            if (!in_if_then_state) {
                if (nextState.equals("else"))
                    continue;
            }
            for (String val : mNodes.get(nextState)) {
                if (tempInput.startsWith(val)) {
                    leftString = inputBuffer.toString();
                    lastState = nextState;
                    inputBuffer.delete(0, val.length());
                    cmdBuffer.append(val);
                    found = true;
                    in_msg_or_time_state = false;

                    if (nextState.equals("message") || nextState.equals("time")) {
                        in_msg_or_time_ind_state = true;
                        lastPreMsg = lastString;
                    } else if (nextState.equals("if")) {
                        in_if_state = true;
                    } else if (nextState.equals("while")) {
                        in_while_state = true;
                    } else if (nextState.equals("then")) {
                        if (in_if_state)
                            in_if_then_state = true;
                        in_if_state = false;
                        in_while_state = false;
                    } else if (in_if_then_state && nextState.equals("else")) {
                        in_if_then_state = false;
                    }
                    lastString = val;
                    curState = nextState;
                    break;
                } else if (nextState.equals("message") && val.startsWith(tempInput)) {
                    lastState = nextState;
                }
            }
            if (inputBuffer.length() == 0)
                break;
        }
        if (inputBuffer.length() == 0)
            break;
        if (found)
            continue;
        if (curState.equals("message") || mLinks.get(curState).contains("message")) {
            in_msg_or_time_state = true;
            found = true;
            curState = "message";
            cmdBuffer.append(inputBuffer.charAt(0));
            inputBuffer.deleteCharAt(0);
        } else if (curState.equals("time") || mLinks.get(curState).contains("time")) {
            in_msg_or_time_state = true;
            found = true;
            curState = "time";
            cmdBuffer.append(inputBuffer.charAt(0));
            inputBuffer.deleteCharAt(0);
        }
        if (!found)
            break;
    }

    String cmdString = cmdBuffer.toString();
    Set<AutoCompleteItem> resultSet = new HashSet<>();

    if (in_msg_or_time_ind_state) {
        String cmd = cmdString + mMessageSeq;
        if (curState.equals("time")) {
            addTimeToolItemToResult(resultSet);
            addDateToolItemToResult(resultSet);
        }
        // 1
        addFavorToolItemToResult(resultSet);
        // 2
        addMsgHistoryItemToResult(resultSet, context, cmdString, lastPreMsg, curState);
        // 3
        resultSet.add(new AutoCompleteItem(curState, 1.0f, mMessageSeq, cmd));
    } else if (inputBuffer.length() == 0) {
        ArrayList<AutoCompleteItem> unweightItems = new ArrayList<>();
        String tempLeft = new StringBuilder(leftString).delete(0, lastString.length()).toString();
        if (tempLeft.length() != 0) {
            if (curState.equals("message") || curState.equals("time")) {
                for (String nextState : mLinks.get(lastState)) {
                    for (String val : mNodes.get(nextState)) {
                        if (val.startsWith(tempLeft)) {
                            String tempCmd = new StringBuilder(val).delete(0, tempLeft.length()).toString();
                            String cmd = cmdString + tempCmd;
                            //                                resultSet.add(new AutoCompleteItem(nextState, Float.MAX_VALUE, val, cmd));
                            unweightItems.add(
                                    new AutoCompleteItem(nextState, DEFAULT_AUTOCOMPLETE_WEIGHT, val, cmd));
                        }
                    }
                }
            } else {
                for (String val : mNodes.get(curState)) {
                    if (val.startsWith(tempLeft) && !val.equals(tempLeft)) {
                        String tempCmd = new StringBuilder(val).delete(0, lastString.length()).toString();
                        String cmd = cmdString + tempCmd;
                        //                            resultSet.add(new AutoCompleteItem(curState, Float.MAX_VALUE, val, cmd));
                        unweightItems
                                .add(new AutoCompleteItem(curState, DEFAULT_AUTOCOMPLETE_WEIGHT, val, cmd));
                    }
                }
            }
        } else if (leftString.equals(lastString)) {
            for (String val : mNodes.get(curState)) {
                if (val.startsWith(leftString) && val.length() != leftString.length()) {
                    String tempCmd = new StringBuilder(val).delete(0, lastString.length()).toString();
                    String cmd = cmdString + tempCmd;
                    //                        resultSet.add(new AutoCompleteItem(curState, DEFAULT_AUTOCOMPLETE_WEIGHT, val, cmd));
                    unweightItems.add(new AutoCompleteItem(curState, DEFAULT_AUTOCOMPLETE_WEIGHT, val, cmd));
                }
            }
        }

        if (in_msg_or_time_state) {
            addTimeToolItemToResult(resultSet);
            addDateToolItemToResult(resultSet);
            addFavorToolItemToResult(resultSet);
        }
        for (String nextState : mLinks.get(curState)) {
            if (nextState.equals("then")) {
                if (in_if_state || in_while_state) {
                    for (String val : mNodes.get(nextState)) {
                        String cmd = cmdString + val;
                        resultSet.add(new AutoCompleteItem(nextState, 1.0f, val, cmd));
                    }
                }
            } else if (nextState.equals("else")) {
                if (in_if_then_state) {
                    for (String val : mNodes.get(nextState)) {
                        String cmd = cmdString + val;
                        resultSet.add(new AutoCompleteItem(nextState, 1.0f, val, cmd));
                    }
                }
            } else {
                if (nextState.equals("compare") || nextState.equals("logical"))
                    if (!in_if_state && !in_while_state)
                        continue;
                if (nextState.equals("message") || nextState.equals("time")) {
                    addTimeToolItemToResult(resultSet);
                    addDateToolItemToResult(resultSet);
                    addFavorToolItemToResult(resultSet);
                }
                for (String val : mNodes.get(nextState)) {
                    String cmd = cmdString + val;
                    unweightItems.add(new AutoCompleteItem(nextState, DEFAULT_AUTOCOMPLETE_WEIGHT, val, cmd));
                }
            }
        }
        if (unweightItems.size() != 0) {
            setItemWeight(context, unweightItems, lastString);
            resultSet.addAll(unweightItems);
        }
    } else {
        String tempInput = inputBuffer.toString();
        ArrayList<AutoCompleteItem> unweightItems = new ArrayList<>();
        if (tempInput.length() != 0) {
            for (String nextState : mLinks.get(curState)) {
                for (String val : mNodes.get(nextState)) {
                    if (val.startsWith(tempInput)) {
                        String cmd = cmdString + val;
                        unweightItems
                                .add(new AutoCompleteItem(nextState, DEFAULT_AUTOCOMPLETE_WEIGHT, val, cmd));
                    }
                }
            }
        }
        if (unweightItems.size() != 0) {
            setItemWeight(context, unweightItems, tempInput);
            resultSet.addAll(unweightItems);
        }
    }
    List<AutoCompleteItem> resultList = new ArrayList<>(resultSet);
    Collections.sort(resultList, mResultComparator);
    BusProvider.getRestBusInstance().post(new MGetAutoCompleteItemEvent(resultList));
}

From source file:com.wabacus.system.component.application.report.configbean.crosslist.AbsCrossListReportColAndGroupBean.java

public String[] getSelectColumnsAndOrderbyClause(Map<String, String> mOrderbysInDynColGroupDatasetSql) {
    StringBuffer selectColumnsBuf = new StringBuffer();
    StringBuffer orderbyClauseBuf = null;
    if (getRootCrossColGroupBean() instanceof CrossListReportGroupBean) {
        orderbyClauseBuf = new StringBuffer();
    }/*  w w  w .  j ava  2s. c  o  m*/
    this.dynColGroupSpecificBean.getSelectColumnsAndOrderbyClause(selectColumnsBuf, orderbyClauseBuf,
            mOrderbysInDynColGroupDatasetSql);
    if (selectColumnsBuf.charAt(selectColumnsBuf.length() - 1) == ',')
        selectColumnsBuf.deleteCharAt(selectColumnsBuf.length() - 1);
    if (orderbyClauseBuf != null && orderbyClauseBuf.length() > 0
            && orderbyClauseBuf.charAt(orderbyClauseBuf.length() - 1) == ',')
        orderbyClauseBuf.deleteCharAt(orderbyClauseBuf.length() - 1);
    String orderby = "";
    if (orderbyClauseBuf != null)
        orderby = orderbyClauseBuf.toString();
    if (!orderby.trim().equals(""))
        orderby = " order by " + orderby;
    return new String[] { selectColumnsBuf.toString(), orderby };
}

From source file:com.wabacus.system.component.application.report.configbean.crosslist.AbsCrossListReportColAndGroupBean.java

protected void afterGetRuntimeColGroups(CrossListReportType crossListReportType,
        Map<String, Boolean> mDynamicColGroupDisplayType, StringBuffer allDynColConditonsBuf,
        StringBuffer dynSelectedColsBuf, List lstAllRuntimeChildren, List<ColBean> lstAllRuntimeColBeans,
        List lstDynChildren, AbsReportDataPojo headDataObj) {
    if (headDataObj != null) {
        headDataObj.format();/* w w  w .  j av a 2  s  .c  om*/
        getRealDisplayLabel(crossListReportType.getReportRequest(), headDataObj, lstDynChildren);
    }
    if (dynSelectedColsBuf.length() > 0 && dynSelectedColsBuf.charAt(dynSelectedColsBuf.length() - 1) == ',') {
        dynSelectedColsBuf.deleteCharAt(dynSelectedColsBuf.length() - 1);
    }
    String selectedCols = dynSelectedColsBuf.toString();
    if (this.hasDisplayStatisBeansOfReport(mDynamicColGroupDisplayType)) {
        StringBuffer tmpBuf = new StringBuffer();
        String allColConditions = allDynColConditonsBuf.toString().trim();
        if (allColConditions.endsWith("or"))
            allColConditions = allColConditions.substring(0, allColConditions.length() - 2);
        createStatisForWholeRow(crossListReportType, tmpBuf, lstDynChildren, allColConditions,
                mDynamicColGroupDisplayType);
        if (!tmpBuf.toString().trim().equals("")) {
            if (selectedCols.trim().equals("")) {
                selectedCols = tmpBuf.toString();
            } else {
                selectedCols = selectedCols + "," + tmpBuf.toString();
            }
        }
    }
    if (!selectedCols.trim().equals("")) {
        createAllDisplayChildren(lstAllRuntimeColBeans, lstAllRuntimeChildren, lstDynChildren);
    }
    crossListReportType.addDynamicSelectCols(this, selectedCols);
}

From source file:org.hyperic.hq.product.jmx.ServiceTypeFactory.java

private String getObjectNameProperty(ObjectName objectName) {
    final StringBuffer objectNameProperty = new StringBuffer(objectName.getDomain()).append(':');
    Hashtable keyProperties = objectName.getKeyPropertyList();
    for (Iterator iterator = keyProperties.entrySet().iterator(); iterator.hasNext();) {
        Map.Entry keyProperty = (Map.Entry) iterator.next();
        objectNameProperty.append(keyProperty.getKey()).append('=');
        // for now, recognize only type and subtype - replace all others
        // with variable placeholders
        if ("type".equals(keyProperty.getKey()) || "subtype".equals(keyProperty.getKey())) {
            objectNameProperty.append(keyProperty.getValue());
        } else {/*from www .  ja  v  a 2 s.c  o  m*/
            objectNameProperty.append('%').append(keyProperty.getKey()).append('%');
        }
        objectNameProperty.append(',');
    }
    objectNameProperty.deleteCharAt(objectNameProperty.length() - 1);
    return objectNameProperty.toString();
}

From source file:de.marcelkapfer.morseconverter.MainActivity.java

public void mll(View view) {
    EditText editText = (EditText) findViewById(R.id.edit_message);
    StringBuffer message = new StringBuffer(editText.getText());
    if (message.toString().endsWith(" ")) {
        message = message.deleteCharAt(message.length() - 1);
    }/*ww  w .j  a va  2s.  c om*/
    String input;
    StringBuffer output = new StringBuffer();
    input = message.toString().toUpperCase() + "#";
    StringBuffer inputToSign = new StringBuffer(input);
    while (!message.toString().equals("   ")) {
        int d = 0;
        boolean signFull = true;
        StringBuffer sign = new StringBuffer();
        while (signFull) {
            if (inputToSign.toString().startsWith("       ")) {
                output.append(" ");
                inputToSign.delete(d, d + 9);
            } else if (inputToSign.toString().substring(d, d + 3).equals("   ")) {
                if (d == 0) {
                    inputToSign.delete(0, 3);
                } else {
                    sign.replace(0, sign.length(), inputToSign.toString().substring(0, d));
                    inputToSign.delete(0, d);
                    signFull = false;
                }
            } else {
                d++;
            }
        }
        if (sign.toString().equals(".-")) {
            output.append("A");
        } else if (sign.toString().equals("-...")) {
            output.append("B");
        } else if (sign.toString().equals("-.-.")) {
            output.append("C");
        } else if (sign.toString().equals("-..")) {
            output.append("D");
        } else if (sign.toString().equals(".")) {
            output.append("E");
        } else if (sign.toString().equals("..-.")) {
            output.append("F");
        } else if (sign.toString().equals("--.")) {
            output.append("G");
        } else if (sign.toString().equals("....")) {
            output.append("H");
        } else if (sign.toString().equals("..")) {
            output.append("I");
        } else if (sign.toString().equals(".---")) {
            output.append("J");
        } else if (sign.toString().equals("-.-")) {
            output.append("K");
        } else if (sign.toString().equals(".-..")) {
            output.append("L");
        } else if (sign.toString().equals("--")) {
            output.append("M");
        } else if (sign.toString().equals("-.")) {
            output.append("N");
        } else if (sign.toString().equals("---")) {
            output.append("O");
        } else if (sign.toString().equals(".--.")) {
            output.append("P");
        } else if (sign.toString().equals("--.-")) {
            output.append("Q");
        } else if (sign.toString().equals(".-.")) {
            output.append("R");
        } else if (sign.toString().equals("...")) {
            output.append("S");
        } else if (sign.toString().equals("-")) {
            output.append("T");
        } else if (sign.toString().equals("..-")) {
            output.append("U");
        } else if (sign.toString().equals("...-")) {
            output.append("V");
        } else if (sign.toString().equals(".--")) {
            output.append("W");
        } else if (sign.toString().equals("-..-")) {
            output.append("X");
        } else if (sign.toString().equals("-.--")) {
            output.append("Y");
        } else if (sign.toString().equals("--..")) {
            output.append("Z");
        } else if (sign.toString().equals("-----")) {
            output.append(". (zero)");
        } else if (sign.toString().equals(".----")) {
            output.append("-");
        } else if (sign.toString().equals("..---")) {
            output.append("2");
        } else if (sign.toString().equals("...--")) {
            output.append("3");
        } else if (sign.toString().equals("....-")) {
            output.append("4");
        } else if (sign.toString().equals(".....")) {
            output.append("5");
        } else if (sign.toString().equals("-....")) {
            output.append("6");
        } else if (sign.toString().equals("--...")) {
            output.append("7");
        } else if (sign.toString().equals("---..")) {
            output.append("8");
        } else if (sign.toString().equals("----.")) {
            output.append("9");
        } else if (sign.toString().equals(".-.-")) {
            output.append("");
        } else if (sign.toString().equals("---.")) {
            output.append("");
        } else if (sign.toString().equals("..--")) {
            output.append("");
        } else if (sign.toString().equals("...--...")) {
            output.append("");
        } else if (sign.toString().equals("----")) {
            output.append("CH");
        } else if (sign.toString().equals(".-.-.-")) {
            output.append(".");
        } else if (sign.toString().equals("--..--")) {
            output.append(",");
        } else if (sign.toString().equals("---...")) {
            output.append(":");
        } else if (sign.toString().equals("-.-.-.")) {
            output.append(";");
        } else if (sign.toString().equals("..--..")) {
            output.append("?");
        } else if (sign.toString().equals("-.-.--")) {
            output.append("!");
        } else if (sign.toString().equals("-....-")) {
            output.append("-");
        } else if (sign.toString().equals("..--.-")) {
            output.append("_");
        } else if (sign.toString().equals("-.--.")) {
            output.append("(");
        } else if (sign.toString().equals("-.--.-")) {
            output.append(")");
        } else if (sign.toString().equals(".----.")) {
            output.append("'");
        } else if (sign.toString().equals("-...-")) {
            output.append("=");
        } else if (sign.toString().equals(".-.-.")) {
            output.append("+ or End of the signal");
        } else if (sign.toString().equals("-..-.")) {
            output.append("/");
        } else if (sign.toString().equals(".--.-.")) {
            output.append("@");
        } else if (sign.toString().equals("-.-.-")) {
            output.append("Begin of the signal");
        } else if (sign.toString().equals("-...-")) {
            output.append("Wait");
        } else if (sign.toString().equals("...-.")) {
            output.append("Understood");
        } else if (sign.toString().equals("...-.-")) {
            output.append("End of work");
        } else if (sign.toString().equals("...---...")) {
            output.append("SOS");
        } else if (sign.toString().equals("........")) {
            output.append("Error");
        } else {
            tfOutput = "Code not listed or wrong.";
        }
    }
    tfOutput = output.toString();
    lastFragment = 1;
    After(view);
}

From source file:de.marcelkapfer.morseconverter.MainActivity.java

public void encode(View view) {
    EditText editText = (EditText) findViewById(R.id.edit_message);
    StringBuffer message = new StringBuffer(editText.getText());
    if (message.toString().endsWith(" ")) {
        message = message.deleteCharAt(message.length() - 1);
    }//  w w w  . ja v a2s .  c o m
    // Variables
    String input;
    StringBuffer output = new StringBuffer();
    input = message.toString().toUpperCase() + "#";
    StringBuffer inputToSign = new StringBuffer(input);
    while (!inputToSign.toString().equals("#")) {
        int d = 0;
        boolean signFull = true;
        StringBuffer sign = new StringBuffer();
        while (signFull) {
            if (inputToSign.toString().charAt(d) == '+' || inputToSign.toString().charAt(d) == '#') {
                if (d == 0) {
                    if (inputToSign.toString().startsWith("+")) {
                        output.append(" ");
                    }
                    inputToSign.deleteCharAt(0);
                } else {
                    sign.replace(0, sign.length(), inputToSign.toString().substring(0, d));
                    inputToSign.delete(0, d);
                    signFull = false;
                }
            } else {
                d++;
            }
        }
        if (input.equals("")) {
            break;
        } else if (sign.toString().equals("01")) {
            output.append("A");
        } else if (sign.toString().equals("1000")) {
            output.append("B");
        } else if (sign.toString().equals("1010")) {
            output.append("C");
        } else if (sign.toString().equals("100")) {
            output.append("D");
        } else if (sign.toString().equals("0")) {
            output.append("E");
        } else if (sign.toString().equals("0010")) {
            output.append("F");
        } else if (sign.toString().equals("110")) {
            output.append("G");
        } else if (sign.toString().equals("0000")) {
            output.append("H");
        } else if (sign.toString().equals("00")) {
            output.append("I");
        } else if (sign.toString().equals("0111")) {
            output.append("J");
        } else if (sign.toString().equals("101")) {
            output.append("K");
        } else if (sign.toString().equals("0100")) {
            output.append("L");
        } else if (sign.toString().equals("11")) {
            output.append("M");
        } else if (sign.toString().equals("10")) {
            output.append("N");
        } else if (sign.toString().equals("111")) {
            output.append("O");
        } else if (sign.toString().equals("0110")) {
            output.append("P");
        } else if (sign.toString().equals("1101")) {
            output.append("Q");
        } else if (sign.toString().equals("010")) {
            output.append("R");
        } else if (sign.toString().equals("000")) {
            output.append("S");
        } else if (sign.toString().equals("1")) {
            output.append("T");
        } else if (sign.toString().equals("001")) {
            output.append("U");
        } else if (sign.toString().equals("0001")) {
            output.append("V");
        } else if (sign.toString().equals("011")) {
            output.append("W");
        } else if (sign.toString().equals("1001")) {
            output.append("X");
        } else if (sign.toString().equals("1011")) {
            output.append("Y");
        } else if (sign.toString().equals("1100")) {
            output.append("Z");
        } else if (sign.toString().equals("11111")) {
            output.append("0 (zero)");
        } else if (sign.toString().equals("01111")) {
            output.append("1");
        } else if (sign.toString().equals("00111")) {
            output.append("2");
        } else if (sign.toString().equals("00011")) {
            output.append("3");
        } else if (sign.toString().equals("00001")) {
            output.append("4");
        } else if (sign.toString().equals("00000")) {
            output.append("5");
        } else if (sign.toString().equals("10000")) {
            output.append("6");
        } else if (sign.toString().equals("11000")) {
            output.append("7");
        } else if (sign.toString().equals("11100")) {
            output.append("8");
        } else if (sign.toString().equals("11110")) {
            output.append("9");
        } else if (sign.toString().equals("0101")) {
            output.append("");
        } else if (sign.toString().equals("1110")) {
            output.append("");
        } else if (sign.toString().equals("0011")) {
            output.append("");
        } else if (sign.toString().equals("00011000")) {
            output.append("");
        } else if (sign.toString().equals("1111")) {
            output.append("CH");
        } else if (sign.toString().equals("010101")) {
            output.append(".");
        } else if (sign.toString().equals("110011")) {
            output.append(",");
        } else if (sign.toString().equals("111000")) {
            output.append(":");
        } else if (sign.toString().equals("101010")) {
            output.append(";");
        } else if (sign.toString().equals("001100")) {
            output.append("?");
        } else if (sign.toString().equals("101011")) {
            output.append("!");
        } else if (sign.toString().equals("100001")) {
            output.append("-");
        } else if (sign.toString().equals("001101")) {
            output.append("_");
        } else if (sign.toString().equals("10110")) {
            output.append("(");
        } else if (sign.toString().equals("101101")) {
            output.append(")");
        } else if (sign.toString().equals("011110")) {
            output.append("'");
        } else if (sign.toString().equals("10001")) {
            output.append("=");
        } else if (sign.toString().equals("01010")) {
            output.append("+ or End of the signal");
        } else if (sign.toString().equals("10010")) {
            output.append("/");
        } else if (sign.toString().equals("011010")) {
            output.append("@");
        } else if (sign.toString().equals("10101")) {
            output.append("Begin of the signal");
        } else if (sign.toString().equals("10001")) {
            output.append("Wait");
        } else if (sign.toString().equals("00010")) {
            output.append("Understood");
        } else if (sign.toString().equals("000101")) {
            output.append("End of work");
        } else if (sign.toString().equals("000111000")) {
            output.append("SOS");
        } else if (sign.toString().equals("00000000")) {
            output.append("Error");
        } else {
            tfOutput = "Code not listed or wrong.";
        }
    }
    tfOutput = output.toString();
    lastFragment = 0;
    After(view);
    /*} catch (Exception e) {
       tfOutput.setText("Some error occured. I'm sorry!");
    }*/
}

From source file:net.groupbuy.service.impl.OrderServiceImpl.java

@Transactional(readOnly = true)
public Order build(Cart cart, Receiver receiver, PaymentMethod paymentMethod, ShippingMethod shippingMethod,
        CouponCode couponCode, boolean isInvoice, String invoiceTitle, boolean useBalance, String memo) {
    Assert.notNull(cart);/*from w  w w . j  a v a 2  s  .  c  o m*/
    Assert.notNull(cart.getMember());
    Assert.notEmpty(cart.getCartItems());

    Order order = new Order();
    order.setShippingStatus(ShippingStatus.unshipped);
    order.setFee(new BigDecimal(0));
    order.setPromotionDiscount(cart.getDiscount());
    order.setCouponDiscount(new BigDecimal(0));
    order.setOffsetAmount(new BigDecimal(0));
    order.setPoint(cart.getEffectivePoint());
    order.setMemo(memo);
    order.setMember(cart.getMember());

    if (receiver != null) {
        order.setConsignee(receiver.getConsignee());
        order.setAreaName(receiver.getAreaName());
        order.setAddress(receiver.getAddress());
        order.setZipCode(receiver.getZipCode());
        order.setPhone(receiver.getPhone());
        order.setArea(receiver.getArea());
    }

    if (!cart.getPromotions().isEmpty()) {
        StringBuffer promotionName = new StringBuffer();
        for (Promotion promotion : cart.getPromotions()) {
            if (promotion != null && promotion.getName() != null) {
                promotionName.append(" " + promotion.getName());
            }
        }
        if (promotionName.length() > 0) {
            promotionName.deleteCharAt(0);
        }
        order.setPromotion(promotionName.toString());
    }

    order.setPaymentMethod(paymentMethod);

    if (shippingMethod != null && paymentMethod != null
            && paymentMethod.getShippingMethods().contains(shippingMethod)) {
        BigDecimal freight = shippingMethod.calculateFreight(cart.getWeight());
        for (Promotion promotion : cart.getPromotions()) {
            if (promotion.getIsFreeShipping()) {
                freight = new BigDecimal(0);
                break;
            }
        }
        order.setFreight(freight);
        order.setShippingMethod(shippingMethod);
    } else {
        order.setFreight(new BigDecimal(0));
    }

    if (couponCode != null && cart.isCouponAllowed()) {
        couponCodeDao.lock(couponCode, LockModeType.PESSIMISTIC_WRITE);
        if (!couponCode.getIsUsed() && couponCode.getCoupon() != null && cart.isValid(couponCode.getCoupon())) {
            BigDecimal couponDiscount = cart.getEffectivePrice().subtract(
                    couponCode.getCoupon().calculatePrice(cart.getQuantity(), cart.getEffectivePrice()));
            couponDiscount = couponDiscount.compareTo(new BigDecimal(0)) > 0 ? couponDiscount
                    : new BigDecimal(0);
            order.setCouponDiscount(couponDiscount);
            order.setCouponCode(couponCode);
        }
    }

    List<OrderItem> orderItems = order.getOrderItems();
    for (CartItem cartItem : cart.getCartItems()) {
        if (cartItem != null && cartItem.getProduct() != null) {
            Product product = cartItem.getProduct();
            OrderItem orderItem = new OrderItem();
            orderItem.setSn(product.getSn());
            orderItem.setName(product.getName());
            orderItem.setFullName(product.getFullName());
            orderItem.setPrice(cartItem.getPrice());
            orderItem.setWeight(product.getWeight());
            orderItem.setThumbnail(product.getThumbnail());
            orderItem.setIsGift(false);
            orderItem.setQuantity(cartItem.getQuantity());
            orderItem.setShippedQuantity(0);
            orderItem.setReturnQuantity(0);
            orderItem.setProduct(product);
            orderItem.setOrder(order);
            orderItems.add(orderItem);
        }
    }

    for (GiftItem giftItem : cart.getGiftItems()) {
        if (giftItem != null && giftItem.getGift() != null) {
            Product gift = giftItem.getGift();
            OrderItem orderItem = new OrderItem();
            orderItem.setSn(gift.getSn());
            orderItem.setName(gift.getName());
            orderItem.setFullName(gift.getFullName());
            orderItem.setPrice(new BigDecimal(0));
            orderItem.setWeight(gift.getWeight());
            orderItem.setThumbnail(gift.getThumbnail());
            orderItem.setIsGift(true);
            orderItem.setQuantity(giftItem.getQuantity());
            orderItem.setShippedQuantity(0);
            orderItem.setReturnQuantity(0);
            orderItem.setProduct(gift);
            orderItem.setOrder(order);
            orderItems.add(orderItem);
        }
    }

    Setting setting = SettingUtils.get();
    if (setting.getIsInvoiceEnabled() && isInvoice && StringUtils.isNotEmpty(invoiceTitle)) {
        order.setIsInvoice(true);
        order.setInvoiceTitle(invoiceTitle);
        order.setTax(order.calculateTax());
    } else {
        order.setIsInvoice(false);
        order.setTax(new BigDecimal(0));
    }

    if (useBalance) {
        Member member = cart.getMember();
        if (member.getBalance().compareTo(order.getAmount()) >= 0) {
            order.setAmountPaid(order.getAmount());
        } else {
            order.setAmountPaid(member.getBalance());
        }
    } else {
        order.setAmountPaid(new BigDecimal(0));
    }

    if (order.getAmountPayable().compareTo(new BigDecimal(0)) == 0) {
        order.setOrderStatus(OrderStatus.confirmed);
        order.setPaymentStatus(PaymentStatus.paid);
    } else if (order.getAmountPayable().compareTo(new BigDecimal(0)) > 0
            && order.getAmountPaid().compareTo(new BigDecimal(0)) > 0) {
        order.setOrderStatus(OrderStatus.confirmed);
        order.setPaymentStatus(PaymentStatus.partialPayment);
    } else {
        order.setOrderStatus(OrderStatus.unconfirmed);
        order.setPaymentStatus(PaymentStatus.unpaid);
    }

    if (paymentMethod != null && paymentMethod.getTimeout() != null
            && order.getPaymentStatus() == PaymentStatus.unpaid) {
        order.setExpire(DateUtils.addMinutes(new Date(), paymentMethod.getTimeout()));
    }

    return order;
}

From source file:dao.PersonalinfoDaoDb.java

private void getYourkeywords(String loginId, Userpage userpage) {

    if (RegexStrUtil.isNull(loginId) || (userpage == null)) {
        return;/*from w w  w .j  a  va2s .  c  o  m*/
    }

    /**
     *  Get scalability datasource for yourkeywords - not partitioned
     */
    String sourceName = scalabilityManager.getReadZeroScalability();
    ds = scalabilityManager.getSource(sourceName);
    if (ds == null) {
        throw new BaseDaoException("ds null, getYourKeywords() " + sourceName);
    }

    List result = null;
    try {
        result = yourKeywordsQuery.execute(loginId);
    } catch (Exception e) {
        throw new BaseDaoException("exception occured in executing YourkeywordsQuery() "
                + yourKeywordsQuery.getSql() + ", loginId = " + loginId, e);
    }

    StringBuffer allwords = new StringBuffer();
    int size = result.size();
    if ((size > 0)) {
        for (int i = 0; i < size; i++) {
            Yourkeywords yourwords = (Yourkeywords) result.get(i);
            allwords = allwords.append(yourwords.getValue(DbConstants.YOURKEYWORD));
            allwords = allwords.append(",");
        }
        allwords = allwords.deleteCharAt(allwords.length() - 1);
        userpage.setValue(DbConstants.YOURKEYWORDS, allwords.toString());
    }
}

From source file:com.collabnet.ccf.pt.schemageneration.PTLayoutExtractor.java

private Object generateFieldDocumentation(String displayName, String fieldName, String alternativeFieldName,
        FieldValueTypeValue fieldValueType, String fieldType, String isNullValueSupported,
        Option[] fieldValues) {//ww  w .  j  a  v  a  2 s .co m
    StringBuffer documentation = new StringBuffer();
    documentation.append(displayName + " (" + fieldValueType + ")\n");

    if (fieldValues != null) {
        documentation.append(" Values: [");
        Set<String> sortedValues = new TreeSet<String>();
        for (Option fieldValue : fieldValues) {
            String fieldDisplayName = fieldValue.getDisplayName();
            if (StringUtils.isEmpty(fieldDisplayName)) {
                sortedValues.add(fieldValue.getTagName());
            } else {
                sortedValues.add(fieldDisplayName);
            }
        }
        for (String fieldValueOption : sortedValues) {
            documentation.append(" '" + fieldValueOption + "',");
        }
        if (fieldValues.length == 0) {
            documentation.append("<empty>,");
        }
        documentation.deleteCharAt(documentation.length() - 1);
        documentation.append(" ]");

    }
    return documentation.toString();
}