Example usage for java.lang StringBuilder deleteCharAt

List of usage examples for java.lang StringBuilder deleteCharAt

Introduction

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

Prototype

@Override
public StringBuilder deleteCharAt(int index) 

Source Link

Usage

From source file:eu.hansolo.fx.weatherfx.darksky.DarkSky.java

private String createUrl(final double LATITUDE, final double LONGITUDE, final Unit UNIT,
        final Language LANGUAGE, final Exclude... EXCLUDES) {
    final StringBuilder PARAMETERS = new StringBuilder().append(Double.toString(LATITUDE)).append(",")
            .append(Double.toString(LONGITUDE)).append("?").append("units=").append(UNIT.value).append("&")
            .append("lang=").append(LANGUAGE.value);
    // Add excludes
    if (EXCLUDES.length > 0) {
        PARAMETERS.append("&").append("exclude=");
        for (Exclude exclude : EXCLUDES) {
            PARAMETERS.append(exclude.value).append(",");
        }/*from  w  ww.ja  va 2  s. com*/
        PARAMETERS.deleteCharAt(PARAMETERS.length() - 1);
    }
    final String URL_STRING = String.join("", DARK_SKY_URL, PARAMETERS.toString());
    return URL_STRING;
}

From source file:edu.indiana.d2i.htrc.dataapi.DataAPIWrapper.java

private String makeVolumesURL(List<String> volIDs) {
    StringBuilder builder = new StringBuilder();

    /**//from   w w  w.  j a  v a  2  s . co m
     * The last one has the delimiter will not cause any problem when
     * &concat=true parameter doesn't appear, however, it will be treated as
     * wrong syntax when the concat option is used, so we remove the last
     * delimiter anyway
     */
    for (String id : volIDs)
        builder.append(id + delimiter);

    // remove the last delimiter
    builder.deleteCharAt(builder.length() - 1);

    if (isConcat)
        builder.append("&concat=true");

    return dataAPIEPR + dataAPIVolPrefix + builder.toString();
}

From source file:DatasetCreation.DatasetCSVBuilder.java

/**
 * Return CSV string which represent the dataset
 *
 * @param elements ArrayList of elements to build dataset from
 * @param featureExtractor a Feature Extractor object
 * @param selectedFeatures the top selected features to build the dataset
 * with/*from ww  w .  jav a  2  s . c  o  m*/
 * @param classification the classification of all the records in the
 * dataset
 * @param addElementIDColumn add prefix column identifying the record
 * @param addClassificationColumn add suffix column identifying the class of
 * the record
 * @return CSV string which represent the dataset
 */
public StringBuilder BuildDatabaseCSV(ArrayList<T> elements, IFeatureExtractor<T> featureExtractor,
        ArrayList<Pair<String, Integer>> selectedFeatures, int totalElementsNum,
        FeatureRepresentation featureRepresentation, Classification classification, boolean addElementIDColumn,
        boolean addClassificationColumn) {
    StringBuilder datasetCSV = new StringBuilder();
    StringBuilder elementFeaturesVectorCSV;

    for (T element : elements) {
        elementFeaturesVectorCSV = GetFeaturesVectorCSV(element, featureExtractor, selectedFeatures,
                totalElementsNum, featureRepresentation, classification, addElementIDColumn,
                addClassificationColumn);

        if (elementFeaturesVectorCSV != null) {
            datasetCSV.append(elementFeaturesVectorCSV);
            datasetCSV.append("\n");
        }
    }
    datasetCSV.deleteCharAt(datasetCSV.lastIndexOf("\n"));
    return datasetCSV;
}

From source file:com.ming800.core.p.service.impl.JmenuManagerImpl.java

/**
 * JnodeJson?StringBuilder/*  w  ww. j  av a 2s .  co  m*/
 *
 * @param jnode
 * @param type  ??
 * @return
 */
