当前位置: 首页>>代码示例>>Java>>正文


Java Unit.multiply方法代码示例

本文整理汇总了Java中javax.measure.Unit.multiply方法的典型用法代码示例。如果您正苦于以下问题:Java Unit.multiply方法的具体用法?Java Unit.multiply怎么用?Java Unit.multiply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.measure.Unit的用法示例。


在下文中一共展示了Unit.multiply方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convertUnit

import javax.measure.Unit; //导入方法依赖的package包/类
public Unit<?> convertUnit(UnitDefinition unitDefinition) {
    Unit<?> resultUnit = new ProductUnit();
    for (org.sbml.jsbml.Unit sbmlUnit : unitDefinition.getListOfUnits()) {
        Unit unitComponent = getUnitForKind(sbmlUnit.getKind());
        unitComponent = unitComponent.transform(
                UnitPrefixes.getUnitPrefixFromScale(sbmlUnit.getScale()).getCorrespondingConverter());
        unitComponent = unitComponent.pow((int) sbmlUnit.getExponent());
        unitComponent = unitComponent.multiply(sbmlUnit.getMultiplier());
        resultUnit = resultUnit.multiply(unitComponent);
    }
    logger.debug("Parsed unit {},", resultUnit.toString());
    return resultUnit;
}
 
开发者ID:cleberecht,项目名称:singa,代码行数:14,代码来源:SBMLUnitConverter.java

示例2: Term

import javax.measure.Unit; //导入方法依赖的package包/类
final public Unit Term() throws TokenException {
    Unit result = ONE;
    Unit temp = ONE;
    result = Component();
    label_1:
    while (true) {
        switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
            case DOT:
            case SOLIDUS:
                break;
            default:
                jj_la1[0] = jj_gen;
                break label_1;
        }
        switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
            case DOT:
                jj_consume_token(DOT);
                temp = Component();
                result = result.multiply(temp);
                break;
            case SOLIDUS:
                jj_consume_token(SOLIDUS);
                temp = Component();
                result = result.divide(temp);
                break;
            default:
                jj_la1[1] = jj_gen;
                jj_consume_token(-1);
                throw new TokenException();
        }
    }
    {
        return result;
    }
}
 
开发者ID:unitsofmeasurement,项目名称:uom-systems,代码行数:36,代码来源:UCUMFormatParser.java

示例3: AddExpr

import javax.measure.Unit; //导入方法依赖的package包/类
final public Unit AddExpr() throws TokenException {
    Unit result = ONE;
    Number n1 = null;
    Token sign1 = null;
    Number n2 = null;
    Token sign2 = null;
    if (jj_2_1(2147483647)) {
        n1 = NumberExpr();
        sign1 = Sign();
    } else {
    }
    result = MulExpr();
    switch ((nextTokenIndex == -1) ? jj_ntk() : nextTokenIndex) {
        case PLUS:
        case MINUS:
            sign2 = Sign();
            n2 = NumberExpr();
            break;
        default:
            laA[1] = genInt;
    }
    if (n1 != null) {
        if (sign1.image.equals("-")) {
            result = result.multiply(-1);
        }
        result = result.shift(n1.doubleValue());
    }
    if (n2 != null) {
        double offset = n2.doubleValue();
        if (sign2.image.equals("-")) {
            offset = -offset;
        }
        result = result.shift(offset);
    }
    {
        return result;
    }
}
 
开发者ID:unitsofmeasurement,项目名称:uom-systems,代码行数:39,代码来源:UnitFormatParser.java

示例4: Component

