类java.util.MissingFormatArgumentException源码实例Demo

下面列出了怎么用java.util.MissingFormatArgumentException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: dragonwell8_jdk   文件: GetFormatSpecifier.java
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);
            }
        }
    }
 
源代码2 项目: TencentKona-8   文件: GetFormatSpecifier.java
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);
            }
        }
    }
 
源代码3 项目: native-obfuscator   文件: GetFormatSpecifier.java
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);
            }
        }
    }
 
源代码4 项目: jdk8u60   文件: GetFormatSpecifier.java
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);
            }
        }
    }
 
源代码5 项目: openjdk-jdk8u   文件: GetFormatSpecifier.java
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);
            }
        }
    }
 
源代码6 项目: openjdk-jdk8u-backup   文件: GetFormatSpecifier.java
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);
            }
        }
    }
 
源代码7 项目: openjdk-jdk9   文件: GetFormatSpecifier.java
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);
            }
        }
    }
 
源代码8 项目: jdk8u-jdk   文件: GetFormatSpecifier.java
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);
            }
        }
    }
 
源代码9 项目: starcor.xul   文件: XulLog.java
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;
}
 
源代码10 项目: hottub   文件: GetFormatSpecifier.java
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);
            }
        }
    }
 
源代码11 项目: openjdk-8-source   文件: GetFormatSpecifier.java
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);
            }
        }
    }
 
源代码12 项目: openjdk-8   文件: GetFormatSpecifier.java
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);
            }
        }
    }
 
源代码13 项目: jdk8u_jdk   文件: GetFormatSpecifier.java
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);
            }
        }
    }
 
