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:net.roboconf.dm.templating.internal.helpers.IsKeyHelper.java
@Override public CharSequence apply(String context, Options options) throws IOException { CharSequence result = StringUtils.EMPTY; Object model = options.context.model(); if (model instanceof VariableContextBean) { String name = ((VariableContextBean) model).getName(); if (Objects.equals(name, context)) result = ((VariableContextBean) model).getValue(); }// w w w . j a va 2s . c o m return result; }
From source file:de.bund.bva.isyfact.benutzerverwaltung.sicherheit.BenutzerverwaltungAufrufKontextImpl.java
@Override public String getDurchfuehrenderBenutzerKennung() { if (super.getDurchfuehrenderBenutzerKennung() == null) { return StringUtils.EMPTY; }//from ww w . j a v a 2 s .co m return super.getDurchfuehrenderBenutzerKennung(); }
From source file:dtu.ds.warnme.app.ws.client.https.GsonHttpResponseHandler.java
@Override @Deprecated// w w w . java 2 s . c om public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { try { String response = responseBody != null ? new String(responseBody, getCharset()) : StringUtils.EMPTY; T object = gson.fromJson(response, type); onSuccess(statusCode, headers, object); } catch (UnsupportedEncodingException e) { Log.v(TAG, "String encoding failed, calling onFailure(int, Header[], String, Throwable)"); onFailure(0, headers, (String) null, e); } }
From source file:com.github.jknack.handlebars.helper.DefaultFilterHelper.java
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override/*from w ww . j a v a 2s . c o m*/ public CharSequence apply(final Object context, final Options options) throws IOException { if (context == null) { return StringUtils.EMPTY; } if (context instanceof Iterable) { String[] filterValues = null; String filterValue = ""; String targetField = ""; if (options.hash.size() > 0) { for (Map.Entry<String, Object> item : options.hash.entrySet()) { if (item != null) { filterValues = StringUtils.defaultString(item.getValue().toString()).split(","); if (filterValues != null && filterValues.length > 0) { filterValue = StringUtils.defaultString(filterValues[0]).trim(); if (filterValues.length > 1) { targetField = StringUtils.defaultString(filterValues[1]).trim(); } } break; } } } if (filterValues != null && filterValues.length > 0) { Set<Entry<String, Object>> propertySet = options.propertySet(context); Iterator<Entry<String, Object>> contextLoop = ((Iterable) context).iterator(); while (contextLoop.hasNext()) { Object item = contextLoop.next(); if (item != null) { String typeValue = getFieldValue(item, TYPEVALUE); boolean matched = StringUtils.isNotBlank(typeValue) && filterValue.equalsIgnoreCase(typeValue); if (matched) { return getFieldValue(item, targetField); } } } } } return hashContext(context, options); }
From source file:ch.cyberduck.core.local.WorkspaceTrashFeature.java
/** * Move file to trash on main interface thread using <code>NSWorkspace.RecycleOperation</code>. *//*from w w w .j a v a 2 s . com*/ @Override public void trash(final Local file) throws LocalAccessDeniedException { if (file.exists()) { synchronized (NSWorkspace.class) { if (log.isDebugEnabled()) { log.debug(String.format("Move %s to Trash", file)); } final NSWorkspace workspace = NSWorkspace.sharedWorkspace(); // Asynchronous operation. 0 if the operation is performed synchronously and succeeds, and a positive // integer if the operation is performed asynchronously and succeeds if (!workspace.performFileOperation(NSWorkspace.RecycleOperation, file.getParent().getAbsolute(), StringUtils.EMPTY, NSArray.arrayWithObject(file.getName()))) { throw new LocalAccessDeniedException( String.format("Failed to move %s to Trash", file.getName())); } } } }
From source file:com.fun.util.TesseractUtil.java
/** * /* www. j a va 2 s . c o m*/ * * @param imageFile * @param enlargeTimes * @param isEnlarge * @return * @throws IOException */ public static String recognize(File imageFile, int enlargeTimes, boolean isEnlarge) throws IOException { // 3??? File tmpScaledImage = File.createTempFile("tesseract-ocr-scaled", null); tmpScaledImage.deleteOnExit(); if (isEnlarge) scaled(imageFile, enlargeTimes, tmpScaledImage); // File tmpOutputBase = new File(tmpScaledImage.getAbsolutePath() + ".out"); File tmpOutputText = new File(tmpScaledImage.getAbsolutePath() + ".out.txt"); try { int exitCode = Runtime.getRuntime().exec(new String[] { "tesseract", // command tmpScaledImage.getAbsolutePath(), // imagename tmpOutputBase.getAbsolutePath(), // outputbase "-psm", "8", // pagesegmode, treat the image as a single word }).waitFor(); tmpScaledImage.delete(); // } catch (Exception e) { e.printStackTrace(); } // ? String text = Files.readFirstLine(tmpOutputText, Charsets.UTF_8); tmpOutputText.delete(); // if (StringUtils.isNotBlank(text)) { return text.trim().replaceAll("\\s|,", ""); } tmpOutputBase.delete(); return StringUtils.EMPTY; }
From source file:com.googlecode.jsendnsca.MessagePayloadTest.java
@Test public void shouldConstructValidObjectWhenUsingNoArgConstructor() throws Exception { final MessagePayload messagePayload = new MessagePayload(); assertTrue(StringUtils.isNotEmpty(messagePayload.getHostname())); assertEquals(Level.UNKNOWN, messagePayload.getLevel()); assertEquals("UNDEFINED", messagePayload.getServiceName()); assertEquals(StringUtils.EMPTY, messagePayload.getMessage()); }
From source file:com.aqnote.app.wifianalyzer.vendor.model.VendorService.java
public String findVendorName(String macAddress) { String key = MacAddress.clean(macAddress); if (cache.containsKey(key)) { return cache.get(key); }//from ww w. j a v a2 s . com Database database = MainContext.INSTANCE.getDatabase(); String result = database.find(macAddress); if (result != null) { result = VendorNameUtils.cleanVendorName(result); cache.put(key, result); return result; } if (!remoteCalls.contains(key)) { remoteCalls.add(key); getRemoteCall().execute(macAddress); } return StringUtils.EMPTY; }
From source file:de.blizzy.documentr.web.filter.TrimWriter.java
void write(String text, OutputStream out, Charset charset) throws IOException { BufferedReader in = null;/* www . jav a2 s.c o m*/ try { in = new BufferedReader(new StringReader(text)); String line; boolean textareaTag = false; boolean preTag = false; boolean notrimTag = false; boolean trim = true; while ((line = in.readLine()) != null) { String origLine = line; line = StringUtils.replace(line, "__NOTRIM__", StringUtils.EMPTY); //$NON-NLS-1$ line = StringUtils.replace(line, "__/NOTRIM__", StringUtils.EMPTY); //$NON-NLS-1$ line = REMOVE_COMMENT.replaceAll(line); if (trim) { line = TRIM_LEFT.replaceAll(line); } if (origLine.contains("<textarea")) { //$NON-NLS-1$ textareaTag = true; } if (origLine.contains("<pre")) { //$NON-NLS-1$ preTag = true; } if (origLine.contains("__NOTRIM__")) { //$NON-NLS-1$ notrimTag = true; } if (textareaTag || preTag || notrimTag) { trim = false; } if (origLine.contains("</textarea")) { //$NON-NLS-1$ textareaTag = false; } if (origLine.contains("</pre")) { //$NON-NLS-1$ preTag = false; } if (origLine.contains("__/NOTRIM__")) { //$NON-NLS-1$ notrimTag = false; } if (!textareaTag && !preTag && !notrimTag) { trim = true; } if (trim) { line = TRIM_RIGHT.replaceAll(line); } boolean doWrite = !trim || StringUtils.isNotBlank(line); if (doWrite) { writeln(line, out, charset); } } } finally { Closeables.closeQuietly(in); } }
From source file:com.twosigma.beakerx.groovy.evaluator.GroovyClassLoaderFactory.java
public static void addImportPathToImportCustomizer(ImportCustomizer icz, ImportPath importLine) { if (importLine.asString().startsWith(STATIC_WORD_WITH_SPACE)) { String pureImport = importLine.asString().replace(STATIC_WORD_WITH_SPACE, StringUtils.EMPTY) .replace(DOT_STAR_POSTFIX, StringUtils.EMPTY); if (importLine.asString().endsWith(DOT_STAR_POSTFIX)) { icz.addStaticStars(pureImport); } else {/*from w w w . j a va 2 s. c o m*/ int index = pureImport.lastIndexOf('.'); if (index == -1) { return; } icz.addStaticImport(pureImport.substring(0, index), pureImport.substring(index + 1)); } } else { if (importLine.asString().endsWith(DOT_STAR_POSTFIX)) { icz.addStarImports(importLine.asString().replace(DOT_STAR_POSTFIX, StringUtils.EMPTY)); } else { icz.addImports(importLine.asString()); } } }