List of usage examples for com.google.common.base Strings nullToEmpty
public static String nullToEmpty(@Nullable String string)
From source file:org.apache.sentry.core.common.utils.PathUtils.java
/** * URI is a a special case. For URI's, /a implies /a/b. * Therefore the test is "/a/b".startsWith("/a"); *///from w ww . j a va 2 s . co m public static boolean impliesURI(URI privilegeURI, URI requestURI) throws URISyntaxException { if (privilegeURI.getPath() == null || requestURI.getPath() == null) { return false; } // ensure that either both schemes are null or equal if (privilegeURI.getScheme() == null) { if (requestURI.getScheme() != null) { return false; } } else if (!privilegeURI.getScheme().equals(requestURI.getScheme())) { return false; } // request path does not contain relative parts /a/../b && // request path starts with privilege path && // authorities (nullable) are equal String requestPath = ensureEndsWithSeparator(requestURI.getPath()).replace("//", "/"); String privilegePath = ensureEndsWithSeparator(privilegeURI.getPath()).replace("//", "/"); if (requestURI.getPath().equals(requestURI.normalize().getPath()) && requestPath.startsWith(privilegePath) && Strings.nullToEmpty(privilegeURI.getAuthority()) .equals(Strings.nullToEmpty(requestURI.getAuthority()))) { return true; } return false; }
From source file:com.qcadoo.mes.cmmsMachineParts.hooks.ActionForPlannedEventHooks.java
public void onSave(final DataDefinition actionDD, final Entity actionForPlannedEvent) { if (actionForPlannedEvent.getBelongsToField(ActionForPlannedEventFields.RESPONSIBLE_WORKER) != null) { String person = Strings.nullToEmpty( actionForPlannedEvent.getBelongsToField(ActionForPlannedEventFields.RESPONSIBLE_WORKER) .getStringField(StaffFields.NAME)) + " " + Strings.nullToEmpty(/*from w ww . ja v a 2 s.c om*/ actionForPlannedEvent.getBelongsToField(ActionForPlannedEventFields.RESPONSIBLE_WORKER) .getStringField(StaffFields.SURNAME)); actionForPlannedEvent.setField(ActionForPlannedEventFields.RESPONSIBLE_WORKER_NAME, person); } }
From source file:org.gradle.api.publish.ivy.internal.dependency.DefaultIvyDependency.java
public DefaultIvyDependency(String organisation, String module, String revision, String confMapping, boolean transitive) { this.organisation = organisation; this.module = module; this.revision = Strings.nullToEmpty(revision); this.confMapping = confMapping; this.transitive = transitive; }
From source file:com.google.testing.security.firingrange.tests.escape.JsEscape.java
@Override public void service(HttpServletRequest request, HttpServletResponse response) throws IOException { String echoedParam = Strings.nullToEmpty(request.getParameter(ECHOED_PARAM)); String template;// ww w. ja v a 2 s . c o m try { template = Templates.getTemplate(request, getClass()); } catch (IOException e) { logger.fine(e.toString()); Responses.sendError(response, e.getMessage(), 400); return; } Responses.sendXssed(response, Templates.replacePayload(template, stringEscape(echoedParam))); }
From source file:org.apache.sentry.policy.search.SearchWildcardPrivilege.java
public SearchWildcardPrivilege(String wildcardString) { wildcardString = Strings.nullToEmpty(wildcardString).trim(); if (wildcardString.isEmpty()) { throw new IllegalArgumentException("Wildcard string cannot be null or empty."); }/* www. ja v a2s . c om*/ List<KeyValue> parts = Lists.newArrayList(); for (String authorizable : ProviderConstants.AUTHORIZABLE_SPLITTER.trimResults().split(wildcardString)) { if (authorizable.isEmpty()) { throw new IllegalArgumentException("Privilege '" + wildcardString + "' has an empty section"); } parts.add(new KeyValue(authorizable)); } if (parts.isEmpty()) { throw new AssertionError("Should never occur: " + wildcardString); } this.parts = ImmutableList.copyOf(parts); }
From source file:org.apache.sentry.policy.indexer.IndexerWildcardPrivilege.java
public IndexerWildcardPrivilege(String wildcardString) { wildcardString = Strings.nullToEmpty(wildcardString).trim(); if (wildcardString.isEmpty()) { throw new IllegalArgumentException("Wildcard string cannot be null or empty."); }//ww w . ja va 2 s . c om List<KeyValue> parts = Lists.newArrayList(); for (String authorizable : ProviderConstants.AUTHORIZABLE_SPLITTER.trimResults().split(wildcardString)) { if (authorizable.isEmpty()) { throw new IllegalArgumentException("Privilege '" + wildcardString + "' has an empty section"); } parts.add(new KeyValue(authorizable)); } if (parts.isEmpty()) { throw new AssertionError("Should never occur: " + wildcardString); } this.parts = ImmutableList.copyOf(parts); }
From source file:rabbit.ui.internal.viewers.TreeViewerColumnLabelSorter.java
@Override protected int doCompare(Viewer v, TreePath parentPath, Object e1, Object e2) { String s1 = Strings.nullToEmpty(labelProvider.getText(e1)); String s2 = Strings.nullToEmpty(labelProvider.getText(e2)); return s1.compareToIgnoreCase(s2); }
From source file:com.facebook.buck.util.KeystoreProperties.java
/** * @return a non-null, non-empty value for the specified property * @throws HumanReadableException if there is no value for the specified property *///from www .j a va2 s . com private static String getOrThrowException(Properties properties, String propertyName, Path pathToKeystorePropertiesFile) { String value = Strings.nullToEmpty(properties.getProperty(propertyName)).trim(); if (value.isEmpty()) { throw new HumanReadableException("properties file %s did not contain a value for the property %s", pathToKeystorePropertiesFile, propertyName); } else { return value; } }
From source file:edu.cmu.lti.oaqa.bioqa.providers.query.PubMedQueryStringConstructor.java
@Override public String formatQueryConcept(String formatQueryField, String formatQueryText) { return formatQueryText + Strings.nullToEmpty(formatQueryField); }
From source file:org.sosy_lab.cpachecker.exceptions.RefinementFailedException.java
private static String getMessage(Reason r, @Nullable Throwable t) { StringBuilder sb = new StringBuilder(); sb.append("Refinement failed: "); sb.append(r.toString());// w ww .j a v a 2s.c om if (t != null) { String msg = Strings.nullToEmpty(t.getMessage()); if (!msg.isEmpty()) { sb.append(" ("); sb.append(msg); sb.append(")"); } } return sb.toString(); }