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.shenit.commons.codec.CodecUtils.java
/** * ?MD5//w w w.ja v a2 s .c o m * * @param source * @param salt * @return */ public static String md5Hex(String source, String salt) { return DigestUtils .md5Hex(source + (salt == null ? StringUtils.EMPTY : (ShenStrings.DELIMITER_UNDERSCORE + salt))); }
From source file:com.beginner.core.listener.ZookeeperListener.java
public void contextInitialized(ServletContextEvent event) { logger.info("Servlet?..."); try {/*w ww. j av a 2s .co m*/ // Zookeeper zk = new ZkClient(new ZkConnection(PropertyUtil.getStr("zookeeper.zkServers"), PropertyUtil.getInt("zookeeper.sessionTimeOut"))); // ?IP? String ip = ProjectUtil.getIp(); // Web??? String port = ProjectUtil.getPort(); // ?? String name = ProjectUtil.appName(); // ?zNode String path = getPath(name, ip, port); // ? String param = new String(); // URL String url = StringUtils.EMPTY; if (zk.exists(path)) zk.readData(path); // ?? url = encapsulation(ip, port, url, param); // ?API?? String result = HttpUtil.post(url, param, 1000); if (StringUtils.isNotBlank(result)) { // ?JSON?? setProperties(result); // ?zNode?? addListener(path); } } catch (Exception e) { if (null != zk) zk.close(); logger.error("ZookeeperListener?", e); } }
From source file:com.cognifide.aet.job.common.ArtifactDAOMock.java
@Override public Artifact getArtifact(DBKey dbKey, String objectID) { URL filePath = getClass().getClassLoader().getResource(mocksPath + "/" + objectID); Artifact result = null;//from w ww. j av a 2 s . c o m try { result = new Artifact(new FileInputStream(filePath.getFile()), StringUtils.EMPTY); } catch (FileNotFoundException e) { return null; } return result; }
From source file:com.vrem.wifianalyzer.wifi.graph.channel.ChannelAxisLabelTest.java
@Test public void testXAxisWithFrequencyNotAllowedInLocale() throws Exception { WiFiChannel wiFiChannel = WiFiBand.GHZ2.getWiFiChannels().getWiFiChannelLast(); assertEquals(StringUtils.EMPTY, fixture.formatLabel(wiFiChannel.getFrequency(), true)); }
From source file:net.sf.appstatus.web.pages.RadiatorPage.java
public void doGet(StatusWebHandler webHandler, HttpServletRequest req, HttpServletResponse resp) throws UnsupportedEncodingException, IOException { // Setup response resp.setContentType("text/html"); resp.setCharacterEncoding("UTF-8"); // Get Health checks List<ICheckResult> results = webHandler.getAppStatus().checkAll(req.getLocale()); int status = STATUS_OK; for (ICheckResult r : results) { if (r.getCode() != ICheckResult.OK && !r.isFatal() && status == STATUS_OK) { status = STATUS_WARN;/* w w w. jav a2s.c om*/ } if (r.getCode() != ICheckResult.OK && r.isFatal()) { status = STATUS_ERROR; break; } } String btnClass = "btn-success"; if (status == STATUS_WARN) { btnClass = "btn-warning"; } if (status == STATUS_ERROR) { btnClass = "btn-danger"; } // Get batchs status. IBatchManager manager = webHandler.getAppStatus().getBatchManager(); String batchStatus = " progress-success "; String active = StringUtils.EMPTY; int width = 0; if (manager != null) { batchStatus = manager.getErrorBatches().size() > 0 ? " progress-danger " : " progress-success "; active = manager.getRunningBatches().size() > 0 ? " progress-striped active " : ""; width = manager.getRunningBatches().size() + manager.getFinishedBatches().size() > 0 ? 100 : 0; } Writer w = resp.getWriter(); w.append("<html>"); w.append("<head>"); w.append("<meta http-equiv=\"refresh\" content=\"60;\">"); w.append("<link href=\"?resource=appstatus.css\" rel=\"stylesheet\">"); w.append("</head>"); w.append("<body style=\"background: #000; text-align: center; padding-top: 5%;\">"); w.append("<p style=\"color: #fff; font-size: 200%;\" >" + webHandler.getApplicationName() + "</p>"); w.append("<p style=\" padding-top: 10%;\"><a href=\"?p=status\" target=\"_blank\" class=\"btn btn-large " + btnClass + "\" >Status</a></p>"); w.append("<div class=\"progress " + batchStatus + active + "\" style=\"margin-top: 5%; width: 90%; margin-left: 5%; margin-right: 5%;\"> <div class=\"bar\" style=\"width: " + width + "%;\"></div></div>"); w.append("</body></html>"); }
From source file:ch.cyberduck.core.irods.IRODSDownloadFeature.java
@Override public void download(final Path file, final Local local, final BandwidthThrottle throttle, final StreamListener listener, final TransferStatus status, final ConnectionCallback connectionCallback, final PasswordCallback passwordCallback) throws BackgroundException { try {/* ww w . j ava 2 s . co m*/ final IRODSFileSystemAO fs = session.getClient(); final IRODSFile f = fs.getIRODSFileFactory().instanceIRODSFile(file.getAbsolute()); if (f.exists()) { final TransferControlBlock block = DefaultTransferControlBlock.instance(StringUtils.EMPTY, preferences.getInteger("connection.retry")); final TransferOptions options = new DefaultTransferOptionsConfigurer() .configure(new TransferOptions()); options.setUseParallelTransfer( session.getHost().getTransferType().equals(Host.TransferType.concurrent)); block.setTransferOptions(options); final DataTransferOperations transfer = fs.getIRODSAccessObjectFactory() .getDataTransferOperations(fs.getIRODSAccount()); transfer.getOperation(f, new File(local.getAbsolute()), new DefaultTransferStatusCallbackListener(status, listener, block), block); } else { throw new NotfoundException(file.getAbsolute()); } } catch (JargonException e) { throw new IRODSExceptionMappingService().map("Download {0} failed", e, file); } }
From source file:ch.cyberduck.core.transfer.download.RenameExistingFilter.java
@Override public void apply(final Path file, final Local local, final TransferStatus status, final ProgressListener listener) throws BackgroundException { if (status.isExists()) { Local rename;/* w ww .j a va 2 s . com*/ do { String proposal = MessageFormat.format( PreferencesFactory.get().getProperty("queue.download.file.rename.format"), FilenameUtils.getBaseName(file.getName()), UserDateFormatterFactory.get().getMediumFormat(System.currentTimeMillis(), false) .replace(local.getDelimiter(), '-').replace(':', '-'), StringUtils.isNotBlank(file.getExtension()) ? String.format(".%s", file.getExtension()) : StringUtils.EMPTY); rename = LocalFactory.get(local.getParent().getAbsolute(), proposal); } while (rename.exists()); if (log.isInfoEnabled()) { log.info(String.format("Rename existing file %s to %s", local, rename)); } local.rename(rename); if (log.isDebugEnabled()) { log.debug(String.format("Clear exist flag for file %s", local)); } status.setExists(false); } super.apply(file, local, status, listener); }
From source file:com.qcadoo.mes.workPlans.pdf.document.operation.product.column.QuantityPerUnitOperationProductColumn.java
@Override public String getColumnValue(Entity operationProduct) { List<Entity> orders = operationProduct .getBelongsToField(OperationProductInComponentFields.OPERATION_COMPONENT) .getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY) .getHasManyField(TechnologyFieldsO.ORDERS); if (orders.isEmpty()) { return StringUtils.EMPTY; }/*from w w w . j a v a 2 s .c o m*/ return String.valueOf(numberService.format(numberService .setScale((operationProduct.getDecimalField(OperationProductInComponentFields.QUANTITY).divide( orders.get(0).getDecimalField(OrderFields.PLANNED_QUANTITY), RoundingMode.HALF_UP))))); }
From source file:com.omnigon.aem.handlebars.helpers.MomentHelper.java
@Override public CharSequence apply(Object context, Options options) throws IOException { Date date = null;//from w w w. ja v a2 s .c o m if (context instanceof Date) { date = (Date) context; } else { try { date = new Date((Long) context); //date gets converted to Long for handlebars, need to handle. } catch (Exception e) { logger.error("Invalid object passed as date, cannot cast to string or string is not an integer"); return StringUtils.EMPTY; } } String format = DEFAULT_FORMAT; // default parameter if (options.params.length > 0) { format = options.params[0].toString(); } else if (options.hash.containsKey(FORMAT_PARAM)) { format = options.hash.get(FORMAT_PARAM).toString(); } /* Moment.js and Java Datetime format patterns differ in some details. Moment.js: D DD 1..31 Day of month DDD DDDD 1..365 Day of year ddd dddd Mon...Sunday Day name in locale set by moment.locale() Java: D DDD Day in year Number 189 d dd Day in month Number 10 So we need to convert D to d and DD to dd. */ if (!format.contains("DDD") // true for DDDD as well && format.contains("D")) { // true for DD as well format = format.replace("D", "d"); } String formattedMoment = format(format, date); return formattedMoment; }
From source file:com.cognifide.aet.validation.impl.ValidationResultBuilderImplTest.java
@Test public void testToString() throws Exception { //empty builder ValidationResultBuilderImpl validationResultBuilder = new ValidationResultBuilderImpl(); assertThat(ValidationUtils.validationResultToString(validationResultBuilder), is(StringUtils.EMPTY)); //single error message validationResultBuilder.addErrorMessage("MSG_1"); assertThat(ValidationUtils.validationResultToString(validationResultBuilder), containsString("1 errors were found")); assertThat(ValidationUtils.validationResultToString(validationResultBuilder), containsString("Message: MSG_1")); //two error messages validationResultBuilder.addErrorMessage("MSG_2"); assertThat(ValidationUtils.validationResultToString(validationResultBuilder), containsString("2 errors were found")); assertThat(ValidationUtils.validationResultToString(validationResultBuilder), containsString("Message: MSG_1")); assertThat(ValidationUtils.validationResultToString(validationResultBuilder), containsString("Message: MSG_2")); //two error messages validationResultBuilder.addErrorMessage("MSG_3", new NoSuchFieldException()); assertThat(ValidationUtils.validationResultToString(validationResultBuilder), containsString("3 errors were found")); assertThat(ValidationUtils.validationResultToString(validationResultBuilder), containsString("Message: MSG_1")); assertThat(ValidationUtils.validationResultToString(validationResultBuilder), containsString("Message: MSG_2")); assertThat(ValidationUtils.validationResultToString(validationResultBuilder), containsString("Message: MSG_3")); assertThat(ValidationUtils.validationResultToString(validationResultBuilder), containsString("Caused by: java.lang.NoSuchFieldException")); }