net.sf.saxon.value.YearMonthDurationValue.getLengthInMonths()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(103)

本文整理了Java中net.sf.saxon.value.YearMonthDurationValue.getLengthInMonths()方法的一些代码示例,展示了YearMonthDurationValue.getLengthInMonths()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YearMonthDurationValue.getLengthInMonths()方法的具体详情如下:
包路径:net.sf.saxon.value.YearMonthDurationValue
类名称:YearMonthDurationValue
方法名:getLengthInMonths

YearMonthDurationValue.getLengthInMonths介绍

[英]Get the number of months in the duration
[中]获取持续时间中的月数

代码示例

代码示例来源:origin: net.sf.saxon/Saxon-HE

  1. /**
  2. * Compare the value to another duration value
  3. *
  4. * @param other The other dateTime value
  5. * @return negative value if this one is the earler, 0 if they are chronologically equal,
  6. * positive value if this one is the later. For this purpose, dateTime values with an unknown
  7. * timezone are considered to be UTC values (the Comparable interface requires
  8. * a total ordering).
  9. * @throws ClassCastException if the other value is not a DateTimeValue (the parameter
  10. * is declared as Object to satisfy the Comparable interface)
  11. */
  12. public int compareTo(YearMonthDurationValue other) {
  13. return Integer.compare(getLengthInMonths(), other.getLengthInMonths());
  14. }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon

  1. /**
  2. * Compare the value to another duration value
  3. *
  4. * @param other The other dateTime value
  5. * @return negative value if this one is the earler, 0 if they are chronologically equal,
  6. * positive value if this one is the later. For this purpose, dateTime values with an unknown
  7. * timezone are considered to be UTC values (the Comparable interface requires
  8. * a total ordering).
  9. * @throws ClassCastException if the other value is not a DateTimeValue (the parameter
  10. * is declared as Object to satisfy the Comparable interface)
  11. */
  12. public int compareTo(YearMonthDurationValue other) {
  13. return Integer.compare(getLengthInMonths(), other.getLengthInMonths());
  14. }

代码示例来源:origin: net.sf.saxon/Saxon-HE

  1. /**
  2. * Negate a duration (same as subtracting from zero, but it preserves the type of the original duration)
  3. */
  4. public DurationValue negate() {
  5. return fromMonths(-getLengthInMonths());
  6. }

代码示例来源:origin: net.sourceforge.saxon/saxon

  1. /**
  2. * Negate a duration (same as subtracting from zero, but it preserves the type of the original duration)
  3. */
  4. public DurationValue negate() {
  5. return fromMonths(-getLengthInMonths());
  6. }

代码示例来源:origin: net.sourceforge.saxon/saxon

  1. /**
  2. * Create a copy of this atomic value, with a different type label
  3. *
  4. * @param typeLabel the type label of the new copy. The caller is responsible for checking that
  5. * the value actually conforms to this type.
  6. */
  7. public AtomicValue copyAsSubType(AtomicType typeLabel) {
  8. YearMonthDurationValue v = YearMonthDurationValue.fromMonths(getLengthInMonths());
  9. v.typeLabel = typeLabel;
  10. return v;
  11. }

代码示例来源:origin: net.sf.saxon/Saxon-HE

  1. /**
  2. * Create a copy of this atomic value, with a different type label
  3. *
  4. * @param typeLabel the type label of the new copy. The caller is responsible for checking that
  5. * the value actually conforms to this type.
  6. */
  7. /*@NotNull*/
  8. public AtomicValue copyAsSubType(AtomicType typeLabel) {
  9. YearMonthDurationValue v = YearMonthDurationValue.fromMonths(getLengthInMonths());
  10. v.typeLabel = typeLabel;
  11. return v;
  12. }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon

  1. /**
  2. * Create a copy of this atomic value, with a different type label
  3. *
  4. * @param typeLabel the type label of the new copy. The caller is responsible for checking that
  5. * the value actually conforms to this type.
  6. */
  7. /*@NotNull*/
  8. public AtomicValue copyAsSubType(AtomicType typeLabel) {
  9. YearMonthDurationValue v = YearMonthDurationValue.fromMonths(getLengthInMonths());
  10. v.typeLabel = typeLabel;
  11. return v;
  12. }

代码示例来源:origin: org.opengis.cite.saxon/saxon9

  1. /**
  2. * Create a copy of this atomic value, with a different type label
  3. *
  4. * @param typeLabel the type label of the new copy. The caller is responsible for checking that
  5. * the value actually conforms to this type.
  6. */
  7. public AtomicValue copyAsSubType(AtomicType typeLabel) {
  8. YearMonthDurationValue v = YearMonthDurationValue.fromMonths(getLengthInMonths());
  9. v.typeLabel = typeLabel;
  10. return v;
  11. }

代码示例来源:origin: org.opengis.cite.saxon/saxon9

  1. /**
  2. * Negate a duration (same as subtracting from zero, but it preserves the type of the original duration)
  3. */
  4. public DurationValue negate() {
  5. return fromMonths(-getLengthInMonths());
  6. }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon

  1. /**
  2. * Negate a duration (same as subtracting from zero, but it preserves the type of the original duration)
  3. */
  4. public DurationValue negate() {
  5. return fromMonths(-getLengthInMonths());
  6. }

代码示例来源:origin: net.sf.saxon/Saxon-HE

  1. /**
  2. * Add two year-month-durations
  3. */
  4. public DurationValue add(DurationValue other) throws XPathException {
  5. if (other instanceof YearMonthDurationValue) {
  6. return fromMonths(getLengthInMonths() +
  7. ((YearMonthDurationValue) other).getLengthInMonths());
  8. } else {
  9. XPathException err = new XPathException("Cannot add two durations of different type");
  10. err.setErrorCode("XPTY0004");
  11. throw err;
  12. }
  13. }

