Example usage for java.text ChoiceFormat nextDouble

List of usage examples for java.text ChoiceFormat nextDouble

Introduction

In this page you can find the example usage for java.text ChoiceFormat nextDouble.

Prototype

public static final double nextDouble(double d) 

Source Link

Document

Finds the least double greater than d .

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {

    double d = 1.2;

    double d2 = ChoiceFormat.nextDouble(d);
    System.out.println(d2);//  www .j a va2 s .c om
}

From source file:org.springframework.cloud.deployer.resource.maven.MavenArtifactResolver.java

/**
 * Resolve an artifact and return its location in the local repository. Aether performs the normal
 * Maven resolution process ensuring that the latest update is cached to the local repository.
 * In addition, if the {@link MavenProperties#resolvePom} flag is <code>true</code>,
 * the POM is also resolved and cached.// ww  w .  j  a  v  a2  s . c o m
 * @param resource the {@link MavenResource} representing the artifact
 * @return a {@link FileSystemResource} representing the resolved artifact in the local repository
 * @throws IllegalStateException if the artifact does not exist or the resolution fails
 */
Resource resolve(MavenResource resource) {
    Assert.notNull(resource, "MavenResource must not be null");
    validateCoordinates(resource);
    RepositorySystemSession session = newRepositorySystemSession(this.repositorySystem,
            this.properties.getLocalRepository());
    ArtifactResult resolvedArtifact;
    try {
        List<ArtifactRequest> artifactRequests = new ArrayList<>(2);
        if (properties.isResolvePom()) {
            artifactRequests.add(
                    new ArtifactRequest(toPomArtifact(resource), this.remoteRepositories, JavaScopes.RUNTIME));
        }
        artifactRequests
                .add(new ArtifactRequest(toJarArtifact(resource), this.remoteRepositories, JavaScopes.RUNTIME));

        List<ArtifactResult> results = this.repositorySystem.resolveArtifacts(session, artifactRequests);
        resolvedArtifact = results.get(results.size() - 1);
    } catch (ArtifactResolutionException e) {

        ChoiceFormat pluralizer = new ChoiceFormat(new double[] { 0d, 1d, ChoiceFormat.nextDouble(1d) },
                new String[] { "repositories: ", "repository: ", "repositories: " });
        MessageFormat messageFormat = new MessageFormat(
                "Failed to resolve MavenResource: {0}. Configured remote {1}: {2}");
        messageFormat.setFormat(1, pluralizer);
        String repos = properties.getRemoteRepositories().isEmpty() ? "none"
                : StringUtils.collectionToDelimitedString(properties.getRemoteRepositories().keySet(), ",", "[",
                        "]");
        throw new IllegalStateException(messageFormat
                .format(new Object[] { resource, properties.getRemoteRepositories().size(), repos }), e);
    }
    return toResource(resolvedArtifact);
}