Example usage for org.apache.commons.lang3.text WordUtils capitalize

List of usage examples for org.apache.commons.lang3.text WordUtils capitalize

Introduction

In this page you can find the example usage for org.apache.commons.lang3.text WordUtils capitalize.

Prototype

public static String capitalize(final String str) 

Source Link

Document

Capitalizes all the whitespace separated words in a String.

Usage

From source file:grammar.refactoring.Capitalizer.java

public static void main(String[] args) throws IOException {
    String fullPathFilename = "grammars/CSharp4Lexer.g";
    String str = FileSystem.readTextFile(fullPathFilename);
    String capitalize = WordUtils.capitalize(str);
    FileSystem.writeTextFile(capitalize, fullPathFilename);
}

From source file:accinapdf.ACCinaPDF.java

/**
 * @param args the command line arguments
 *///from   w  w  w.  j av a2 s. c om
public static void main(String[] args) {

    controller.Logger.create();
    controller.Bundle.getBundle();

    if (GraphicsEnvironment.isHeadless()) {
        // Headless
        // Erro 
        String fich;
        if (args.length != 1) {
            System.err.println(Bundle.getBundle().getString("invalidArgs"));
            return;
        } else {
            fich = args[0];
        }

        try {
            System.out.println(Bundle.getBundle().getString("validating") + " " + fich);
            ArrayList<SignatureValidation> alSv = CCInstance.getInstance().validatePDF(fich, null);
            if (alSv.isEmpty()) {
                System.out.println(Bundle.getBundle().getString("notSigned"));
            } else {
                String newLine = System.getProperty("line.separator");
                String toWrite = "(";
                int numSigs = alSv.size();
                if (numSigs == 1) {
                    toWrite += "1 " + Bundle.getBundle().getString("signature");
                } else {
                    toWrite += numSigs + " " + Bundle.getBundle().getString("signatures");
                }
                toWrite += ")" + newLine;
                for (SignatureValidation sv : alSv) {
                    toWrite += "\t" + sv.getName() + " - ";
                    toWrite += (sv.isCertification()
                            ? WordUtils.capitalize(Bundle.getBundle().getString("certificate"))
                            : WordUtils.capitalize(Bundle.getBundle().getString("signed"))) + " "
                            + Bundle.getBundle().getString("by") + " " + sv.getSignerName();
                    toWrite += newLine + "\t\t";
                    if (sv.isChanged()) {
                        toWrite += Bundle.getBundle().getString("certifiedChangedOrCorrupted");
                    } else {
                        if (sv.isCertification()) {
                            if (sv.isValid()) {
                                if (sv.isChanged() || !sv.isCoversEntireDocument()) {
                                    toWrite += Bundle.getBundle().getString("certifiedButChanged");
                                } else {
                                    toWrite += Bundle.getBundle().getString("certifiedOk");
                                }
                            } else {
                                toWrite += Bundle.getBundle().getString("changedAfterCertified");
                            }
                        } else {
                            if (sv.isValid()) {
                                if (sv.isChanged()) {
                                    toWrite += Bundle.getBundle().getString("signedButChanged");
                                } else {
                                    toWrite += Bundle.getBundle().getString("signedOk");
                                }
                            } else {
                                toWrite += Bundle.getBundle().getString("signedChangedOrCorrupted");
                            }
                        }
                    }
                    toWrite += newLine + "\t\t";
                    if (sv.getOcspCertificateStatus().equals(CertificateStatus.OK)
                            || sv.getCrlCertificateStatus().equals(CertificateStatus.OK)) {
                        toWrite += Bundle.getBundle().getString("certOK");
                    } else if (sv.getOcspCertificateStatus().equals(CertificateStatus.REVOKED)
                            || sv.getCrlCertificateStatus().equals(CertificateStatus.REVOKED)) {
                        toWrite += Bundle.getBundle().getString("certRevoked");
                    } else if (sv.getOcspCertificateStatus().equals(CertificateStatus.UNCHECKED)
                            && sv.getCrlCertificateStatus().equals(CertificateStatus.UNCHECKED)) {
                        toWrite += Bundle.getBundle().getString("certNotVerified");
                    } else if (sv.getOcspCertificateStatus().equals(CertificateStatus.UNCHAINED)) {
                        toWrite += Bundle.getBundle().getString("certNotChained");
                    } else if (sv.getOcspCertificateStatus().equals(CertificateStatus.EXPIRED)) {
                        toWrite += Bundle.getBundle().getString("certExpired");
                    } else if (sv.getOcspCertificateStatus().equals(CertificateStatus.CHAINED_LOCALLY)) {
                        toWrite += Bundle.getBundle().getString("certChainedLocally");
                    }
                    toWrite += newLine + "\t\t";
                    if (sv.isValidTimeStamp()) {
                        toWrite += Bundle.getBundle().getString("validTimestamp");
                    } else {
                        toWrite += Bundle.getBundle().getString("signerDateTime");
                    }
                    toWrite += newLine + "\t\t";

                    toWrite += WordUtils.capitalize(Bundle.getBundle().getString("revision")) + ": "
                            + sv.getRevision() + " " + Bundle.getBundle().getString("of") + " "
                            + sv.getNumRevisions();
                    toWrite += newLine + "\t\t";
                    final DateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
                    final SimpleDateFormat sdf = new SimpleDateFormat("Z");
                    if (sv.getSignature().getTimeStampToken() == null) {
                        Calendar cal = sv.getSignature().getSignDate();
                        String date = sdf.format(cal.getTime().toLocaleString());
                        toWrite += date + " " + sdf.format(cal.getTime()) + " ("
                                + Bundle.getBundle().getString("signerDateTimeSmall") + ")";
                    } else {
                        Calendar ts = sv.getSignature().getTimeStampDate();
                        String date = df.format(ts.getTime());
                        toWrite += Bundle.getBundle().getString("date") + " " + date + " "
                                + sdf.format(ts.getTime());
                    }
                    toWrite += newLine + "\t\t";
                    boolean ltv = (sv.getOcspCertificateStatus() == CertificateStatus.OK
                            || sv.getCrlCertificateStatus() == CertificateStatus.OK);
                    toWrite += Bundle.getBundle().getString("isLtv") + ": "
                            + (ltv ? Bundle.getBundle().getString("yes") : Bundle.getBundle().getString("no"));
                    String reason = sv.getSignature().getReason();
                    toWrite += newLine + "\t\t";
                    toWrite += Bundle.getBundle().getString("reason") + ": ";
                    if (reason == null) {
                        toWrite += Bundle.getBundle().getString("notDefined");
                    } else if (reason.isEmpty()) {
                        toWrite += Bundle.getBundle().getString("notDefined");
                    } else {
                        toWrite += reason;
                    }
                    String location = sv.getSignature().getLocation();
                    toWrite += newLine + "\t\t";
                    toWrite += Bundle.getBundle().getString("location") + ": ";
                    if (location == null) {
                        toWrite += Bundle.getBundle().getString("notDefined");
                    } else if (location.isEmpty()) {
                        toWrite += Bundle.getBundle().getString("notDefined");
                    } else {
                        toWrite += location;
                    }
                    toWrite += newLine + "\t\t";
                    toWrite += Bundle.getBundle().getString("allowsChanges") + ": ";
                    try {
                        int certLevel = CCInstance.getInstance().getCertificationLevel(sv.getFilename());
                        if (certLevel == PdfSignatureAppearance.CERTIFIED_FORM_FILLING) {
                            toWrite += Bundle.getBundle().getString("onlyAnnotations");
                        } else if (certLevel == PdfSignatureAppearance.CERTIFIED_FORM_FILLING_AND_ANNOTATIONS) {
                            toWrite += Bundle.getBundle().getString("annotationsFormFilling");
                        } else if (certLevel == PdfSignatureAppearance.CERTIFIED_NO_CHANGES_ALLOWED) {
                            toWrite += Bundle.getBundle().getString("no");
                        } else {
                            toWrite += Bundle.getBundle().getString("yes");
                        }
                    } catch (IOException ex) {
                        controller.Logger.getLogger().addEntry(ex);
                    }
                    toWrite += newLine + "\t\t";
                    if (sv.getOcspCertificateStatus() == CertificateStatus.OK
                            || sv.getCrlCertificateStatus() == CertificateStatus.OK) {
                        toWrite += (Bundle.getBundle().getString("validationCheck1") + " "
                                + (sv.getOcspCertificateStatus() == CertificateStatus.OK
                                        ? Bundle.getBundle().getString("validationCheck2") + ": "
                                                + CCInstance.getInstance().getCertificateProperty(
                                                        sv.getSignature().getOcsp().getCerts()[0].getSubject(),
                                                        "CN")
                                                + " " + Bundle.getBundle().getString("at") + " "
                                                + df.format(sv.getSignature().getOcsp().getProducedAt())
                                        : (sv.getCrlCertificateStatus() == CertificateStatus.OK ? "CRL" : ""))
                                + (sv.getSignature().getTimeStampToken() != null
                                        ? Bundle.getBundle().getString("validationCheck3") + ": "
                                                + CCInstance.getInstance()
                                                        .getCertificateProperty(sv.getSignature()
                                                                .getTimeStampToken().getSID().getIssuer(), "O")
                                        : ""));
                    } else if (sv.getSignature().getTimeStampToken() != null) {
                        toWrite += (Bundle.getBundle().getString("validationCheck3") + ": "
                                + CCInstance.getInstance().getCertificateProperty(
                                        sv.getSignature().getTimeStampToken().getSID().getIssuer(), "O"));
                    }
                    toWrite += newLine;
                }

                System.out.println(toWrite);
                System.out.println(Bundle.getBundle().getString("validationFinished"));
            }
        } catch (IOException | DocumentException | GeneralSecurityException ex) {
            System.err.println(Bundle.getBundle().getString("validationError"));
            Logger.getLogger(ACCinaPDF.class.getName()).log(Level.SEVERE, null, ex);
        }

    } else {
        // GUI
        CCSignatureSettings defaultSettings = new CCSignatureSettings(false);
        if (SystemUtils.IS_OS_WINDOWS) {
            for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                if ("Windows".equals(info.getName())) {
                    try {
                        UIManager.setLookAndFeel(info.getClassName());
                    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
                            | UnsupportedLookAndFeelException ex) {
                        Logger.getLogger(ACCinaPDF.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    break;
                }
            }
        } else if (SystemUtils.IS_OS_LINUX) {
            for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    try {
                        UIManager.setLookAndFeel(info.getClassName());
                    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
                            | UnsupportedLookAndFeelException ex) {
                        Logger.getLogger(ACCinaPDF.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    break;
                }
            }
        } else if (SystemUtils.IS_OS_MAC_OSX) {
            try {
                UIManager.setLookAndFeel("com.sun.java.swing.plaf.mac.MacLookAndFeel");
            } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
                    | UnsupportedLookAndFeelException ex) {
                Logger.getLogger(ACCinaPDF.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

        new SplashScreen().setVisible(true);
    }
}

From source file:com.anrisoftware.sscontrol.core.groovy.statementsmap.StatementsEnumToString.java

/**
 * Returns the statements key name from the statement enumeration constant.
 *
 * @param statementsEnum//w ww .  ja va  2 s . c o  m
 *            the enumeration {@link Enum} constant.
 *
 * @return the statement key {@link String} name.
 */
public static String toString(Enum<?> statementsEnum) {
    String[] split = split(lowerCase(statementsEnum.name()), SEPERATOR);
    for (int i = 1; i < split.length - 1; i++) {
        split[i] = WordUtils.capitalize(split[i]);
    }
    String name = join(split, EMPTY, 0, split.length - 1);
    return name;
}

From source file:de.cbb.mplayer.util.ReflectionHelper.java

public static String getterName(String field, Class type) {
    if (Boolean.class.getSimpleName().toLowerCase().equals(type.getSimpleName().toLowerCase()))
        return "is" + WordUtils.capitalize(field);
    else//w  ww . j a  v  a  2  s  . c  om
        return "get" + WordUtils.capitalize(field);
}

From source file:com.zaradai.bloodstone.text.TextUtils.java

@Override
public String capitalize(String str) {
    return WordUtils.capitalize(str);
}

From source file:com.chiorichan.session.SessionManager.java

/**
 * Gets the Default Session Name//from   w w w  .j  a  v  a2 s. com
 *
 * @return Session Name as string
 */
public static String getDefaultSessionName() {
    return "_ws" + WordUtils.capitalize(AppConfig.get().getString("sessions.defaultCookieName", "sessionId"));
}

From source file:com.music.model.PartType.java

public String getTitle() {
    return WordUtils.capitalize(name().toLowerCase().replace('_', ' '));
}

From source file:com.lyncode.jtwig.functions.internal.string.Title.java

@Override
public Object execute(Object... arguments) throws FunctionException {
    if (arguments.length != 1)
        throw new FunctionException("Invalid number of arguments");
    if (arguments[0] == null)
        return null;
    return WordUtils.capitalize((String) arguments[0]);
}

From source file:ca.uhn.fhir.util.reflection.JavaReflectBeanUtil.java

@Override
public Method findAccessor(Class<?> theClassToIntrospect, Class<?> theTargetReturnType, String thePropertyName)
        throws NoSuchFieldException {
    String methodName = "get" + WordUtils.capitalize(thePropertyName);
    try {/*from  w  w w. j  a  v a2 s  .c om*/
        Method method = theClassToIntrospect.getMethod(methodName);
        if (theTargetReturnType.isAssignableFrom(method.getReturnType())) {
            return method;
        }
    } catch (NoSuchMethodException e) {
        // fall through
    } catch (SecurityException e) {
        throw new ConfigurationException(
                "Failed to scan class '" + theClassToIntrospect + "' because of a security exception", e);
    }
    throw new NoSuchFieldException(theClassToIntrospect + " has no accessor for field " + thePropertyName);
}

From source file:com.techcavern.wavetact.eventListeners.MCStatusListener.java

public void run() {
    while (true) {
        try {/*from ww  w . j  av a 2s  . co m*/
            JsonArray mcstatus = GeneralUtils.getJsonArray("https://status.mojang.com/check");
            mcstatus.forEach(status -> {
                String name = status.getAsJsonObject().entrySet().iterator().next().getKey().toString();
                if (name.equalsIgnoreCase("minecraft.net")) {
                    name = "Website";
                } else if (name.equalsIgnoreCase("api.mojang.com")) {
                    name = "API";
                } else if (name.equalsIgnoreCase("authserver.mojang.com")) {
                    name = "AuthServer";
                } else if (name.equalsIgnoreCase("sessionserver.mojang.com")) {
                    name = "SessionServer";
                } else {
                    name = WordUtils.capitalize(name.replace(".minecraft.net", "").replace(".mojang.com", ""));
                }
                String value = status.getAsJsonObject().entrySet().iterator().next().getValue().getAsString();
                if (value.equalsIgnoreCase("green")) {
                    value = "Online";
                } else if (value.equalsIgnoreCase("yellow")) {
                    value = "Overloaded";
                } else {
                    value = "Offline";
                }
                final String mcname = name;
                final String mcvalue = value;
                if (MCStatus.get(name) != null && !MCStatus.get(name).equalsIgnoreCase(value)) {
                    Registry.networks.values().forEach(bot -> {
                        bot.getUserChannelDao().getAllChannels().forEach(chan -> {
                            Record prop = DatabaseUtils.getChannelProperty(
                                    IRCUtils.getNetworkNameByNetwork(bot), chan.getName(), "notifymc");
                            if (prop != null && prop.getValue(CHANNELPROPERTY.VALUE).equalsIgnoreCase("true")) {
                                IRCUtils.sendMessage(bot, chan, "[MC Status] " + mcname + " is now " + mcvalue,
                                        "");
                            }
                        });
                    });
                }
                MCStatus.put(name, value);
            });
        } catch (Exception e) {

        }
        try {
            TimeUnit.MINUTES.sleep(1);
        } catch (Exception e) {

        }
    }
}