use of java.util.UnknownFormatConversionException in project azure-tools-for-java by Microsoft.
the class AbfsUri method parse.
// We assume rawUri is already encoded
public static AbfsUri parse(final String rawUri) {
Matcher matcher;
if (StringUtils.startsWithIgnoreCase(rawUri, "abfs")) {
matcher = ABFS_URI_PATTERN.matcher(rawUri);
} else if (StringUtils.startsWithIgnoreCase(rawUri, "http")) {
matcher = HTTP_URI_PATTERN.matcher(rawUri);
} else {
throw new UnknownFormatConversionException("Unsupported ADLS Gen2 URI Scheme: " + rawUri);
}
if (matcher.matches()) {
AbfsUri abfsUri = new AbfsUri(URI.create(rawUri));
abfsUri.accountName.set(matcher.group("accountName"));
abfsUri.fileSystem.set(matcher.group("fileSystem"));
abfsUri.path.set(URI.create(matcher.group("relativePath")));
return abfsUri;
}
throw new UnknownFormatConversionException("Unmatched ADLS Gen2 URI: " + rawUri);
}
use of java.util.UnknownFormatConversionException in project azure-tools-for-java by Microsoft.
the class AdlUri method parse.
public static AdlUri parse(final String adlUri) {
Matcher matcher;
if (StringUtils.startsWithIgnoreCase(adlUri, "adl")) {
matcher = ADL_URI_PATTERN.matcher(adlUri);
} else if (StringUtils.startsWithIgnoreCase(adlUri, "http")) {
matcher = HTTP_URI_PATTERN.matcher(adlUri);
} else {
throw new UnknownFormatConversionException("Unsupported Azure ADLS Gen 1 URI Scheme: " + adlUri);
}
if (!matcher.matches()) {
throw new UnknownFormatConversionException("Unmatched Azure ADLS Gen 1 URI: " + adlUri);
}
final AdlUri uri = new AdlUri(URI.create(adlUri));
uri.storageName.set(matcher.group("storageName"));
final String pathMatched = matcher.group("path");
final String relativePathMatched = URI.create("/" + (pathMatched == null ? "" : pathMatched)).getPath();
uri.path.set(URI.create(relativePathMatched));
return uri;
}
use of java.util.UnknownFormatConversionException in project binnavi by google.
the class IdaHelpers method createIdaProcess.
/**
* Exports an IDB using BinExport to a .BinExport file. This is a modified version of the code in
* BinNavi, currently only used from BinDiff. It should be refactored so it can be used from both.
*/
public static Process createIdaProcess(final String idaExe, final File idcPath, final String idbFileName, final String outputDirectory) throws IdaException {
final String idcFileString = idcPath.getAbsolutePath();
final String sArgument = getSArgument(idcFileString, SystemHelpers.isRunningWindows());
// Setup the invocation of the IDA to SQL exporter
final ProcessBuilder processBuilder = new ProcessBuilder(idaExe, "-A", "-OExporterModule:" + outputDirectory, sArgument, idbFileName);
// Now launch the exporter to export the IDB to the database
try {
Process processInfo = null;
processBuilder.redirectErrorStream(true);
processInfo = processBuilder.start();
// process blocks, i.e. IDA hangs, so we need to consume them.
try (BufferedReader reader = new BufferedReader(new InputStreamReader(processInfo.getInputStream()))) {
reader.lines().forEach(System.out::println);
} catch (final IOException exception) {
// Ignore
}
return processInfo;
} catch (final Exception exception) {
try {
// TODO: What can we do here ? Do we have a ZyLib-wide logger ?
// CUtilityFunctions.logException(exception);
} catch (final UnknownFormatConversionException e) {
// Some Windows error messages contain %1 characters.
}
throw new IdaException("Failed attempting to launch the importer with IDA: " + exception, exception);
}
}
use of java.util.UnknownFormatConversionException in project j2objc by google.
the class FormatterTest method test_formatLjava_lang_String$Ljava_lang_Object_FloatDoubleBigDecimalConversionException.
/**
* java.util.Formatter#format(String, Object...) for exceptions in
* Float/Double/BigDecimal conversion type 'e', 'E', 'g', 'G', 'f', 'a', 'A'
*/
public void test_formatLjava_lang_String$Ljava_lang_Object_FloatDoubleBigDecimalConversionException() {
Formatter f = null;
final char[] conversions = { 'e', 'E', 'g', 'G', 'f', 'a', 'A' };
final Object[] illArgs = { false, (byte) 1, (short) 2, 3, (long) 4, new BigInteger("5"), new Character('c'), new Object(), new Date() };
for (int i = 0; i < illArgs.length; i++) {
for (int j = 0; j < conversions.length; j++) {
try {
f = new Formatter(Locale.UK);
f.format("%" + conversions[j], illArgs[i]);
fail("should throw IllegalFormatConversionException");
} catch (IllegalFormatConversionException e) {
// expected
}
}
}
try {
f = new Formatter(Locale.UK);
f.format("%a", new BigDecimal(1));
fail("should throw IllegalFormatConversionException");
} catch (IllegalFormatConversionException e) {
// expected
}
try {
f = new Formatter(Locale.UK);
f.format("%A", new BigDecimal(1));
fail("should throw IllegalFormatConversionException");
} catch (IllegalFormatConversionException e) {
// expected
}
final String[] flagsConversionMismatches = { "%,e", "%,E", "%#g", "%#G", "%,a", "%,A", "%(a", "%(A" };
for (int i = 0; i < flagsConversionMismatches.length; i++) {
try {
f = new Formatter(Locale.CHINA);
f.format(flagsConversionMismatches[i], new BigDecimal(1));
fail("should throw FormatFlagsConversionMismatchException");
} catch (FormatFlagsConversionMismatchException e) {
// expected
}
try {
f = new Formatter(Locale.JAPAN);
f.format(flagsConversionMismatches[i], (BigDecimal) null);
fail("should throw FormatFlagsConversionMismatchException");
} catch (FormatFlagsConversionMismatchException e) {
// expected
}
}
final String[] missingFormatWidths = { "%-0e", "%0e", "%-e", "%-0E", "%0E", "%-E", "%-0g", "%0g", "%-g", "%-0G", "%0G", "%-G", "%-0f", "%0f", "%-f", "%-0a", "%0a", "%-a", "%-0A", "%0A", "%-A" };
for (int i = 0; i < missingFormatWidths.length; i++) {
try {
f = new Formatter(Locale.KOREA);
f.format(missingFormatWidths[i], 1f);
fail("should throw MissingFormatWidthException");
} catch (MissingFormatWidthException e) {
// expected
}
try {
f = new Formatter(Locale.KOREA);
f.format(missingFormatWidths[i], (Float) null);
fail("should throw MissingFormatWidthException");
} catch (MissingFormatWidthException e) {
// expected
}
}
final String[] illFlags = { "%+ e", "%+ E", "%+ g", "%+ G", "%+ f", "%+ a", "%+ A", "%-03e", "%-03E", "%-03g", "%-03G", "%-03f", "%-03a", "%-03A" };
for (int i = 0; i < illFlags.length; i++) {
try {
f = new Formatter(Locale.CANADA);
f.format(illFlags[i], 1.23d);
fail("should throw IllegalFormatFlagsException");
} catch (IllegalFormatFlagsException e) {
// expected
}
try {
f = new Formatter(Locale.CANADA);
f.format(illFlags[i], (Double) null);
fail("should throw IllegalFormatFlagsException");
} catch (IllegalFormatFlagsException e) {
// expected
}
}
f = new Formatter(Locale.US);
try {
f.format("%F", 1);
fail("should throw UnknownFormatConversionException");
} catch (UnknownFormatConversionException e) {
// expected
}
}
use of java.util.UnknownFormatConversionException in project j2objc by google.
the class FormatterTest method test_formatLjava_lang_String$Ljava_lang_Object_BigDecimalExceptionOrder.
/**
* java.util.Formatter#format(String, Object...) for BigDecimal
* exception throwing order
*/
public void test_formatLjava_lang_String$Ljava_lang_Object_BigDecimalExceptionOrder() {
Formatter f = null;
BigDecimal bd = new BigDecimal("1.0");
/*
* Summary: UnknownFormatConversionException >
* MissingFormatWidthException > IllegalFormatFlagsException >
* FormatFlagsConversionMismatchException >
* IllegalFormatConversionException
*
*/
try {
// compare FormatFlagsConversionMismatchException and
// IllegalFormatConversionException
f = new Formatter(Locale.US);
f.format("%,e", (byte) 1);
fail("should throw FormatFlagsConversionMismatchException");
} catch (FormatFlagsConversionMismatchException e) {
// expected
}
try {
// compare IllegalFormatFlagsException and
// FormatFlagsConversionMismatchException
f = new Formatter(Locale.US);
f.format("%+ ,e", bd);
fail("should throw IllegalFormatFlagsException");
} catch (IllegalFormatFlagsException e) {
// expected
}
try {
// compare MissingFormatWidthException and
// IllegalFormatFlagsException
f = new Formatter(Locale.US);
f.format("%+ -e", bd);
fail("should throw MissingFormatWidthException");
} catch (MissingFormatWidthException e) {
// expected
}
// MissingFormatWidthException
try {
f = new Formatter(Locale.US);
f.format("%-F", bd);
fail("should throw UnknownFormatConversionException");
} catch (UnknownFormatConversionException e) {
// expected
}
}
Aggregations