Example usage for java.lang StringBuffer substring

List of usage examples for java.lang StringBuffer substring

Introduction

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

Prototype

@Override
public synchronized String substring(int start, int end) 

Source Link

Usage

From source file:com.github.gekoh.yagen.ddl.CreateDDL.java

public String updateCreateIndex(Dialect dialect, StringBuffer buf, String name, Table table,
        List<org.hibernate.mapping.Column> columns) {
    String newName = getProfile().getNamingStrategy().indexName(name);

    if (!name.equals(newName)) {
        Matcher matcher = IDX_CREATE_PATTERN.matcher(buf.toString());
        if (matcher.find()) {
            StringBuilder builder = new StringBuilder();
            builder.append(buf.substring(0, matcher.start(2)));
            builder.append(newName);//from ww  w  .jav a 2 s  . c o  m
            builder.append(buf.substring(matcher.end(2)));
            buf = new StringBuffer(builder.toString());
        }
        name = newName;
    }

    String tableNameLC = getProfile().getNamingStrategy().tableName(table.getName()).toLowerCase();
    if (!renderTable(tableNameLC)) {
        return "-- skipped creation of index '" + name + "' for table '" + tableNameLC
                + "' as the mapped entity was not chosen to be processed";
    }

    if (externalViews.contains(tableNameLC)) {
        return "-- skipped creation of index '" + name + "' on table '" + tableNameLC
                + "' since there is a view in place";
    }
    TableConfig tableConfig = tblNameToConfig.get(tableNameLC);

    checkObjectName(dialect, name);

    IntervalPartitioning partitioning = tableConfig.getTableAnnotationOfType(IntervalPartitioning.class);
    if (partitioning != null && supportsPartitioning(dialect)) {
        Matcher matcher = IDX_CREATE_PATTERN.matcher(buf.toString());
        // find create index and define local not for unique indexes
        if (matcher.find() && matcher.group(1) == null) {
            buf.append(" local");
        }
    }

    String i18nFK = tableConfig.getI18nBaseEntityFkCol();

    if (i18nFK != null) {
        StringBuilder sql = new StringBuilder();
        String i18nTblName = getI18NDetailTableName(tableNameLC);

        if (columns.size() == 1) {
            if (hasIndex(table, i18nTblName, columns.get(0))) {
                return "-- table " + i18nTblName + " already has an index on column "
                        + columns.get(0).getName();
            }
            tblColNameHasSingleColIndex.add(i18nTblName + "." + columns.get(0).getName().toLowerCase());
        }

        Matcher matcher = IDX_CREATE_PATTERN.matcher(buf.toString());
        if (matcher.find()) {
            sql.append(buf.substring(0, matcher.start(3))).append(i18nTblName)
                    .append(buf.substring(matcher.end(3)));
        }

        getProfile().duplex(ObjectType.INDEX, name, sql.toString());

        return sql.toString();
    }

    if (columns.size() == 1) {
        if (hasIndex(table, tableNameLC, columns.get(0))) {
            return "-- table " + table.getName() + " already has an index on column "
                    + columns.get(0).getName();
        }

        tblColNameHasSingleColIndex.add(tableNameLC + "." + columns.get(0).getName().toLowerCase());
    }

    getProfile().duplex(ObjectType.INDEX, name, buf.toString());

    return buf.toString();
}

From source file:org.apache.stratos.autoscaler.service.impl.AutoscalerServiceImpl.java

