/** * Determines if this number is equal to another. * * @param comparator The object to compare to. * * @return <tt>true</tt> if the comparator is a number equal in value to this one, <tt>false</tt> otherwise. */ public boolean equals(Object comparator) { if (this == comparator) { return true; } if ((comparator == null) || !(comparator instanceof NumericType)) { return false; } NumericType comparatorNumber = (NumericType) comparator; return value == comparatorNumber.intValue(); }
/** * Determines if this number is equal to another. * * @param comparator The object to compare to. * * @return <tt>true</tt> if the comparator is a number equal in value to this one, <tt>false</tt> otherwise. */ public boolean equals(Object comparator) { if (this == comparator) { return true; } if ((comparator == null) || !(comparator instanceof NumericType)) { return false; } NumericType comparatorNumber = (NumericType) comparator; return value == comparatorNumber.intValue(); }
/** * Evaluates the arithmetic comparison on its two numeric arguments. * * @param firstNumber The first argument. * @param secondNumber The second argument. * * @return The result of performing the arithmetic comparison on its arguments. */ protected boolean evaluate(NumericType firstNumber, NumericType secondNumber) { // If either of the arguments is a real number, then use real number arithmetic, otherwise use integer arithmetic. if (firstNumber.isInteger() && secondNumber.isInteger()) { return firstNumber.intValue() >= secondNumber.intValue(); } else { return firstNumber.doubleValue() >= secondNumber.doubleValue(); } } }
/** * Evaluates the arithmetic comparison on its two numeric arguments. * * @param firstNumber The first argument. * @param secondNumber The second argument. * * @return The result of performing the arithmetic comparison on its arguments. */ protected boolean evaluate(NumericType firstNumber, NumericType secondNumber) { // If either of the arguments is a real number, then use real number arithmetic, otherwise use integer arithmetic. if (firstNumber.isInteger() && secondNumber.isInteger()) { return firstNumber.intValue() > secondNumber.intValue(); } else { return firstNumber.doubleValue() > secondNumber.doubleValue(); } } }
/** * Evaluates the arithmetic comparison on its two numeric arguments. * * @param firstNumber The first argument. * @param secondNumber The second argument. * * @return The result of performing the arithmetic comparison on its arguments. */ protected boolean evaluate(NumericType firstNumber, NumericType secondNumber) { // If either of the arguments is a real number, then use real number arithmetic, otherwise use integer arithmetic. if (firstNumber.isInteger() && secondNumber.isInteger()) { return firstNumber.intValue() < secondNumber.intValue(); } else { return firstNumber.doubleValue() < secondNumber.doubleValue(); } } }
/** * Evaluates the arithmetic comparison on its two numeric arguments. * * @param firstNumber The first argument. * @param secondNumber The second argument. * * @return The result of performing the arithmetic comparison on its arguments. */ protected boolean evaluate(NumericType firstNumber, NumericType secondNumber) { // If either of the arguments is a real number, then use real number arithmetic, otherwise use integer arithmetic. if (firstNumber.isInteger() && secondNumber.isInteger()) { return firstNumber.intValue() <= secondNumber.intValue(); } else { return firstNumber.doubleValue() <= secondNumber.doubleValue(); } } }
/** * Extracts all restricted int types from the type checked model and caches them in 'catalogueTypes' parameter by * name. * * @param catalogueTypes The map to build up the catalogue types in. */ private void initializeAllRestrictedIntTypes(Map<String, Type> catalogueTypes) { String queryString = "?-normal_type(integer_range, MN, JT, _MP), member(from(From), _MP), member(to(To), _MP)."; Iterable<Map<String, Variable>> bindingsIterable = runQuery(queryString); for (Map<String, Variable> bindings : bindingsIterable) { String typeName = engine.getFunctorName((Functor) bindings.get("MN").getValue()); String javaTypeName = engine.getFunctorName((Functor) bindings.get("JT").getValue()); NumericType fromTerm = (NumericType) bindings.get("From").getValue(); NumericType toTerm = (NumericType) bindings.get("To").getValue(); if ("int".equals(javaTypeName)) { catalogueTypes.put(typeName, IntRangeType.createInstance(typeName, fromTerm.intValue(), toTerm.intValue())); } else if ("long".equals(javaTypeName)) { } } }
/** * Evaluates the arithmetic operator on its two numeric arguments. * * @param firstNumber The first argument. * @param secondNumber The second argument. * * @return The result of performing the arithmetic operator on its arguments. */ protected NumericType evaluate(NumericType firstNumber, NumericType secondNumber) { // If either of the arguments is a real number, then use real number arithmetic, otherwise use integer arithmetic. if (firstNumber.isInteger() && secondNumber.isInteger()) { return new IntLiteral(firstNumber.intValue() * secondNumber.intValue()); } else { return new DoubleLiteral(firstNumber.doubleValue() * secondNumber.doubleValue()); } } }
/** * Evaluates the arithmetic operator on its two numeric arguments. * * @param firstNumber The first argument. * @param secondNumber The second argument. * * @return The result of performing the arithmetic operator on its arguments. */ protected NumericType evaluate(NumericType firstNumber, NumericType secondNumber) { // If either of the arguments is a real number, then use real number arithmetic, otherwise use integer arithmetic. if (firstNumber.isInteger() && secondNumber.isInteger()) { return new IntLiteral(firstNumber.intValue() - secondNumber.intValue()); } else { return new DoubleLiteral(firstNumber.doubleValue() - secondNumber.doubleValue()); } } }
/** * Evaluates the arithmetic operator on its two numeric arguments. * * @param firstNumber The first argument. * @param secondNumber The second argument. * * @return The result of performing the arithmetic operator on its arguments. */ protected NumericType evaluate(NumericType firstNumber, NumericType secondNumber) { // If either of the arguments is a real number, then use real number arithmetic, otherwise use integer arithmetic. if (firstNumber.isInteger() && secondNumber.isInteger()) { return new IntLiteral(firstNumber.intValue() + secondNumber.intValue()); } else { return new DoubleLiteral(firstNumber.doubleValue() + secondNumber.doubleValue()); } } }
/** * Evaluates the arithmetic operator on its two numeric arguments. * * @param firstNumber The first argument. * @param secondNumber The second argument. * * @return The result of performing the arithmetic operator on its arguments. */ protected NumericType evaluate(NumericType firstNumber, NumericType secondNumber) { // If either of the arguments is a real number, then use real number arithmetic, otherwise use integer arithmetic. if (firstNumber.isInteger() && secondNumber.isInteger()) { return new IntLiteral(firstNumber.intValue() / secondNumber.intValue()); } else { return new DoubleLiteral(firstNumber.doubleValue() / secondNumber.doubleValue()); } } }
length = ((NumericType) lengthTerm).intValue();
/** * Evaluates the arithmetic operator on its numeric argument. * * @param firstNumber The first argument. * * @return The result of performing the arithmetic operator on its argument. */ protected NumericType evaluate(NumericType firstNumber) { // If the argument is a real number, then use real number arithmetic, otherwise use integer arithmetic. if (firstNumber.isInteger()) { return new IntLiteral(-firstNumber.intValue()); } else { return new DoubleLiteral(-firstNumber.doubleValue()); } } }