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.apache.oodt.cas.product.rdf.RDFDatasetServlet.java

public void outputRDF(List<ProductType> productTypes, String base, HttpServletResponse resp)
        throws ServletException {

    try {/*from   w w  w .  java 2s  .  c  o m*/
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setNamespaceAware(true);
        Document doc = factory.newDocumentBuilder().newDocument();

        Element rdf = XMLUtils.addNode(doc, doc, "rdf:RDF");
        RDFUtils.addNamespaces(doc, rdf, this.rdfConf);

        for (ProductType type : productTypes) {
            Element productTypeRdfDesc = XMLUtils.addNode(doc, rdf,
                    this.rdfConf.getTypeNs(type.getName()) + ":" + type.getName());
            XMLUtils.addAttribute(doc, productTypeRdfDesc, "rdf:about",
                    base + "?typeID=" + type.getProductTypeId());

            // for all of its metadata keys and values, loop through them
            // and add RDF nodes underneath the RdfDesc for this product

            if (type.getTypeMetadata() != null) {
                for (String key : type.getTypeMetadata().getMap().keySet()) {
                    List<String> vals = type.getTypeMetadata().getAllMetadata(key);

                    if (vals != null && vals.size() > 0) {

                        for (String val : vals) {
                            //OODT-665 fix, take keys like 
                            //PRODUCT Experiment Type
                            //and transform it into ProductExperimentType
                            String outputKey = key;
                            if (outputKey.contains(" ")) {
                                outputKey = StringUtils.join(WordUtils.capitalizeFully(outputKey).split(" "));
                            }

                            val = StringEscapeUtils.escapeXml(val);
                            Element rdfElem = RDFUtils.getRDFElement(outputKey, val, this.rdfConf, doc);
                            productTypeRdfDesc.appendChild(rdfElem);
                        }

                    }
                }
            }

        }

        DOMSource source = new DOMSource(doc);
        TransformerFactory transFactory = TransformerFactory.newInstance();
        Transformer transformer = transFactory.newTransformer();
        transformer.setOutputProperty("indent", "yes");
        StreamResult result = new StreamResult(resp.getOutputStream());
        resp.setContentType("text/xml");
        transformer.transform(source, result);

    } catch (ParserConfigurationException e) {
        throw new ServletException(e);
    } catch (TransformerException e) {
        throw new ServletException(e);
    } catch (IOException e) {
        throw new ServletException(e);
    }
}

From source file:org.apache.oodt.cas.product.rdf.RDFProductServlet.java

public void outputRDF(List<Product> products, ProductType type, String base, HttpServletResponse resp)
        throws ServletException {

    try {/* w w  w. j av  a  2 s  .  com*/
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setNamespaceAware(true);
        Document doc = factory.newDocumentBuilder().newDocument();

        Element rdf = XMLUtils.addNode(doc, doc, "rdf:RDF");
        RDFUtils.addNamespaces(doc, rdf, this.rdfConf);

        for (Product p : products) {
            String productTypeIdStr = p.getProductType().getProductTypeId();
            ProductType productType;

            if (type != null) {
                productType = type;
            } else {
                try {
                    productType = fClient.getProductTypeById(productTypeIdStr);
                } catch (RepositoryManagerException e) {
                    LOG.log(Level.SEVERE, e.getMessage());
                    LOG.log(Level.SEVERE,
                            "Unable to obtain product type from product type id: ["
                                    + ((Product) products.get(0)).getProductType().getProductTypeId()
                                    + "]: Message: " + e.getMessage());
                    return;
                }
            }

            p.setProductType(productType);

            Element productRdfDesc = XMLUtils.addNode(doc, rdf,
                    this.rdfConf.getTypeNs(productType.getName()) + ":" + productType.getName());
            XMLUtils.addAttribute(doc, productRdfDesc, "rdf:about", base + "?productID=" + p.getProductId());

            // now add all its metadata
            Metadata prodMetadata = safeGetMetadata(p);

            // for all of its metadata keys and values, loop through them
            // and add RDF nodes underneath the RdfDesc for this product

            if (prodMetadata != null) {
                for (String key : prodMetadata.getMap().keySet()) {
                    List<String> vals = prodMetadata.getAllMetadata(key);

                    if (vals != null && vals.size() > 0) {

                        for (String val : vals) {
                            String outputKey = key;
                            if (outputKey.contains(" ")) {
                                outputKey = StringUtils.join(WordUtils.capitalizeFully(outputKey).split(" "));
                            }

                            val = StringEscapeUtils.escapeXml(val);
                            Element rdfElem = RDFUtils.getRDFElement(outputKey, val, this.rdfConf, doc);
                            productRdfDesc.appendChild(rdfElem);
                        }

                    }
                }
            }

        }

        DOMSource source = new DOMSource(doc);
        TransformerFactory transFactory = TransformerFactory.newInstance();
        Transformer transformer = transFactory.newTransformer();
        transformer.setOutputProperty("indent", "yes");
        StreamResult result = new StreamResult(resp.getOutputStream());
        resp.setContentType("text/xml");
        transformer.transform(source, result);

    } catch (ParserConfigurationException e) {
        throw new ServletException(e);
    } catch (TransformerException e) {
        throw new ServletException(e);
    } catch (IOException e) {
        throw new ServletException(e);
    }
}