private String editLine(String textinLine, String tenantName) {

    // Format of the line will be <IP>=<IPvalue>,<Path>=<PathValue>..

    StringBuffer outputBuffer = new StringBuffer();
    Map<String, String> paramMap = new HashMap<String, String>();
    String[] params = textinLine.split(AutoscalerConstant.ENTRY_SEPARATOR);

    for (int i = 0; i < params.length; i++) {

        // split the params one by one
        String param = params[i];
        String[] values = param.split(AutoscalerConstant.VALUE_SEPARATOR);

        if (values.length != 2) {
            throw new AutoscalerServiceException("Incorrect format in parameters file");
        }/*from www . j ava 2 s.c  o  m*/

        String key = values[0];
        String value = values[1];

        String updatedValue = value;

        if (AutoscalerConstant.TENANT_KEY.equals(key)) {
            updatedValue = tenantName;
        } else if (AutoscalerConstant.APP_PATH_KEY.equals(key)) {
            updatedValue = getAppPathForTenant(tenantName, value);
        }
        paramMap.put(key, updatedValue);
    }

    // Loop through the map and put values into a string
    reOrganizeContent(outputBuffer, paramMap);

    // cleanup output buffer
    if (outputBuffer.substring(0, 1).equals(AutoscalerConstant.ENTRY_SEPARATOR)) {
        outputBuffer.delete(0, 1);
    }

    return outputBuffer.toString();
}

From source file:org.codehaus.mojo.dbupgrade.sqlexec.DefaultSQLExec.java

/**
 * read in lines and execute them// ww w  . j ava2 s  .  c o  m
 */
private void runStatements(Reader reader, PrintStream out) throws SQLException, IOException {
    String line;

    StringBuffer sql = new StringBuffer();

    BufferedReader in = new BufferedReader(reader);

    while ((line = in.readLine()) != null) {
        if (!config.isKeepFormat()) {
            line = line.trim();
        }

        if (!config.isKeepFormat()) {
            if (line.startsWith("#")) {
                continue;
            }
            if (line.startsWith("//")) {
                continue;
            }
            if (line.startsWith("--")) {
                continue;
            }
            StringTokenizer st = new StringTokenizer(line);
            if (st.hasMoreTokens()) {
                String token = st.nextToken();
                if ("REM".equalsIgnoreCase(token)) {
                    continue;
                }
            }
        }

        if (!config.isKeepFormat()) {
            sql.append(" ").append(line);
        } else {
            sql.append("\n").append(line);
        }

        // SQL defines "--" as a comment to EOL
        // and in Oracle it may contain a hint
        // so we cannot just remove it, instead we must end it
        if (!config.isKeepFormat()) {
            if (SqlSplitter.containsSqlEnd(line, config.getDelimiter()) == SqlSplitter.NO_END) {
                sql.append("\n");
            }
        }

        DelimiterType delimiterType = this.config.getDelimiterType();
        String delimiter = this.config.getDelimiter();

        if ((delimiterType.equals(DelimiterType.NORMAL) && SqlSplitter.containsSqlEnd(line, delimiter) > 0)
                || (delimiterType.equals(DelimiterType.ROW) && line.trim().equals(delimiter))) {
            execSQL(sql.substring(0, sql.length() - delimiter.length()), out);
            sql.setLength(0); // clean buffer
        }
    }

    // Catch any statements not followed by ;
    if (!sql.toString().equals("")) {
        execSQL(sql.toString(), out);
    }
}

From source file:architecture.common.util.TextUtils.java

