List of usage examples for org.apache.commons.lang3 StringUtils EMPTY
String EMPTY
To view the source code for org.apache.commons.lang3 StringUtils EMPTY.
Click Source Link
From source file:com.nridge.core.base.field.FieldRow.java
/** * Return a the cell value identified by the column offset. * * @param aColOffset Column offset in the row. * * @return Cell value./*from www . j a va2 s . c om*/ */ public String getValue(int aColOffset) { if ((aColOffset >= 0) && (aColOffset < mCells.length)) return mCells[aColOffset].getValue(); else return StringUtils.EMPTY; }
From source file:com.todev.rabbitmqmanagement.ui.channel.list.ChannelListEntryPresenterTest.java
@Test public void should_display_all_values_on_bind() { // Given/*from w ww . j a v a 2s .c o m*/ doReturn(channelDetails).when(channel).getChannelDetails(); doReturn("172.17.0.1").when(channelDetails).getPeerHost(); doReturn(35128).when(channelDetails).getPeerPort(); doReturn(1).when(channel).getNumber(); doReturn("test").when(channel).getUser(); doReturn("running").when(channel).getState(); doReturn(0).when(channel).getMessagesUnconfirmed(); doReturn(16830).when(channel).getMessagesUnacknowledged(); doReturn(0).when(channel).getMessagesUncommitted(); doReturn(0).when(channel).getAcksUncommitted(); doReturn(messageStats).when(channel).getMessageStats(); doReturn(details).when(messageStats).getPublishDetails(); doReturn(details).when(messageStats).getConfirmDetails(); doReturn(details).when(messageStats).getReturnUnroutableDetails(); doReturn(details).when(messageStats).getDeliverGetDetails(); doReturn(details).when(messageStats).getRedeliverDetails(); doReturn(details).when(messageStats).getAckDetails(); doReturn(0.0f).when(details).getRate(); // When presenter.bind(channel); // Then verify(view).displayName("172.17.0.1", 35128, 1); verify(view).displayUsername("test"); verify(view).displayMode(StringUtils.EMPTY); verify(view).displayState("running"); verify(view).displayUnconfirmed(0); verify(view).displayPrefetch(StringUtils.EMPTY); verify(view).displayUnacked(16830); verify(view).displayUncommittedMessages(0); verify(view).displayUncommittedAcks(0); verify(view).displayPublish(0.0f); verify(view).displayConfirm(0.0f); verify(view).displayReturnMandatory(0.0f); verify(view).displayDeliverGet(0.0f); verify(view).displayRedelivered(0.0f); verify(view).displayAck(0.0f); }
From source file:com.vrem.wifianalyzer.wifi.accesspoint.AccessPointsAdapterGroup.java
String getGroupExpandKey(@NonNull WiFiDetail wiFiDetail) { String result = StringUtils.EMPTY; if (GroupBy.SSID.equals(this.groupBy)) { result = wiFiDetail.getSSID();//from w w w . j a va 2 s .com } if (GroupBy.CHANNEL.equals(this.groupBy)) { result += wiFiDetail.getWiFiSignal().getPrimaryWiFiChannel().getChannel(); } return result; }
From source file:com.adguard.commons.lang.Wildcard.java
/** * Extracts longest string that does not contain * or ? symbols. * * @param pattern Wildcard pattern/*w ww . j a va 2 s. com*/ * @return Longest string without special symbols */ private static String extractShortcut(String pattern) { char[] wildcardChars = new char[] { '*', '?' }; int startIndex = 0; int endIndex = StringUtils.indexOfAny(pattern, wildcardChars); if (endIndex < 0) { return pattern; } String shortcut = endIndex == startIndex ? StringUtils.EMPTY : pattern.substring(startIndex, endIndex - startIndex); while (endIndex >= 0) { startIndex = startIndex + endIndex + 1; if (pattern.length() <= startIndex) { break; } endIndex = StringUtils.indexOfAny(pattern.substring(startIndex), wildcardChars); String tmpShortcut = endIndex < 0 ? pattern.substring(startIndex) : pattern.substring(startIndex, endIndex + startIndex); if (tmpShortcut.length() > shortcut.length()) { shortcut = tmpShortcut; } } return shortcut; }
From source file:de.blizzy.documentr.search.GetSearchHitTask.java
@Override public SearchHit call() throws IOException { Formatter formatter = new SimpleHTMLFormatter("<strong>", "</strong>"); //$NON-NLS-1$ //$NON-NLS-2$ Scorer scorer = new QueryScorer(query); Highlighter highlighter = new Highlighter(formatter, scorer); highlighter.setTextFragmenter(new SimpleFragmenter(FRAGMENT_SIZE)); highlighter.setEncoder(new SimpleHTMLEncoder()); Document doc = reader.document(docId); String projectName = doc.get(PageIndex.PROJECT); String branchName = doc.get(PageIndex.BRANCH); String path = doc.get(PageIndex.PATH); String title = doc.get(PageIndex.TITLE); String text = doc.get(PageIndex.TEXT); String[] tagsArray = doc.getValues(PageIndex.TAG); List<String> tags = Lists.newArrayList(tagsArray); Collections.sort(tags);/* www . j a v a 2 s . c o m*/ TokenStream tokenStream = null; String highlightedText = StringUtils.EMPTY; try { tokenStream = TokenSources.getAnyTokenStream(reader, docId, PageIndex.TEXT, doc, analyzer); String[] fragments = highlighter.getBestFragments(tokenStream, text, NUM_FRAGMENTS); cleanupFragments(fragments); highlightedText = Util.join(fragments, " <strong>...</strong> "); //$NON-NLS-1$ } catch (InvalidTokenOffsetsException e) { // ignore } finally { Closeables.closeQuietly(tokenStream); } return new SearchHit(projectName, branchName, path, title, highlightedText, tags); }
From source file:lineage2.gameserver.data.xml.parser.EtcItemParser.java
/** * Method readData./*from ww w . ja v a 2s .c o m*/ * @param rootElement org.dom4j.Element * @throws Exception */ @Override protected void readData(org.dom4j.Element rootElement) throws Exception { for (Iterator<org.dom4j.Element> itemIterator = rootElement.elementIterator(); itemIterator.hasNext();) { org.dom4j.Element itemElement = itemIterator.next(); StatsSet set = new StatsSet(); set.set("item_id", itemElement.attributeValue("id")); set.set("name", itemElement.attributeValue("name")); set.set("add_name", itemElement.attributeValue("add_name", StringUtils.EMPTY)); int slot = 0; for (Iterator<org.dom4j.Element> subIterator = itemElement.elementIterator(); subIterator.hasNext();) { org.dom4j.Element subElement = subIterator.next(); String subName = subElement.getName(); if (subName.equalsIgnoreCase("set")) { set.set(subElement.attributeValue("name"), subElement.attributeValue("value")); } else if (subName.equalsIgnoreCase("equip")) { for (Iterator<org.dom4j.Element> slotIterator = subElement.elementIterator(); slotIterator .hasNext();) { org.dom4j.Element slotElement = slotIterator.next(); Bodypart bodypart = Bodypart.valueOf(slotElement.attributeValue("id")); if (bodypart.getReal() != null) { slot = bodypart.mask(); } else { slot |= bodypart.mask(); } } } } set.set("bodypart", slot); ItemTemplate template = null; try { template = new EtcItemTemplate(set); } catch (Exception e) { warn("Fail create item: " + set.get("item_id"), e); continue; } for (Iterator<org.dom4j.Element> subIterator = itemElement.elementIterator(); subIterator.hasNext();) { org.dom4j.Element subElement = subIterator.next(); String subName = subElement.getName(); if (subName.equalsIgnoreCase("for")) { parseFor(subElement, template); } else if (subName.equalsIgnoreCase("triggers")) { parseTriggers(subElement, template); } else if (subName.equalsIgnoreCase("skills")) { for (Iterator<org.dom4j.Element> nextIterator = subElement.elementIterator(); nextIterator .hasNext();) { org.dom4j.Element nextElement = nextIterator.next(); int id = Integer.parseInt(nextElement.attributeValue("id")); int level = Integer.parseInt(nextElement.attributeValue("level")); Skill skill = SkillTable.getInstance().getInfo(id, level); if (skill != null) { template.attachSkill(skill); } else { info("Skill not found(" + id + "," + level + ") for item:" + set.getObject("item_id") + "; file:" + getCurrentFileName()); } } } else if (subName.equalsIgnoreCase("enchant4_skill")) { int id = Integer.parseInt(subElement.attributeValue("id")); int level = Integer.parseInt(subElement.attributeValue("level")); Skill skill = SkillTable.getInstance().getInfo(id, level); if (skill != null) { template.setEnchant4Skill(skill); } } else if (subName.equalsIgnoreCase("unequip_skill")) { int id = Integer.parseInt(subElement.attributeValue("id")); int level = Integer.parseInt(subElement.attributeValue("level")); Skill skill = SkillTable.getInstance().getInfo(id, level); if (skill != null) { template.setUnequipeSkill(skill); } } else if (subName.equalsIgnoreCase("cond")) { Condition condition = parseFirstCond(subElement); if (condition != null) { int msgId = parseNumber(subElement.attributeValue("msgId")).intValue(); condition.setSystemMsg(msgId); template.setCondition(condition); } } else if (subName.equalsIgnoreCase("attributes")) { int[] attributes = new int[6]; for (Iterator<org.dom4j.Element> nextIterator = subElement.elementIterator(); nextIterator .hasNext();) { org.dom4j.Element nextElement = nextIterator.next(); Element element; if (nextElement.getName().equalsIgnoreCase("attribute")) { element = Element.getElementByName(nextElement.attributeValue("element")); attributes[element.getId()] = Integer.parseInt(nextElement.attributeValue("value")); } } template.setBaseAtributeElements(attributes); } else if (subName.equalsIgnoreCase("enchant_options")) { for (Iterator<org.dom4j.Element> nextIterator = subElement.elementIterator(); nextIterator .hasNext();) { org.dom4j.Element nextElement = nextIterator.next(); if (nextElement.getName().equalsIgnoreCase("level")) { int val = Integer.parseInt(nextElement.attributeValue("val")); int i = 0; int[] options = new int[3]; for (org.dom4j.Element optionElement : nextElement.elements()) { OptionDataTemplate optionData = OptionDataHolder.getInstance() .getTemplate(Integer.parseInt(optionElement.attributeValue("id"))); if (optionData == null) { error("Not found option_data for id: " + optionElement.attributeValue("id") + "; item_id: " + set.get("item_id")); continue; } options[i++] = optionData.getId(); } template.addEnchantOptions(val, options); } } } } getHolder().addItem(template); } }
From source file:com.todev.rabbitmqmanagement.ui.connection.list.ConnectionListEntryPresenterTest.java
@Test public void should_display_all_values_on_bind() { // Given// w ww .ja v a 2s .co m doReturn("172.17.0.1").when(connection).getPeerHost(); doReturn(35128).when(connection).getPeerPort(); doReturn("test").when(connection).getUser(); doReturn("running").when(connection).getState(); doReturn(false).when(connection).isSsl(); doReturn("AMQP 0-9-1").when(connection).getProtocol(); doReturn(1).when(connection).getChannels(); doReturn(65535).when(connection).getChannelMax(); doReturn(131072).when(connection).getFrameMax(); doReturn("PLAIN").when(connection).getAuthMechanism(); doReturn(clientProperties).when(connection).getClientProperties(); doReturn("rabbitpy").when(clientProperties).getProduct(); doReturn("Python 3.5.2").when(clientProperties).getPlatform(); doReturn("1.0.0").when(clientProperties).getVersion(); doReturn(135.0f).when(details).getRate(); doReturn(details).when(connection).getRecvOctDetails(); doReturn(details).when(connection).getSendOctDetails(); doReturn(60).when(connection).getTimeout(); doReturn(1482317490720L).when(connection).getConnectedAt(); // When presenter.bind(connection); // Then verify(view).displayName("172.17.0.1", 35128); verify(view).displayUsername("test"); verify(view).displayState("running"); verify(view).displaySslTls(false); verify(view).displaySslDetails(StringUtils.EMPTY); verify(view).displayProtocol("AMQP 0-9-1"); verify(view).displayChannels(1); verify(view).displayChannelMax(65535); verify(view).displayFrameMax(131072); verify(view).displayAuthMechanism("PLAIN"); verify(view).displayClient(clientProperties); verify(view).displayClientFromRate(135.0f); verify(view).displayClientToRate(135.0f); verify(view).displayHeartbeat(60); verify(view).displayConnectedAt(1482317490720L); }
From source file:com.vrem.wifianalyzer.wifi.AccessPointDetailTest.java
@Test public void testMakeViewShouldUseGivenView() throws Exception { // setup// ww w.ja va2 s .c o m View expected = mainActivity.getLayoutInflater().inflate(AccessPointView.COMPLETE.getLayout(), null, false); WiFiDetail wiFiDetail = withWiFiDetail(SSID, new WiFiAdditional(StringUtils.EMPTY, true)); // execute View actual = fixture.makeView(expected, null, wiFiDetail, false); // validate assertEquals(expected, actual); }
From source file:ch.cyberduck.cli.TerminalListProgressListener.java
@Override public void chunk(final Path folder, final AttributedList<Path> list) throws ListCanceledException { for (int i = size; i < list.size(); i++) { final Path file = list.get(i); if (l) {/*from w w w. j a v a 2 s . com*/ if (file.isSymbolicLink()) { console.printf("%n%sl%s\t%s\t%s -> %s%s", Ansi.ansi().bold(), file.attributes().getPermission().getSymbol(), formatter.getMediumFormat(file.attributes().getModificationDate()), file.getName(), file.getSymlinkTarget().getAbsolute(), Ansi.ansi().reset()); } else { console.printf("%n%s%s%s\t%s\t%s\t%s%s", Ansi.ansi().bold(), file.isDirectory() ? "d" : "-", file.attributes().getPermission().getSymbol(), formatter.getMediumFormat(file.attributes().getModificationDate()), StringUtils.isNotBlank(file.attributes().getRegion()) ? file.attributes().getRegion() : StringUtils.EMPTY, file.getName(), Ansi.ansi().reset()); } } else { console.printf("%n%s%s%s", Ansi.ansi().bold(), file.getName(), Ansi.ansi().reset()); } } size += list.size() - size; try { super.chunk(folder, list); } catch (ListCanceledException e) { final String message = String.format("%s %s?: ", MessageFormat.format(LocaleFactory.localizedString( "Continue listing directory with more than {0} files.", "Alert"), e.getChunk().size()), LocaleFactory.localizedString("Continue", "Credentials")); if (!prompt.prompt(message)) { throw e; } } }
From source file:lineage2.gameserver.data.xml.parser.ArmorItemParser.java
/** * Method readData./*from www. j av a 2 s.c o m*/ * @param rootElement org.dom4j.Element * @throws Exception */ @Override protected void readData(org.dom4j.Element rootElement) throws Exception { for (Iterator<org.dom4j.Element> itemIterator = rootElement.elementIterator(); itemIterator.hasNext();) { org.dom4j.Element itemElement = itemIterator.next(); StatsSet set = new StatsSet(); set.set("item_id", itemElement.attributeValue("id")); set.set("name", itemElement.attributeValue("name")); set.set("add_name", itemElement.attributeValue("add_name", StringUtils.EMPTY)); int slot = 0; for (Iterator<org.dom4j.Element> subIterator = itemElement.elementIterator(); subIterator.hasNext();) { org.dom4j.Element subElement = subIterator.next(); String subName = subElement.getName(); if (subName.equalsIgnoreCase("set")) { set.set(subElement.attributeValue("name"), subElement.attributeValue("value")); } else if (subName.equalsIgnoreCase("equip")) { for (Iterator<org.dom4j.Element> slotIterator = subElement.elementIterator(); slotIterator .hasNext();) { org.dom4j.Element slotElement = slotIterator.next(); Bodypart bodypart = Bodypart.valueOf(slotElement.attributeValue("id")); if (bodypart.getReal() != null) { slot = bodypart.mask(); } else { slot |= bodypart.mask(); } } } } set.set("bodypart", slot); ItemTemplate template = null; try { if (itemElement.getName().equalsIgnoreCase("armor")) { if (!set.containsKey("class")) { if ((slot & ItemTemplate.SLOTS_ARMOR) > 0) { set.set("class", ItemTemplate.ItemClass.ARMOR); } else if ((slot & ItemTemplate.SLOTS_JEWELRY) > 0) { set.set("class", ItemTemplate.ItemClass.JEWELRY); } else { set.set("class", ItemTemplate.ItemClass.ACCESSORY); } } template = new ArmorTemplate(set); } } catch (Exception e) { warn("Fail create item: " + set.get("item_id"), e); continue; } for (Iterator<org.dom4j.Element> subIterator = itemElement.elementIterator(); subIterator.hasNext();) { org.dom4j.Element subElement = subIterator.next(); String subName = subElement.getName(); if (subName.equalsIgnoreCase("for")) { parseFor(subElement, template); } else if (subName.equalsIgnoreCase("triggers")) { parseTriggers(subElement, template); } else if (subName.equalsIgnoreCase("skills")) { for (Iterator<org.dom4j.Element> nextIterator = subElement.elementIterator(); nextIterator .hasNext();) { org.dom4j.Element nextElement = nextIterator.next(); int id = Integer.parseInt(nextElement.attributeValue("id")); int level = Integer.parseInt(nextElement.attributeValue("level")); Skill skill = SkillTable.getInstance().getInfo(id, level); if (skill != null) { template.attachSkill(skill); } else { info("Skill not found(" + id + "," + level + ") for item:" + set.getObject("item_id") + "; file:" + getCurrentFileName()); } } } else if (subName.equalsIgnoreCase("enchant4_skill")) { int id = Integer.parseInt(subElement.attributeValue("id")); int level = Integer.parseInt(subElement.attributeValue("level")); Skill skill = SkillTable.getInstance().getInfo(id, level); if (skill != null) { template.setEnchant4Skill(skill); } } else if (subName.equalsIgnoreCase("unequip_skill")) { int id = Integer.parseInt(subElement.attributeValue("id")); int level = Integer.parseInt(subElement.attributeValue("level")); Skill skill = SkillTable.getInstance().getInfo(id, level); if (skill != null) { template.setUnequipeSkill(skill); } } else if (subName.equalsIgnoreCase("cond")) { Condition condition = parseFirstCond(subElement); if (condition != null) { int msgId = parseNumber(subElement.attributeValue("msgId")).intValue(); condition.setSystemMsg(msgId); template.setCondition(condition); } } else if (subName.equalsIgnoreCase("attributes")) { int[] attributes = new int[6]; for (Iterator<org.dom4j.Element> nextIterator = subElement.elementIterator(); nextIterator .hasNext();) { org.dom4j.Element nextElement = nextIterator.next(); Element element; if (nextElement.getName().equalsIgnoreCase("attribute")) { element = Element.getElementByName(nextElement.attributeValue("element")); attributes[element.getId()] = Integer.parseInt(nextElement.attributeValue("value")); } } template.setBaseAtributeElements(attributes); } else if (subName.equalsIgnoreCase("enchant_options")) { for (Iterator<org.dom4j.Element> nextIterator = subElement.elementIterator(); nextIterator .hasNext();) { org.dom4j.Element nextElement = nextIterator.next(); if (nextElement.getName().equalsIgnoreCase("level")) { int val = Integer.parseInt(nextElement.attributeValue("val")); int i = 0; int[] options = new int[3]; for (org.dom4j.Element optionElement : nextElement.elements()) { OptionDataTemplate optionData = OptionDataHolder.getInstance() .getTemplate(Integer.parseInt(optionElement.attributeValue("id"))); if (optionData == null) { error("Not found option_data for id: " + optionElement.attributeValue("id") + "; item_id: " + set.get("item_id")); continue; } options[i++] = optionData.getId(); } template.addEnchantOptions(val, options); } } } } getHolder().addItem(template); } }