当前位置: 首页>>代码示例>>Java>>正文


Java StringJoiner类代码示例

本文整理汇总了Java中java.util.StringJoiner的典型用法代码示例。如果您正苦于以下问题:Java StringJoiner类的具体用法?Java StringJoiner怎么用?Java StringJoiner使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


StringJoiner类属于java.util包,在下文中一共展示了StringJoiner类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ClassifierReference

import java.util.StringJoiner; //导入依赖的package包/类
/**
 * Creates a resolved classifier reference. This means a classifier with a valid uri of its declaration.
 *
 * @param qualifiedName
 *            QualifiedName of the classifier
 * @param uri
 *            Platform uri of the classifier declaration
 */
public ClassifierReference(QualifiedName qualifiedName, URI uri) {
	this.classifierName = qualifiedName.getLastSegment();
	List<String> frontSegments = qualifiedName.getSegments();
	if (frontSegments.size() > 0) {
		StringJoiner joiner = new StringJoiner(N4JSQualifiedNameConverter.DELIMITER);
		for (String segment : frontSegments.subList(0, frontSegments.size() - 1)) {
			joiner.add(segment);
		}
		this.classifierModuleSpecifier = joiner.toString();
	} else {
		this.classifierModuleSpecifier = "";
	}
	this.uri = uri;

}
 
开发者ID:eclipse,项目名称:n4js,代码行数:24,代码来源:ClassifierReference.java

示例2: collectData

