Example usage for org.apache.commons.lang WordUtils capitalizeFully

List of usage examples for org.apache.commons.lang WordUtils capitalizeFully

Introduction

In this page you can find the example usage for org.apache.commons.lang WordUtils capitalizeFully.

Prototype

public static String capitalizeFully(String str) 

Source Link

Document

Converts all the whitespace separated words in a String into capitalized words, that is each word is made up of a titlecase character and then a series of lowercase characters.

Usage

From source file:org.openregistry.core.aspect.NameSuffixAspect.java

@Around("set(@org.openregistry.core.domain.normalization.NameSuffix * *)")
public Object transformFieldValue(final ProceedingJoinPoint joinPoint) throws Throwable {
    final String value = (String) joinPoint.getArgs()[0];

    if (isDisabled() || value == null || value.isEmpty()) {
        return joinPoint.proceed();
    }//  www .j  a v  a2  s.  c o m

    final String overrideValue = getCustomMapping().get(value);

    if (overrideValue != null) {
        return joinPoint.proceed(new Object[] { overrideValue });
    }

    final String casifyValue;
    if (value.matches("^[IiVv]+$")) { //TODO Generalize II - VIII
        casifyValue = value.toUpperCase();
    } else {
        casifyValue = WordUtils.capitalizeFully(value);
    }

    return joinPoint.proceed(new Object[] { casifyValue });
}

From source file:org.openvpms.component.business.domain.im.lookup.Lookup.java

/**
 * Returns the name./*from  w w  w .  j a v a  2 s .  c om*/
 *
 * @return the name
 */
public String getName() {
    String name = super.getName();
    if (name == null && code != null) {
        name = code.replace('_', ' ');
        name = WordUtils.capitalizeFully(name);
    }
    return name;
}

From source file:org.sakaiproject.profile2.util.ProfileUtils.java

/**
 * Convert a string to propercase. ie This Is Proper Text
 * @param input      string to be formatted
 * @return// www  . j a v  a 2 s.com
 */
public static String toProperCase(String input) {
    return WordUtils.capitalizeFully(input);
}

From source file:org.seasr.meandre.components.analytics.socialnetworking.AbstractLinkCreationComponent.java

@Override
public void executeCallBack(ComponentContext cc) throws Exception {
    Strings inMetaTuple = (Strings) cc.getDataComponentFromInput(IN_META_TUPLE);
    SimpleTuplePeer tuplePeer = new SimpleTuplePeer(inMetaTuple);
    console.fine("Input meta tuple: " + tuplePeer.toString());

    StringsArray inTuples = (StringsArray) cc.getDataComponentFromInput(IN_TUPLES);
    Strings[] tuples = BasicDataTypesTools.stringsArrayToJavaArray(inTuples);

    int SENTENCE_ID_IDX = tuplePeer.getIndexForFieldName(OpenNLPNamedEntity.SENTENCE_ID_FIELD);
    int TYPE_IDX = tuplePeer.getIndexForFieldName(OpenNLPNamedEntity.TYPE_FIELD);
    int TEXT_IDX = tuplePeer.getIndexForFieldName(OpenNLPNamedEntity.TEXT_FIELD);

    // Linked list of sentences keyed by sentence id - the HashSet is the set of entities in that sentence
    LinkedList<KeyValuePair<Integer, HashSet<Entity>>> _sentencesWindow = new LinkedList<KeyValuePair<Integer, HashSet<Entity>>>();

    // Note: The algorithm used to mark entities as adjacent if they fall within the specified sentence distance
    //       relies on a sliding-window of sentences that are within the 'adjacency' range. As new sentences are
    //       considered, the window moves to the right and old sentences that are now too far fall out of scope.

    SimpleTuple tuple = tuplePeer.createTuple();
    for (Strings t : tuples) {
        tuple.setValues(t);/*ww  w .j  a  va 2 s .co m*/

        Integer sentenceId = Integer.parseInt(tuple.getValue(SENTENCE_ID_IDX));
        String tupleType = tuple.getValue(TYPE_IDX);
        String tupleValue = tuple.getValue(TEXT_IDX);

        // If the entity is of the type we're interested in
        if (_entityTypes.contains(tupleType)) {

            if (_normalizeEntities) {
                // Normalize whitespaces
                StringBuilder sb = new StringBuilder();
                Matcher nonWhitespaceMatcher = REGEXP_NONWHITESPACE.matcher(tupleValue);
                while (nonWhitespaceMatcher.find())
                    sb.append(" ").append(nonWhitespaceMatcher.group(1));

                if (sb.length() > 0)
                    tupleValue = sb.substring(1);
                else
                    continue;

                // Normalize people's names
                if (tupleType.toLowerCase().equals("person")) {
                    sb = new StringBuilder();
                    Matcher personMatcher = REGEXP_PERSON.matcher(tupleValue);
                    while (personMatcher.find())
                        sb.append(" ").append(personMatcher.group(1));

                    if (sb.length() > 0)
                        tupleValue = sb.substring(1);
                    else
                        continue;

                    // ignore names with 1 character
                    if (tupleValue.length() == 1)
                        continue;
                }

                tupleValue = WordUtils.capitalizeFully(tupleValue);
            }

            // ... create an object for it
            Entity entity = new Entity(tupleType, tupleValue);

            // Check if we already recorded this entity before
            Entity oldEntity = _entities.get(entity);
            if (oldEntity == null)
                // If not, record it
                _entities.put(entity, entity);
            else
                // Otherwise retrieve the entity we used before
                entity = oldEntity;

            HashSet<Entity> sentenceEntities;

            // Remove all sentences (together with any entities they contained) from the set
            // of sentences that are too far from the current sentence of this entity
            while (_sentencesWindow.size() > 0 && sentenceId - _sentencesWindow.peek().getKey() > _offset)
                _sentencesWindow.remove();

            if (_sentencesWindow.size() > 0) {
                // If this sentence is different from the last sentence in the window
                if (_sentencesWindow.getLast().getKey() != sentenceId) {
                    // Create an entry for it and add it at the end of the window
                    sentenceEntities = new HashSet<Entity>();
                    _sentencesWindow
                            .addLast(new KeyValuePair<Integer, HashSet<Entity>>(sentenceId, sentenceEntities));
                } else
                    sentenceEntities = _sentencesWindow.getLast().getValue();
            } else {
                // If there are no sentences in the window, create an entry for this sentence and add it
                sentenceEntities = new HashSet<Entity>();
                _sentencesWindow
                        .addLast(new KeyValuePair<Integer, HashSet<Entity>>(sentenceId, sentenceEntities));
            }

            // Iterate through all the sentences in the window
            for (KeyValuePair<Integer, HashSet<Entity>> kvp : _sentencesWindow)
                // ... and all the entities in each sentence
                for (Entity e : kvp.getValue()) {
                    // ignore self-references
                    if (e.equals(entity))
                        continue;

                    // ... and mark the new entity as being adjacent to all the entities in the window
                    e.addOutwardLink(entity);
                    entity.addInwardLink(e);
                }

            // Add the new entity to the window
            sentenceEntities.add(entity);
        }
    }

    if (!_isStreaming)
        generateAndPushOutputInternal();
}