private final static void linkURL(StringBuffer str, String target) {
    String urlToDisplay;//from w w w . ja v a 2  s . c o  m

    int lastEndIndex = -1; // Stores the index position, within the whole
    // string, of the ending char of the last URL
    // found.

    String targetString = ((target == null) || (target.trim().length() == 0)) ? ""
            : (" target=\"" + target.trim() + '\"');

    while (true) {
        int linkStartIndex = getStartUrl(str, lastEndIndex);

        // if no more links found - then end the loop
        if (linkStartIndex == -1) {
            break;
        } else {
            // Get the whole URL...
            // We move forward and add each character to the URL string
            // until we encounter
            // an invalid URL character (we assume that the URL ends there).
            int linkEndIndex = linkStartIndex;
            String urlStr = "";

            while (true) {
                // if char at linkEndIndex is '&' then we look at the next 4
                // chars
                // to see if they make up "&amp;" altogether. This is the
                // html coded
                // '&' and will pretty much stuff up an otherwise valid link
                // becos of the ';'.
                // We therefore have to remove it before proceeding...
                if (str.charAt(linkEndIndex) == '&') {
                    if (((linkEndIndex + 6) <= str.length())
                            && "&quot;".equals(str.substring(linkEndIndex, linkEndIndex + 6))) {
                        break;
                    } else if (((linkEndIndex + 5) <= str.length())
                            && "&amp;".equals(str.substring(linkEndIndex, linkEndIndex + 5))) {
                        str.replace(linkEndIndex, linkEndIndex + 5, "&");
                    }
                }

                if (isValidURLChar(str.charAt(linkEndIndex))) {
                    urlStr += str.charAt(linkEndIndex);
                    linkEndIndex++;

                    if (linkEndIndex == str.length()) { // Reached end of
                        // str...

                        break;
                    }
                } else {
                    break;
                }
            }

            // if the characters before the linkStart equal 'href="' then
            // don't link the url - CORE-44
            if (linkStartIndex >= 6) { // 6 = "href\"".length()

                String prefix = str.substring(linkStartIndex - 6, linkStartIndex);

                if ("href=\"".equals(prefix)) {
                    lastEndIndex = linkEndIndex;

                    continue;
                }
            }

            // if the characters after the linkEnd are '</a>' then this url
            // is probably already linked - CORE-44
            if (str.length() >= (linkEndIndex + 4)) { // 4 = "</a>".length()

                String suffix = str.substring(linkEndIndex, linkEndIndex + 4);

                if ("</a>".equals(suffix)) {
                    lastEndIndex = linkEndIndex + 4;

                    continue;
                }
            }

            // Decrement linkEndIndex back by 1 to reflect the real ending
            // index position of the URL...
            linkEndIndex--;

            // If the last char of urlStr is a '.' we exclude it. It is most
            // likely a full stop and
            // we don't want that to be part of an url.
            while (true) {
                char lastChar = urlStr.charAt(urlStr.length() - 1);

                if (lastChar == '.') {
                    urlStr = urlStr.substring(0, urlStr.length() - 1);
                    linkEndIndex--;
                } else {
                    break;
                }
            }

            // if the URL had a '(' before it, and has a ')' at the end,
            // trim the last ')' from the url
            // ie '(www.opensymphony.com)' => '(<a
            // href="http://www.openymphony.com/">www.opensymphony.com</a>)'
            char lastChar = urlStr.charAt(urlStr.length() - 1);

            if (lastChar == ')') {
                if ((linkStartIndex > 0) && ('(' == (str.charAt(linkStartIndex - 1)))) {
                    urlStr = urlStr.substring(0, urlStr.length() - 1);
                    linkEndIndex--;
                }
            } else if (lastChar == '\'') {
                if ((linkStartIndex > 0) && ('\'' == (str.charAt(linkStartIndex - 1)))) {
                    urlStr = urlStr.substring(0, urlStr.length() - 1);
                    linkEndIndex--;
                }
            }
            // perhaps we ended with '&gt;', '&lt;' or '&quot;'
            // We need to strip these
            // ie '&quot;www.opensymphony.com&quot;' => '&quot;<a
            // href="http://www.openymphony.com/">www.opensymphony.com</a>&quot;'
            // ie '&lt;www.opensymphony.com&gt;' => '&lt;<a
            // href="http://www.openymphony.com/">www.opensymphony.com</a>&gt;'
            else if (lastChar == ';') {
                // 6 = "&quot;".length()
                if ((urlStr.length() > 6) && "&quot;".equalsIgnoreCase(urlStr.substring(urlStr.length() - 6))) {
                    urlStr = urlStr.substring(0, urlStr.length() - 6);
                    linkEndIndex -= 6;
                }
                // 4 = "&lt;".length() || "&gt;".length()
                else if (urlStr.length() > 4) {
                    final String endingStr = urlStr.substring(urlStr.length() - 4);

                    if ("&lt;".equalsIgnoreCase(endingStr) || "&gt;".equalsIgnoreCase(endingStr)) {
                        urlStr = urlStr.substring(0, urlStr.length() - 4);
                        linkEndIndex -= 4;
                    }
                }
            }

            // we got the URL string, now we validate it and convert it into
            // a hyperlink...
            urlToDisplay = htmlEncode(urlStr);

            if (urlStr.toLowerCase().startsWith("www.")) {
                urlStr = "http://" + urlStr;
            }

            if (verifyHierachicalURI(urlStr, new String[] { "javascript" })) {
                // Construct the hyperlink for the url...
                String urlLink = "<a href=\"" + urlStr + '\"' + targetString + '>' + urlToDisplay + "</a>";

                // Remove the original urlStr from str and put urlLink there
                // instead...
                str.replace(linkStartIndex, linkEndIndex + 1, urlLink);

                // Set lastEndIndex to reflect the position of the end of
                // urlLink
                // within the whole string...
                lastEndIndex = (linkStartIndex - 1) + urlLink.length();
            } else {
                // lastEndIndex is different from the one above cos' there's
                // no
                // <a href...> tags added...
                lastEndIndex = (linkStartIndex - 1) + urlStr.length();
            }
        }
    }
}

