Example usage for org.apache.commons.lang3 StringUtils EMPTY

List of usage examples for org.apache.commons.lang3 StringUtils EMPTY

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils EMPTY.

Prototype

String EMPTY

To view the source code for org.apache.commons.lang3 StringUtils EMPTY.

Click Source Link

Document

The empty String "" .

Usage

From source file:cognition.common.utils.StringTools.java

public static String getCompletingString(String string, int begin, int end) {
    while (begin > 0 && StringUtils.isAlphanumeric(string.substring(begin, begin + 1))) {
        begin -= 1;//from   w ww.  j a  v  a  2 s  .c om
    }
    if (begin != 0)
        begin += 1;

    while (end < string.length() - 1 && StringUtils.isAlphanumeric(string.substring(end, end + 1))) {
        end += 1;
    }

    String regex = "\\w+(\\(?\\)?\\s+\\w+)*";
    Pattern pattern = Pattern.compile(regex);
    Matcher matcher = pattern.matcher(string.substring(begin, end));

    if (matcher.find()) {
        return matcher.group();
    }

    return StringUtils.EMPTY;
}

From source file:com.aqnote.app.wifianalyzer.wifi.graph.channel.ChannelAxisLabelTest.java

@Test
public void testXAxisWithFrequencyNotAllowedInLocale() throws Exception {
    // setup// w  w  w.j  a  va  2s. com
    WiFiChannel wiFiChannel = WiFiBand.GHZ2.getWiFiChannels().getWiFiChannelLast();
    // execute
    String actual = fixture.formatLabel(wiFiChannel.getFrequency(), true);
    // validate
    assertEquals(StringUtils.EMPTY, actual);
}

From source file:cl.monsoon.s1next.binding.TextViewBindingAdapter.java

