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


Java WordUtils类代码示例

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


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

示例1: provideExtractorForValue

import org.apache.commons.lang3.text.WordUtils; //导入依赖的package包/类
private <T> ValueExtractor provideExtractorForValue(Class<T> clazz, int target, List<String> chainOfProperties) {
    Class<?> propertyClass = clazz;
    List<ValueExtractor> chainedExtractors = Lists.newArrayList();

    for (String property : chainOfProperties) {
        Class<?> finalPropertyClass = propertyClass;

        Optional<Method> matchingMethod = Stream.of(property,
                "get" + WordUtils.capitalize(property),
                "is" + WordUtils.capitalize(property))
                .map(token -> MethodUtils.getMatchingMethod(finalPropertyClass, token))
                .findFirst();

        Method method = matchingMethod.orElseThrow(
                () -> new InvalidQueryException(
                        String.format("Cannot find appropriate method for property [%s] on class [%s]",
                                property, finalPropertyClass)));

        ReflectionExtractor extractor = new ReflectionExtractor(method.getName());
        chainedExtractors.add(extractor);
        propertyClass = method.getDeclaringClass();
    }

    return new ChainedExtractor(chainedExtractors.toArray(new ValueExtractor[chainedExtractors.size()]));
}
 
开发者ID:michalwojciechowski,项目名称:coherence-sql,代码行数:26,代码来源:ReflectionExtractorFactory.java

示例2: getSingleItemDescription

import org.apache.commons.lang3.text.WordUtils; //导入依赖的package包/类
@Override
protected String getSingleItemDescription(String expression) {
    String exp = expression;
    if (expression.contains("#")) {
        exp = expression.substring(0, expression.indexOf("#"));
    } else if (expression.contains("L")) {
        exp = exp.replace("L", "");
    }
    if (StringUtils.isNumeric(exp)) {
        int dayOfWeekNum = Integer.parseInt(exp);
        boolean isZeroBasedDayOfWeek = (options == null || options.isZeroBasedDayOfWeek());
        boolean isInvalidDayOfWeekForSetting = (options != null && !options.isZeroBasedDayOfWeek() && dayOfWeekNum <= 1);
        if (isInvalidDayOfWeekForSetting || (isZeroBasedDayOfWeek && dayOfWeekNum == 0)) {
            return DateAndTimeUtils.getDayOfWeekName(7);
        } else if (options != null && !options.isZeroBasedDayOfWeek()) {
            dayOfWeekNum -= 1;
        }
        return DateAndTimeUtils.getDayOfWeekName(dayOfWeekNum);
    } else {
        DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("EEE").withLocale(Locale.ENGLISH);
        return dateTimeFormatter.parseDateTime(WordUtils.capitalizeFully(exp)).dayOfWeek().getAsText(I18nMessages.getCurrentLocale());
    }
}
 
开发者ID:quanticc,项目名称:sentry,代码行数:24,代码来源:DayOfWeekDescriptionBuilder.java

示例3: initGui