源代码14 项目: FeatureFu   文件: Operator.java
/**
 * 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;
}
 
源代码15 项目: jdk8u-jdk   文件: GetFormatSpecifier.java
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);
            }
        }
    }
 
源代码16 项目: jdk8u-dev-jdk   文件: GetFormatSpecifier.java
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);
            }
        }
    }
 
源代码17 项目: Moss   文件: MicrosoftTeamsNotifier.java
private String safeFormat(String format, Object... args) {
    try {
        return String.format(format, args);
    } catch (MissingFormatArgumentException e) {
        LOGGER.warn("Exception while trying to format the message. Falling back by using the format string.", e);
        return format;
    }
}
 
private static void checkInvalidVoiceInstructions(RouteOptions routeOptions) {
  Boolean instructions = routeOptions.voiceInstructions();
  boolean invalidVoiceInstructions = instructions == null
    || !instructions;
  if (invalidVoiceInstructions) {
    throw new MissingFormatArgumentException("Using the default milestones requires the "
      + "directions route to be requested with voice instructions enabled.");
  }
}
 
private static void checkInvalidBannerInstructions(RouteOptions routeOptions) {
  Boolean instructions = routeOptions.bannerInstructions();
  boolean invalidBannerInstructions = instructions == null || !instructions;
  if (invalidBannerInstructions) {
    throw new MissingFormatArgumentException("Using the default milestones requires the "
      + "directions route to be requested with banner instructions enabled.");
  }
}
 
@Test(expected = MissingFormatArgumentException.class)
public void validDirectionsRoute_isInvalidWithNullRouteOptions() throws Exception {
  DirectionsRoute route = buildTestDirectionsRoute(DIRECTIONS_WITHOUT_VOICE_INSTRUCTIONS);
  RouteOptions invalidRouteOptions = null;
  route = route.toBuilder().routeOptions(invalidRouteOptions).build();

  ValidationUtils.validDirectionsRoute(route, true);
}
 
源代码21 项目: butterfly   文件: StringFormatTest.java
@Test
public void formatArgumentMismatchTest() {
    StringFormat stringFormat = new StringFormat("This %s is %s");
    assertEquals(stringFormat.getFormat(), "This %s is %s");
    assertEquals(stringFormat.getAttributeNames(), new String[]{});
    assertEquals(stringFormat.getDescription(), "Apply transformation context attributes [] to 'This %s is %s'");

    TUExecutionResult executionResult = stringFormat.execution(transformedAppFolder, transformationContext);
    assertEquals(executionResult.getType(), TUExecutionResult.Type.ERROR);
    assertNull(executionResult.getValue());
    assertEquals(executionResult.getException().getClass(), TransformationUtilityException.class);
    assertEquals(executionResult.getException().getMessage(), "String format and arguments don't match");
    assertEquals(executionResult.getException().getCause().getClass(), MissingFormatArgumentException.class);
    assertEquals(executionResult.getException().getCause().getMessage(), "Format specifier '%s'");
}
 
源代码22 项目: MyHearts   文件: Log.java
public static void i(String msg, Object... args) {
	try {
		if (BuildConfig.DEBUG) 
			android.util.Log.i(TAG, String.format(msg, args));
	} catch (MissingFormatArgumentException e) {
		android.util.Log.e(TAG, "vitamio.Log", e);
		android.util.Log.i(TAG, msg);
	}
}
 
源代码23 项目: MyHearts   文件: Log.java
public static void d(String msg, Object... args) {
	try {
		if (BuildConfig.DEBUG) 
			android.util.Log.d(TAG, String.format(msg, args));
	} catch (MissingFormatArgumentException e) {
		android.util.Log.e(TAG, "vitamio.Log", e);
		android.util.Log.d(TAG, msg);
	}
}
 
源代码24 项目: HPlayer   文件: Log.java
public static void i(String msg, Object... args) {
	try {
		if (BuildConfig.DEBUG) 
			android.util.Log.i(TAG, String.format(msg, args));
	} catch (MissingFormatArgumentException e) {
		android.util.Log.e(TAG, "vitamio.Log", e);
		android.util.Log.i(TAG, msg);
	}
}
 
源代码25 项目: HPlayer   文件: Log.java
public static void d(String msg, Object... args) {
	try {
		if (BuildConfig.DEBUG) 
			android.util.Log.d(TAG, String.format(msg, args));
	} catch (MissingFormatArgumentException e) {
		android.util.Log.e(TAG, "vitamio.Log", e);
		android.util.Log.d(TAG, msg);
	}
}
 
源代码26 项目: video-player   文件: Log.java
public static void i(String msg, Object... args) {
	try {
		if (BuildConfig.DEBUG) 
			android.util.Log.i(TAG, String.format(msg, args));
	} catch (MissingFormatArgumentException e) {
		android.util.Log.e(TAG, "vitamio.Log", e);
		android.util.Log.i(TAG, msg);
	}
}
 
源代码27 项目: video-player   文件: Log.java
public static void d(String msg, Object... args) {
	try {
		if (BuildConfig.DEBUG) 
			android.util.Log.d(TAG, String.format(msg, args));
	} catch (MissingFormatArgumentException e) {
		android.util.Log.e(TAG, "vitamio.Log", e);
		android.util.Log.d(TAG, msg);
	}
}
 
源代码28 项目: NetEasyNews   文件: Log.java
public static void i(String msg, Object... args) {
	try {
		if (BuildConfig.DEBUG) 
			android.util.Log.i(TAG, String.format(msg, args));
	} catch (MissingFormatArgumentException e) {
		android.util.Log.e(TAG, "vitamio.Log", e);
		android.util.Log.i(TAG, msg);
	}
}
 
源代码29 项目: NetEasyNews   文件: Log.java
public static void d(String msg, Object... args) {
	try {
		if (BuildConfig.DEBUG) 
			android.util.Log.d(TAG, String.format(msg, args));
	} catch (MissingFormatArgumentException e) {
		android.util.Log.e(TAG, "vitamio.Log", e);
		android.util.Log.d(TAG, msg);
	}
}
 
源代码30 项目: react-native-android-vitamio   文件: Log.java
public static void i(String msg, Object... args) {
	try {
		if (BuildConfig.DEBUG) 
			android.util.Log.i(TAG, String.format(msg, args));
	} catch (MissingFormatArgumentException e) {
		android.util.Log.e(TAG, "vitamio.Log", e);
		android.util.Log.i(TAG, msg);
	}
}
 
 类所在包
 同包方法