当前位置: 首页>>代码示例>>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;未经允许,请勿转载。