@BindingAdapter({ "eventBus", "post" })
public static void setCount(TextView textView, EventBus eventBus, Post post) {
    String text = "#" + post.getCount();
    // there is no need to quote #1
    if ("1".equals(post.getCount())) {
        textView.setText(text);//  w  w  w  .j a v  a  2  s .  c  o  m
    } else {
        Spannable spannable = new SpannableString(text);
        URLSpan urlSpan = new URLSpan(StringUtils.EMPTY) {
            @Override
            public void onClick(@NonNull View widget) {
                eventBus.post(new QuoteEvent(post.getId(), post.getCount()));
            }
        };
        spannable.setSpan(urlSpan, 0, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        textView.setText(spannable);
    }
}

From source file:com.vrem.wifianalyzer.wifi.AccessPointsDetailTest.java

@Test
public void testSetViewWithWiFiDetailAsScanResult() throws Exception {
    // setup//ww w . j a  va 2s.  c o  m
    WiFiDetail wiFiDetail = new WiFiDetail(StringUtils.EMPTY, "BSSID", "capabilities",
            new WiFiSignal(1, WiFiWidth.MHZ_20, 2), new WiFiAdditional(StringUtils.EMPTY, false));
    // execute
    fixture.setView(mainActivity.getResources(), view, wiFiDetail, true, true);
    // validate
    validateTextViewValues(wiFiDetail, "***");
    WiFiSignal wiFiSignal = wiFiDetail.getWiFiSignal();
    validateTextViewValue(String.format("%d - %d %s", wiFiSignal.getFrequencyStart(),
            wiFiSignal.getFrequencyEnd(), WifiInfo.FREQUENCY_UNITS), R.id.channel_frequency_range);

    assertEquals(View.GONE, view.findViewById(R.id.ipAddress).getVisibility());
    assertEquals(View.GONE, view.findViewById(R.id.configuredImage).getVisibility());
    assertEquals(View.GONE, view.findViewById(R.id.vendor).getVisibility());
    assertEquals(View.VISIBLE, view.findViewById(R.id.tab).getVisibility());
    assertEquals(View.GONE, view.findViewById(R.id.groupIndicator).getVisibility());
    assertEquals(View.VISIBLE, view.findViewById(R.id.channel_frequency_range_row).getVisibility());
}

From source file:com.quatico.base.aem.test.api.setup.Pages.java

@Override
public Resource aPageWithParents(Resource parent, String relativePath, Object... properties) throws Exception {
    if (relativePath == null) {
        relativePath = StringUtils.EMPTY;
    }//w w  w.  jav  a2 s  . c o  m
    if (StringUtils.isNotEmpty(relativePath) && !StringUtils.startsWith(relativePath, "/")) {
        relativePath += "/";
    }
    return aPageWithParents(parent.getPath() + relativePath, properties);
}

From source file:com.precioustech.fxtrading.oanda.restapi.position.OandaPositionManagementProvider.java

@Override
public Collection<Position<String>> getPositionsForAccount(Long accountId) {
    Collection<Position<String>> allPositions = Lists.newArrayList();
    CloseableHttpClient httpClient = getHttpClient();
    try {/*from w w  w.  ja v a2  s  . com*/
        String strResp = getResponseAsString(getPositionsForAccountUrl(accountId), httpClient);
        if (strResp != StringUtils.EMPTY) {
            Object obj = JSONValue.parse(strResp);
            JSONObject jsonResp = (JSONObject) obj;
            JSONArray accPositions = (JSONArray) jsonResp.get(positions);
            for (Object o : accPositions) {
                JSONObject accPosition = (JSONObject) o;
                Position<String> positionInfo = parsePositionInfo(accPosition);
                allPositions.add(positionInfo);
            }
        }
    } catch (Exception ex) {
        LOG.error("error encountered whilst fetching positions for account:" + accountId, ex);
    } finally {
        TradingUtils.closeSilently(httpClient);
    }
    return allPositions;
}

From source file:com.precioustech.fxtrading.instrument.InstrumentServiceTest.java

private Collection<TradeableInstrument<String>> createInstruments() {
    Collection<TradeableInstrument<String>> instruments = Lists.newArrayList();

    instruments.add(new TradeableInstrument<String>("GBP_USD", nonjpypip,
            mock(InstrumentPairInterestRate.class), StringUtils.EMPTY));
    instruments.add(new TradeableInstrument<String>("GBP_CHF", nonjpypip,
            mock(InstrumentPairInterestRate.class), StringUtils.EMPTY));
    instruments.add(new TradeableInstrument<String>("EUR_USD", nonjpypip,
            mock(InstrumentPairInterestRate.class), StringUtils.EMPTY));
    instruments.add(new TradeableInstrument<String>("NZD_USD", nonjpypip,
            mock(InstrumentPairInterestRate.class), StringUtils.EMPTY));
    instruments.add(new TradeableInstrument<String>("USD_JPY", jpypip, mock(InstrumentPairInterestRate.class),
            StringUtils.EMPTY));/*from ww w  .ja  v a  2s  .  c o m*/
    instruments.add(new TradeableInstrument<String>("AUD_JPY", jpypip, mock(InstrumentPairInterestRate.class),
            StringUtils.EMPTY));
    return instruments;
}

From source file:com.aqnote.app.wifianalyzer.wifi.model.WiFiDetailTest.java

@Test
public void testWiFiDetailCopyConstructor() throws Exception {
    // setup/*from w  w w .  ja v a  2 s.c  o m*/
    WiFiDetail expected = new WiFiDetail(StringUtils.EMPTY, BSSID, WPA, wiFiSignal);
    // execute
    WiFiDetail actual = new WiFiDetail(expected, expected.getWiFiAdditional());
    // validate
    assertEquals(expected, actual);
    assertEquals(expected.getSSID(), actual.getSSID());
    assertEquals(expected.getBSSID(), actual.getBSSID());
    assertEquals(expected.getCapabilities(), actual.getCapabilities());
    assertEquals(expected.getTitle(), actual.getTitle());
    assertEquals(expected.getSecurity(), actual.getSecurity());
    assertEquals(expected.isHidden(), actual.isHidden());
    assertEquals(expected.getWiFiAdditional(), actual.getWiFiAdditional());
    assertEquals(expected.getWiFiSignal(), actual.getWiFiSignal());
}

From source file:com.precioustech.fxtrading.oanda.restapi.marketdata.OandaCurrentPriceInfoProvider.java

@Override
public Map<TradeableInstrument<String>, Price<String>> getCurrentPricesForInstruments(
        Collection<TradeableInstrument<String>> instruments) {
    StringBuilder instrumentCsv = new StringBuilder();
    boolean firstTime = true;
    for (TradeableInstrument<String> instrument : instruments) {
        if (firstTime) {
            firstTime = false;//from w ww .java  2s  .co m
        } else {
            instrumentCsv.append(TradingConstants.ENCODED_COMMA);
        }
        instrumentCsv.append(instrument.getInstrument());
    }

    Map<TradeableInstrument<String>, Price<String>> pricesMap = Maps.newHashMap();
    CloseableHttpClient httpClient = getHttpClient();
    try {
        HttpUriRequest httpGet = new HttpGet(
                this.url + OandaConstants.PRICES_RESOURCE + "?instruments=" + instrumentCsv.toString());
        httpGet.setHeader(this.authHeader);
        httpGet.setHeader(OandaConstants.UNIX_DATETIME_HEADER);
        LOG.info(TradingUtils.executingRequestMsg(httpGet));
        HttpResponse resp = httpClient.execute(httpGet);
        String strResp = TradingUtils.responseToString(resp);
        if (strResp != StringUtils.EMPTY) {
            Object obj = JSONValue.parse(strResp);
            JSONObject jsonResp = (JSONObject) obj;
            JSONArray prices = (JSONArray) jsonResp.get(OandaJsonKeys.prices);
            for (Object price : prices) {
                JSONObject trade = (JSONObject) price;
                Long priceTime = Long.parseLong(trade.get(time).toString());
                TradeableInstrument<String> instrument = new TradeableInstrument<String>(
                        (String) trade.get(OandaJsonKeys.instrument));
                Price<String> pi = new Price<String>(instrument, ((Number) trade.get(bid)).doubleValue(),
                        ((Number) trade.get(ask)).doubleValue(),
                        new DateTime(TradingUtils.toMillisFromNanos(priceTime)));
                pricesMap.put(instrument, pi);
            }
        } else {
            TradingUtils.printErrorMsg(resp);
        }
    } catch (Exception ex) {
        LOG.error(ex);
    } finally {
        TradingUtils.closeSilently(httpClient);
    }
    return pricesMap;
}