From source file:cc.siara.csv_ml_demo.MainActivity.java

/**
 * Evaluates given XPath from Input box against Document generated by
 * parsing csv_ml in input box and sets value or node list to output box.
 *///from   ww w .j a  v  a  2 s. c om
void processXPath() {
    EditText etInput = (EditText) findViewById(R.id.etInput);
    EditText etXPath = (EditText) findViewById(R.id.etXPath);
    CheckBox cbPretty = (CheckBox) findViewById(R.id.cbPretty);
    XPath xpath = XPathFactory.newInstance().newXPath();
    MultiLevelCSVParser parser = new MultiLevelCSVParser();
    Document doc = null;
    try {
        doc = parser.parseToDOM(new StringReader(etInput.getText().toString()), false);
    } catch (IOException e1) {
        e1.printStackTrace();
    }
    if (doc == null)
        return;
    StringBuffer out_str = new StringBuffer();
    try {
        XPathExpression expr = xpath.compile(etXPath.getText().toString());
        try {
            Document outDoc = Util.parseXMLToDOM("<output></output>");
            Element rootElement = outDoc.getDocumentElement();
            NodeList ret = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);
            for (int i = 0; i < ret.getLength(); i++) {
                Object o = ret.item(i);
                if (o instanceof String) {
                    out_str.append(o);
                } else if (o instanceof Node) {
                    Node n = (Node) o;
                    short nt = n.getNodeType();
                    switch (nt) {
                    case Node.TEXT_NODE:
                    case Node.ATTRIBUTE_NODE:
                    case Node.CDATA_SECTION_NODE: // Only one value gets
                                                  // evaluated?
                        if (out_str.length() > 0)
                            out_str.append(',');
                        if (nt == Node.ATTRIBUTE_NODE)
                            out_str.append(n.getNodeValue());
                        else
                            out_str.append(n.getTextContent());
                        break;
                    case Node.ELEMENT_NODE:
                        rootElement.appendChild(outDoc.importNode(n, true));
                        break;
                    }
                }
            }
            if (out_str.length() > 0) {
                rootElement.setTextContent(out_str.toString());
                out_str.setLength(0);
            }
            out_str.append(Util.docToString(outDoc, true));
        } catch (Exception e) {
            // Thrown most likely because the given XPath evaluates to a
            // string
            out_str.append(expr.evaluate(doc));
        }
    } catch (XPathExpressionException e) {
        e.printStackTrace();
    }
    if (out_str.length() > 5 && out_str.substring(0, 5).equals("<?xml"))
        out_str.delete(0, out_str.indexOf(">") + 1);
    EditText etOutput = (EditText) findViewById(R.id.etOutput);
    etOutput.setText(out_str.toString());
    // tfOutputSize.setText(String.valueOf(xmlString.length()));
}