private StringBuilder getJnodeJson(Jnode jnode, Integer type) {
    StringBuilder jNodeJson = new StringBuilder(50);
    String roleType = "ALL";

    Boolean access;

    /*     if(type != null && type == PConst.JMENU_TYPE_HEAD){      //??
    access = doHeadRoleFilter(jnode,role);
         }else{
    access = doRoleFilter(jnode,role);
         }*/

    if (!doRoleFilter(jnode, roleType))
        return jNodeJson;

    //        access = doLisenceFilter(jnode,role);
    //
    //        if (!access) return jNodeJson;

    /*        Map<String, String> settingMap = AuthorizationUtil.getMyUser().getSettingMap();
            access = doSettingFilter(jnode, settingMap);
            
            if (!access) return jNodeJson;*/

    String text = jnode.getText_zh_CN();
    //        String locale = AuthorizationUtil.getBigUser().getLocale().toString();
    String locale = "zh_CN";
    if (locale.startsWith("en")) {
        text = jnode.getText_en_US();
    }
    jNodeJson.append('{');
    jNodeJson.append("\"id\":\"" + jnode.getId()).append("\",").append("\"text\":\"" + text).append("\",")
            .append("\"state\":\"" + jnode.getState()).append("\",")
            //easyUIURL ? attributes???????
            .append("\"attributes\":{").append("\"url\":\"" + jnode.getUrl()).append("\"").append("},");
    StringBuilder childrenBuilder = new StringBuilder(100);
    if (jnode.getChildren() != null && jnode.getChildren().size() > 0) {
        jNodeJson.append("\"children\":[");
        for (Jnode childJnode : jnode.getChildren()) {
            childrenBuilder.append(this.getJnodeJson(childJnode, type));
        }
        if (childrenBuilder.toString().endsWith(",")) {
            childrenBuilder.deleteCharAt(childrenBuilder.length() - 1);
        }
        jNodeJson.append(childrenBuilder);
        jNodeJson.append("]").append(",");
    }
    jNodeJson.deleteCharAt(jNodeJson.length() - 1);
    jNodeJson.append("}").append(",");
    if (jnode.getUrl().equals("") && (childrenBuilder.length() == 0)) {
        jNodeJson = new StringBuilder("");
    }
    return jNodeJson;
}

From source file:es.juntadeandalucia.panelGestion.negocio.utiles.PanelSettings.java

private static void readMapeaConfiguration(Document xmlConfiguration) {
    mapeaUrl = null;// w w  w  . ja va2 s.  c  o  m

    StringBuilder mapeaUrlConfigBuilder = new StringBuilder();

    Element doc = xmlConfiguration.getDocumentElement();

    // mapea node
    NodeList mapeaNodes = doc.getElementsByTagName("mapea");
    Node mapeaNode = mapeaNodes.item(0);
    NodeList mapeaChildNodes = mapeaNode.getChildNodes();

    // child nodes
    for (int i = 0; i < mapeaChildNodes.getLength(); i++) {
        Node mapeaChildNode = mapeaChildNodes.item(i);
        if (mapeaChildNode.getNodeType() == Node.ELEMENT_NODE) {
            String tagName = mapeaChildNode.getNodeName();
            if (!StringUtils.isEmpty(tagName)) {
                if ("url".equalsIgnoreCase(tagName)) {
                    mapeaUrl = ((Element) mapeaChildNode).getAttribute("value");
                    mapeaUrl = Utils.removeLastSlash(mapeaUrl);
                } else {
                    String tagValue = ((Element) mapeaChildNode).getAttribute("value");
                    mapeaUrlConfigBuilder.append(tagName).append("=").append(tagValue);
                    mapeaUrlConfigBuilder.append("&");
                }
            }
        }
    }

    // removes last &
    mapeaUrlConfigBuilder.deleteCharAt(mapeaUrlConfigBuilder.length() - 1);

    mapeaUrl += mapeaUrlConfigBuilder.toString();
}

From source file:fi.cosky.sdk.API.java