From source file:org.soaplab.clients.spinet.Category.java

/*************************************************************************
 * Return the name of this category in a more "human-readable" form.
 *************************************************************************/
public String getDisplayName() {
    return WordUtils.capitalizeFully(StringUtils.replace(getName(), "_", "&nbsp;"));
}

From source file:org.talend.dataprep.transformation.actions.bool.Negate.java

@Override
public void applyOnColumn(DataSetRow row, ActionContext context) {
    final String columnId = context.getColumnId();
    final String value = row.get(columnId);
    if (isBoolean(value)) {
        final Boolean boolValue = Boolean.valueOf(value);
        row.set(columnId, WordUtils.capitalizeFully("" + !boolValue));
    }/*from ww w.  j  a  v a  2 s .co  m*/
}

From source file:org.talend.dataprep.transformation.actions.text.ProperCase.java

/**
 * @see ColumnAction#applyOnColumn(DataSetRow, ActionContext)
 *//*  w  w w.j  a  va2s  . com*/
@Override
public void applyOnColumn(DataSetRow row, ActionContext context) {
    final String columnId = context.getColumnId();
    final String toProperCase = row.get(columnId);
    if (toProperCase != null) {
        row.set(columnId, WordUtils.capitalizeFully(toProperCase));
    }
}

From source file:pt.ist.fenixedu.integration.task.exportData.parking.ExportCarParkUsers.java

private void appendTestUserInfo(PrintStream printStream) {
    printStream.print(invert("4f86bb68"));
    printStream.print("=a");
    printStream.print(truncate(20, WordUtils.capitalizeFully(StringNormalizer.normalize("Utilizador Teste"))));
    printStream.print(date(new DateTime(2015, 2, 27, 0, 0, 0)));
    printStream.print(date(new DateTime(2015, 4, 1, 0, 0, 0)));
    printStream.print("\r\n");
}

From source file:pt.ist.fenixedu.integration.task.exportData.parking.ExportCarParkUsers.java

private void appendUserInfo(final PrintStream printStream, final User user) {
    final String rfid = getUserRFID(user);
    if (rfid != null) {
        printStream.print(toHex(rfid.trim()));
        printStream.print("=a");
        printStream.print(truncate(20,/* ww w  .  j  a v  a  2 s . co  m*/
                WordUtils.capitalizeFully(StringNormalizer.normalize(user.getProfile().getDisplayName()))));
        printStream.print(date(getStartDate(user)));
        printStream.print(date(getEndDate(user)));
        printStream.print("\r\n");
    }
}

From source file:raptor.util.CreateBugButtonActions.java

public static void main(String args[]) throws Exception {
    File file = new File(Raptor.RESOURCES_DIR + "sounds/bughouse");
    String[] bugSounds = file.list(new FilenameFilter() {
        public boolean accept(File dir, String name) {
            return name.endsWith(".wav");
        }/*from  w  w w  . j  av a2 s.  co m*/
    });

    for (String sound : bugSounds) {
        sound = StringUtils.remove(sound, ".wav");
        String name = WordUtils.capitalizeFully(sound.toLowerCase());
        File scriptFile = new File(Raptor.RESOURCES_DIR + "/actions/" + name + ".properties");
        if (!scriptFile.exists()) {
            ScriptedAction scriptedAction = new ScriptedAction();
            scriptedAction.setCategory(Category.PartnerTells);
            scriptedAction.setName(name);
            scriptedAction.setDescription("Sends the command: ptell " + sound);
            scriptedAction.setScript("context.send(\"ptell " + sound + "\");");
            Properties properties = RaptorActionFactory.save(scriptedAction);
            properties.store(new FileOutputStream(scriptFile), "Raptor System Action");
            System.err.println("Created " + scriptFile.getAbsolutePath());
        }
    }
}