本文整理汇总了Java中org.apache.commons.math3.exception.util.Localizable类的典型用法代码示例。如果您正苦于以下问题:Java Localizable类的具体用法?Java Localizable怎么用?Java Localizable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Localizable类属于org.apache.commons.math3.exception.util包,在下文中一共展示了Localizable类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkValidity
import org.apache.commons.math3.exception.util.Localizable; //导入依赖的package包/类
@Override
protected void checkValidity(List<Integer> chromosomeRepresentation) throws InvalidRepresentationException {
if(chromosomeRepresentation.size()!=18) throw new InvalidRepresentationException(new Localizable() {
@Override
public String getSourceString() {
return "The chromosome must have exactly 18 gens. It currently have "+chromosomeRepresentation.size();
}
@Override
public String getLocalizedString(Locale locale) {
return this.getSourceString();
}
});
}
示例2: MathIllegalStateException
import org.apache.commons.math3.exception.util.Localizable; //导入依赖的package包/类
/**
* Simple constructor.
*
* @param cause Root cause.
* @param pattern Message pattern explaining the cause of the error.
* @param args Arguments.
*/
public MathIllegalStateException(Throwable cause,
Localizable pattern,
Object ... args) {
super(cause);
context = new ExceptionContext(this);
context.addMessage(pattern, args);
}
示例3: NumberIsTooLargeException
import org.apache.commons.math3.exception.util.Localizable; //导入依赖的package包/类
/**
* Construct the exception with a specific context.
*
* @param specific Specific context pattern.
* @param wrong Value that is larger than the maximum.
* @param max Maximum.
* @param boundIsAllowed if true the maximum is included in the allowed range.
*/
public NumberIsTooLargeException(Localizable specific,
Number wrong,
Number max,
boolean boundIsAllowed) {
super(specific, wrong, max);
this.max = max;
this.boundIsAllowed = boundIsAllowed;
}
示例4: NumberIsTooSmallException
import org.apache.commons.math3.exception.util.Localizable; //导入依赖的package包/类
/**
* Construct the exception with a specific context.
*
* @param specific Specific context pattern.
* @param wrong Value that is smaller than the minimum.
* @param min Minimum.
* @param boundIsAllowed Whether {@code min} is included in the allowed range.
*/
public NumberIsTooSmallException(Localizable specific,
Number wrong,
Number min,
boolean boundIsAllowed) {
super(specific, wrong, min);
this.min = min;
this.boundIsAllowed = boundIsAllowed;
}
示例5: NoBracketingException
import org.apache.commons.math3.exception.util.Localizable; //导入依赖的package包/类
/**
* Construct the exception with a specific context.
*
* @param specific Contextual information on what caused the exception.
* @param lo Lower end of the interval.
* @param hi Higher end of the interval.
* @param fLo Value at lower end of the interval.
* @param fHi Value at higher end of the interval.
* @param args Additional arguments.
*/
public NoBracketingException(Localizable specific,
double lo, double hi,
double fLo, double fHi,
Object ... args) {
super(specific, Double.valueOf(lo), Double.valueOf(hi), Double.valueOf(fLo), Double.valueOf(fHi), args);
this.lo = lo;
this.hi = hi;
this.fLo = fLo;
this.fHi = fHi;
}
示例6: checkNotNull
import org.apache.commons.math3.exception.util.Localizable; //导入依赖的package包/类
/**
* Checks that an object is not null.
*
* @param o Object to be checked.
* @param pattern Message pattern.
* @param args Arguments to replace the placeholders in {@code pattern}.
* @throws NullArgumentException if {@code o} is {@code null}.
*/
public static void checkNotNull(Object o,
Localizable pattern,
Object ... args)
throws NullArgumentException {
if (o == null) {
throw new NullArgumentException(pattern, args);
}
}
示例7: NoBracketingException
import org.apache.commons.math3.exception.util.Localizable; //导入依赖的package包/类
/**
* Construct the exception with a specific context.
*
* @param specific Contextual information on what caused the exception.
* @param lo Lower end of the interval.
* @param hi Higher end of the interval.
* @param fLo Value at lower end of the interval.
* @param fHi Value at higher end of the interval.
* @param args Additional arguments.
*/
public NoBracketingException(Localizable specific,
double lo, double hi,
double fLo, double fHi,
Object ... args) {
super(specific, lo, hi, fLo, fHi, args);
this.lo = lo;
this.hi = hi;
this.fLo = fLo;
this.fHi = fHi;
}
示例8: addAndCheck
import org.apache.commons.math3.exception.util.Localizable; //导入依赖的package包/类
/**
* Add two long integers, checking for overflow.
*
* @param a Addend.
* @param b Addend.
* @param pattern Pattern to use for any thrown exception.
* @return the sum {@code a + b}.
* @throws MathArithmeticException if the result cannot be represented
* as a {@code long}.
* @since 1.2
*/
private static long addAndCheck(long a, long b, Localizable pattern) {
long ret;
if (a > b) {
// use symmetry to reduce boundary cases
ret = addAndCheck(b, a, pattern);
} else {
// assert a <= b
if (a < 0) {
if (b < 0) {
// check for negative overflow
if (Long.MIN_VALUE - b <= a) {
ret = a + b;
} else {
throw new MathArithmeticException(pattern, a, b);
}
} else {
// opposite sign addition is always safe
ret = a + b;
}
} else {
// assert a >= 0
// assert b >= 0
// check for positive overflow
if (a <= Long.MAX_VALUE - b) {
ret = a + b;
} else {
throw new MathArithmeticException(pattern, a, b);
}
}
}
return ret;
}
示例9: RuggedException
import org.apache.commons.math3.exception.util.Localizable; //导入依赖的package包/类
/** Simple constructor.
* Build an exception from a cause and with a specified message
* @param message descriptive message
* @param cause underlying cause
*/
public RuggedException(final Localizable message, final Throwable cause) {
super(cause);
this.context = null;
this.specifier = message;
this.parts = new Object[0];
}
示例10: createInternalError
import org.apache.commons.math3.exception.util.Localizable; //导入依赖的package包/类
/** Create an {@link java.lang.RuntimeException} for an internal error.
* @param cause underlying cause
* @return an {@link java.lang.RuntimeException} for an internal error
*/
public static RuntimeException createInternalError(final Throwable cause) {
/** Format specifier (to be translated). */
final Localizable specifier = RuggedMessages.INTERNAL_ERROR;
/** Parts to insert in the format (no translation). */
final String parts = "[email protected]";
return new RuntimeException() {
/** Serializable UID. */
private static final long serialVersionUID = 20140309L;
/** {@inheritDoc} */
@Override
public String getMessage() {
return buildMessage(Locale.US, specifier, parts);
}
/** {@inheritDoc} */
@Override
public String getLocalizedMessage() {
return buildMessage(Locale.getDefault(), specifier, parts);
}
};
}
示例11: of
import org.apache.commons.math3.exception.util.Localizable; //导入依赖的package包/类
private static Localizable of(String string) {
return new Localizable() {
@Override
public String getSourceString() {
return string;
}
@Override
public String getLocalizedString(Locale locale) {
return string;
}
};
}
示例12: MathIllegalArgumentException
import org.apache.commons.math3.exception.util.Localizable; //导入依赖的package包/类
/**
* @param pattern Message pattern explaining the cause of the error.
* @param args Arguments.
*/
public MathIllegalArgumentException(Localizable pattern,
Object ... args) {
context = new ExceptionContext(this);
context.addMessage(pattern, args);
}
示例13: MathUnsupportedOperationException
import org.apache.commons.math3.exception.util.Localizable; //导入依赖的package包/类
/**
* @param pattern Message pattern providing the specific context of
* the error.
* @param args Arguments.
*/
public MathUnsupportedOperationException(Localizable pattern,
Object ... args) {
context = new ExceptionContext(this);
context.addMessage(pattern, args);
}
示例14: MathRuntimeException
import org.apache.commons.math3.exception.util.Localizable; //导入依赖的package包/类
/**
* @param pattern Message pattern explaining the cause of the error.
* @param args Arguments.
*/
public MathRuntimeException(Localizable pattern,
Object ... args) {
context = new ExceptionContext(this);
context.addMessage(pattern, args);
}