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


Java Strings类代码示例

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


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

示例1: smallCamel

import joptsimple.internal.Strings; //导入依赖的package包/类
private static String smallCamel(String... name) {

    if (name.length == 1 && isBlank(name[0])) {

      return "root";
    }

    List<String> values = new ArrayList<>();
    for (int i = 0; i < name.length; i++) {
      String s = name[i];
      NameFixer format = NameFixer.CAMEL_LOWER;
      values.add(buildPart(i, s, format));
    }

    return Strings.join(values, "");
  }
 
开发者ID:mulesoft-labs,项目名称:raml-java-tools,代码行数:17,代码来源:Names.java

示例2: buildJavaFriendlyName

import joptsimple.internal.Strings; //导入依赖的package包/类
/**
 * <p>
 * buildJavaFriendlyName.
 * </p>
 *
 * @param source a {@link String} object.
 * @return a {@link String} object.
 */
private static String buildJavaFriendlyName(final String source, NameFixer format,
                                            int currentIndex) {
  final String baseName =
      source.replaceAll("\\W+", "_").replaceAll("^_+", "").replaceAll("[^\\w_]", "");
  List<String> friendlyNameBits = new ArrayList<>();
  int i = currentIndex;
  for (String s : baseName.split("_")) {

    if (s.isEmpty()) {
      continue;
    }

    String friendlyName = firstOrOthers(format, i, s);

    if (isDigits(left(friendlyName, 1))) {

      friendlyName = "_" + friendlyName;
    }

    friendlyNameBits.add(friendlyName);
    i++;
  }

  return Strings.join(friendlyNameBits, "");
}
 
开发者ID:mulesoft-labs,项目名称:raml-java-tools,代码行数:34,代码来源:Names.java

示例3: toString

import joptsimple.internal.Strings; //导入依赖的package包/类
@Override
public String toString() {
    StringBuilder builder = new StringBuilder();
    builder.append("MethodTransformer [");
    builder.append(getMethod() != null ? getMethod().toString()  : "null");
    builder.append("] ");
    if(tasks.isEmpty()) builder.append("No transform tasks");
    else {
        builder.append("Found ");
        builder.append(tasks.size());
        builder.append(" transform tasks: ");
        Iterator<TaskElement> it = tasks.iterator();
        while (it.hasNext()) {
            TaskElement next = it.next();
            String desc = next.getMethod().getDeclaredAnnotation(Inject.class).description();
            if(!Strings.isNullOrEmpty(desc)) {
                builder.append(desc);
            }
            if(it.hasNext()) builder.append(", ");
        }
    }
    return builder.toString();
}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:24,代码来源:MethodTransformer.java

示例4: lookup

import joptsimple.internal.Strings; //导入依赖的package包/类
@Override
protected Field lookup() throws Exception {
    for(State state : State.values()) {
        String n = name.getByState(state);
        if(!Strings.isNullOrEmpty(n)) try {
                Field f = insideClass.getDeclaredField(n);
                f.setAccessible(true);
                if(stripFinal) {
                    Field modifiersField = Field.class.getDeclaredField("modifiers");
                    modifiersField.setAccessible(true);
                    modifiersField.setInt(f, f.getModifiers() & ~Modifier.FINAL);
                }
                return f;
        } catch (Exception e) {
            ;
        }
    }
    return null;
}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:20,代码来源:FastField.java

示例5: onClientChat

import joptsimple.internal.Strings; //导入依赖的package包/类
@SubscribeEvent
public void onClientChat(ClientChatReceivedEvent event) {
    String message = ( event.getMessage().getUnformattedText() );
     if (message.contains(search.get()) && !message.startsWith(MC.getSession().getUsername() )) {
         String append;
         switch (mode.get().toUpperCase()) {
             case "REPLY":
                 append = "/w ";
                 break;
             case "CHAT":
             default:
                 append = Strings.EMPTY;
                 break;
         }
         getLocalPlayer().sendChatMessage(append + reply.get());
     }
}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:18,代码来源:AutoReply.java

示例6: extract

