Example usage for java.lang String toUpperCase

List of usage examples for java.lang String toUpperCase

Introduction

In this page you can find the example usage for java.lang String toUpperCase.

Prototype

public String toUpperCase() 

Source Link

Document

Converts all of the characters in this String to upper case using the rules of the default locale.

Usage

From source file:Main.java

/**
 * Converts a string to title casing./*  w  w w. j  a v  a2  s .c o  m*/
 * @param str
 *      The string to convert.
 * @return
 *      The converted string.
 */
public static String toTitleCase(String str) {
    if (str == null) {
        return null;
    }
    // skip if already contains mixed case
    if (!str.equals(str.toLowerCase()) && !str.equals(str.toUpperCase())) {
        return str;
    }

    boolean isSeparator = true;
    StringBuilder builder = new StringBuilder(str);
    final int len = builder.length();

    for (int i = 0; i < len; ++i) {
        char c = builder.charAt(i);
        if (isSeparator) {
            if (Character.isLetterOrDigit(c)) {
                // Convert to title case and switch out of whitespace mode.
                builder.setCharAt(i, Character.toTitleCase(c));
                isSeparator = false;
            }
        } else if (!Character.isLetterOrDigit(c)) {
            isSeparator = true;
        } else {
            builder.setCharAt(i, Character.toLowerCase(c));
        }
    }

    return builder.toString();
}

From source file:edu.berkeley.ground.common.model.version.GroundType.java

/**
 * Return a type based on the string name.
 *
 * @param str the name of the type//  ww w . j  a va  2 s .c om
 * @return the corresponding GroundType
 * @throws GroundException no such type
 */
@JsonCreator
public static GroundType fromString(String str) throws GroundException {
    if (str == null) {
        return null;
    }
    try {
        return GroundType.valueOf(str.toUpperCase());
    } catch (IllegalArgumentException iae) {
        throw new GroundException(ExceptionType.OTHER, String.format("Invalid type: %s.", str));
    }
}

From source file:Main.java

public static String fieldToParams(String fieldName) {

    for (char a : fieldName.toCharArray()) {
        if (a >= 65 && a <= 90) {
            fieldName = fieldName.replaceFirst(String.valueOf(a), "_" + a);
        }/*from  w  ww  . ja v  a2 s  . co m*/
    }
    fieldName = fieldName.toUpperCase();
    return fieldName;
}

From source file:com.cubeia.backoffice.report.RequestBean.java

@SuppressWarnings("rawtypes")
public static RequestBean parse(String name, Map params, String format) {
    Map<String, String> map = checkParameters(params);
    Format f = Format.valueOf(format.toUpperCase());
    if (f == null)
        throw new IllegalArgumentException("Unknown format: " + format);
    return new RequestBean(name, map, f);
}

From source file:Main.java

public static String validateBluetoothAddress(String address) {
    if (BluetoothAdapter.checkBluetoothAddress(address)) {
        return address;
    } else {//  w  w  w.j av a 2 s.  c om
        StringBuilder buf = new StringBuilder(17);
        buf.append(address.toUpperCase());

        buf.insert(2, ':');
        buf.insert(5, ':');
        buf.insert(8, ':');
        buf.insert(11, ':');
        buf.insert(14, ':');

        return buf.toString();
    }
}

From source file:com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.distributed.kubernetes.v1.ResourceBuilder.java