From source file:org.sakaiproject.tool.assessment.facade.AssessmentFacadeQueries.java

private void updateTitleForCopy(AssessmentData assessmentData, String apepndCopyTitle) {
    //String apepndCopyTitle = ContextUtil.getLocalizedString("org.sakaiproject.tool.assessment.bundle.AuthorMessages", "append_copy_title");
    StringBuffer sb = new StringBuffer(assessmentData.getTitle());
    sb.append(" ");
    sb.append(apepndCopyTitle);//ww  w.j  ava2  s. c  om
    if (sb.length() >= assessmentData.TITLE_LENGTH) { //title max size
        String appendCopyText = "... " + apepndCopyTitle;
        String titleCut = sb.substring(0, assessmentData.TITLE_LENGTH - appendCopyText.length() - 1); //cut until size needed to add ellipsis and copyTitle without exceed DB field size
        log.debug("titleCut = " + titleCut);
        sb = new StringBuffer(titleCut);
        sb.append(appendCopyText);
    }
    String newTitle = getNewAssessmentTitleForCopy(sb.toString());
    assessmentData.setTitle(newTitle);
}

From source file:com.topsec.tsm.sim.report.web.TopoReportController.java

private void setImfo(List<Map<String, Object>> subResult, Map<String, Object> params, ReportBean bean,
        StringBuffer layout, StringBuffer subUrl, Map layoutValue, String scanNodeId,
        Map<Integer, Integer> rowColumns, String sUrl, int screenWidth) {

    for (int i = 0, len = subResult.size(); i < len; i++) {
        params.remove("sTime");
        Map subMap = subResult.get(i);
        if (i == 0) {
            bean.setViewItem(StringUtil.toString(subMap.get("viewItem"), ""));
        }//  ww w.  j a  v a2 s.c om
        Integer row = (Integer) subMap.get("subRow");
        layout.append(row + ":" + subMap.get("subColumn") + ",");
        if (GlobalUtil.isNullOrEmpty(subMap)) {
            continue;
        }
        params.put("sTime", bean.getTalStartTime());
        params.put("dvcType", subMap.get("subject"));
        sUrl = getComprehensiveUrl(ReportUiConfig.subEvtUrl, scanNodeId, params, bean.getTalCategory())
                .toString();
        params.remove("dvcType");
        subUrl.replace(0, subUrl.length(), sUrl);
        subUrl.append("&").append(ReportUiConfig.subrptid).append("=").append(subMap.get("subId"));
        subUrl.substring(0, subUrl.length());
        int column = rowColumns.get(row);
        String width = String.valueOf((screenWidth - 10 * column) / column);
        String _column = subMap.get("subColumn").toString();
        layoutValue.put(row + _column, ReportUiUtil.createSubTitle(subMap, width, subUrl.toString(),
                bean.getTalCategory(), StringUtil.toInt(bean.getTalTop(), 5)));
    }
}

From source file:weka.gui.explorer.ClassifierPanelRemoteLauncher.java

/**
 * Purge the supplied tasks from the server
 * /*from  w ww  .  j a  v a  2 s.c  o m*/
 * @param taskIDs a list of task IDs of tasks to purge
 */