import joptsimple.internal.Strings; //导入依赖的package包/类
private static boolean extract(String message, Pattern[] patterns, BiConsumer<GameProfile, String> callback) {
    for(Pattern pattern : patterns) {
        Matcher matcher = pattern.matcher(message);
        if (matcher.find()) {
            final String messageSender = matcher.group(1);
            final String messageOnly = matcher.group(2);
            if (!Strings.isNullOrEmpty(messageSender)) {
                for (NetworkPlayerInfo data : getLocalPlayer().connection.getPlayerInfoMap()) {
                    if (String.CASE_INSENSITIVE_ORDER.compare(messageSender, data.getGameProfile().getName()) == 0) {
                        callback.accept(data.getGameProfile(), messageOnly);
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:19,代码来源:ChatIdentifierService.java

示例7: onTick

import joptsimple.internal.Strings; //导入依赖的package包/类
@SubscribeEvent
public void onTick(LocalPlayerUpdateEvent event) {
    if(!SENDING.isEmpty() && System.currentTimeMillis() > nextSendMs) {
        SENDING.stream()
                .filter(msg -> {
                    if(!Strings.isNullOrEmpty(msg.getType())) {
                        long time = customDelays.getOrDefault(msg.getType(), new AtomicLong(0)).get();
                        return System.currentTimeMillis() > time;
                    } else
                        return true;
                })
                .sorted()
                .findFirst()
                .ifPresent(msg -> {
                    getLocalPlayer().sendChatMessage(msg.getMessage());
                    customDelays.computeIfAbsent(msg.getType(), t -> new AtomicLong(0L))
                            .set(System.currentTimeMillis() + msg.getDelay());
                    nextSendMs = System.currentTimeMillis() + delay.get();
                    SENDING.remove(msg);
                });
    }
}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:23,代码来源:SpamService.java

示例8: processChildren

import joptsimple.internal.Strings; //导入依赖的package包/类
protected boolean processChildren(@Nonnull String[] args) throws CommandExecuteException, NullPointerException {
    if (args.length > 0) {
        final String lookup = (args[0] != null ? args[0] : Strings.EMPTY).toLowerCase();
        Command child = getChild(lookup);
        if(child != null) { // perfect match, use this
            child.run(CommandHelper.forward(args));
            return true;
        } else { // no match found, try and infer
            List<Command> results = children.stream()
                    .filter(cmd -> cmd.getName().toLowerCase().startsWith(lookup))
                    .collect(Collectors.toList());

            if(results.size() == 1) { // if found 1 result, use that
                results.get(0).run(CommandHelper.forward(args));
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:21,代码来源:Command.java

示例9: validate

import joptsimple.internal.Strings; //导入依赖的package包/类
/**
 * Verifies that String and numeric values are within their allowed ranges, then ensures that term vectors are
 * properly enabled on the target index.
 * 
 * @param query
 *            the String query to expand
 * @param fbDocs
 *            the int number of feedback documents
 * @param fbTerms
 *            the int number of feedback terms
 * @return the String error message, or null if no errors are encountered
 * @throws IOException
 *             if the indexMetaData fails to deserialize into a map
 */
public String validate(String query, int fbDocs, int fbTerms) throws IOException {
    if (Strings.isNullOrEmpty(query)) {
        return NULL_QUERY_ERROR;
    } else if (fbDocs < 1) {
        return INVALID_FB_DOCS_ERROR;
    } else if (fbTerms < 1) {
        return INVALID_FB_TERMS_ERROR;
    } else if (Strings.isNullOrEmpty(index)) {
        return NULL_INDEX_ERROR;
    } else if (Strings.isNullOrEmpty(type)) {
        return NULL_TYPE_ERROR;
    } else if (Strings.isNullOrEmpty(field)) {
        return NULL_FIELD_ERROR;
    } else if (ALPHA_BETA_MIN > alpha || alpha > ALPHA_BETA_MAX) {
        return INVALID_ALPHA_ERROR;
    } else if (ALPHA_BETA_MIN > beta || beta > ALPHA_BETA_MAX) {
        return INVALID_BETA_ERROR;
    } else if (K1_MIN > k1 || k1 > K1_MAX) {
        return INVALID_K1_ERROR;
    } else if (B_MIN > b || b > B_MAX) {
        return INVALID_B_ERROR;
    }
    return this.ensureTermVectors();
}
 
开发者ID:biocaddie,项目名称:elasticsearch-queryexpansion-plugin,代码行数:39,代码来源:Rocchio.java

示例10: execute

import joptsimple.internal.Strings; //导入依赖的package包/类
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
	EntityPlayerMP player = CommandBase.getCommandSenderAsPlayer(sender);
	
	if(args.length == 0) {
		throw new WrongUsageException("No parameters given!");
	}
	
	String newName = Strings.join(args, " ").trim();
	
	if(newName.isEmpty()) {
		return;
	}
	
	ItemStack itemStack = player.getHeldItemMainhand();
	
	if(itemStack != null) {
		itemStack.setStackDisplayName(newName);
	}
}
 
开发者ID:tiffit,项目名称:TaleCraft,代码行数:21,代码来源:RenameCommand.java

示例11: write

import joptsimple.internal.Strings; //导入依赖的package包/类
private void write(HttpServletResponse response, List<String> missed, byte[] png, String renderer) throws IOException {
	if (rendererHeader) {
		response.setHeader("X-Visage-Renderer", renderer);
	}
	response.setContentType("image/png");
	response.setContentLength(png.length);
	if (cacheHeader) {
		if (missed.isEmpty()) {
			response.setHeader("X-Visage-Cache-Miss", "none");
		} else {
			response.setHeader("X-Visage-Cache-Miss", Strings.join(missed, ", "));
		}
	}
	response.getOutputStream().write(png);
	response.getOutputStream().flush();
	response.setStatus(200);
	response.flushBuffer();
}
 
开发者ID:surgeplay,项目名称:Visage,代码行数:19,代码来源:VisageHandler.java

示例12: formattedHelpOutput

import joptsimple.internal.Strings; //导入依赖的package包/类
private String formattedHelpOutput() {
  StringBuilder formatted = new StringBuilder();

  formatted.append(LINE_SEPARATOR);

  String commandsDisplay = commandRows.render();
  if (!Strings.isNullOrEmpty(commandsDisplay)) {
    formatted.append(commandsDisplay)
      .append(LINE_SEPARATOR)
      .append(LINE_SEPARATOR);
  }

  formatted.append(optionRows.render());

  formatted.append(LINE_SEPARATOR);

  return formatted.toString();
}
 
开发者ID:joesteele,项目名称:tissue,代码行数:19,代码来源:TissueHelpFormatter.java

示例13: createDocString

import joptsimple.internal.Strings; //导入依赖的package包/类
private static String createDocString(IMethodDescription desc) {
	// (arg:type[, optionArg:type]):resultType -- Description

	List<String> args = Lists.newArrayList();

	for (IArgumentDescription arg : desc.arguments())
		args.add(arg.name() + ":" + decorate(arg.type().describe(), arg));

	final IScriptType returnTypes = desc.returnTypes();

	String argsJoined = Joiner.on(',').join(args);
	String argsAndResult;
	if (TypeHelper.isVoid(returnTypes)) {
		argsAndResult = String.format("(%s)", argsJoined);
	} else {
		final String ret = returnTypes.describe();
		argsAndResult = String.format("(%s):%s", argsJoined, ret);
	}

	return !Strings.isNullOrEmpty(desc.description())? argsAndResult + " -- " + desc.description() : argsAndResult;
}
 
开发者ID:OpenMods,项目名称:OpenPeripheral,代码行数:22,代码来源:DocUtils.java

示例14: createPeripheralHelpText

import joptsimple.internal.Strings; //导入依赖的package包/类
public static String createPeripheralHelpText(Class<? extends Object> cls, String type, IMethodMap methods) {
	StringBuilder builder = new StringBuilder();
	builder.append("----OpenPeripheral doc----\n");
	builder.append("Peripheral type: ");
	builder.append(type);
	builder.append("\n\n");

	final String docText = DOC_TEXT_CACHE.getOrCreate(cls);
	if (!Strings.isNullOrEmpty(docText)) {
		builder.append(docText);
		builder.append("\n\n");
	}

	builder.append("---Methods---\n");

	listMethods(builder, methods);

	return builder.toString();
}
 
开发者ID:OpenMods,项目名称:OpenPeripheral,代码行数:20,代码来源:DocUtils.java

示例15: typeName

import joptsimple.internal.Strings; //导入依赖的package包/类
public static String typeName(String... name) {
  if (name.length == 1 && isBlank(name[0])) {

    return "Root";
  }

  List<String> values = new ArrayList<>();
  int i = 0;
  for (String s : name) {
    String value = buildPart(i, s, NameFixer.CAMEL_UPPER);
    values.add(value);
    i++;
  }
  return Strings.join(values, "");
}
 
开发者ID:mulesoft-labs,项目名称:raml-java-tools,代码行数:16,代码来源:Names.java


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