本文整理了Java中net.sf.saxon.value.YearMonthDurationValue
类的一些代码示例,展示了YearMonthDurationValue
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YearMonthDurationValue
类的具体详情如下:
包路径:net.sf.saxon.value.YearMonthDurationValue
类名称:YearMonthDurationValue
[英]A value of type xs:yearMonthDuration
[中]类型为xs:yearMonthDuration的值
代码示例来源:origin: net.sf.saxon/Saxon-HE
public ConversionResult convertString( CharSequence input) {
return YearMonthDurationValue.makeYearMonthDurationValue(input);
}
}
代码示例来源:origin: net.sourceforge.saxon/saxon
/**
* Construct a duration value as a number of months.
*
* @param months the number of months (may be negative)
* @return the corresponding xs:yearMonthDuration value
*/
public static YearMonthDurationValue fromMonths(int months) {
YearMonthDurationValue mdv = new YearMonthDurationValue();
mdv.negative = (months < 0);
mdv.months = (months < 0 ? -months : months);
mdv.seconds = 0;
mdv.microseconds = 0;
return mdv;
}
代码示例来源:origin: net.sf.saxon/Saxon-HE
/**
* Negate a duration (same as subtracting from zero, but it preserves the type of the original duration)
*/
public DurationValue negate() {
return fromMonths(-getLengthInMonths());
}
代码示例来源:origin: net.sf.saxon/Saxon-HE
/**
* Compare the value to another duration value
*
* @param other The other dateTime value
* @return negative value if this one is the earler, 0 if they are chronologically equal,
* positive value if this one is the later. For this purpose, dateTime values with an unknown
* timezone are considered to be UTC values (the Comparable interface requires
* a total ordering).
* @throws ClassCastException if the other value is not a DateTimeValue (the parameter
* is declared as Object to satisfy the Comparable interface)
*/
public int compareTo(YearMonthDurationValue other) {
return Integer.compare(getLengthInMonths(), other.getLengthInMonths());
}
代码示例来源:origin: org.opengis.cite.saxon/saxon9
/**
* Convert to string
*
* @return ISO 8601 representation.
*/
public CharSequence getStringValueCS() {
// The canonical representation has months in the range 0-11
int y = getYears();
int m = getMonths();
FastStringBuffer sb = new FastStringBuffer(32);
if (negative) {
sb.append('-');
}
sb.append('P');
if (y != 0) {
sb.append(y + "Y");
}
if (m != 0 || y == 0) {
sb.append(m + "M");
}
return sb;
}
代码示例来源:origin: net.sourceforge.saxon/saxon
StringTokenizer tok = new StringTokenizer(Whitespace.trimWhitespace(s).toString(), "-+PYM", true);
if (!tok.hasMoreElements()) {
return badDuration("empty string", s);
return badDuration("+ sign not allowed in a duration", s);
} else if ("-".equals(part)) {
negative = true;
return badDuration("missing 'P'", s);
int value = simpleInteger(part);
if (value < 0) {
return badDuration("non-numeric component", s);
return badDuration("missing unit letter at end", s);
case'Y':
if (state > 0) {
return badDuration("Y is out of sequence", s);
break;
} else {
return badDuration("M is out of sequence", s);
return badDuration("misplaced " + delim, s);
return badDuration("duration specifies no components", s);
return badDuration("duration exceeds limits", s);
代码示例来源:origin: net.sf.saxon/Saxon-HE
public YearMonthDurationValue convert(AtomicValue input) {
return YearMonthDurationValue.fromMonths(((DurationValue) input).getTotalMonths());
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon
/**
* Compare the value to another duration value
*
* @param other The other dateTime value
* @return negative value if this one is the earler, 0 if they are chronologically equal,
* positive value if this one is the later. For this purpose, dateTime values with an unknown
* timezone are considered to be UTC values (the Comparable interface requires
* a total ordering).
* @throws ClassCastException if the other value is not a DateTimeValue (the parameter
* is declared as Object to satisfy the Comparable interface)
*/
public int compareTo(YearMonthDurationValue other) {
return Integer.compare(getLengthInMonths(), other.getLengthInMonths());
}
代码示例来源:origin: net.sf.saxon/Saxon-HE
/**
* Convert to string
*
* @return ISO 8601 representation.
*/
public CharSequence getPrimitiveStringValue() {
// The canonical representation has months in the range 0-11
int y = getYears();
int m = getMonths();
FastStringBuffer sb = new FastStringBuffer(32);
if (negative) {
sb.append('-');
}
sb.append('P');
if (y != 0) {
sb.append(y + "Y");
}
if (m != 0 || y == 0) {
sb.append(m + "M");
}
return sb;
}
代码示例来源:origin: org.opengis.cite.saxon/saxon9
StringTokenizer tok = new StringTokenizer(Whitespace.trimWhitespace(s).toString(), "-+PYM", true);
if (!tok.hasMoreElements()) {
return badDuration("empty string", s);
return badDuration("+ sign not allowed in a duration", s);
} else if ("-".equals(part)) {
negative = true;
return badDuration("missing 'P'", s);
int value = simpleInteger(part);
if (value < 0) {
return badDuration("non-numeric component", s);
return badDuration("missing unit letter at end", s);
case'Y':
if (state > 0) {
return badDuration("Y is out of sequence", s);
break;
} else {
return badDuration("M is out of sequence", s);
return badDuration("misplaced " + delim, s);
return badDuration("duration specifies no components", s);
return badDuration("duration exceeds limits", s);
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon
public YearMonthDurationValue convert(AtomicValue input) {
return YearMonthDurationValue.fromMonths(((DurationValue) input).getTotalMonths());
}
}
代码示例来源:origin: net.sf.saxon/Saxon-HE
/**
* Create a copy of this atomic value, with a different type label
*
* @param typeLabel the type label of the new copy. The caller is responsible for checking that
* the value actually conforms to this type.
*/
/*@NotNull*/
public AtomicValue copyAsSubType(AtomicType typeLabel) {
YearMonthDurationValue v = YearMonthDurationValue.fromMonths(getLengthInMonths());
v.typeLabel = typeLabel;
return v;
}
代码示例来源:origin: net.sourceforge.saxon/saxon
/**
* Compare the value to another duration value
*
* @param other The other dateTime value
* @return negative value if this one is the earler, 0 if they are chronologically equal,
* positive value if this one is the later. For this purpose, dateTime values with an unknown
* timezone are considered to be UTC values (the Comparable interface requires
* a total ordering).
* @throws ClassCastException if the other value is not a DateTimeValue (the parameter
* is declared as Object to satisfy the Comparable interface)
*/
public int compareTo(Object other) {
if (other instanceof YearMonthDurationValue) {
return getLengthInMonths() - ((YearMonthDurationValue)other).getLengthInMonths();
} else {
throw new ClassCastException("Cannot compare a yearMonthDuration to an object of class "
+ other.getClass());
}
}
代码示例来源:origin: net.sourceforge.saxon/saxon
/**
* Convert to string
*
* @return ISO 8601 representation.
*/
public CharSequence getStringValueCS() {
// The canonical representation has months in the range 0-11
int y = getYears();
int m = getMonths();
FastStringBuffer sb = new FastStringBuffer(32);
if (negative) {
sb.append('-');
}
sb.append('P');
if (y != 0) {
sb.append(y + "Y");
}
if (m != 0 || y == 0) {
sb.append(m + "M");
}
return sb;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon
public ConversionResult convertString( CharSequence input) {
return YearMonthDurationValue.makeYearMonthDurationValue(input);
}
}
代码示例来源:origin: net.sf.saxon/Saxon-HE
/**
* Static factory: create a year-month duration value from a supplied string, in
* ISO 8601 format [+|-]PnYnM
*
* @param s a string in the lexical space of xs:yearMonthDuration.
* @return either a YearMonthDurationValue, or a ValidationFailure if the string was
* not in the lexical space of xs:yearMonthDuration.
*/
public static ConversionResult makeYearMonthDurationValue(CharSequence s) {
ConversionResult d = DurationValue.makeDuration(s, true, false);
if (d instanceof ValidationFailure) {
return d;
}
DurationValue dv = (DurationValue) d;
return YearMonthDurationValue.fromMonths((dv.getYears() * 12 + dv.getMonths()) * dv.signum());
}
代码示例来源:origin: net.sf.saxon/Saxon-HE
/**
* Construct a duration value as a number of months.
*
* @param months the number of months (may be negative)
* @return the corresponding xs:yearMonthDuration value
*/
public static YearMonthDurationValue fromMonths(int months) {
YearMonthDurationValue mdv = new YearMonthDurationValue();
mdv.negative = months < 0;
mdv.months = months < 0 ? -months : months;
mdv.seconds = 0;
mdv.nanoseconds = 0;
return mdv;
}
代码示例来源:origin: net.sourceforge.saxon/saxon
/**
* Negate a duration (same as subtracting from zero, but it preserves the type of the original duration)
*/
public DurationValue negate() {
return fromMonths(-getLengthInMonths());
}
代码示例来源:origin: org.opengis.cite.saxon/saxon9
/**
* Compare the value to another duration value
*
* @param other The other dateTime value
* @return negative value if this one is the earler, 0 if they are chronologically equal,
* positive value if this one is the later. For this purpose, dateTime values with an unknown
* timezone are considered to be UTC values (the Comparable interface requires
* a total ordering).
* @throws ClassCastException if the other value is not a DateTimeValue (the parameter
* is declared as Object to satisfy the Comparable interface)
*/
public int compareTo(Object other) {
if (other instanceof YearMonthDurationValue) {
return getLengthInMonths() - ((YearMonthDurationValue)other).getLengthInMonths();
} else {
throw new ClassCastException("Cannot compare a yearMonthDuration to an object of class "
+ other.getClass());
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon
/**
* Convert to string
*
* @return ISO 8601 representation.
*/
public CharSequence getPrimitiveStringValue() {
// The canonical representation has months in the range 0-11
int y = getYears();
int m = getMonths();
FastStringBuffer sb = new FastStringBuffer(32);
if (negative) {
sb.append('-');
}
sb.append('P');
if (y != 0) {
sb.append(y + "Y");
}
if (m != 0 || y == 0) {
sb.append(m + "M");
}
return sb;
}
内容来源于网络,如有侵权,请联系作者删除!