protected void purgeTasksFromServer(List<String> taskIDs) {
    InputStream is = null;
    PostMethod post = null;
    StringBuffer tasks = new StringBuffer();
    for (String id : taskIDs) {
        tasks.append(id + ",");
    }
    String taskList = tasks.substring(0, tasks.lastIndexOf(","));

    try {
        String service = PurgeTaskServlet.CONTEXT_PATH + "/?name=" + taskList + "&client=Y";
        post = new PostMethod(constructURL(service));
        post.setDoAuthentication(true);
        post.addRequestHeader(new Header("Content-Type", "text/plain"));

        // Get HTTP client
        HttpClient client = WekaServer.ConnectionManager.getSingleton().createHttpClient();
        WekaServer.ConnectionManager.addCredentials(client, m_username, m_password);

        int result = client.executeMethod(post);
        if (result == 401) {
            logMessage("Unable to purge tasks from server - authentication " + "required");
        } else {
            is = post.getResponseBodyAsStream();
            ObjectInputStream ois = new ObjectInputStream(new BufferedInputStream(is));
            Object response = ois.readObject();
            if (response.toString().startsWith(WekaServlet.RESPONSE_ERROR)) {

                logMessage("Server returned an error: " + "while trying to purge completed tasks: '" + taskList
                        + "'. (" + response.toString() + ")." + " Check logs on server.");
            }
        }
    } catch (Exception ex) {
        logMessage(
                "An error occurred while trying to purge completed tasks from " + "server: " + ex.getMessage());
        ex.printStackTrace();
    } finally {
        if (is != null) {
            try {
                is.close();
            } catch (Exception e) {
            }
        }

        if (post != null) {
            // Release current connection to the connection pool
            post.releaseConnection();
        }
    }
}

From source file:net.phase.wallet.Currency.java

public void run() {
    balance = 0;/*  w w w  . j a v a  2s  . c  o m*/
    int i = 0;
    StringBuffer url = new StringBuffer(baseUrl);
    int status = MESSAGE_STATUS_SUCCESS;
    boolean fastKeyFound = false;

    for (Key k : wallet.keys) {
        if (!fast) {
            k.hit = 0;
        } else {
            if (k.hit > 0) {
                fastKeyFound = true;
            }
        }
    }

    // if we asked for fast, but no fast keys found, just override this
    if (fast && !fastKeyFound) {
        fast = false;
    }

    try {
        int numberOfKeys = wallet.keys.length;

        if (fast) {
            numberOfKeys = wallet.getActiveKeyCount();
        }

        updateHandler.sendMessage(updateHandler.obtainMessage(MESSAGE_SETLENGTH, numberOfKeys, 0));
        updateHandler.sendMessage(updateHandler.obtainMessage(MESSAGE_UPDATE));

        for (Key key : wallet.keys) {
            if ((i % maxlength) == (maxlength - 1)) {
                updateBalanceFromUrl(url.substring(0, url.length() - 1));

                url = new StringBuffer(baseUrl);
            }

            if (!fast || key.hit > 0) {
                url.append(key.hash);
                url.append('.');
                i++;
            }
            updateHandler.sendMessage(updateHandler.obtainMessage(MESSAGE_UPDATE));
        }

        updateBalanceFromUrl(url.substring(0, url.length() - 1));

        updateHandler.sendMessage(updateHandler.obtainMessage(MESSAGE_UPDATE));

        // look through previous transactions and debit payments
        for (prevout previousOut : pendingDebits) {
            tx matchingTx = getMatchingTx(previousOut.prevTxHash, previousOut.rec);

            if (matchingTx != null) {
                balance -= matchingTx.value;

                tx outputTx = getFirstNonMatchingTx(previousOut.txhash, wallet.keys);
                if (outputTx != null) {
                    transactions.add(new Transaction(previousOut.date, -matchingTx.value, previousOut.addr,
                            outputTx.outKeyHash));
                } else {
                    transactions.add(
                            new Transaction(previousOut.date, -matchingTx.value, previousOut.addr, "unknown"));
                }
            } else {
                status = MESSAGE_STATUS_MISSING_TX;
                // not sure how this can happen, but it happened once for a
                // user, so handle it here
                Log.w("wallet",
                        "could not retrieve previous tx for " + previousOut.prevTxHash + ":" + previousOut.rec);
            }
        }
    } catch (IOException e) {
        status = MESSAGE_STATUS_NETWORK;
    } catch (JSONException e) {
        status = MESSAGE_STATUS_JSON;
    } catch (java.text.ParseException e) {
        status = MESSAGE_STATUS_PARSE;
    }

    updateHandler.sendMessage(updateHandler.obtainMessage(MESSAGE_FINISHED, status, 0));

    if (status == MESSAGE_STATUS_SUCCESS) {
        if (wallet.balance != 0 && wallet.balance != balance) {
            wallet.notifyUser();
        }
        wallet.balance = balance;
        wallet.lastUpdated = new Date();
        wallet.transactions = new Transaction[transactions.size()];
        transactions.toArray(wallet.transactions);
    }
}