@SuppressWarnings("unchecked")
public <T extends BaseData> T navigate(Class<T> tClass, Link l, HashMap<String, String> queryParameters)
        throws IOException {
    Object result;/*from w  ww .j  a  va2s. c  o  m*/
    retry = true;
    long start = 0;
    long end;

    if (isTimed()) {
        start = System.currentTimeMillis();
    }

    if (tClass.equals(TokenData.class)) {
        result = sendRequest(l, tClass, null);
        return (T) result;
    }

    if (l.getRel().equals("authenticate")) {
        HashMap<String, String> headers = new HashMap<String, String>();
        String authorization = "Basic "
                + Base64.encodeBase64String((this.ClientKey + ":" + this.ClientSecret).getBytes());
        headers.put("authorization", authorization);
        result = sendRequestWithAddedHeaders(Verb.POST, this.baseUrl + l.getUri(), tClass, null, headers);
        return (T) result;
    }

    String uri = l.getUri();
    if (l.getMethod().equals("GET") && queryParameters != null && !queryParameters.isEmpty()) {
        StringBuilder sb = new StringBuilder(uri + "?");

        for (String key : queryParameters.keySet()) {
            sb.append(key + "=" + queryParameters.get(key) + "&");
        }
        sb.deleteCharAt(sb.length() - 1);
        uri = sb.toString();
    }

    if (l.getMethod().equals("GET") && !uri.contains(":")) {
        result = sendRequest(l, tClass, null);
    } else if (l.getMethod().equals("PUT")) {
        result = sendRequest(l, tClass, null);
    } else if (l.getMethod().equals("POST")) {
        result = sendRequest(l, tClass, null);
    } else if (l.getMethod().equals("DELETE")) {
        result = sendRequest(l, tClass, new Object());
    } else {
        result = sendRequest(l, tClass, null);
    }
    if (isTimed()) {
        end = System.currentTimeMillis();
        long time = end - start;
        System.out.println("Method " + l.getMethod() + " on " + l.getUri() + " doing " + l.getRel() + " took "
                + time + " ms.");
    }
    return (T) result;
}

From source file:au.com.infiniterecursion.vidiom.utils.PublishingUtils.java

public static CharSequence readFile(Activity activity, int id) {
    BufferedReader in = null;/*from  w  w  w .ja v a2  s .co m*/
    try {
        in = new BufferedReader(new InputStreamReader(activity.getResources().openRawResource(id)));
        String line;
        StringBuilder buffer = new StringBuilder();
        while ((line = in.readLine()) != null) {
            buffer.append(line).append('\n');
        }
        // Chomp the last newline
        buffer.deleteCharAt(buffer.length() - 1);
        return buffer;
    } catch (IOException e) {
        return "";
    } finally {
        closeStream(in);
    }
}

From source file:com.openteach.qsync.service.declare.AssembleService.java

/**
 * ??//from  w w w  . j  a  va2  s.c  o m
 * @param order
 * @return
 */
