當前位置: 首頁>>代碼示例>>Java>>正文


Java Strings.nullToEmpty方法代碼示例

本文整理匯總了Java中com.google.common.base.Strings.nullToEmpty方法的典型用法代碼示例。如果您正苦於以下問題:Java Strings.nullToEmpty方法的具體用法?Java Strings.nullToEmpty怎麽用?Java Strings.nullToEmpty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.base.Strings的用法示例。


在下文中一共展示了Strings.nullToEmpty方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isSourceFolder

import com.google.common.base.Strings; //導入方法依賴的package包/類
/**
 * Returns {@code true} if the folder argument is declared as a source container in the container project. Otherwise
 * returns with {@code false}.
 *
 * @param folder
 *            the folder to test whether it is a source container, or not. Can be {@code null}. If {@code null},
 *            this method immediately returns with {@code false}.
 * @return {@code true} if the folder is a source folder, otherwise returns with {@code false}.
 */
public boolean isSourceFolder(IFolder folder) {

	if (null == folder || !folder.exists()) {
		return false;
	}

	IN4JSProject project = getProject(folder.getProject());

	if (null != project) {
		String relativePath = Strings.nullToEmpty(folder.getProjectRelativePath().toOSString());
		return from(project.getSourceContainers()).transform(src -> src.getRelativeLocation())
				.contains(relativePath);
	}

	return false;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:26,代碼來源:N4JSProjectExplorerHelper.java

示例2: isOutputFolder

import com.google.common.base.Strings; //導入方法依賴的package包/類
/**
 * Returns with {@code true} if the folder argument represents a output folder in its container project. Otherwise
 * returns with {@code false}.
 *
 * @param folder
 *            the folder to test whether it is an output folder or not.
 * @return {@code true} if the folder is configured as an output folder in the project, otherwise returns with
 *         {@code false}.
 */
public boolean isOutputFolder(IFolder folder) {

	if (null == folder || !folder.exists()) {
		return false;
	}

	IN4JSProject project = getProject(folder.getProject());

	if (null != project) {
		String relativePath = Strings.nullToEmpty(folder.getProjectRelativePath().toOSString());
		return relativePath.equals(project.getOutputPath());
	}

	return false;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:25,代碼來源:N4JSProjectExplorerHelper.java

示例3: fixQuery

import com.google.common.base.Strings; //導入方法依賴的package包/類
private String fixQuery(String query)
{
	query = Strings.nullToEmpty(query);

	if( !query.startsWith("*") )
	{
		query = "*" + query;
	}

	if( !query.endsWith("*") )
	{
		query += "*";
	}

	return query;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:17,代碼來源:UserServiceImpl.java

示例4: startHandlers

import com.google.common.base.Strings; //導入方法依賴的package包/類
protected void startHandlers(final String nameSuffix, final int numHandlers,
    final List<BlockingQueue<CallRunner>> callQueues,
    final int qindex, final int qsize, final int port) {
  final String threadPrefix = name + Strings.nullToEmpty(nameSuffix);
  for (int i = 0; i < numHandlers; i++) {
    final int index = qindex + (i % qsize);
    Thread t = new Thread(new Runnable() {
      @Override
      public void run() {
        consumerLoop(callQueues.get(index));
      }
    });
    t.setDaemon(true);
    t.setName(threadPrefix + "RpcServer.handler=" + handlers.size() +
      ",queue=" + index + ",port=" + port);
    t.start();
    LOG.debug(threadPrefix + " Start Handler index=" + handlers.size() + " queue=" + index);
    handlers.add(t);
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:21,代碼來源:RpcExecutor.java

示例5: prepareApplicationIcon

import com.google.common.base.Strings; //導入方法依賴的package包/類
private boolean prepareApplicationIcon(File outputPngFile) {
  String userSpecifiedIcon = Strings.nullToEmpty(project.getIcon());
  try {
    BufferedImage icon;
    if (!userSpecifiedIcon.isEmpty()) {
      File iconFile = new File(project.getAssetsDirectory(), userSpecifiedIcon);
      icon = ImageIO.read(iconFile);
      if (icon == null) {
        // This can happen if the iconFile isn't an image file.
        // For example, icon is null if the file is a .wav file.
        // TODO(lizlooney) - This happens if the user specifies a .ico file. We should fix that.
        userErrors.print(String.format(ICON_ERROR, userSpecifiedIcon));
        return false;
      }
    } else {
      // Load the default image.
      icon = ImageIO.read(Compiler.class.getResource(DEFAULT_ICON));
    }
    ImageIO.write(icon, "png", outputPngFile);
  } catch (Exception e) {
    e.printStackTrace();
    // If the user specified the icon, this is fatal.
    if (!userSpecifiedIcon.isEmpty()) {
      userErrors.print(String.format(ICON_ERROR, userSpecifiedIcon));
      return false;
    }
  }

  return true;
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:31,代碼來源:Compiler.java

示例6: mapHttpSourceTestToCsvRow

import com.google.common.base.Strings; //導入方法依賴的package包/類
public static String[] mapHttpSourceTestToCsvRow(HttpSourceTest httpSourceTest) {
    return new String[]{
            httpSourceTest.getUrl(), httpSourceTest.getSource(),
            BaseEncoding.base64().encode(httpSourceTest.getHtml().getBytes(Charsets.UTF_8)),
            Objects.toString(httpSourceTest.getUrlAccepted(), "false"),
            Strings.nullToEmpty(httpSourceTest.getTitle()),
            Strings.nullToEmpty(httpSourceTest.getText()),
            Strings.nullToEmpty(httpSourceTest.getDate())
    };
}
 
開發者ID:tokenmill,項目名稱:crawling-framework,代碼行數:11,代碼來源:HttpSourceTestCSVUtils.java

示例7: insertString

import com.google.common.base.Strings; //導入方法依賴的package包/類
@Override
public void insertString( int iOffset, String str, AttributeSet a ) throws BadLocationException
{
  if( Strings.isNullOrEmpty( str ) )
  {
    return;
  }

  String strText = IdentifierTextField.this.getText();
  StringBuilder strbText = new StringBuilder( Strings.nullToEmpty( strText ) );

  if( iOffset <= strbText.length() )
  {
    strbText.insert( iOffset, str );
  }
  else
  {
    strbText.append( str );
  }

  if( !isValidIdentifier( strbText, _bAcceptDot ) || strbText.toString().contains( "$" ) )
  {
    String validID = makeValidIdentifier( strbText.toString(), _bAcceptDot, _bAcceptUnderscore );
    if( !_bAcceptUnderscore )
    {
      validID = validID.replace( "$", "" );
    }
    str = validID.substring( iOffset, iOffset + (validID.length() - strText.length()) );
  }

  super.insertString( iOffset, str, a );
}
 
開發者ID:manifold-systems,項目名稱:manifold-ij,代碼行數:33,代碼來源:IdentifierTextField.java

示例8: submitCopyJobsFromListing

import com.google.common.base.Strings; //導入方法依賴的package包/類
private void submitCopyJobsFromListing(
    AmazonS3URI sourceS3Uri,
    final AmazonS3URI targetS3Uri,
    ListObjectsRequest request,
    ObjectListing listing) {
  LOG.debug("Found objects to copy {}, for request {}/{}", listing.getObjectSummaries(), request.getBucketName(),
      request.getPrefix());
  List<S3ObjectSummary> objectSummaries = listing.getObjectSummaries();
  for (final S3ObjectSummary s3ObjectSummary : objectSummaries) {
    String fileName = StringUtils.removeStart(s3ObjectSummary.getKey(), sourceS3Uri.getKey());
    final String targetKey = Strings.nullToEmpty(targetS3Uri.getKey()) + fileName;
    LOG.info("copying object from '{}/{}' to '{}/{}'", s3ObjectSummary.getBucketName(), s3ObjectSummary.getKey(),
        targetS3Uri.getBucket(), targetKey);

    CopyObjectRequest copyObjectRequest = new CopyObjectRequest(s3ObjectSummary.getBucketName(),
        s3ObjectSummary.getKey(), targetS3Uri.getBucket(), targetKey);

    TransferStateChangeListener stateChangeListener = new TransferStateChangeListener() {

      @Override
      public void transferStateChanged(Transfer transfer, TransferState state) {
        if (state == TransferState.Completed) {
          // NOTE: running progress doesn't seem to be reported correctly.
          // transfer.getProgress().getBytesTransferred() is always 0. Unsure what is the cause of this at this moment
          // so just printing total bytes when completed.
          LOG.debug("copied object from '{}/{}' to '{}/{}': {} bytes transferred", s3ObjectSummary.getBucketName(),
              s3ObjectSummary.getKey(), targetS3Uri.getBucket(), targetKey,
              transfer.getProgress().getTotalBytesToTransfer());
        }
      }
    };
    Copy copy = transferManager.copy(copyObjectRequest, srcClient, stateChangeListener);
    totalBytesToReplicate += copy.getProgress().getTotalBytesToTransfer();
    copyJobs.add(copy);
  }
}
 
開發者ID:HotelsDotCom,項目名稱:circus-train,代碼行數:37,代碼來源:S3S3Copier.java

示例9: getRenderableContents

import com.google.common.base.Strings; //導入方法依賴的package包/類
@Override
protected SectionRenderable getRenderableContents(RenderContext context)
{
	final Model model = getModel(context);

	final String theQuery = Strings.nullToEmpty(query.getValue(context));
	final boolean invalidQuery = theQuery.length() > 0 && !validQuery(theQuery);
	final boolean hasNoResults = !Check.isEmpty(theQuery)
		&& courseList.getListModel().getOptions(context).size() == 0;

	model.setInvalidQuery(invalidQuery);
	model.setHasNoResults(hasNoResults);

	if( !hasNoResults && !invalidQuery )
	{
		getOk().setClickHandler(
			context,
			new OverrideHandler(new FunctionCallStatement(getOkCallback(), courseList.createGetExpression()),
				new FunctionCallStatement(getCloseFunction())));
	}

	if( courseList.getSelectedValue(context) == null )
	{
		getOk().disable(context);
	}

	return viewFactory.createResult("selectcourse.ftl", this);
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:29,代碼來源:SelectCourseDialog.java

示例10: filterRequest

import com.google.common.base.Strings; //導入方法依賴的package包/類
@Override
public FilterResult filterRequest(HttpServletRequest request, HttpServletResponse response) throws IOException,
	ServletException
{
	FilterResult result = new FilterResult(request);

	String contextPath = Strings.nullToEmpty(request.getContextPath());
	String originalServletPath = (request.getServletPath() + Strings.nullToEmpty(request.getPathInfo()))
		.substring(1);
	String accessNoLeadingSlash = WebConstants.ACCESS_PATH.substring(1);
	if( originalServletPath.endsWith(accessNoLeadingSlash + WebConstants.DASHBOARD_PAGE)
		|| originalServletPath.endsWith(accessNoLeadingSlash + WebConstants.SEARCHING_PAGE)
		|| originalServletPath.endsWith(accessNoLeadingSlash + WebConstants.CLOUDSEARCH_PAGE)
		|| originalServletPath.endsWith(accessNoLeadingSlash + WebConstants.HIERARCHY_PAGE)
		|| originalServletPath.endsWith(accessNoLeadingSlash + "logonnotice.do") )
	{
		String truncatedPath = originalServletPath.substring(WebConstants.ACCESS_PATH.length() - 2);
		String reconstitutedPath = contextPath + truncatedPath;
		Map<String, String[]> params = request.getParameterMap();
		String query = SectionUtils.getParameterString(SectionUtils.getParameterNameValues(params, false));
		if( !Check.isEmpty(query) )
		{
			reconstitutedPath += '?' + query;
		}
		response.sendRedirect(reconstitutedPath);
		result.setStop(true);
	}
	return result;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:30,代碼來源:RedirectedAccessFilter.java

示例11: validQuery

import com.google.common.base.Strings; //導入方法依賴的package包/類
protected boolean validQuery(String query)
{
	String q = Strings.nullToEmpty(query);
	for( int i = 0; i < q.length(); i++ )
	{
		if( Character.isLetterOrDigit(q.codePointAt(i)) )
		{
			return true;
		}
	}
	return false;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:13,代碼來源:AbstractSelectUserSection.java

示例12: searchable

import com.google.common.base.Strings; //導入方法依賴的package包/類
private boolean searchable(String queryText)
{
	String q = Strings.nullToEmpty(queryText);
	for( int i = 0; i < q.length(); i++ )
	{
		if( Character.isLetterOrDigit(q.codePointAt(i)) )
		{
			return true;
		}
	}
	return false;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:13,代碼來源:RoleSearchModel.java

示例13: nullToEmpty

import com.google.common.base.Strings; //導入方法依賴的package包/類
/**
 * @deprecated Use Strings.nullToEmpty() instead.
 */
@Deprecated
public static String nullToEmpty(String s)
{
	return Strings.nullToEmpty(s);
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:9,代碼來源:Check.java

示例14: getMcVersion

import com.google.common.base.Strings; //導入方法依賴的package包/類
public static String getMcVersion() {
    return Strings.nullToEmpty(getConfigProperties().getProperty("forgehax.mc.version"));
}
 
開發者ID:fr1kin,項目名稱:ForgeHax,代碼行數:4,代碼來源:ForgeHaxProperties.java

示例15: getSortingRules

import com.google.common.base.Strings; //導入方法依賴的package包/類
@Override
public String getSortingRules()
{
    return ((overridesMetadata || !modMetadata.useDependencyInformation) ? Strings.nullToEmpty(annotationDependencies) : modMetadata.printableSortingRules());
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:6,代碼來源:FMLModContainer.java


注:本文中的com.google.common.base.Strings.nullToEmpty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。