import org.apache.commons.lang3.text.WordUtils; //导入依赖的package包/类
@Override
public void initGui() {
    super.initGui();

    if (searchGui != null) {
        inventorySlots.getSlot(editingSlot).putStack(searchGui.getSearchStack());
        NetworkHandler.sendToServer(new PacketSetLogisticsFilterStack(logistics, searchGui.getSearchStack(), editingSlot));
        searchGui = null;
    }
    if (fluidSearchGui != null && fluidSearchGui.getFilter() != null) {
        FluidStack filter = new FluidStack(fluidSearchGui.getFilter(), 1000);
        logistics.setFilter(editingSlot, filter);
        NetworkHandler.sendToServer(new PacketSetLogisticsFluidFilterStack(logistics, filter, editingSlot));
        fluidSearchGui = null;
    }
    String invisibleText = I18n.format("gui.logistic_frame.invisible");
    addWidget(invisible = new GuiCheckBox(9, guiLeft + xSize - 15 - fontRenderer.getStringWidth(invisibleText), guiTop + 7, 0xFF404040, invisibleText));
    invisible.setTooltip(Arrays.asList(WordUtils.wrap(I18n.format("gui.logistic_frame.invisible.tooltip"), 40).split(System.getProperty("line.separator"))));
    addWidget(new WidgetLabel(guiLeft + 8, guiTop + 18, I18n.format(String.format("gui.%s.filters", SemiBlockManager.getKeyForSemiBlock(logistics)))));
    addWidget(new WidgetLabel(guiLeft + 8, guiTop + 90, I18n.format("gui.logistic_frame.liquid")));
    for (int i = 0; i < 9; i++) {
        addWidget(new WidgetFluidStack(i, guiLeft + i * 18 + 8, guiTop + 101, logistics.getTankFilter(i)));
    }
    addInfoTab(I18n.format("gui.tab.info." + SemiBlockManager.getKeyForSemiBlock(logistics)));
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:26,代码来源:GuiLogisticsBase.java

示例4: addTooltip

import org.apache.commons.lang3.text.WordUtils; //导入依赖的package包/类
@Override
public void addTooltip(int mouseX, int mouseY, List<String> curTip, boolean shiftPressed) {
    super.addTooltip(mouseX, mouseY, curTip, shiftPressed);
    for (IGuiWidget widget : widgets) {
        if (widget.getBounds().contains(mouseX, mouseY)) {
            widget.addTooltip(mouseX, mouseY, curTip, shiftPressed);
        }
    }
    boolean isInBounds = false;
    for (Rectangle rect : tooltipRectangles) {
        if (rect.contains(mouseX, mouseY)) {
            isInBounds = true;
        }
    }
    if (!isInBounds) {
        curTip.add(I18n.format("gui.amadron.amadronWidget.selling", getStringForObject(offer.getOutput())));
        curTip.add(I18n.format("gui.amadron.amadronWidget.buying", getStringForObject(offer.getInput())));
        curTip.add(I18n.format("gui.amadron.amadronWidget.vendor", offer.getVendor()));
        curTip.add(I18n.format("gui.amadron.amadronWidget.inBasket", shoppingAmount));
        if (offer.getStock() >= 0) curTip.add(I18n.format("gui.amadron.amadronWidget.stock", offer.getStock()));
        if (offer.getVendor().equals(PneumaticCraftRepressurized.proxy.getPlayer().getName())) {
            curTip.addAll(Arrays.asList(WordUtils.wrap(I18n.format("gui.amadron.amadronWidget.sneakRightClickToRemove"), 40).split(System.getProperty("line.separator"))));
        }
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:26,代码来源:WidgetAmadronOffer.java

示例5: addInformation

import org.apache.commons.lang3.text.WordUtils; //导入依赖的package包/类
/**
 * allows items to add custom lines of information to the mouseover description
 */
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack remote, World world, List<String> curInfo, ITooltipFlag moreInfo) {
    super.addInformation(remote, world, curInfo, moreInfo);
    curInfo.add(I18n.format("gui.remote.tooltip.sneakRightClickToEdit"));
    NBTTagCompound tag = remote.getTagCompound();
    if (tag != null && tag.hasKey("securityX")) {
        int x = tag.getInteger("securityX");
        int y = tag.getInteger("securityY");
        int z = tag.getInteger("securityZ");
        int dimensionId = tag.getInteger("securityDimension");
        Collections.addAll(curInfo, WordUtils.wrap(I18n.format("gui.remote.tooltip.boundToSecurityStation", dimensionId, x, y, z), 40).split(System.getProperty("line.separator")));
    } else {
        Collections.addAll(curInfo, WordUtils.wrap(I18n.format("gui.remote.tooltip.rightClickToBind"), 40).split(System.getProperty("line.separator")));
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:20,代码来源:ItemRemote.java

示例6: renderExtraInfo

import org.apache.commons.lang3.text.WordUtils; //导入依赖的package包/类
@Override
public void renderExtraInfo() {
    if (getExtraStringInfo() != null) {
        GL11.glPushMatrix();
        GL11.glScaled(0.5, 0.5, 0.5);
        FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
        String[] splittedInfo = WordUtils.wrap(getExtraStringInfo(), 40).split(System.getProperty("line.separator"));
        for (int i = 0; i < splittedInfo.length; i++) {
            int stringLength = fr.getStringWidth(splittedInfo[i]);
            int startX = getWidth() / 2 - stringLength / 4;
            int startY = getHeight() / 2 - (fr.FONT_HEIGHT + 1) * (splittedInfo.length - 1) / 4 + (fr.FONT_HEIGHT + 1) * i / 2 - fr.FONT_HEIGHT / 4;
            Gui.drawRect(startX * 2 - 1, startY * 2 - 1, startX * 2 + stringLength + 1, startY * 2 + fr.FONT_HEIGHT + 1, 0xFFFFFFFF);
            fr.drawString(splittedInfo[i], startX * 2, startY * 2, 0xFF000000);
        }
        GL11.glPopMatrix();
        GL11.glColor4d(1, 1, 1, 1);
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:19,代码来源:ProgWidget.java

示例7: register

import org.apache.commons.lang3.text.WordUtils; //导入依赖的package包/类
public void register(String eventName, ScriptEventHandler handler) {
    Class<? extends Event> eventClass = null;
    for (String eventPackage : eventPackages) {
        try {
            eventClass = Class.forName(eventPackage + "." + WordUtils.capitalize(eventName) + "Event").asSubclass(Event.class);
            break;
        } catch (ClassNotFoundException e) {
        }
    }

    if (eventClass == null) {
        throw new RuntimeException("Event class not found: " + eventName);
    }

    entries.add(new EventHandlerEntry(eventClass, handler));
}
 
开发者ID:GloriousEggroll,项目名称:quorrabot,代码行数:17,代码来源:ScriptEventManager.java

示例8: setupAbilitiesMenu

import org.apache.commons.lang3.text.WordUtils; //导入依赖的package包/类
public static void setupAbilitiesMenu(Player player, boolean temporary) {
	String title = temporary ? "Temporary" : "Permanent";
	Inventory inventory = Bukkit.createInventory(player, Convert.getInventorySize(plugin.getAbilityManager().getAbilities().size()),
			ChatColor.BOLD + title + " God Tokens");
	for(Ability ability : plugin.getAbilityManager().getAbilities()) {
		List<String> description = new ArrayList<>(ability.getDescription());
		
		// Adding price depending whetver ability is permanent or temporary
		if(temporary) {
			description.add(ChatColor.GRAY + "Duration: " + ChatColor.RED + "15 minutes");
		}
		int price = temporary ? ability.getTemporaryPrice() : ability.getPermanentPrice();
		String line = ChatColor.GRAY + "Price: " + ChatColor.RED + price + " GT";
		description.add(line);
		
		description.add(ChatColor.GRAY + "Supported items:");
		for(ItemType item : ability.getItems()) {
			description.add(ChatColor.RED + "- " + WordUtils.capitalize(item.toString().replaceAll("_", "").toLowerCase()));
		}
		
		inventory.addItem(ItemStackGenerator.createItem(ability.getIcon(), 0, 0, ChatColor.RED + ability.getName(), description, true));
	}
	player.openInventory(inventory);
}
 
开发者ID:benNek,项目名称:AsgardAscension,代码行数:25,代码来源:GodTokensInventory.java

示例9: setup

import org.apache.commons.lang3.text.WordUtils; //导入依赖的package包/类
public static void setup(Player player) {
	Inventory inv = Bukkit.createInventory(player, Convert.getInventorySize(plugin.getChallengesFile().getChallengesAmount()), ChatColor.BOLD + "Challenges");
	String status = ChatColor.GREEN + " [COMPLETED]";
	int level = plugin.getPlayerManager().getRank(player);
	int prestige = plugin.getPlayerManager().getPrestige(player);
	for(int i = 1; i <= plugin.getChallengesFile().getChallengesAmount(); i++) {
		if(level + 1 == i)
			status = ChatColor.YELLOW + " [CURRENT]";
		else if(i > level)
			status = ChatColor.RED + " [LOCKED]";
		inv.addItem(ItemStackGenerator.createItem(plugin.getChallengesFile().getTypeMaterial(i), 0, 0, ChatColor.GOLD + "" + i + Convert.getOrdinalFor(i) + " challenge" + status,
				Arrays.asList(ChatColor.GRAY + "Type: " + ChatColor.RED + WordUtils.capitalize(plugin.getChallengesFile().getType(i)),
						ChatColor.GRAY + "Cost: " + Convert.toPrice(plugin.getChallengesFile().getPrice(i) * (prestige + 1), true)), true));
	}
	player.openInventory(inv);
}
 
开发者ID:benNek,项目名称:AsgardAscension,代码行数:17,代码来源:ChallengesMenu.java

示例10: annotate

import org.apache.commons.lang3.text.WordUtils; //导入依赖的package包/类
public void annotate(final MethodStep methodStep, final Method m) {

    // resources are not annotated at all, because the resource itself will contain a method
    // that will get into the public API. It is a method with GET annotation and empty path.
    if (!TypeHelper.isResource(methodStep.getReturnType())) {
      final String description = restOperation != null && restOperation.getDescription() != null ? restOperation.getDescription() : WordUtils.capitalize(StringHelper.splitCamelCase(m.getName()));

      getMethod().annotate(ApiOperation.class) //
        .param("value", StringHelper.firstSentence(description))
        .param("notes", description)
      ;

      if (restOperation != null && restOperation.getExternalDocUrl() != null) {
        getMethod().annotate(ExternalDocs.class)
          .param("value", "Reference Guide")
          .param("url", restOperation.getExternalDocUrl())
        ;
      }
    }
  }
 
开发者ID:camunda,项目名称:camunda-bpm-swagger,代码行数:21,代码来源:ApiOperationStep.java

示例11: wrapParagraph

import org.apache.commons.lang3.text.WordUtils; //导入依赖的package包/类
/**
 * A utility method to wrap multiple lines of text, while respecting the original
 * newlines.
 *
 * @param input the String of text to wrap
 * @param width the width in characters into which to wrap the text. Less than 1 is treated as 1
 * @return the original string with newlines added, and starting spaces trimmed
 * so that the resulting lines fit inside a column of with characters.
 */
public static String wrapParagraph(final String input, final int width) {
    if (input == null || input.isEmpty()) {
        return input;
    }
    final StringBuilder out = new StringBuilder();
    try (final BufferedReader bufReader = new BufferedReader(new StringReader(input))) {

        out.append(bufReader.lines()
                .map(line -> WordUtils.wrap(line, width))
                .collect(Collectors.joining("\n")));

    } catch (IOException e) {
        throw new RuntimeException("Unreachable Statement.\nHow did the Buffered reader throw when it was " +
                "wrapping a StringReader?", e);
    }

    //if the last character of the input is a newline, we need to add another newline to conserve that.
    if (input.charAt(input.length() - 1) == '\n') {
        out.append('\n');
    }
    return out.toString();
}
 
开发者ID:broadinstitute,项目名称:barclay,代码行数:32,代码来源:Utils.java

示例12: buildName

import org.apache.commons.lang3.text.WordUtils; //导入依赖的package包/类
private static String buildName( String displayName ) {
    String[] temp = displayName.split( " " );
    StringBuilder newName = new StringBuilder();

    for ( int i = 0; i < temp.length; i++ ) {
        String old = temp[i];
        if ( old.contains( "(" ) ) {
            old = old.replaceAll( "\\(", "" );
            old = old.replaceAll( "\\)", "" );
        }

        String part = WordUtils.capitalize( old.replaceAll( "'", "" ) );
        newName.append( part );
    }

    return newName.toString();
}
 
开发者ID:GoMint,项目名称:GoMint,代码行数:18,代码来源:ItemGenerator.java

示例13: printCommandHelp

import org.apache.commons.lang3.text.WordUtils; //导入依赖的package包/类
public String printCommandHelp(CommandInfo description) {
    StringBuilder sb = new StringBuilder();

    sb.append(String.format("Usage: %s%s\n", Style.bold(Constants.command()),
            Style.bold(description.usage())));
    if (!description.aliases().isEmpty()) {
        sb.append(String.format("%s: %s\n",
                com.atomist.rug.cli.utils.StringUtils.puralize("Alias", "Aliases",
                        description.aliases()),
                Style.bold(
                        StringUtils.collectionToDelimitedString(description.aliases(), ", "))));
    }
    sb.append(String.format("%s.\n", description.description()));

    printOptions(description.globalOptions(), sb, Style.bold("Options"));
    printOptions(description.options(), sb, Style.bold("Command Options"));

    sb.append("\n");
    sb.append(WordUtils.wrap(description.detail(), WRAP));
    sb.append(WordUtils.wrap(HELP_FOOTER, WRAP));

    return sb.toString();

}
 
开发者ID:atomist-attic,项目名称:rug-cli,代码行数:25,代码来源:CommandHelpFormatter.java

示例14: printHelp

import org.apache.commons.lang3.text.WordUtils; //导入依赖的package包/类
public String printHelp(CommandInfoRegistry commandRegistry, GestureRegistry gestureRegistry,
        Options options) {
    StringBuilder sb = new StringBuilder();

    sb.append(String.format("Usage: %s\n",
            Style.bold(Constants.command() + "[OPTION]... [COMMAND]...")));
    sb.append("Work with Rugs like editors or generators.\n");

    printOptions(options, sb, Style.bold("Options"));

    printCommands(sb, commandRegistry);
    printGestures(sb, gestureRegistry);

    sb.append("\n");
    sb.append(String.format("Run '%sCOMMAND --help' for more detailed information on COMMAND.",
            Constants.command()));

    if (Constants.isShell()) {
        sb.append(WordUtils.wrap(SHELL_HELP_FOOTER, WRAP));
    }
    sb.append(WordUtils.wrap(HELP_FOOTER, WRAP));

    return sb.toString();
}
 
开发者ID:atomist-attic,项目名称:rug-cli,代码行数:25,代码来源:CommandHelpFormatter.java

示例15: convertJSONObjectToDirectoryObject

import org.apache.commons.lang3.text.WordUtils; //导入依赖的package包/类
/**
 * This is a generic method that copies the simple attribute values from an
 * argument jsonObject to an argument generic object.
 *
 * @param jsonObject The jsonObject from where the attributes are to be copied.
 * @param destObject The object where the attributes should be copied into.
 * @throws Exception Throws a Exception when the operation are unsuccessful.
 */
public static <T> void convertJSONObjectToDirectoryObject(JSONObject jsonObject, T destObject) throws Exception {

  // Get the list of all the field names.
  Field[] fieldList = destObject.getClass().getDeclaredFields();

  // For all the declared field.
  for (int i = 0; i < fieldList.length; i++) {
    // If the field is of type String, that is
    // if it is a simple attribute.
    if (fieldList[i].getType().equals(String.class)) {
      // Invoke the corresponding set method of the destObject using
      // the argument taken from the jsonObject.
      destObject
        .getClass()
        .getMethod(String.format("set%s", WordUtils.capitalize(fieldList[i].getName())),
          String.class)
        .invoke(destObject, jsonObject.optString(fieldList[i].getName()));
    }
  }
}
 
开发者ID:SonarQubeCommunity,项目名称:sonar-auth-aad,代码行数:29,代码来源:JSONHelper.java


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