Java 类java.util.UnknownFormatConversionException 实例源码
项目:AgentWeb
文件:DownLoader.java
@Override
protected void onProgressUpdate(Integer... values) {
try {
//LogUtils.i(TAG, "progress:" + ((tmp + loaded) / Float.valueOf(totals) * 100) + "tmp:" + tmp + " load=:" + loaded + " total:" + totals);
long c = System.currentTimeMillis();
if (mNotify != null && c - time > 800) {
time = c;
if (!mNotify.hasDeleteContent())
mNotify.setDelecte(buildCancelContent(mDownLoadTask.getContext().getApplicationContext(), mDownLoadTask.getId()));
int mProgress = (int) ((tmp + loaded) / Float.valueOf(totals) * 100);
mNotify.setContentText(String.format(mDownLoadTask.getDownLoadMsgConfig().getLoading(), mProgress + "%"));
mNotify.setProgress(100, mProgress, false);
}
} catch (UnknownFormatConversionException e) {
e.printStackTrace();
}
long current = System.currentTimeMillis();
used = current - begin;
}
项目:AgentWebX5
文件:RealDownLoader.java
@Override
protected void onProgressUpdate(Integer... values) {
try {
//LogUtils.i(TAG, "progress:" + ((tmp + loaded) / Float.valueOf(totals) * 100) + "tmp:" + tmp + " load=:" + loaded + " total:" + totals);
long c = System.currentTimeMillis();
if (mNotify != null && c - time > 800) {
time = c;
if (!mNotify.hasDeleteContent())
mNotify.setDelecte(buildCancelContent(mDownLoadTask.getContext().getApplicationContext(), mDownLoadTask.getId()));
int mProgress = (int) ((tmp + loaded) / Float.valueOf(totals) * 100);
mNotify.setContentText(String.format(mDownLoadTask.getDownLoadMsgConfig().getLoading(), mProgress + "%"));
mNotify.setProgress(100, mProgress, false);
}
} catch (UnknownFormatConversionException e) {
e.printStackTrace();
}
long current = System.currentTimeMillis();
used = current - begin;
}
项目:form-follows-function
文件:F3Formatter.java
private char conversion(String s) {
c = s.charAt(0);
if (!dt) {
if (!Conversion.isValid(c))
throw new UnknownFormatConversionException(String.valueOf(c));
if (Character.isUpperCase(c))
f.add(Flags.UPPERCASE);
c = Character.toLowerCase(c);
if (Conversion.isText(c))
index = -2;
}
if (s.length() == 2) {
c2 = s.charAt(1);
}
return c;
}
项目:gatk
文件:SeekableByteChannelPrefetcher.java
public String getStatistics() {
try {
double returnedPct = (bytesRead > 0 ? (100.0 * bytesReturned / bytesRead) : 100.0);
return String
.format("Bytes read: %12d\n returned: %12d ( %3.2f %% )", bytesRead, bytesReturned,
returnedPct)
+ String.format("\nReads past the end: %3d", nbReadsPastEnd)
+ String.format("\nReads forcing re-fetching of an earlier block: %3d", nbGoingBack)
// A near-hit is when we're already fetching the data the user is asking for,
// but we're not done loading it in.
+ String
.format("\nCache\n hits: %12d\n near-hits: %12d\n misses: %12d", nbHit,
nbNearHit, nbMiss);
} catch (UnknownFormatConversionException x) {
// let's not crash the whole program, instead just return no info
return "(error while formatting statistics)";
}
}
项目:bazel
文件:FormatSpecifier.java
private void checkText() {
if (precision != -1)
throw new IllegalFormatPrecisionException(precision);
switch (c) {
case Conversion.PERCENT_SIGN:
if (f.valueOf() != Flags.LEFT_JUSTIFY.valueOf()
&& f.valueOf() != Flags.NONE.valueOf())
throw new IllegalFormatFlagsException(f.toString());
// '-' requires a width
if (width == -1 && f.contains(Flags.LEFT_JUSTIFY))
throw new MissingFormatWidthException(toString());
break;
case Conversion.LINE_SEPARATOR:
if (width != -1)
throw new IllegalFormatWidthException(width);
if (f.valueOf() != Flags.NONE.valueOf())
throw new IllegalFormatFlagsException(f.toString());
break;
default:
throw new UnknownFormatConversionException(String.valueOf(c));
}
}
项目:Ultrastructure
文件:CoreDbConfiguration_ESTest.java
@Test(timeout = 4000)
public void test06() throws Throwable {
CoreDbConfiguration coreDbConfiguration0 = new CoreDbConfiguration();
CoreDbConfiguration.JDBC_URL = "%jj;97ATvw)UDwSM|";
// Undeclared exception!
try {
coreDbConfiguration0.getCoreJdbcURL();
fail("Expecting exception: UnknownFormatConversionException");
} catch (UnknownFormatConversionException e) {
//
// Conversion = 'j'
//
assertThrownBy("java.util.Formatter$FormatSpecifier", e);
}
}
项目:Ultrastructure
文件:CoreDbConfiguration_ESTest.java
@Test(timeout = 4000)
public void test09() throws Throwable {
CoreDbConfiguration coreDbConfiguration0 = new CoreDbConfiguration();
coreDbConfiguration0.corePassword = "jdbc:postgresql://null:183/core";
CoreDbConfiguration.JDBC_URL = "";
CoreDbConfiguration.JDBC_URL = "3B=3WSv`LLpD)\"E<%";
// Undeclared exception!
try {
coreDbConfiguration0.getCoreConnection();
fail("Expecting exception: UnknownFormatConversionException");
} catch (UnknownFormatConversionException e) {
//
// Conversion = '%'
//
assertThrownBy("java.util.Formatter", e);
}
}
项目:cactoos
文件:FormattedTextTest.java
@Test(expected = UnknownFormatConversionException.class)
public void failsForInvalidPattern() throws IOException {
new FormattedText(
new TextOf("%%. Formatted %$"),
new ListOf<>(1, "invalid")
).asString();
}
项目:Elf-Editor
文件:MainActivity.java
@Override
protected String doInBackground(InputStream... params) {
try {
parseELF(callback, params[0]);
} catch (UnknownFormatConversionException | IOException e) {
e.printStackTrace();
return "failed";
}
return getString(R.string.success);
}
项目:mochalog
文件:FormatSpec.java
/**
* Apply formatting rule corresponding to given identifier
* @param identifier Symbolic identifier following '$'
* @param arg Object argument
* @return Formatted string
* @throws IllegalFormatException Unable to format given object argument
* according to specified rule
*/
public String applyRule(String identifier, Object arg) throws IllegalFormatException
{
FormattingRule rule = formattingRules.get(identifier);
if (rule == null)
{
throw new UnknownFormatConversionException("Formatting rule not available corresponding " +
"to given identifier " + identifier);
}
return rule.apply(identifier, arg);
}
项目:tornadofx-controls
文件:UnitConverter.java
public Long fromString(String string) {
if (string == null || string.isEmpty()) return null;
Matcher matcher = ValueWithUnit.matcher(string.toLowerCase());
if (!matcher.matches()) throw new UnknownFormatConversionException(String.format("Invalid format %s", string));
Long value = Long.valueOf(matcher.group(1));
String unit = matcher.group(2);
if (unit.isEmpty()) return value;
int index = units.toLowerCase().indexOf(unit.toLowerCase());
return value * (long) Math.pow(getBase(), (double) index + 1);
}
项目:aptoide-client
文件:AptoideUtils.java
public static String getFormattedString(Context context, @StringRes int resId, Object... formatArgs) {
String result;
final Resources resources = context.getResources();
try {
result = resources.getString(resId, formatArgs);
}catch (UnknownFormatConversionException ex){
final String resourceEntryName = resources.getResourceEntryName(resId);
final String displayLanguage = Locale.getDefault().getDisplayLanguage();
Logger.e("UnknownFormatConversion", "String: " + resourceEntryName + " Locale: " + displayLanguage);
Crashlytics.log(3, "UnknownFormatConversion", "String: " + resourceEntryName + " Locale: " + displayLanguage);
result = resources.getString(resId);
}
return result;
}
项目:aptoide-client-v8
文件:AptoideUtils.java
public static String getFormattedString(@StringRes int resId, Resources resources,
Object... formatArgs) {
String result;
try {
result = resources.getString(resId, formatArgs);
} catch (UnknownFormatConversionException ex) {
final String resourceEntryName = resources.getResourceEntryName(resId);
final String displayLanguage = Locale.getDefault()
.getDisplayLanguage();
Logger.e("UnknownFormatConversion",
"String: " + resourceEntryName + " Locale: " + displayLanguage);
result = ResourseU.getString(resId, resources);
}
return result;
}
项目:Rocket.Chat-android
文件:ChatActivity.java
@Override
public void processFile(String filePath, String media) {
mFabMenu.onBackPressed();
mUploadProgress.setVisibility(View.VISIBLE);
File file = new File(Util.getPath(getApplicationContext(), filePath));
if (file.exists()) {
Observable.create(new Observable.OnSubscribe<String[]>() {
@Override
public void call(Subscriber<? super String[]> subscriber) {
String str = Util.decodeFile(file);
if (str != null) {
int chunkSize = 4 * 8 * 1024;
subscriber.onNext(Util.splitStringBySize(str, chunkSize).toArray(new String[0]));
subscriber.onCompleted();
} else {
subscriber.onError(new UnknownFormatConversionException("failed to convert " + filePath + " to string"));
}
}
})
.subscribeOn(Schedulers.computation())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Subscriber<String[]>() {
@Override
public void onCompleted() {
}
@Override
public void onError(Throwable e) {
mUploadProgress.setVisibility(View.GONE);
}
@Override
public void onNext(String[] strings) {
uploadFile(file.getName(), media, file.length(), strings);
}
});
}
}
项目:Smack
文件:SubscribeForm.java
/**
* Get the time at which the leased subscription will expire, or has expired.
*
* @return The expiry date
*/
public Date getExpiry()
{
String dateTime = getFieldValue(SubscribeOptionFields.expire);
try
{
return XmppDateTime.parseDate(dateTime);
}
catch (ParseException e)
{
UnknownFormatConversionException exc = new UnknownFormatConversionException(dateTime);
exc.initCause(e);
throw exc;
}
}
项目:FMTech
文件:AddressUtils.java
public static char[] determineAddressFieldsToDisplay(String paramString)
throws UnknownFormatConversionException
{
if (TextUtils.isEmpty(paramString)) {
throw new UnknownFormatConversionException("Cannot convert null/empty formats");
}
ArrayList localArrayList1 = new ArrayList();
Iterator localIterator1 = getFormatSubStrings(paramString).iterator();
while (localIterator1.hasNext())
{
String str = (String)localIterator1.next();
if ((str.matches("%.")) && (!str.equals("%n"))) {
localArrayList1.add(Character.valueOf(str.charAt(1)));
}
}
ArrayList localArrayList2 = new ArrayList();
Iterator localIterator2 = localArrayList1.iterator();
while (localIterator2.hasNext())
{
char c = ((Character)localIterator2.next()).charValue();
if (c == 'A')
{
localArrayList2.add(Character.valueOf('1'));
localArrayList2.add(Character.valueOf('2'));
localArrayList2.add(Character.valueOf('3'));
}
else
{
localArrayList2.add(Character.valueOf(c));
}
}
char[] arrayOfChar = new char[localArrayList2.size()];
for (int i = 0; i < arrayOfChar.length; i++) {
arrayOfChar[i] = ((Character)localArrayList2.get(i)).charValue();
}
return arrayOfChar;
}
项目:FMTech
文件:AddressUtils.java
private static ArrayList<String> getFormatSubStrings(String paramString)
throws UnknownFormatConversionException
{
ArrayList localArrayList = new ArrayList();
int i = 0;
char[] arrayOfChar = paramString.toCharArray();
int j = arrayOfChar.length;
int k = 0;
if (k < j)
{
char c = arrayOfChar[k];
if (i != 0)
{
i = 0;
if ("%n".equals("%" + c)) {
localArrayList.add("%n");
}
}
for (;;)
{
k++;
break;
if (!AddressField.exists(c)) {
throw new UnknownFormatConversionException("Cannot determine AddressField for '" + c + "'");
}
localArrayList.add("%" + c);
i = 0;
continue;
if (c == '%') {
i = 1;
} else {
localArrayList.add(Character.toString(c));
}
}
}
return localArrayList;
}
项目:EIM
文件:SubscribeForm.java
/**
* Get the time at which the leased subscription will expire, or has expired.
*
* @return The expiry date
*/
public Date getExpiry()
{
String dateTime = getFieldValue(SubscribeOptionFields.expire);
try
{
return format.parse(dateTime);
}
catch (ParseException e)
{
UnknownFormatConversionException exc = new UnknownFormatConversionException(dateTime);
exc.initCause(e);
throw exc;
}
}
项目:form-follows-function
文件:F3Formatter.java
private void checkText(String s) {
int idx;
// If there are any '%' in the given string, we got a bad format
// specifier.
if ((idx = s.indexOf('%')) != -1) {
char c = (idx > s.length() - 2 ? '%' : s.charAt(idx + 1));
throw new UnknownFormatConversionException(String.valueOf(c));
}
}
项目:form-follows-function
文件:F3Formatter.java
FormatSpecifier(F3Formatter formatter, String[] sa) {
this.formatter = formatter;
int idx = 0;
index(sa[idx++]);
flags(sa[idx++]);
width(sa[idx++]);
precision(sa[idx++]);
if (sa[5] != null) {
dt = true;
if (sa[5].equals("T"))
f.add(Flags.UPPERCASE);
conversion(sa[6]);
} else {
conversion(sa[idx]);
}
if (dt)
checkDateTime();
else if (Conversion.isGeneral(c))
checkGeneral();
else if (Conversion.isCharacter(c))
checkCharacter();
else if (Conversion.isInteger(c))
checkInteger();
else if (Conversion.isFloat(c))
checkFloat();
else if (Conversion.isText(c))
checkText();
else
throw new UnknownFormatConversionException(String.valueOf(c));
}
项目:form-follows-function
文件:F3Formatter.java
private void checkDateTime() {
if (precision != -1)
throw new IllegalFormatPrecisionException(precision);
if (!DateTime.isValid(c, c2))
throw new UnknownFormatConversionException("t" + c);
checkBadFlags(Flags.ALTERNATE, Flags.PLUS, Flags.LEADING_SPACE,
Flags.ZERO_PAD, Flags.GROUP, Flags.PARENTHESES);
// '-' requires a width
if (width == -1 && f.contains(Flags.LEFT_JUSTIFY))
throw new MissingFormatWidthException(toString());
}
项目:androidPN-client.
文件:SubscribeForm.java
/**
* Get the time at which the leased subscription will expire, or has expired.
*
* @return The expiry date
*/
public Date getExpiry()
{
String dateTime = getFieldValue(SubscribeOptionFields.expire);
try
{
return StringUtils.parseDate(dateTime);
}
catch (ParseException e)
{
UnknownFormatConversionException exc = new UnknownFormatConversionException(dateTime);
exc.initCause(e);
throw exc;
}
}
项目:rom-manager
文件:OfflineListProviderPlugin.java
public GameSave<?> parse(String string)
{
String[] tokens = string.split("_");
if (tokens.length == 1 && tokens[0].compareToIgnoreCase(GBA.Save.Type.NONE.toString()) == 0)
return new GBA.Save(GBA.Save.Type.NONE);
else if (tokens.length >= 2)
{
if (tokens.length > 2)
tokens[1] = tokens[2];
for (GBA.Save.Type type : GBA.Save.Type.values())
{
if (tokens[0].toLowerCase().contains(type.toString().toLowerCase()))
{
Version[] versions = GBA.Save.valuesForType(type);
for (Version version : versions)
{
if (tokens[1].contains(version.toString()))
return new GBA.Save(type, version);
}
throw new UnknownFormatConversionException("Unable to parse GBA save: "+string);
}
}
}
return new GBA.Save(GBA.Save.Type.NONE);
}
项目:rom-manager
文件:OfflineListProviderPlugin.java
public GameSave<?> parse(String string)
{
if (string.equals("TBC"))
return new NDS.Save(NDS.Save.Type.TBC);
else if (string.equals("None"))
return new NDS.Save(NDS.Save.Type.NONE);
String[] tokens = string.split(" - ");
tokens = Arrays.stream(tokens).map(String::trim).map(String::toLowerCase).toArray(String[]::new);
NDS.Save.Type type = null;
long multiplier = 0;
if (tokens[0].equals("flash"))
type = NDS.Save.Type.FLASH;
else if (tokens[0].equals("eeprom"))
type = NDS.Save.Type.EEPROM;
else
throw new UnknownFormatConversionException("Unable to parse NDS save: "+string);
if (tokens[1].endsWith("kbit"))
multiplier = RomSize.KBIT;
else if (tokens[1].endsWith("mbit"))
multiplier = RomSize.MEGABIT;
else
throw new UnknownFormatConversionException("Unable to parse NDS save: "+string);
String ntoken = tokens[1].substring(0, tokens[1].length() - 4).trim();
multiplier *= Integer.valueOf(ntoken);
return new NDS.Save(type, multiplier);
}
项目:xmppsupport_v2
文件:SubscribeForm.java
/**
* Get the time at which the leased subscription will expire, or has
* expired.
*
* @return The expiry date
*/
public Date getExpiry() {
String dateTime = getFieldValue(SubscribeOptionFields.expire);
try {
return format.parse(dateTime);
} catch (ParseException e) {
UnknownFormatConversionException exc = new UnknownFormatConversionException(
dateTime);
exc.initCause(e);
throw exc;
}
}
项目:cn1
文件:UnknownFormatConversionExceptionTest.java
/**
* @tests java.util.UnknownFormatConversionException#UnknownFormatConversionException(String)
*/
public void test_unknownFormatConversionException() {
// RI 5.0 will not throw NullPointerException, it is the bug according
// to spec.
try {
new UnknownFormatConversionException(null);
fail("should throw NullPointerExcepiton");
} catch (NullPointerException e) {
}
}
项目:cn1
文件:UnknownFormatConversionExceptionTest.java
/**
* @tests java.util.UnknownFormatConversionException#getConversion()
*/
public void test_getConversion() {
String s = "MYTESTSTRING";
UnknownFormatConversionException UnknownFormatConversionException = new UnknownFormatConversionException(
s);
assertEquals(s, UnknownFormatConversionException.getConversion());
}
项目:cn1
文件:UnknownFormatConversionExceptionTest.java
/**
* @tests java.util.UnknownFormatConversionException#getMessage()
*/
public void test_getMessage() {
String s = "MYTESTSTRING";
UnknownFormatConversionException UnknownFormatConversionException = new UnknownFormatConversionException(
s);
assertTrue(null != UnknownFormatConversionException.getMessage());
}
项目:cn1
文件:UnknownFormatConversionExceptionTest.java
public void assertDeserialized(Serializable initial,
Serializable deserialized) {
SerializationTest.THROWABLE_COMPARATOR.assertDeserialized(initial,
deserialized);
UnknownFormatConversionException initEx = (UnknownFormatConversionException) initial;
UnknownFormatConversionException desrEx = (UnknownFormatConversionException) deserialized;
assertEquals("Conversion", initEx.getConversion(), desrEx
.getConversion());
}
项目:cn1
文件:UnknownFormatConversionExceptionTest.java
/**
* @tests serialization/deserialization compatibility with RI.
*/
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this,
new UnknownFormatConversionException("MYTESTSTRING"),
exComparator);
}
项目:bazel
文件:FormatSpecifier.java
private char conversion(String s) {
c = s.charAt(0);
if (!dt) {
if (!Conversion.isValid(c))
throw new UnknownFormatConversionException(String.valueOf(c));
if (Character.isUpperCase(c))
f.add(Flags.UPPERCASE);
c = Character.toLowerCase(c);
if (Conversion.isText(c))
index = -2;
}
return c;
}
项目:bazel
文件:FormatSpecifier.java
FormatSpecifier(String source, String[] sa)
throws FormatFlagsConversionMismatchException,
FormatterNumberFormatException {
int idx = 0;
this.source = source;
index(sa[idx++]);
flags(sa[idx++]);
width(sa[idx++]);
precision(sa[idx++]);
if (sa[idx] != null) {
dt = true;
if (sa[idx].equals("T"))
f.add(Flags.UPPERCASE);
}
conversion(sa[++idx]);
if (dt)
checkDateTime();
else if (Conversion.isGeneral(c))
checkGeneral();
else if (Conversion.isCharacter(c))
checkCharacter();
else if (Conversion.isInteger(c))
checkInteger();
else if (Conversion.isFloat(c))
checkFloat();
else if (Conversion.isText(c))
checkText();
else
throw new UnknownFormatConversionException(String.valueOf(c));
}
项目:bazel
文件:FormatSpecifier.java
private void checkDateTime() throws FormatFlagsConversionMismatchException {
if (precision != -1)
throw new IllegalFormatPrecisionException(precision);
if (!DateTime.isValid(c))
throw new UnknownFormatConversionException("t" + c);
checkBadFlags(Flags.ALTERNATE, Flags.PLUS, Flags.LEADING_SPACE,
Flags.ZERO_PAD, Flags.GROUP, Flags.PARENTHESES);
// '-' requires a width
if (width == -1 && f.contains(Flags.LEFT_JUSTIFY))
throw new MissingFormatWidthException(toString());
}
项目:bazel
文件:Formatter.java
private static void checkText(String s) {
int idx;
// If there are any '%' in the given string, we got a bad format
// specifier.
if ((idx = s.indexOf('%')) != -1) {
char c = (idx > s.length() - 2 ? '%' : s.charAt(idx + 1));
throw new UnknownFormatConversionException(String.valueOf(c));
}
}
项目:java-bells
文件:SubscribeForm.java
/**
* Get the time at which the leased subscription will expire, or has expired.
*
* @return The expiry date
*/
public Date getExpiry()
{
String dateTime = getFieldValue(SubscribeOptionFields.expire);
try
{
return StringUtils.parseDate(dateTime);
}
catch (ParseException e)
{
UnknownFormatConversionException exc = new UnknownFormatConversionException(dateTime);
exc.initCause(e);
throw exc;
}
}
项目:freeVM
文件:UnknownFormatConversionExceptionTest.java
/**
* @tests java.util.UnknownFormatConversionException#UnknownFormatConversionException(String)
*/
public void test_unknownFormatConversionException() {
// RI 5.0 will not throw NullPointerException, it is the bug according
// to spec.
try {
new UnknownFormatConversionException(null);
} catch (NullPointerException e) {
fail("should not throw NullPointerExcepiton");
}
}
项目:freeVM
文件:UnknownFormatConversionExceptionTest.java
/**
* @tests java.util.UnknownFormatConversionException#getConversion()
*/
public void test_getConversion() {
String s = "MYTESTSTRING";
UnknownFormatConversionException UnknownFormatConversionException = new UnknownFormatConversionException(
s);
assertEquals(s, UnknownFormatConversionException.getConversion());
}
项目:freeVM
文件:UnknownFormatConversionExceptionTest.java
/**
* @tests java.util.UnknownFormatConversionException#getMessage()
*/
public void test_getMessage() {
String s = "MYTESTSTRING";
UnknownFormatConversionException UnknownFormatConversionException = new UnknownFormatConversionException(
s);
assertTrue(null != UnknownFormatConversionException.getMessage());
}
项目:freeVM
文件:UnknownFormatConversionExceptionTest.java
public void assertDeserialized(Serializable initial,
Serializable deserialized) {
SerializationTest.THROWABLE_COMPARATOR.assertDeserialized(initial,
deserialized);
UnknownFormatConversionException initEx = (UnknownFormatConversionException) initial;
UnknownFormatConversionException desrEx = (UnknownFormatConversionException) deserialized;
assertEquals("Conversion", initEx.getConversion(), desrEx
.getConversion());
}
项目:freeVM
文件:UnknownFormatConversionExceptionTest.java
/**
* @tests serialization/deserialization compatibility with RI.
*/
public void testSerializationCompatibility() throws Exception {
SerializationTest.verifyGolden(this,
new UnknownFormatConversionException("MYTESTSTRING"),
exComparator);
}