From source file:tasly.greathealth.oms.inventory.services.impl.DefaultItemInfoService.java

@Override
@Transactional/*ww  w.  j a  va2s.  c o m*/
public boolean batchUpdateItemlocation(final String newChannels) throws Exception {
    omsInventoryLog.info("batchUpdateItemlocation (for add channel only) Begin********.");
    boolean flag = false;
    // ?Stockroom??
    final List<TaslyStockroomLocationData> tsld = stockroomLocationService.getAll();
    if (tsld != null && tsld.size() > 0) {
        final String[] channelArray = new String[tsld.size()];
        final String[] percentArray = new String[tsld.size()];
        int idx = 0;
        for (final TaslyStockroomLocationData taslyStockroomLocationData : tsld) {
            channelArray[idx] = taslyStockroomLocationData.getLocationId();
            percentArray[idx++] = String.valueOf(taslyStockroomLocationData.getDefaultAllocatePercent());
        }
        // String[] oldChannelArray = null;
        // String[] oldpercentArray = null;
        final Map<String, String> oldChannelMap = new HashMap<String, String>();
        String[] newChannelArray = null;
        // String[] newpercentArray = null;
        final Map<String, String> newChannelMap = new HashMap<String, String>();
        final StringBuffer oldChannelBuf = new StringBuffer();
        final StringBuffer newChannelBuf = new StringBuffer();
        // ?
        if (newChannels != null && newChannels.length() > 0) {
            // ??
            newChannelArray = newChannels.split(",");
            // newpercentArray = new String[newChannelArray.length];
            // ??
            // oldChannelArray = new String[channelArray.length - newChannelArray.length];
            // oldpercentArray = new String[percentArray.length - newpercentArray.length];

            for (int j = 0; j < channelArray.length; j++) {
                boolean newChannelFlag = false;
                final String channel = channelArray[j];
                for (final String newChannel : newChannelArray) {
                    if (newChannel.equals(channel)) {
                        // newpercentArray[i] = percentArray[j];
                        newChannelMap.put(newChannel, percentArray[j]);
                        newChannelFlag = true;
                        newChannelBuf.append(newChannel).append(",");
                        break;
                    }
                }
                if (!newChannelFlag) {
                    // oldChannelArray[oldIdx] = channelArray[j];
                    // oldpercentArray[oldIdx++] = percentArray[j];

                    oldChannelMap.put(channelArray[j], percentArray[j]);

                    oldChannelBuf.append(channelArray[j]).append(",");
                }
            }
        } else {
            for (int k = 0; k < channelArray.length; k++) {
                oldChannelMap.put(channelArray[k], percentArray[k]);
                oldChannelBuf.append(channelArray[k]).append(",");

            }
        }

        // 1??
        if (oldChannelMap.size() > 0) {
            omsInventoryLog.info("ItemLocation?");
            omsInventoryLog.info("ItemLocation?"
                    + oldChannelBuf.substring(0, oldChannelBuf.length() - 1));
            batchUpdateItemLocationSub(oldChannelMap);
            omsInventoryLog.info("ItemLocation??.");
        }
        // 2??
        if (newChannelMap.size() > 0) {
            omsInventoryLog.info("ItemLocation?");
            omsInventoryLog.info("ItemLocation?"
                    + newChannelBuf.substring(0, newChannelBuf.length() - 1));
            batchCreateItemLocationSub(newChannelArray, newChannelMap);
            omsInventoryLog.info("ItemLocation??.");
        }
        // ??
        super.getPersistenceManager().flush();
        flag = true;
    } else {
        omsInventoryLog.equals("StockroomLocation??.");
    }
    omsInventoryLog.info("batchUpdateItemlocation (for add channel only) End********.");
    return flag;
}