代码示例来源:origin: net.sf.saxon/Saxon-HE

  1. /**
  2. * Subtract two year-month-durations
  3. */
  4. public DurationValue subtract(DurationValue other) throws XPathException {
  5. if (other instanceof YearMonthDurationValue) {
  6. return fromMonths(getLengthInMonths() -
  7. ((YearMonthDurationValue) other).getLengthInMonths());
  8. } else {
  9. XPathException err = new XPathException("Cannot subtract two durations of different type");
  10. err.setErrorCode("XPTY0004");
  11. throw err;
  12. }
  13. }

代码示例来源:origin: net.sourceforge.saxon/saxon

  1. /**
  2. * Subtract two year-month-durations
  3. */
  4. public DurationValue subtract(DurationValue other) throws XPathException {
  5. if (other instanceof YearMonthDurationValue) {
  6. return fromMonths(getLengthInMonths() -
  7. ((YearMonthDurationValue)other).getLengthInMonths());
  8. } else {
  9. XPathException err = new XPathException("Cannot subtract two durations of different type");
  10. err.setErrorCode("XPTY0004");
  11. throw err;
  12. }
  13. }

代码示例来源:origin: org.opengis.cite.saxon/saxon9

  1. /**
  2. * Subtract two year-month-durations
  3. */
  4. public DurationValue subtract(DurationValue other) throws XPathException {
  5. if (other instanceof YearMonthDurationValue) {
  6. return fromMonths(getLengthInMonths() -
  7. ((YearMonthDurationValue)other).getLengthInMonths());
  8. } else {
  9. XPathException err = new XPathException("Cannot subtract two durations of different type");
  10. err.setErrorCode("XPTY0004");
  11. throw err;
  12. }
  13. }

代码示例来源:origin: net.sourceforge.saxon/saxon

  1. /**
  2. * Add two year-month-durations
  3. */
  4. public DurationValue add(DurationValue other) throws XPathException {
  5. if (other instanceof YearMonthDurationValue) {
  6. return fromMonths(getLengthInMonths() +
  7. ((YearMonthDurationValue)other).getLengthInMonths());
  8. } else {
  9. XPathException err = new XPathException("Cannot add two durations of different type");
  10. err.setErrorCode("XPTY0004");
  11. throw err;
  12. }
  13. }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon

  1. /**
  2. * Add two year-month-durations
  3. */
  4. public DurationValue add(DurationValue other) throws XPathException {
  5. if (other instanceof YearMonthDurationValue) {
  6. return fromMonths(getLengthInMonths() +
  7. ((YearMonthDurationValue) other).getLengthInMonths());
  8. } else {
  9. XPathException err = new XPathException("Cannot add two durations of different type");
  10. err.setErrorCode("XPTY0004");
  11. throw err;
  12. }
  13. }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon

  1. /**
  2. * Subtract two year-month-durations
  3. */
  4. public DurationValue subtract(DurationValue other) throws XPathException {
  5. if (other instanceof YearMonthDurationValue) {
  6. return fromMonths(getLengthInMonths() -
  7. ((YearMonthDurationValue) other).getLengthInMonths());
  8. } else {
  9. XPathException err = new XPathException("Cannot subtract two durations of different type");
  10. err.setErrorCode("XPTY0004");
  11. throw err;
  12. }
  13. }

代码示例来源:origin: org.opengis.cite.saxon/saxon9

  1. /**
  2. * Add two year-month-durations
  3. */
  4. public DurationValue add(DurationValue other) throws XPathException {
  5. if (other instanceof YearMonthDurationValue) {
  6. return fromMonths(getLengthInMonths() +
  7. ((YearMonthDurationValue)other).getLengthInMonths());
  8. } else {
  9. XPathException err = new XPathException("Cannot add two durations of different type");
  10. err.setErrorCode("XPTY0004");
  11. throw err;
  12. }
  13. }

代码示例来源:origin: net.sf.saxon/Saxon-HE

  1. /**
  2. * Multiply duration by a number.
  3. */
  4. public YearMonthDurationValue multiply(double n) throws XPathException {
  5. if (Double.isNaN(n)) {
  6. XPathException err = new XPathException("Cannot multiply a duration by NaN");
  7. err.setErrorCode("FOCA0005");
  8. throw err;
  9. }
  10. double m = (double) getLengthInMonths();
  11. double product = n * m;
  12. if (Double.isInfinite(product) || product > Integer.MAX_VALUE || product < Integer.MIN_VALUE) {
  13. XPathException err = new XPathException("Overflow when multiplying a duration by a number");
  14. err.setErrorCode("FODT0002");
  15. throw err;
  16. }
  17. return fromMonths((int) Math.round(product));
  18. }

代码示例来源:origin: net.sf.saxon/Saxon-HE

  1. /**
  2. * Divide duration by a number.
  3. */
  4. public DurationValue divide(double n) throws XPathException {
  5. if (Double.isNaN(n)) {
  6. XPathException err = new XPathException("Cannot divide a duration by NaN");
  7. err.setErrorCode("FOCA0005");
  8. throw err;
  9. }
  10. double m = (double) getLengthInMonths();
  11. double product = m / n;
  12. if (Double.isInfinite(product) || product > Integer.MAX_VALUE || product < Integer.MIN_VALUE) {
  13. XPathException err = new XPathException("Overflow when dividing a duration by a number");
  14. err.setErrorCode("FODT0002");
  15. throw err;
  16. }
  17. return fromMonths((int) Math.round(product));
  18. }

相关文章