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


Java MissingFormatArgumentException类代码示例

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


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

示例1: main

import java.util.MissingFormatArgumentException; //导入依赖的package包/类
public static void main(String[] args) {

        // Use the format specifier below, which should throw a
        // MissingFormatArgumentException. Then, use getFormatSpecifier()
        // to make sure the returned value equals the original format string.
        final String formatSpecifier = "%1$5.3s";
        try {
            String formatResult = String.format(formatSpecifier);
            fail("MissingFormatArgumentException not thrown.");
        } catch (MissingFormatArgumentException ex) {
            final String returnedFormatSpecifier = ex.getFormatSpecifier();
            if (!returnedFormatSpecifier.equals(formatSpecifier)) {
                fail("The specified format specifier: " + formatSpecifier
                        + " does not match the value from getFormatSpecifier(): "
                        + returnedFormatSpecifier);
            }
        }
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:GetFormatSpecifier.java

示例2: getFormatMsg

import java.util.MissingFormatArgumentException; //导入依赖的package包/类
private static String getFormatMsg(String msg, Object[] args) {
    String result = "";

    if (msg == null) {
        msg = "<null>";
    } else {
        try {
            result = String.format(msg, args);
        } catch (MissingFormatArgumentException e) {
        }
    }

    // 简单判断是否格式化正确
    if (TextUtils.isEmpty(result.trim()) || !result
            .contains(XulSystemUtil.objectToString(args[args.length - 1]))) {
        StringBuilder builder = new StringBuilder(msg);
        for (Object arg : args) {
            builder.append(" ").append(XulSystemUtil.objectToString(arg));
        }
        result = builder.toString();
    }

    return result;
}
 
开发者ID:starcor-company,项目名称:starcor.xul,代码行数:25,代码来源:XulLog.java

示例3: processCommand

import java.util.MissingFormatArgumentException; //导入依赖的package包/类
public static boolean processCommand(String raw) {
    if (Minecraft.getMinecraft().thePlayer == null || !OptionCore.CLIENT_CHAT_PACKETS.getValue()) return false;
    if (raw.contains(CommandType.PREFIX) && raw.contains(CommandType.SUFFIX)) {
        final Command command;
        try {
            command = new Command(raw);
        } catch (MissingFormatArgumentException e) {
            return false;
        }
        if (command.type != null) {
            if (!command.from.equals(StaticPlayerHelper.getName(Minecraft.getMinecraft()))) command.activate();
            return true;
        }
    }
    return false;
}
 
开发者ID:Tencao,项目名称:SAO-UI---1.8.8,代码行数:17,代码来源:Command.java

示例4: referMapping

import java.util.MissingFormatArgumentException; //导入依赖的package包/类
@Override
public List<String> referMapping(Mapping mapping) {
	final List<String> commands = new LinkedList<>();

	for (String regex : mapping.value()) {
		regex = regex.replace(DASH, " ").replace(SPACE, " ");

		try {
			final String format = regex.replaceAll("\\(.*?\\)", "%s").replace("\\", "");

			commands.add(String.format(format, mapping.args()));
		} catch (MissingFormatArgumentException e) {
			commands.add(regex);
		}
	}

	return commands;
}
 
开发者ID:Cognifide,项目名称:APM,代码行数:19,代码来源:BasicActionMapper.java

示例5: parseOperands

import java.util.MissingFormatArgumentException; //导入依赖的package包/类
/**
 * Use polymorphism here, this is actually being called by Operator implementations, where they know their number of operands
 * @param operands    operands in list of strings
 * @param variableRegistry  registry for registering possible variables found in operands
 * @return operands in List of Expr
 */
protected List<Expr> parseOperands(List<String> operands, VariableRegistry variableRegistry) {
  ArrayList<Expr> list = new ArrayList<Expr>();

  final int numOperands = this.numberOfOperands();

  if (operands.size() != numOperands) {
    throw new MissingFormatArgumentException(
        this.getSymbol() + " expect " + numOperands + " operands, actual number of operands is: " + operands.size());
  }

  for (int i = 0; i < numOperands; i++) {
    list.add(Expression.parse(operands.get(i), variableRegistry));
  }

  return list;
}
 
开发者ID:linkedin,项目名称:FeatureFu,代码行数:23,代码来源:Operator.java

示例6: replicateList

import java.util.MissingFormatArgumentException; //导入依赖的package包/类
/**
 * Replicates a string pattern based on a list of objects, generating a list
 * as result.
 * @param pattern The string pattern.
 * @param values The list of objects to be merged with the pattern.
 * @return A list containing the string pattern replicated to each object
 * from the list.
 * @throws NightingaleException Something wrong happened, to be caught in
 * the higher levels.
 */
public static List<Object> replicateList(String pattern,
        List<Object> values) throws NightingaleException {
    List<Object> result = new ArrayList<Object>();
    for (Object value : values) {
        try {
            result.add(String.format(pattern, value));
        } catch (MissingFormatArgumentException exception) {
            throw new NightingaleException(
                    messages.getMessage(
                            Messages.ERROR_REPLICATELIST_MISSING_FORMAT_ARGUMENTS_EXCEPTION
                    ),
                    exception
            );
        }
    }
    return result;
}
 
开发者ID:cereda,项目名称:nightingale,代码行数:28,代码来源:CommonUtils.java

示例7: format

import java.util.MissingFormatArgumentException; //导入依赖的package包/类
public ArgumentFormatter format(Map<String, ? extends Object> mapper) {
	if (hasFormatted())
		return this;
	StringBuilder sb = new StringBuilder(formatted);
	while(true) {
		int start = sb.indexOf("{");
		int end = sb.indexOf("}");
		if (start < 0 || end < 0) {
			break;
			
		}
		String key = sb.substring(start + 1, end);
		Object value = mapper.get(key);
		if (value == null) {
			throw new MissingFormatArgumentException("Format specifier '" + key + "'");
		}
		sb.replace(start, end + 1, value.toString());
	}
	/* update */
	this.formatted = sb;
	this.hasFormatted = true;
	return this;
}
 
开发者ID:int32bit,项目名称:openstack-java-sdk,代码行数:24,代码来源:ArgumentFormatter.java

示例8: launchSettlementNotAllowedTest

import java.util.MissingFormatArgumentException; //导入依赖的package包/类
@Test
(expected = MissingFormatArgumentException.class)
public void launchSettlementNotAllowedTest() throws Exception {
    String aggregatorId = "[email protected]";
    String providerId = "[email protected]";
    String productClass = "productClass";

    RSUser user = new RSUser();
    user.setDisplayName("username");
    user.setEmail("[email protected]");

    when(userManager.getCurrentUser()).thenReturn(user);
    when(userManager.isAdmin()).thenReturn(false);

    Response response = toTest.launchSettlement(aggregatorId, providerId, productClass);
}
 
开发者ID:conwetlab,项目名称:fiware-rss,代码行数:17,代码来源:SettlementServiceTest.java

示例9: getCDRsNotAdmin2Test

import java.util.MissingFormatArgumentException; //导入依赖的package包/类
@Test
(expected = MissingFormatArgumentException.class)
public void getCDRsNotAdmin2Test() throws Exception {
    String aggregatorId = "[email protected]";
    String providerId = "[email protected]";
    String userId = "[email protected]";

    RSUser user = new RSUser();
    user.setDisplayName("username");
    user.setEmail("[email protected]");

    List <CDR> list = new LinkedList<>();

    when(userManager.getCurrentUser()).thenReturn(user);
    when(userManager.isAdmin()).thenReturn(false);
    when(cdrsManager.getCDRs(userId, providerId)).thenReturn(list);

    Response response = toTest.getCDRs(aggregatorId, providerId);
    Assert.assertEquals(list, response.getEntity());
}
 
开发者ID:conwetlab,项目名称:fiware-rss,代码行数:21,代码来源:CdrsServiceTest.java

示例10: createRSSModelNotAllowedTest

import java.util.MissingFormatArgumentException; //导入依赖的package包/类
@Test
(expected = MissingFormatArgumentException.class)
public void createRSSModelNotAllowedTest() throws Exception {
    RSSModel model = new RSSModel();
    model.setAggregatorId("[email protected]");
    RSSModel returnedModel = new RSSModel();

    RSUser user = new RSUser();
    user.setDisplayName("username");
    user.setEmail("[email protected]");

    when(userManager.isAdmin()).thenReturn(false);
    when(userManager.getCurrentUser()).thenReturn(user);
    when(rssModelsManager.createRssModel(model)).thenReturn(returnedModel);

    toTest.createRSSModel(model);
}
 
开发者ID:conwetlab,项目名称:fiware-rss,代码行数:18,代码来源:RSSModelServiceTest.java

示例11: getRssModelsNotAllowedTest

import java.util.MissingFormatArgumentException; //导入依赖的package包/类
@Test
(expected = MissingFormatArgumentException.class)
public void getRssModelsNotAllowedTest() throws Exception {
    String appProviderId = "[email protected]";
    String productClass = "productClass";
    String aggregatorId = "[email protected]";

    RSUser user = new RSUser();
    user.setDisplayName("username");
    user.setEmail("[email protected]");

    List<RSSModel> rssModels = new LinkedList<>();

    when(userManager.getCurrentUser()).thenReturn(user);
    when(userManager.isAdmin()).thenReturn(false);
    when(rssModelsManager.getRssModels(aggregatorId, appProviderId, productClass)).thenReturn(rssModels);

    Response response = toTest.getRssModels(appProviderId, productClass, aggregatorId);


}
 
开发者ID:conwetlab,项目名称:fiware-rss,代码行数:22,代码来源:RSSModelServiceTest.java

示例12: modifyRSSModelNotAllowedTest

import java.util.MissingFormatArgumentException; //导入依赖的package包/类
@Test
(expected = MissingFormatArgumentException.class)
public void modifyRSSModelNotAllowedTest() throws Exception {
    RSSModel model = new RSSModel();
    model.setAggregatorId("[email protected]");

    RSUser user = new RSUser();
    user.setDisplayName("username");
    user.setEmail("[email protected]");

    when(userManager.getCurrentUser()).thenReturn(user);
    when(userManager.isAdmin()).thenReturn(false);
    when(rssModelsManager.updateRssModel(model)).thenReturn(model);

    toTest.modifyRSSModel(model);
}
 
开发者ID:conwetlab,项目名称:fiware-rss,代码行数:17,代码来源:RSSModelServiceTest.java

示例13: createProviderNotAdminTest

import java.util.MissingFormatArgumentException; //导入依赖的package包/类
@Test
(expected = MissingFormatArgumentException.class)
public void createProviderNotAdminTest() throws Exception {
    String aggregatorId = "[email protected]";
    String providerId = "[email protected]";
    String providerName = "providerName";

    RSSProvider provider = new RSSProvider();
    provider.setAggregatorId(aggregatorId);
    provider.setProviderId(providerId);
    provider.setProviderName(providerName);

    RSUser user = new RSUser();
    user.setDisplayName("username");
    user.setEmail("[email protected]");

    when(userManager.getCurrentUser()).thenReturn(user);
    when(userManager.isAdmin()).thenReturn(false);

    toTest.createProvider(provider);
}
 
开发者ID:conwetlab,项目名称:fiware-rss,代码行数:22,代码来源:ProviderServiceTest.java

示例14: getProvidersNotAllowedTest

import java.util.MissingFormatArgumentException; //导入依赖的package包/类
@Test
(expected = MissingFormatArgumentException.class)
public void getProvidersNotAllowedTest() throws Exception {
    String queryId = "[email protected]";
    String userId = "[email protected]";

    RSUser user = new RSUser();
    user.setDisplayName("username");
    user.setEmail(userId);

    List <RSSProvider> providers = new LinkedList<>();

    when(userManager.getCurrentUser()).thenReturn(user);
    when(userManager.isAdmin()).thenReturn(false);

    toTest.getProviders(queryId);
}
 
开发者ID:conwetlab,项目名称:fiware-rss,代码行数:18,代码来源:ProviderServiceTest.java

示例15: getArgument

import java.util.MissingFormatArgumentException; //导入依赖的package包/类
private FormattedString getArgument(FormattedString[] args, int index,
        FormatSpecifierParser fsp,
        FormattedString lastArgument, boolean hasLastArgumentSet) {
    if (index == FormatToken.LAST_ARGUMENT_INDEX && !hasLastArgumentSet) {
        throw new MissingFormatArgumentException("<");
    }

    if (args == null) {
        return null;
    }

    if (index >= args.length) {
        throw new MissingFormatArgumentException(fsp.getFormatSpecifierText());
    }

    if (index == FormatToken.LAST_ARGUMENT_INDEX) {
        return lastArgument;
    }

    return args[index];
}
 
开发者ID:tilal6991,项目名称:HoloIRC,代码行数:22,代码来源:Formatter.java


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