From source file:org.apache.oodt.cas.product.rss.RSSUtils.java

public static Element emitRSSTag(RSSTag tag, Metadata prodMet, Document doc, Element item) {
    String outputTag = tag.getName();
    if (outputTag.contains(" ")) {
        outputTag = StringUtils.join(WordUtils.capitalizeFully(outputTag).split(" "));
    }//  www .  j a v  a2s  . c  om
    Element rssMetElem = XMLUtils.addNode(doc, item, outputTag);

    // first check if there is a source defined, if so, use that as the value
    if (tag.getSource() != null) {
        rssMetElem.appendChild(doc.createTextNode(
                StringEscapeUtils.escapeXml(PathUtils.replaceEnvVariables(tag.getSource(), prodMet))));
    }

    // check if there are attributes defined, and if so, add to the attributes
    for (RSSTagAttribute attr : tag.getAttrs()) {
        rssMetElem.setAttribute(attr.getName(), PathUtils.replaceEnvVariables(attr.getValue(), prodMet));
    }

    return rssMetElem;
}

From source file:org.apache.tajo.engine.function.string.InitCap.java

@Override
public Datum eval(Tuple params) {
    if (params.isBlankOrNull(0)) {
        return NullDatum.get();
    }//from   w  ww .  java  2s  . c  o  m

    return DatumFactory.createText(WordUtils.capitalizeFully(params.getText(0)));
}

From source file:org.artifactory.api.governance.BlackDuckUtils.java

public static String camelize(String text) {
    return text != null ? WordUtils.capitalizeFully(text.toLowerCase()) : null;
}

From source file:org.axiom_tools.storage.Surrogated.java

/**
 * Normalizes text with full capitalization, without punctuation, and without extraneous whitespace.
 *
 * @param text some text// ww w . ja  v  a  2  s. c  o m
 * @return normalized text
 */
public static String normalizeWords(String text) {
    return WordUtils.capitalizeFully(StringUtils.defaultString(text).trim())
            .replaceAll(PunctuationFilter, Empty).replaceAll(MultipleSpaceFilter, Blank);
}

From source file:org.caleydo.view.bicluster.sorting.CategoricalSortingStrategyFactory.java

@Override
public String getLabel() {
    return WordUtils.capitalizeFully(table.getDataDomain().getLabel());
}

From source file:org.caleydo.view.table.TablePerspectiveAction.java