import java.util.StringJoiner; //导入依赖的package包/类
private static void collectData(DataSeries parentSeries, StackNode parentNode, float baseHeight, float baseWidth,
		StringJoiner sj, IndentLevel indent) {

	if (parentSeries.hasNoChildren())
		return;

	indent.increase();

	Long siblingSum = parentSeries.getChildren().map(s -> s.sum).max(Long::compare).get();
	parentSeries.getChildren().forEach(series -> {
		sj.add(indent.get() + SimpleTimeFormat.convert(series.sum) + " - " + series.name);
		float parentScale = (float) series.sum / parentSeries.sum;
		float siblingScale = (float) series.sum / siblingSum;
		StackNode node = new StackNode(series.name,
				series.name + " took " + SimpleTimeFormat.convert(series.sum),
				parentNode.width * parentScale, baseHeight, parentScale, siblingScale);

		parentNode.addChild(node);
		collectData(series, node, baseHeight, baseWidth, sj, indent);
	});

	indent.decrease();
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:24,代码来源:StackGraphFactory.java

示例3: run

import java.util.StringJoiner; //导入依赖的package包/类
@WithCommand
public void run(CommandSender sender, @WithName("plugin") @WithOptional Plugin plugin) {
    Collection<String> scriptNames;
    if (plugin != null) {
        ScriptRegistry reg = (ScriptRegistry) scripts().get(plugin);
        scriptNames = reg.getEntries().keySet();
    } else
        scriptNames = scripts().getEntries().keySet();
    StringJoiner str = new StringJoiner(GRAY + ", ");
    for (String name : scriptNames)
        str.add(AQUA + name);
    if (scriptNames.size() > 0)
        sender.sendMessage(GOLD + "Showing " + scriptNames.size() + " scripts: " + str.toString());
    else
        sender.sendMessage(RED + "No script found.");
}
 
开发者ID:upperlevel,项目名称:uppercore,代码行数:17,代码来源:ScriptListCommand.java

示例4: addAlladdAll

import java.util.StringJoiner; //导入依赖的package包/类
public void addAlladdAll() {
    StringJoiner sj = new StringJoiner(DASH, "{", "}");
    ArrayList<String> firstOne = new ArrayList<>();
    firstOne.add(ONE);
    firstOne.add(TWO);
    firstOne.add(THREE);
    firstOne.stream().forEachOrdered(sj::add);

    ArrayList<String> nextOne = new ArrayList<>();
    nextOne.add(FOUR);
    nextOne.add(FIVE);
    nextOne.stream().forEachOrdered(sj::add);

    String expected = "{"+ONE+DASH+TWO+DASH+THREE+DASH+FOUR+DASH+FIVE+"}";
    assertEquals(sj.toString(), expected);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:StringJoinerTest.java

示例5: extractDir

import java.util.StringJoiner; //导入依赖的package包/类
/**
 * extractDir parses the input path for wild card characters.
 *
 * @param path String folder path to search
 * @return String up to the wild card character
 */
static String extractDir(String path) {
	String[] parts = path.split(DIR_EXTRACTION);

	StringJoiner dirPath = new StringJoiner(fileSystem.getSeparator());
	for (String part : parts) {
		// append until a wild card
		if (part.contains("*")) { // append until a wild card
			break;
		}
		dirPath.add(part);
	}
	if (dirPath.length() == 0) { // if no path then use the current dir
		return ".";
	}

	return dirPath.toString();
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:24,代码来源:ConversionEntry.java

示例6: generateString

import java.util.StringJoiner; //导入依赖的package包/类
private String generateString() {
    Long pid = fPid;
    Long tid = fTid;

    StringBuilder sb = new StringBuilder();
    if (fName != null) {
        sb.append(fName);
    }

    if (pid != null || tid != null) {
        sb.append(' ');
        StringJoiner sj = new StringJoiner(", ", "(", ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        if (pid != null) {
            sj.add("pid=" + pid.toString()); //$NON-NLS-1$
        }
        if (tid != null) {
            sj.add("tid=" + tid.toString()); //$NON-NLS-1$
        }
        sb.append(sj.toString());
    }

    return sb.toString();
}
 
开发者ID:lttng,项目名称:lttng-scope,代码行数:24,代码来源:LamiProcess.java

示例7: refreshPdeFileImportPreview

import java.util.StringJoiner; //导入依赖的package包/类
private void refreshPdeFileImportPreview() {
    if (! getParameters().importablePdeFiles.isEmpty()) {
        filesDetectedLabel.setForeground(JBColor.BLACK);
        filesDetectedLabel.setText(getParameters().importablePdeFiles.size() + " PDE files");

        StringJoiner importablePdeFilePaths = new StringJoiner("\n");

        for (VirtualFile importablePdeFile : getParameters().importablePdeFiles) {
            importablePdeFilePaths.add(importablePdeFile.getPath());
        }

        importableClassesListTextArea.setText(importablePdeFilePaths.toString());
    } else {
        importableClassesListTextArea.setText("No sketch classes were found at this root directory.");
        filesDetectedLabel.setText("0 PDE files");
        filesDetectedLabel.setForeground(JBColor.RED);
    }
}
 
开发者ID:mistodev,项目名称:processing-idea,代码行数:19,代码来源:ProcessingSketchRootSelectStep.java

示例8: WebServer

import java.util.StringJoiner; //导入依赖的package包/类
public WebServer(URI endpoint) throws IOException {
  this.server = GrizzlyServerFactory.createHttpServer(endpoint, new HttpHandler() {

    @Override
    public void service(Request rqst, Response rspns) throws Exception {
      rspns.setStatus(HttpStatus.NOT_FOUND_404.getStatusCode(), "Not found");
      rspns.getWriter().write("404: not found");
    }
  });

  WebappContext context = new WebappContext("WebappContext", BASE_PATH);
  ServletRegistration registration = context.addServlet("ServletContainer", ServletContainer.class);
  registration.setInitParameter(ServletContainer.RESOURCE_CONFIG_CLASS,
      PackagesResourceConfig.class.getName());

  StringJoiner sj = new StringJoiner(",");
  for (String s : PACKAGES) {
    sj.add(s);
  }

  registration.setInitParameter(PackagesResourceConfig.PROPERTY_PACKAGES, sj.toString());
  registration.addMapping(BASE_PATH);
  context.deploy(server);
}
 
开发者ID:uber,项目名称:AthenaX,代码行数:25,代码来源:WebServer.java

示例9: unnumbered

import java.util.StringJoiner; //导入依赖的package包/类
private String[] unnumbered(String actual[])
{
    for (int i = actual.length-1; i >= 0; i--)
    {
        StringJoiner sj = new StringJoiner("\n");
        String[] bits = actual[i].split("\n");
        for (String bit: bits)
        {
            Pattern p = Pattern.compile("^[0-9.]*");
            Matcher m = p.matcher(bit);
            bit = m.replaceFirst("0");
            sj.add(bit);
        }
        actual[i] = sj.toString();
    }
    return actual;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:18,代码来源:TransformerDebugTest.java

示例10: print

import java.util.StringJoiner; //导入依赖的package包/类
public static void print(Map<String,Method> methods) throws Exception {
    methods.forEach((n,m)->{
        
        Class<?> returnType = m.getReturnType();
        Class<?>[] params = m.getParameterTypes();
        System.out.printf("%-40s ", m.getName());

        // Only string, boolean, long, int double
        //if ( returnType )

        System.out.print(returnType.getSimpleName());

        System.out.print(" <- ");
        StringJoiner sj = new StringJoiner(" ,", "(",")");
        for (Class<?>p : params ) {
            sj.add(p.getSimpleName());
        }
        System.out.print(sj.toString());
        System.out.println();
    });
}
 
开发者ID:afs,项目名称:tdb3,代码行数:22,代码来源:Opts.java

示例11: getConstructorLine

import java.util.StringJoiner; //导入依赖的package包/类
private String getConstructorLine() {
    StringBuilder resultBuilder = new StringBuilder();
    resultBuilder
            .append("public ")
            .append(sourceClass.getName())
            .append("(");
    StringJoiner constructorParams = new StringJoiner(", ");
    variables.stream().forEach(variable -> {
        String name = variable.getName().getValue();
        constructorParams.add(determinClassName(variable) + " " + name);
    });
    resultBuilder.append(constructorParams.toString());
    resultBuilder.append(
            ") {");
    return resultBuilder.toString();
}
 
开发者ID:Ingwersaft,项目名称:ValueClassGenerator,代码行数:17,代码来源:Constructor.java

示例12: nodeToString

import java.util.StringJoiner; //导入依赖的package包/类
/**
 * Returns a text containing all robots currently located in the given node.
 */
@Override
public String nodeToString(final ITreeNode node) {
	ITreeNode nodeToStringify = node;
	// Use an alias if set
	if (this.mOriginalToAlias != null) {
		final ITreeNode alias = this.mOriginalToAlias.get(node);
		if (alias != null) {
			nodeToStringify = alias;
		}
	}

	final StringJoiner joiner = new StringJoiner(", ", "{", "}");
	final SortedSet<Robot> robotsAtNode = this.mNodeToRobots.get(nodeToStringify);
	if (robotsAtNode != null) {
		for (final Robot robot : robotsAtNode) {
			joiner.add(Integer.toString(robot.getId()));
		}
	}
	return joiner.toString();
}
 
开发者ID:ZabuzaW,项目名称:TreeFlood,代码行数:24,代码来源:RobotNodeStringifier.java

示例13: setBeanName

import java.util.StringJoiner; //导入依赖的package包/类
@Override
public void setBeanName(ScanAtom bean) {
	StringJoiner name = new StringJoiner(" ");
	name.add("Scan of");

	ScanRequest<?> scanReq = bean.getScanReq();
	StringJoiner paths = new StringJoiner(", ");
	for (Object pathModel : scanReq.getCompoundModel().getModels()) {
		for (String pathName : pathAssemblerRegister.keySet()) {
			if (pathModel.getClass().getSimpleName().toLowerCase().startsWith(pathName)) {
				paths.add(pathAssemblerRegister.get(pathName).getString(pathModel));
			}
		}
	}
	name.add(paths.toString());
	name.add("collecting data with");
	name.add(scanReq.getDetectors().keySet().stream().map(detName -> "'"+detName+"'").collect(Collectors.joining(", ")));
	name.add("detector(s)");

	bean.setName(name.toString());
}
 
开发者ID:eclipse,项目名称:scanning,代码行数:22,代码来源:ScanAtomAssembler.java

示例14: doNotCache

import java.util.StringJoiner; //导入依赖的package包/类
/**
 * Sets headers so that the response is never cached.
 * @param response the response on which to set the headers.
 * @throws NullPointerException if the argument is {@code null}. 
 */
public static void doNotCache(HttpServletResponse response) {
    requireNonNull(response, "response");
    
    response.setHeader(CacheControl, new StringJoiner(", ")
                                    .add(NoStore)
                                    .add(NoCache)
                                    .add(MustRevalidate)
                                    .toString());
    response.setHeader(Pragma, NoCache);
    response.setIntHeader(Expires, 0);
}
 
开发者ID:openmicroscopy,项目名称:omero-ms-queue,代码行数:17,代码来源:Caches.java

示例15: calculateServerClasspath

import java.util.StringJoiner; //导入依赖的package包/类
/**
 * Calculates the server classpath, which is a colon-delimited string of directories and .jar files.
 * @param baseLibDir    The base directory of server libs and classes
 * @return The classpath
 */
private static String calculateServerClasspath(String baseLibDir) {
    try {
        Path baseLibPath = Paths.get(baseLibDir).toAbsolutePath().normalize();
        Stream<Path> jars = Files.find(baseLibPath, 1, (path, attrs) -> path.toString().endsWith(".jar"));
        StringJoiner joiner = new StringJoiner(":");

        // server libs directory (containing the server Java classes)
        joiner.add(baseLibPath.toString());

        // all .jar files in the same directory
        jars.forEach((path) -> joiner.add(path.toString()));

        return joiner.toString();

    } catch (IOException ex) {
        String message = "Error resolving server base lib dir: " + ex.getMessage();
        logger.error(message, ex);
        throw new IllegalArgumentException(message, ex);
    }
}
 
开发者ID:dvsa,项目名称:mot-automated-testsuite,代码行数:26,代码来源:DataServerManager.java


注:本文中的java.util.StringJoiner类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。