public XmlGoodsDeclarRequest getGoodsXmlRequest(Order order) {
    XmlGoodsDeclarRequest request = new XmlGoodsDeclarRequest();
    XmlGoodsDeclarRequestBody body = new XmlGoodsDeclarRequestBody();
    GoodsDeclarModule goodsDeclarModule = new GoodsDeclarModule();

    GoodsDeclar goodsDeclar = new GoodsDeclar();
    goodsDeclarModule.setGoodsDeclar(goodsDeclar);
    goodsDeclar.setAccountBookNo(configService.getDeclareAccountBookNo()); //? ???
    goodsDeclar.setInOutFlag("I");
    goodsDeclar.setPreEntryNumber(
            configService.getDeclareRecordNo().substring(configService.getDeclareRecordNo().length() - 4)
                    + (BASE_ID + order.getId() + System.currentTimeMillis())); // 4??????
    goodsDeclar.setImportType(configService.getDeclareType());
    goodsDeclar.setInOutDateStr(order.getOrdertime());
    goodsDeclar.setInOutPortNumber(configService.getDeclareInOutPortNumber());
    goodsDeclar.setArrivedPort(configService.getDeclareArrivedPort());
    goodsDeclar.setTransportTool(order.getTransportationObject().getName());
    goodsDeclar.setTransportToolFltNo(order.getTransportationObject().getToolFltNo()); //cc_kata_kplus_transportation.tool_flt_no
    goodsDeclar.setTransportTypeCode(order.getTransportationObject().getTypeCode()); //cc_kata_kplus_transportation.type_code
    goodsDeclar.setDeclareCompanyType(configService.getDeclareCompanyType());
    goodsDeclar.setDeclareCompanyCode(configService.getDeclareCompanyCode());
    goodsDeclar.setDeclareCompanyName(configService.getDeclareCompanyName());
    goodsDeclar.setEeBusinessCompanyCode(configService.getDeclareRecordNo());
    goodsDeclar.setEeBusinessCompanyName(configService.getDeclareRecordName());
    goodsDeclar.setOrderNumber(order.getCode());
    goodsDeclar.setSubCarriageNo(order.getOrderTransportObject().getWaybillnumber()); //???????
    Country fromCountry = countryManager.getById(order.getTransportationObject().getFromCountry());
    if (fromCountry == null) {
        throw new DataAssembleException("order.transportationObject.fromCountry may not be null");
    }
    if (StringUtils.isBlank(fromCountry.getCountryCode())) {
        throw new DataAssembleException("order.transportationObject.fromCountry.countryCode may not be null");
    }
    goodsDeclar.setFromCountry(fromCountry.getCountryCode()); //cc_kata_kplus_transportation.from_country
    goodsDeclar.setPieceNumber(order.getTotalGoodsCount());
    goodsDeclar.setRoughWeight(order.getTotalGoodsWeight());
    goodsDeclar.setNetWeight(order.getTotalGoodsWeight());
    goodsDeclar.setPackType(order.getTransportationObject().getPackType()); //cc_kata_kplus_transportation.pack_type
    goodsDeclar.setRemark("");
    goodsDeclar.setDeclarePortCode(configService.getDeclareInOutPortNumber());
    goodsDeclar.setEnteringPerson("9999");
    goodsDeclar.setEnteringCompanyName("9999");
    goodsDeclar.setDeclarantCode("");
    goodsDeclar.setGoodsYardCode(configService.getDeclareGoodsYardCode());
    goodsDeclar.setSender(order.getOrderTransportObject().getAddressorName()); // cc_kata_kplus_order_transport.addressor_name
    goodsDeclar.setReceiver(order.getOrderTransportObject().getCongsignee());
    Country senderCountry = countryManager.getById(order.getOrderTransportObject().getAddressorCountry());
    if (senderCountry == null) {
        throw new DataAssembleException("order.orderTransportObject.addressorCountry may not be null");
    }
    if (StringUtils.isBlank(senderCountry.getCountryCode())) {
        throw new DataAssembleException(
                "order.orderTransportObject.addressorCountry.countryCode may not be null");
    }
    goodsDeclar.setSenderCountry(senderCountry.getCountryCode()); //cc_kata_kplus_order_transport.addressor_country
    goodsDeclar.setSenderCity(order.getOrderTransportObject().getAddressorCity()); //cc_kata_kplus_order_transport.addressor_city
    goodsDeclar.setReceiverPapersType(order.getMemberObject().getCertificatesType().substring(1)); //???kata_kplus_member.certificates_type
    goodsDeclar.setReceiverPapersNo(order.getMemberObject().getCertificates()); //???kata_kplus_member.certificates
    //worth?302
    goodsDeclar.setCurrency(configService.getDeclareCurrency());

    List<TransportCommodity> transportCommoditiyList = order.getOrderTransportObject()
            .getTransportCommodityList();
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < transportCommoditiyList.size() && i <= 3; i++) {
        TransportCommodity tc = transportCommoditiyList.get(i);
        Commsku commsku = tc.getCommskuObject();
        sb.append(commsku.getName()).append("");
    }
    if (sb.length() > 0)
        sb.deleteCharAt(sb.length() - 1);
    goodsDeclar.setMajorGoodsName(sb.toString());
    goodsDeclar.setInternalAreaCompanyName(configService.getDeclareInternalAreaCompanyName());
    goodsDeclar.setInternalAreaCompanyNo(configService.getDeclareInternalAreaCompanyNo());
    goodsDeclar.setApplicationFormNo(order.getTransportationObject().getApplicationFormNo()); //cc_kata_kplus_transportation.application_form_no
    goodsDeclar.setIsAuthorize((byte) 0);
    Double worth = 0.0;
    List<GoodsDeclarDetail> goodsDeclarDetails = new ArrayList<GoodsDeclarDetail>();
    goodsDeclarModule.setGoodsDeclarDetails(goodsDeclarDetails);
    for (int i = 0; i < transportCommoditiyList.size() && i <= 3; i++) {
        TransportCommodity tc = transportCommoditiyList.get(i);
        Commsku commsku = tc.getCommskuObject();
        GoodsDeclarDetail cdd = new GoodsDeclarDetail();
        cdd.setGoodsOrder(i);
        cdd.setMailTaxNo(commsku.getCommodityObject().getCategoryObject().getTariff()); //cc_kata_kplus_category.tariff
        cdd.setGoodsItemNo(tc.getGoodsItemNo()); // ?? cc_kata_kplus_transport_commodity.goods_item_no   ? ?   
        cdd.setGoodsName(commsku.getName());
        cdd.setGoodsSpecification(commsku.getProperties()); //cc_kata_kplus_commodity.properties
        Country country = countryManager.getById(commsku.getCommodityObject().getSalesCountry());
        if (country == null) {
            throw new DataAssembleException(
                    "order.orderTransportObject.transportCommodityList(i).commsku.commodityObject.salesCountry may not be null");
        }
        if (StringUtils.isBlank(country.getCountryCode())) {
            throw new DataAssembleException(
                    "order.orderTransportObject.transportCommodityList(i).commsku.commodityObject.countryCode may not be null");
        }
        cdd.setProductionMarketingCountry(country.getCountryCode()); //cc_kata_kplus_commodity.sales_country
        cdd.setBargainCurrency(configService.getDeclareCurrency());
        cdd.setBargainTotalPrices(tc.getPrice() * tc.getDelivernum());
        cdd.setDeclarePrice(tc.getPrice());
        cdd.setDeclareTotalPrices(tc.getPrice() * tc.getDelivernum());
        worth += cdd.getDeclareTotalPrices();
        cdd.setPurpose("");
        cdd.setDeclareCount(tc.getDelivernum());
        cdd.setDeclareMeasureUnit(commsku.getCommodityObject().getUnitObject().getCode()); //cc_kata_kplus_unit.code
        cdd.setGoodsRoughWeight(commsku.getCommodityObject().getWeight());
        cdd.setFirstUnit(commsku.getCommodityObject().getUnitObject().getCode()); //cc_kata_kplus_unit.code
        cdd.setFirstCount(tc.getDelivernum());

        cdd.setSecondUnit(commsku.getCommodityObject().getUnitObject().getCode()); // ???????
        cdd.setSecondCount(tc.getDelivernum()); //? ???
        goodsDeclarDetails.add(cdd);
    }
    goodsDeclar.setWorth(worth);

    body.setGoodsDeclarModuleList(Arrays.asList(goodsDeclarModule));
    JkfSign jkfSign = new JkfSign();
    jkfSign.setBusinessType(configService.getDeclareBusinessType());
    jkfSign.setCompanyCode(configService.getCompanyCode());
    jkfSign.setDeclareType(configService.getDeclareType());
    jkfSign.setBusinessNo(generateSequence());
    jkfSign.setNote("?");
    goodsDeclarModule.setJkfSign(jkfSign);

    CommonXmlRequestHead head = new CommonXmlRequestHead();
    head.setBusinessType(CommonXmlRequestHead.PERSONAL_GOODS_DECLAR);
    request.setHead(head);
    request.setBody(body);
    return request;
}

