當前位置: 首頁>>代碼示例>>Java>>正文


Java DatatypeConstants類代碼示例

本文整理匯總了Java中javax.xml.datatype.DatatypeConstants的典型用法代碼示例。如果您正苦於以下問題:Java DatatypeConstants類的具體用法?Java DatatypeConstants怎麽用?Java DatatypeConstants使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DatatypeConstants類屬於javax.xml.datatype包,在下文中一共展示了DatatypeConstants類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: normalize

import javax.xml.datatype.DatatypeConstants; //導入依賴的package包/類
/**
 * <p>Normalize this instance to UTC.</p>
 *
 * <p>2000-03-04T23:00:00+03:00 normalizes to 2000-03-04T20:00:00Z</p>
 * <p>Implements W3C XML Schema Part 2, Section 3.2.7.3 (A).</p>
 */
public XMLGregorianCalendar normalize() {

    XMLGregorianCalendar normalized = normalizeToTimezone(timezone);

    // if timezone was undefined, leave it undefined
    if (getTimezone() == DatatypeConstants.FIELD_UNDEFINED) {
        normalized.setTimezone(DatatypeConstants.FIELD_UNDEFINED);
    }

    // if milliseconds was undefined, leave it undefined
    if (getMillisecond() == DatatypeConstants.FIELD_UNDEFINED) {
        normalized.setMillisecond(DatatypeConstants.FIELD_UNDEFINED);
    }

    return normalized;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:23,代碼來源:XMLGregorianCalendarImpl.java

示例2: createDateTime

import javax.xml.datatype.DatatypeConstants; //導入依賴的package包/類
/**
 * <p>Create a Java instance of XML Schema builtin datatype dateTime.</p>
 *
 * @param year represents both high-order eons and low-order year.
 * @param month of <code>dateTime</code>
 * @param day of <code>dateTime</code>
 * @param hour of <code>dateTime</code>
 * @param minute of <code>dateTime</code>
 * @param second of <code>dateTime</code>
 *
 * @return <code>XMLGregorianCalendar</code> created from parameter values.
 *
 * @throws IllegalArgumentException if any parameter is outside value constraints for the field as specified in
 *   <a href="#datetimefieldmapping">date/time field mapping table</a>.
 *
 * @see DatatypeConstants#FIELD_UNDEFINED
 */
public static XMLGregorianCalendar createDateTime(
    int year,
    int month,
    int day,
    int hour,
    int minute,
    int second) {

    return new XMLGregorianCalendarImpl(
        year,
        month,
        day,
        hour,
        minute,
        second,
        DatatypeConstants.FIELD_UNDEFINED,  //millisecond
            DatatypeConstants.FIELD_UNDEFINED //timezone
    );
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:37,代碼來源:XMLGregorianCalendarImpl.java

示例3: createTime

import javax.xml.datatype.DatatypeConstants; //導入依賴的package包/類
/**
 * Create a Java instance of XML Schema builtin datatype <code>time</code>.
 * @param hours number of hours
 * @param minutes number of minutes
 * @param seconds number of seconds
 * @param timezone offset in minutes. {@link DatatypeConstants#FIELD_UNDEFINED} indicates optional field is not set.
 *
 * @return <code>XMLGregorianCalendar</code> created from parameter values.
 *
 * @see DatatypeConstants#FIELD_UNDEFINED
 *
 * @throws IllegalArgumentException if any parameter is outside value
 * constraints for the field as specified in
 * <a href="#datetimefieldmapping">date/time field mapping table</a>.
 */
public static XMLGregorianCalendar createTime(
    int hours,
    int minutes,
    int seconds,
            int timezone) {

            return new XMLGregorianCalendarImpl(
                    DatatypeConstants.FIELD_UNDEFINED, // Year
                    DatatypeConstants.FIELD_UNDEFINED, // Month
                    DatatypeConstants.FIELD_UNDEFINED, // Day
                    hours,
                    minutes,
                    seconds,
                    DatatypeConstants.FIELD_UNDEFINED, //Millisecond
                    timezone);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:32,代碼來源:XMLGregorianCalendarImpl.java

示例4: getEonAndYear

import javax.xml.datatype.DatatypeConstants; //導入依賴的package包/類
/**
 * <p>Return XML Schema 1.0 dateTime datatype field for
 * <code>year</code>.</p>
 *
 * <p>Value constraints for this value are summarized in
 * <a href="#datetimefield-year">year field of date/time field mapping table</a>.</p>
 *
 * @return sum of <code>eon</code> and <code>BigInteger.valueOf(year)</code>
 * when both fields are defined. When only <code>year</code> is defined,
 * return it. When both <code>eon</code> and <code>year</code> are not
 * defined, return <code>null</code>.
 *
 * @see #getEon()
 * @see #getYear()
 */
public BigInteger getEonAndYear() {

            // both are defined
            if (year != DatatypeConstants.FIELD_UNDEFINED
                    && eon != null) {

                    return eon.add(BigInteger.valueOf((long) year));
            }

            // only year is defined
            if (year != DatatypeConstants.FIELD_UNDEFINED
                    && eon == null) {

                    return BigInteger.valueOf((long) year);
            }

    // neither are defined
    // or only eon is defined which is not valid without a year
            return null;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:36,代碼來源:XMLGregorianCalendarImpl.java

示例5: compareField

import javax.xml.datatype.DatatypeConstants; //導入依賴的package包/類
/**
 * <p>Implement Step B from
 * http://www.w3.org/TR/xmlschema-2/#dateTime-order.</p>
 */
private static int compareField(int Pfield, int Qfield) {
    if (Pfield == Qfield) {

        //fields are either equal in value or both undefined.
        // Step B. 1.1 AND optimized result of performing 1.1-1.4.
        return DatatypeConstants.EQUAL;
    } else {
        if (Pfield == DatatypeConstants.FIELD_UNDEFINED || Qfield == DatatypeConstants.FIELD_UNDEFINED) {
            // Step B. 1.2
            return DatatypeConstants.INDETERMINATE;
        } else {
            // Step B. 1.3-4.
            return (Pfield < Qfield ? DatatypeConstants.LESSER : DatatypeConstants.GREATER);
        }
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:21,代碼來源:XMLGregorianCalendarImpl.java

示例6: hashCode

import javax.xml.datatype.DatatypeConstants; //導入依賴的package包/類
/**
 * <p>Returns a hash code consistent with the definition of the equals method.</p>
 *
 * @return hash code of this object.
 */
public int hashCode() {

    // Following two dates compare to EQUALS since in different timezones.
    // 2000-01-15T12:00:00-05:00 == 2000-01-15T13:00:00-04:00
    //
    // Must ensure both instances generate same hashcode by normalizing
    // this to UTC timezone.
    int timezone = getTimezone();
    if (timezone == DatatypeConstants.FIELD_UNDEFINED) {
        timezone = 0;
    }
    XMLGregorianCalendar gc = this;
    if (timezone != 0) {
        gc = this.normalizeToTimezone(getTimezone());
    }
    return gc.getYear() + gc.getMonth() + gc.getDay() +
            gc.getHour() + gc.getMinute() + gc.getSecond();
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:24,代碼來源:XMLGregorianCalendarImpl.java

示例7: DurationImpl

import javax.xml.datatype.DatatypeConstants; //導入依賴的package包/類
/**
 * <p>Constructs a new Duration object by specifying each field
 * individually.</p>
 *
 * <p>This method is functionally equivalent to
 * invoking another constructor by wrapping
 * all non-zero parameters into {@link BigInteger} and {@link BigDecimal}.
 * Zero value of int parameter is equivalent of null value of
 * the corresponding field.</p>
 *
 * @see #DurationImpl(boolean, BigInteger, BigInteger, BigInteger, BigInteger,
 *   BigInteger, BigDecimal)
 */
protected DurationImpl(
    final boolean isPositive,
    final int years,
    final int months,
    final int days,
    final int hours,
    final int minutes,
    final int seconds) {
    this(
        isPositive,
        wrap(years),
        wrap(months),
        wrap(days),
        wrap(hours),
        wrap(minutes),
        seconds != DatatypeConstants.FIELD_UNDEFINED ? new BigDecimal(String.valueOf(seconds)) : null);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:31,代碼來源:DurationImpl.java

示例8: getFieldAsBigDecimal

import javax.xml.datatype.DatatypeConstants; //導入依賴的package包/類
/**
 * <p>Gets the value of the field as a {@link BigDecimal}.</p>
 *
 * <p>If the field is unset, return 0.</p>
 *
 * @param f Field to get value for.
 *
 * @return  non-null valid {@link BigDecimal}.
 */
private BigDecimal getFieldAsBigDecimal(DatatypeConstants.Field f) {
    if (f == DatatypeConstants.SECONDS) {
        if (seconds != null) {
            return seconds;
        } else {
            return ZERO;
        }
    } else {
        BigInteger bi = (BigInteger) getField(f);
        if (bi == null) {
            return ZERO;
        } else {
            return new BigDecimal(bi);
        }
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:26,代碼來源:DurationImpl.java

示例9: setYear

import javax.xml.datatype.DatatypeConstants; //導入依賴的package包/類
/**
 * <p>Set year of XSD <code>dateTime</code> year field.</p>
 *
 * <p>Unset this field by invoking the setter with a parameter value of
 * {@link DatatypeConstants#FIELD_UNDEFINED}.</p>
 *
 * <p>Note: if the absolute value of the <code>year</code> parameter
 * is less than 10^9, the eon component of the XSD year field is set to
 * <code>null</code> by this method.</p>
 *
 * @param year value constraints are summarized in <a href="#datetimefield-year">year field of date/time field mapping table</a>.
 *   If year is {@link DatatypeConstants#FIELD_UNDEFINED}, then eon is set to <code>null</code>.
 */
public final void setYear(int year) {
    if (year == DatatypeConstants.FIELD_UNDEFINED) {
        this.year = DatatypeConstants.FIELD_UNDEFINED;
        this.eon = null;
    }
    else if (Math.abs(year) < BILLION_I) {
        this.year = year;
        this.eon = null;
    } else {
        BigInteger theYear = BigInteger.valueOf((long) year);
        BigInteger remainder = theYear.remainder(BILLION_B);
        this.year = remainder.intValue();
        setEon(theYear.subtract(remainder));
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:29,代碼來源:XMLGregorianCalendarImpl.java

示例10: equals

import javax.xml.datatype.DatatypeConstants; //導入依賴的package包/類
/**
 * <p>Indicates whether parameter <code>obj</code> is "equal to" this one.</p>
 *
 * @param obj to compare.
 *
 * @return <code>true</code> when <code>compare(this,(XMLGregorianCalendar)obj) == EQUAL.</code>.
 */
public boolean equals(Object obj) {

    if (obj == null || !(obj instanceof XMLGregorianCalendar)) {
        return false;
    }
    if (obj == this) {
        return true;
    }
    return compare((XMLGregorianCalendar) obj) == DatatypeConstants.EQUAL;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:18,代碼來源:XMLGregorianCalendarImpl.java

示例11: getFieldAsBigDecimal

import javax.xml.datatype.DatatypeConstants; //導入依賴的package包/類
/**
 * <p>Gets the value of the field as a {@link BigDecimal}.</p>
 *
 * <p>If the field is unset, return 0.</p>
 *
 * @param f Field to get value for.
 *
 * @return  non-null valid {@link BigDecimal}.
 */
private BigDecimal getFieldAsBigDecimal(DatatypeConstants.Field f) {
    if (f == DatatypeConstants.SECONDS) {
        if (seconds != null) {
            return seconds;
        }
        else {
            return ZERO;
        }
    }
    else {
        BigInteger bi = (BigInteger) getField(f);
        if (bi == null) {
            return ZERO;
        }
        else {
            return new BigDecimal(bi);
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:29,代碼來源:DurationImpl.java

示例12: getXmlDate

import javax.xml.datatype.DatatypeConstants; //導入依賴的package包/類
public static XMLGregorianCalendar getXmlDate(Date dateAndTime) {
    ParamUtil.requireNonNull("dateAndTime", dateAndTime);
    GregorianCalendar cal = new GregorianCalendar();
    cal.setTimeZone(UTC);
    cal.setTime(dateAndTime);

    try {
        XMLGregorianCalendar ret = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal);
        ret.setMillisecond(DatatypeConstants.FIELD_UNDEFINED);
        return ret;
    } catch (DatatypeConfigurationException ex) {
        return null;
    }
}
 
開發者ID:xipki,項目名稱:xitk,代碼行數:15,代碼來源:XmlUtil.java

示例13: createDate

import javax.xml.datatype.DatatypeConstants; //導入依賴的package包/類
/**
 * <p>Create a Java representation of XML Schema builtin datatype <code>date</code> or <code>g*</code>.</p>
 *
 * <p>For example, an instance of <code>gYear</code> can be created invoking this factory
 * with <code>month</code> and <code>day</code> parameters set to
 * {@link DatatypeConstants#FIELD_UNDEFINED}.</p>
 *
 * @param year of <code>XMLGregorianCalendar</code> to be created.
 * @param month of <code>XMLGregorianCalendar</code> to be created.
 * @param day of <code>XMLGregorianCalendar</code> to be created.
 * @param timezone offset in minutes. {@link DatatypeConstants#FIELD_UNDEFINED} indicates optional field is not set.
 *
 * @return <code>XMLGregorianCalendar</code> created from parameter values.
 *
 * @see DatatypeConstants#FIELD_UNDEFINED
 *
 * @throws IllegalArgumentException if any parameter is outside value
 * constraints for the field as specified in
 * <a href="#datetimefieldmapping">date/time field mapping table</a>.
 */
public static XMLGregorianCalendar createDate(
    int year,
    int month,
    int day,
    int timezone) {

    return new XMLGregorianCalendarImpl(
        year,
        month,
        day,
        DatatypeConstants.FIELD_UNDEFINED, // hour
        DatatypeConstants.FIELD_UNDEFINED, // minute
        DatatypeConstants.FIELD_UNDEFINED, // second
            DatatypeConstants.FIELD_UNDEFINED, // millisecond
        timezone);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:37,代碼來源:XMLGregorianCalendarImpl.java

示例14: getSeconds

import javax.xml.datatype.DatatypeConstants; //導入依賴的package包/類
/**
 * @return result of adding second and fractional second field
 */
private BigDecimal getSeconds() {
    if (second == DatatypeConstants.FIELD_UNDEFINED) {
        return DECIMAL_ZERO;
    }
    BigDecimal result = BigDecimal.valueOf((long) second);
    if (fractionalSecond != null) {
        return result.add(fractionalSecond);
    } else {
        return result;
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:15,代碼來源:XMLGregorianCalendarImpl.java

示例15: setYear

import javax.xml.datatype.DatatypeConstants; //導入依賴的package包/類
/**
 * <p>Set year of XSD <code>dateTime</code> year field.</p>
 *
 * <p>Unset this field by invoking the setter with a parameter value of
 * {@link DatatypeConstants#FIELD_UNDEFINED}.</p>
 *
 * <p>Note: if the absolute value of the <code>year</code> parameter
 * is less than 10^9, the eon component of the XSD year field is set to
 * <code>null</code> by this method.</p>
 *
 * @param year value constraints are summarized in <a href="#datetimefield-year">year field of date/time field mapping table</a>.
 *   If year is {@link DatatypeConstants#FIELD_UNDEFINED}, then eon is set to <code>null</code>.
 */
public void setYear(int year) {
    if (year == DatatypeConstants.FIELD_UNDEFINED) {
        this.year = DatatypeConstants.FIELD_UNDEFINED;
        this.eon = null;
    } else if (Math.abs(year) < BILLION.intValue()) {
        this.year = year;
        this.eon = null;
    } else {
        BigInteger theYear = BigInteger.valueOf((long) year);
        BigInteger remainder = theYear.remainder(BILLION);
        this.year = remainder.intValue();
        setEon(theYear.subtract(remainder));
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:28,代碼來源:XMLGregorianCalendarImpl.java


注:本文中的javax.xml.datatype.DatatypeConstants類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。