import javax.measure.Unit; //导入方法依赖的package包/类
final public Unit Component() throws TokenException {
    Unit result = (AbstractUnit) ONE;
    Token token = null;
    if (jj_2_1(2147483647)) {
        result = Annotatable();
        token = jj_consume_token(ANNOTATION);
        {
            return ((AbstractUnit)result).annotate(token.image.substring(1, token.image.length() - 1));
        }
    } else {
        switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
            case ATOM:
                result = Annotatable(); {
                return result;
            }
            case ANNOTATION:
                token = jj_consume_token(ANNOTATION); {
                return ((AbstractUnit)result).annotate(token.image.substring(1, token.image.length() - 1));
            }
            case FACTOR:
                token = jj_consume_token(FACTOR);
                long factor = Long.parseLong(token.image); {
                return result.multiply(factor);
            }
            case SOLIDUS:
                jj_consume_token(SOLIDUS);
                result = Component(); {
                return ONE.divide(result);
            }
            case 14:
                jj_consume_token(14);
                result = Term();
                jj_consume_token(15); {
                return result;
            }
            default:
                jj_la1[2] = jj_gen;
                jj_consume_token(-1);
                throw new TokenException();
        }
    }
}
 
开发者ID:unitsofmeasurement,项目名称:uom-systems,代码行数:43,代码来源:UCUMFormatParser.java

示例5: MulExpr

import javax.measure.Unit; //导入方法依赖的package包/类
final public Unit MulExpr() throws TokenException {
    Unit result = ONE;
    Unit temp = ONE;
    result = ExponentExpr();
    label_2:
    while (true) {
        switch ((nextTokenIndex == -1) ? jj_ntk() : nextTokenIndex) {
            case ASTERISK:
            case MIDDLE_DOT:
            case SOLIDUS:
                break;
            default:
                laA[2] = genInt;
                break label_2;
        }
        switch ((nextTokenIndex == -1) ? jj_ntk() : nextTokenIndex) {
            case ASTERISK:
            case MIDDLE_DOT:
                switch ((nextTokenIndex == -1) ? jj_ntk() : nextTokenIndex) {
                    case ASTERISK:
                        consumeToken(ASTERISK);
                        break;
                    case MIDDLE_DOT:
                        consumeToken(MIDDLE_DOT);
                        break;
                    default:
                        laA[3] = genInt;
                        consumeToken(-1);
                        throw new TokenException();
                }
                temp = ExponentExpr();
                result = result.multiply(temp);
                break;
            case SOLIDUS:
                consumeToken(SOLIDUS);
                temp = ExponentExpr();
                result = result.divide(temp);
                break;
            default:
                laA[4] = genInt;
                consumeToken(-1);
                throw new TokenException();
        }
    }
    {
        return result;
    }
}
 
开发者ID:unitsofmeasurement,项目名称:uom-systems,代码行数:49,代码来源:UnitFormatParser.java

示例6: AtomicExpr

import javax.measure.Unit; //导入方法依赖的package包/类
final public Unit AtomicExpr() throws TokenException {
    Unit result = ONE;
    Number n = null;
    Token token = null;
    switch ((nextTokenIndex == -1) ? jj_ntk() : nextTokenIndex) {
        case INTEGER:
        case FLOATING_POINT:
            n = NumberExpr();
            if (n instanceof Integer) {
                {
                    return result.multiply(n.intValue());
                }
            } else {
                {
                    return result.multiply(n.doubleValue());
                }
            }
        case UNIT_IDENTIFIER:
            token = consumeToken(UNIT_IDENTIFIER);
            Unit unit = symbols.getUnit(token.image);
            if (unit == null) {
                MetricPrefix prefix = symbols.getPrefix(token.image);
                if (prefix != null) {
                    String prefixSymbol = symbols.getSymbol(prefix);
                    unit = symbols.getUnit(token.image.substring(prefixSymbol.length()));
                    if (unit != null) {
                        {
                            return unit.transform(prefix.getConverter());
                        }
                    }
                }
                {
                    throw new TokenException();
                }
            } else {
                {
                    return unit;
                }
            }
        case OPEN_PAREN:
            consumeToken(OPEN_PAREN);
            result = AddExpr();
            consumeToken(CLOSE_PAREN); {
            return result;
        }
        default:
            laA[10] = genInt;
            consumeToken(-1);
            throw new TokenException();
    }
}
 
开发者ID:unitsofmeasurement,项目名称:uom-systems,代码行数:52,代码来源:UnitFormatParser.java


注:本文中的javax.measure.Unit.multiply方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。