static Container buildContainer(String name, ServiceSettings settings, List<ConfigSource> configSources,
        DeploymentEnvironment deploymentEnvironment) {
    int port = settings.getPort();
    List<EnvVar> envVars = settings.getEnv().entrySet().stream().map(e -> {
        EnvVarBuilder envVarBuilder = new EnvVarBuilder();
        return envVarBuilder.withName(e.getKey()).withValue(e.getValue()).build();
    }).collect(Collectors.toList());

    configSources.forEach(c -> {//from   w  ww. jav a 2 s.  c o  m
        c.getEnv().entrySet().forEach(envEntry -> {
            EnvVarBuilder envVarBuilder = new EnvVarBuilder();
            envVars.add(envVarBuilder.withName(envEntry.getKey()).withValue(envEntry.getValue()).build());
        });
    });

    ProbeBuilder probeBuilder = new ProbeBuilder();

    String scheme = settings.getScheme();
    if (StringUtils.isNotEmpty(scheme)) {
        scheme = scheme.toUpperCase();
    } else {
        scheme = null;
    }

    if (settings.getHealthEndpoint() != null) {
        probeBuilder = probeBuilder.withNewHttpGet().withNewPort(port).withPath(settings.getHealthEndpoint())
                .withScheme(scheme).endHttpGet();
    } else {
        probeBuilder = probeBuilder.withNewTcpSocket().withNewPort().withIntVal(port).endPort().endTcpSocket();
    }

    List<VolumeMount> volumeMounts = configSources.stream().map(c -> {
        return new VolumeMountBuilder().withMountPath(c.getMountPath()).withName(c.getId()).build();
    }).collect(Collectors.toList());

    ContainerBuilder containerBuilder = new ContainerBuilder();
    containerBuilder = containerBuilder.withName(name).withImage(settings.getArtifactId())
            .withPorts(new ContainerPortBuilder().withContainerPort(port).build())
            .withVolumeMounts(volumeMounts).withEnv(envVars).withReadinessProbe(probeBuilder.build())
            .withResources(buildResourceRequirements(name, deploymentEnvironment));

    return containerBuilder.build();
}

From source file:com.spectralogic.ds3cli.command.CliCommand.java

/**
 * Lookup help for '--help' COMMAND from resource file
 * (Override or add help text to resources/com/spectralogic/dscli/help.properties
 * @param command//from   w ww .  jav a  2s .c o  m
 * @return
 */
public static String getVerboseHelp(final String command) {
    return CommandHelpText.getHelpText(command.toUpperCase());
}

From source file:Main.java

public static Collection<Element> fetchSubElements(Element e, String subElementName) {
    if (e == null || subElementName == null) {
        return null;
    }/*from ww  w  .j  ava  2s.c om*/

    subElementName = subElementName.toUpperCase();

    Collection<Element> elements = new ArrayList<Element>();

    NodeList list = e.getChildNodes();
    for (int i = 0; i < list.getLength(); i++) {
        if (list.item(i) instanceof Element) {
            Element element = (Element) list.item(i);
            if (element.getTagName().toUpperCase().equals(subElementName)) {
                elements.add(element);
            }
        }
    }

    return elements;
}

From source file:Main.java

public static final String bytesToHexString(byte[] bArray) {
    StringBuffer sb = new StringBuffer(bArray.length);
    String sTemp;
    for (int i = 0; i < bArray.length; i++) {
        sTemp = Integer.toHexString(0xFF & bArray[i]);
        if (sTemp.length() < 2)
            sb.append(0);//www  . j a  va  2  s. co m
        sb.append(sTemp.toUpperCase());
    }
    return sb.toString();
}

From source file:com.aliyun.openservices.odps.console.pub.StatusOfInstanceCommand.java

public static StatusOfInstanceCommand parse(String command, ExecutionContext session)
        throws ODPSConsoleException, OdpsException {

    if (command.toUpperCase().matches("\\s*STATUS\\s+EXTENDED\\s+.*")) {

        command = command.trim();//from ww w .  j av  a2  s  .  c  om
        String str[] = command.split("\\s+");
        if (str.length != 3)
            throw new ODPSConsoleException(ODPSConsoleConstants.BAD_COMMAND);

        InstanceContext instanceContext = new InstanceContext();
        if (instanceContext.getConn() == null) {
            ConnectionCreator tmpCC = new ConnectionCreator();
            instanceContext.setConn(tmpCC.create(session));
        }
        instanceContext.setSession(session);
        instanceContext.setProjectByName(session.getProjectName());

        instanceContext.setInstanceById(str[2]);
        StatusOfInstanceCommand comm = new StatusOfInstanceCommand(str[2], command, session, true,
                instanceContext);
        return comm;

    } else if (command.toUpperCase().matches("\\s*STATUS\\s+.*")) {
        command = command.trim();
        String str[] = command.split("\\s+");
        if (str.length == 3)
            return null;
        if (str.length != 2)
            throw new ODPSConsoleException(ODPSConsoleConstants.BAD_COMMAND);
        return new StatusOfInstanceCommand(str[1], command, session, false, null);
    }
    return null;
}