當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。