@Override
public Collection<Pair<String, Runnable>> create(TablePerspective tablePerspective, Object sender) {
    List<Pair<String, Runnable>> r = new ArrayList<>();
    r.add(Pair.make("Show in Table",
            show(TableView.VIEW_TYPE, AOpenViewHandler.createSecondaryID() + "_lazy", tablePerspective)));
    r.add(export("Export Data", tablePerspective, null, null));
    final String recLabel = WordUtils
            .capitalizeFully(tablePerspective.getDataDomain().getRecordIDCategory().getCategoryName());
    final String dimLabel = WordUtils
            .capitalizeFully(tablePerspective.getDataDomain().getDimensionIDCategory().getCategoryName());
    if (ExportTablePerspectiveAction.hasGrouping(tablePerspective, EDimension.RECORD))
        r.add(export("Export " + recLabel + " Grouping Data", tablePerspective, null, EDimension.RECORD));
    if (ExportTablePerspectiveAction.hasGrouping(tablePerspective, EDimension.DIMENSION))
        r.add(export("Export " + dimLabel + " Grouping Data", tablePerspective, null, EDimension.DIMENSION));
    r.add(export("Export " + recLabel + " Identifiers", tablePerspective, EDimension.RECORD, null));
    r.add(export("Export " + dimLabel + " Identifiers", tablePerspective, EDimension.DIMENSION, null));
    return r;// w  w  w.j  a  v a 2  s .  c o  m
}

From source file:org.carewebframework.rpms.ui.common.LookupController.java

private void loadResults(List<String> v) {
    lbResults.getItems().clear();/*from w w  w.  j av a 2s.  c o  m*/

    for (String s : v) {
        Listitem item = new Listitem();
        item.addForward(Events.ON_DOUBLE_CLICK, btnSelect, Events.ON_CLICK);
        lbResults.appendChild(item);
        String pcs[] = s.split("\\^");
        StringBuilder sb = new StringBuilder();

        for (ColumnControl ctrl : lookupParams.colControl) {
            int p = ctrl.piece - 1; // Piece # for column
            String t = p < 0 ? "" : p < pcs.length ? pcs[p] : "";

            if (ctrl.capitalize) {
                t = WordUtils.capitalizeFully(t);
            }

            sb.append(t).append(StrUtil.U);
            new Listcell(t).setParent(item);
        }

        item.setValue(sb.toString());
    }

    int sortCol = lookupParams.sortCol;

    if (sortCol >= 0) {
        ((Listheader) lbResults.getListhead().getChildren().get(sortCol)).sort(true, true);
    }
}

From source file:org.carewebframework.shell.plugins.PluginContainer.java

/**
 * Notify listeners of plugin events.// w w  w .jav  a 2  s  . co  m
 * 
 * @param event The plugin event containing the action.
 */
public void onAction(final PluginEvent event) {
    PluginLifecycleEventException exception = null;
    PluginAction action = event.getAction();
    boolean debug = log.isDebugEnabled();

    if (pluginEventListeners1 != null) {
        for (IPluginEvent listener : new ArrayList<IPluginEvent>(pluginEventListeners1)) {
            try {
                if (debug) {
                    log.debug("Invoking IPluginEvent.on" + WordUtils.capitalizeFully(action.name())
                            + " for listener " + listener);
                }

                switch (action) {
                case LOAD:
                    listener.onLoad(this);
                    continue;

                case UNLOAD:
                    listener.onUnload();
                    continue;

                case ACTIVATE:
                    listener.onActivate();
                    continue;

                case INACTIVATE:
                    listener.onInactivate();
                    continue;
                }
            } catch (Throwable e) {
                exception = createChainedException(action.name(), e, exception);
            }
        }
    }

    if (pluginEventListeners2 != null) {
        for (IPluginEventListener listener : new ArrayList<IPluginEventListener>(pluginEventListeners2)) {
            try {
                if (debug) {
                    log.debug("Delivering " + action.name() + " event to IPluginEventListener listener "
                            + listener);
                }
                listener.onPluginEvent(event);
            } catch (Throwable e) {
                exception = createChainedException(action.name(), e, exception);
            }
        }
    }

    if (action == PluginAction.LOAD) {
        doAfterLoad();
    }

    if (exception != null) {
        throw exception;
    }
}