From source file:org.apache.camel.component.olingo2.api.Olingo2AppIntegrationTest.java

private static String prettyPrint(Map<String, Object> properties, int level) {
    StringBuilder b = new StringBuilder();
    Set<Map.Entry<String, Object>> entries = properties.entrySet();

    for (Map.Entry<String, Object> entry : entries) {
        indent(b, level);/*from   w  w  w  .java  2 s  .  c  o  m*/
        b.append(entry.getKey()).append(": ");
        Object value = entry.getValue();
        if (value instanceof Map) {
            @SuppressWarnings("unchecked")
            final Map<String, Object> objectMap = (Map<String, Object>) value;
            value = prettyPrint(objectMap, level + 1);
            b.append(value).append(NEW_LINE);
        } else if (value instanceof Calendar) {
            Calendar cal = (Calendar) value;
            value = SimpleDateFormat.getInstance().format(cal.getTime());
            b.append(value).append(NEW_LINE);
        } else if (value instanceof ODataDeltaFeed) {
            ODataDeltaFeed feed = (ODataDeltaFeed) value;
            List<ODataEntry> inlineEntries = feed.getEntries();
            b.append("{");
            for (ODataEntry oDataEntry : inlineEntries) {
                value = prettyPrint(oDataEntry.getProperties(), level + 1);
                b.append("\n[\n").append(value).append("\n],");
            }
            b.deleteCharAt(b.length() - 1);
            indent(b, level);
            b.append("}\n");
        } else {
            b.append(value).append(NEW_LINE);
        }
    }
    // remove last line break
    b.deleteCharAt(b.length() - 1);
    return b.toString();
}