当前位置: 首页>>代码示例>>Java>>正文


Java WordUtils.capitalize方法代码示例

本文整理汇总了Java中org.apache.commons.text.WordUtils.capitalize方法的典型用法代码示例。如果您正苦于以下问题:Java WordUtils.capitalize方法的具体用法?Java WordUtils.capitalize怎么用?Java WordUtils.capitalize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.text.WordUtils的用法示例。


在下文中一共展示了WordUtils.capitalize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resolveOnce

import org.apache.commons.text.WordUtils; //导入方法依赖的package包/类
@Override
protected void resolveOnce() {
	double titles[] = new double[100];
	String cmd[] = new String[]{
		configuration.getMPlayerPath(),
		"-identify",
		"-endpos",
		"0",
		"-ao",
		"null",
		"-vc",
		"null",
		"-vo",
		"null",
		"-dvd-device",
		ProcessUtil.getShortFileNameIfWideChars(file.getAbsolutePath()),
		"dvd://"
	};
	OutputParams params = new OutputParams(configuration);
	params.maxBufferSize = 1;
	params.log = true;
	final ProcessWrapperImpl pw = new ProcessWrapperImpl(cmd, params, true, false);
	Runnable r = new Runnable() {
		@Override
		public void run() {
			try {
				Thread.sleep(10000);
			} catch (InterruptedException e) {
			}
			pw.stopProcess();
		}
	};
	Thread failsafe = new Thread(r, "DVDISO Failsafe");
	failsafe.start();
	pw.runInSameThread();
	List<String> lines = pw.getOtherResults();
	if (lines != null) {
		for (String line : lines) {
			if (line.startsWith("ID_DVD_TITLE_") && line.contains("_LENGTH")) {
				int rank = Integer.parseInt(line.substring(13, line.indexOf("_LENGT")));
				double duration = Double.parseDouble(line.substring(line.lastIndexOf("LENGTH=") + 7));
				titles[rank] = duration;
			} else if (line.startsWith("ID_DVD_VOLUME_ID")) {
				String volumeId = line.substring(line.lastIndexOf("_ID=") + 4).trim();
				if (configuration.isPrettifyFilenames()) {
					volumeId = volumeId.replaceAll("_", " ");
					if (isNotBlank(volumeId) && volumeId.equals(volumeId.toUpperCase(PMS.getLocale()))) {
						volumeId = WordUtils.capitalize(volumeId.toLowerCase(PMS.getLocale()));
					}
				}
				this.volumeId = volumeId;
			}
		}
	}

	double oldduration = -1;

	for (int i = 1; i < 99; i++) {
		/**
		 * Don't take into account titles less than 10 seconds
		 * Also, workaround for the MPlayer bug which reports a unique title with the same length several times
		 * The "maybe wrong" title is taken into account only if its duration is less than 1 hour.
		 * Common-sense is a single video track on a DVD is usually greater than 1h
		 */
		if (titles[i] > 10 && (titles[i] != oldduration || oldduration < 3600)) {
			DVDISOTitle dvd = new DVDISOTitle(file, volumeId, i);
			addChild(dvd);
			oldduration = titles[i];
		}
	}

	if (childrenNumber() > 0) {
		PMS.get().storeFileInCache(file, Format.ISO);
	}

}
 
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:77,代码来源:DVDISOFile.java

示例2: toSource

import org.apache.commons.text.WordUtils; //导入方法依赖的package包/类
public static String toSource(final J48 tree, final String prefix) throws Exception {
        PRINT_ID = 0;
        /** The decision tree */
        final ClassifierTree m_root = (ClassifierTree) getPrivateFieldValue(tree.getClass(), tree, "m_root");
        /** Local model at node. */
//        final ClassifierSplitModel m_localModel = (ClassifierSplitModel) getPrivateFieldValue(m_root.getClass(), m_root, "m_localModel");

        final StringBuilder[] source = toSourceClassifierTree(m_root, prefix);
        final StringBuilder sb = new StringBuilder();
        sb.append("  function getParamFor" + WordUtils.capitalize(prefix) + "(){\n");
        sb.append("    param = [").append(RetailSalePrediction.ATTR.values().length - 1).append("];\n");
        for (RetailSalePrediction.ATTR attr : RetailSalePrediction.ATTR.values()) {
            //для последнего делаем вычисления, поэтому его в параметрах не должно быть
            if (attr.ordinal() != RetailSalePrediction.ATTR.values().length - 1) {
                sb.append("    param[");
                sb.append(attr.ordinal());
                sb.append("] = ");
                sb.append(attr.getFunctionName());
                sb.append("();\n");
            }
        }
        sb.append("    return param;\n");
        sb.append("  }\n");

        sb.append("  function getValueFor" + WordUtils.capitalize(prefix) + "(idx){\n");
        sb.append("    values = [];\n");
        sb.append("    values[0] = 'менее 50';\n");
        sb.append("    values[1] = 'около 50';\n");
        int idx = 2;
        for (final String number : RetailSalePrediction.numbers) {
            for (final String word : RetailSalePrediction.words) {
                sb.append("    values[").append(idx).append("] = '").append(word).append(" ").append(number).append("';\n");
                ++idx;
            }
        }
        sb.append("    return values[idx];\n");
        sb.append("  }\n");

        return sb.toString()
                + "  function " + prefix + "() {\n"
                + "    i = getParamFor" + WordUtils.capitalize(prefix) + "();\n"
                + "    p = " + prefix + "Classify(i);\n"
                + "    return getValueFor" + WordUtils.capitalize(prefix) + "(p);\n"
                + "  }\n"
                + "  function " + prefix + "Classify(i) {\n"
                + "    p = NaN;\n"
                + source[0]  // Assignment code
                + "    return p;\n"
                + "  }\n"
                + source[1]  // Support code
                ;
    }
 
开发者ID:cobr123,项目名称:VirtaMarketAnalyzer,代码行数:53,代码来源:ClassifierToJs.java


注:本文中的org.apache.commons.text.WordUtils.capitalize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。