Java Code Examples for javax.xml.datatype.DatatypeConstants#INDETERMINATE
The following examples show how to use
javax.xml.datatype.DatatypeConstants#INDETERMINATE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XMLGregorianCalendarImpl.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * <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); } } }
Example 2
Source File: XMLTimeUtil.java From keycloak with Apache License 2.0 | 6 votes |
/** * Validate that the current time falls between the two boundaries * * @param now * @param notbefore * @param notOnOrAfter * * @return */ public static boolean isValid(XMLGregorianCalendar now, XMLGregorianCalendar notbefore, XMLGregorianCalendar notOnOrAfter) { int val; if (notbefore != null) { val = notbefore.compare(now); if (val == DatatypeConstants.INDETERMINATE || val == DatatypeConstants.GREATER) return false; } if (notOnOrAfter != null) { val = notOnOrAfter.compare(now); if (val != DatatypeConstants.GREATER) return false; } return true; }
Example 3
Source File: XMLGregorianCalendarImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * <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); } } }
Example 4
Source File: XMLGregorianCalendarImpl.java From JDKSourceCode1.8 with MIT License | 6 votes |
/** * <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); } } }
Example 5
Source File: XMLGregorianCalendarImpl.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * <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); } } }
Example 6
Source File: XMLGregorianCalendarImpl.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private static int compareField(BigInteger Pfield, BigInteger Qfield) { if (Pfield == null) { return (Qfield == null ? DatatypeConstants.EQUAL : DatatypeConstants.INDETERMINATE); } if (Qfield == null) { return DatatypeConstants.INDETERMINATE; } return Pfield.compareTo(Qfield); }
Example 7
Source File: FEELXMLGregorianCalendar.java From jdmn with Apache License 2.0 | 5 votes |
private static int compareField(BigInteger field1, BigInteger field2) { if (field1 == null) { return field2 == null ? DatatypeConstants.EQUAL : DatatypeConstants.INDETERMINATE; } if (field2 == null) { return DatatypeConstants.INDETERMINATE; } return field1.compareTo(field2); }
Example 8
Source File: XMLGregorianCalendarImpl.java From Bytecoder with Apache License 2.0 | 5 votes |
private static int compareField(BigInteger Pfield, BigInteger Qfield) { if (Pfield == null) { return (Qfield == null ? DatatypeConstants.EQUAL : DatatypeConstants.INDETERMINATE); } if (Qfield == null) { return DatatypeConstants.INDETERMINATE; } return Pfield.compareTo(Qfield); }
Example 9
Source File: DurationImpl.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private int compareResults(int resultA, int resultB){ if ( resultB == DatatypeConstants.INDETERMINATE ) { return DatatypeConstants.INDETERMINATE; } else if ( resultA!=resultB) { return DatatypeConstants.INDETERMINATE; } return resultA; }
Example 10
Source File: XMLGregorianCalendarImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static int compareField(BigInteger Pfield, BigInteger Qfield) { if (Pfield == null) { return (Qfield == null ? DatatypeConstants.EQUAL : DatatypeConstants.INDETERMINATE); } if (Qfield == null) { return DatatypeConstants.INDETERMINATE; } return Pfield.compareTo(Qfield); }
Example 11
Source File: XMLGregorianCalendarImpl.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private static int compareField(BigInteger Pfield, BigInteger Qfield) { if (Pfield == null) { return (Qfield == null ? DatatypeConstants.EQUAL : DatatypeConstants.INDETERMINATE); } if (Qfield == null) { return DatatypeConstants.INDETERMINATE; } return Pfield.compareTo(Qfield); }
Example 12
Source File: XMLGregorianCalendarImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static int compareField(BigInteger Pfield, BigInteger Qfield) { if (Pfield == null) { return (Qfield == null ? DatatypeConstants.EQUAL : DatatypeConstants.INDETERMINATE); } if (Qfield == null) { return DatatypeConstants.INDETERMINATE; } return Pfield.compareTo(Qfield); }
Example 13
Source File: DurationImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private int compareResults(int resultA, int resultB) { if ( resultB == DatatypeConstants.INDETERMINATE ) { return DatatypeConstants.INDETERMINATE; } else if ( resultA!=resultB) { return DatatypeConstants.INDETERMINATE; } return resultA; }
Example 14
Source File: DurationImpl.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
private int compareResults(int resultA, int resultB){ if ( resultB == DatatypeConstants.INDETERMINATE ) { return DatatypeConstants.INDETERMINATE; } else if ( resultA!=resultB) { return DatatypeConstants.INDETERMINATE; } return resultA; }
Example 15
Source File: XMLGregorianCalendarImpl.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
private static int compareField(BigInteger Pfield, BigInteger Qfield) { if (Pfield == null) { return (Qfield == null ? DatatypeConstants.EQUAL : DatatypeConstants.INDETERMINATE); } if (Qfield == null) { return DatatypeConstants.INDETERMINATE; } return Pfield.compareTo(Qfield); }
Example 16
Source File: DurationComparison.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * See JDK-5077522, Duration.compare returns equal for INDETERMINATE * comparisons */ public void testCompareWithInderterminateRelation() { final String [][] partialOrder = { // partialOrder {"P1Y", "<>", "P365D"}, {"P1Y", "<>", "P366D"}, {"P1M", "<>", "P28D"}, {"P1M", "<>", "P29D"}, {"P1M", "<>", "P30D"}, {"P1M", "<>", "P31D"}, {"P5M", "<>", "P150D"}, {"P5M", "<>", "P151D"}, {"P5M", "<>", "P152D"}, {"P5M", "<>", "P153D"}, {"PT2419200S", "<>", "P1M"}, {"PT2678400S", "<>", "P1M"}, {"PT31536000S", "<>", "P1Y"}, {"PT31622400S", "<>", "P1Y"}, {"PT525600M", "<>", "P1Y"}, {"PT527040M", "<>", "P1Y"}, {"PT8760H", "<>", "P1Y"}, {"PT8784H", "<>", "P1Y"}, {"P365D", "<>", "P1Y"}, }; DatatypeFactory df = null; try { df = DatatypeFactory.newInstance(); } catch (DatatypeConfigurationException ex) { ex.printStackTrace(); fail(ex.toString()); } for (int valueIndex = 0; valueIndex < partialOrder.length; ++valueIndex) { Duration duration1 = df.newDuration(partialOrder[valueIndex][0]); Duration duration2 = df.newDuration(partialOrder[valueIndex][2]); int cmp = duration1.compare(duration2); int expected = ">".equals(partialOrder[valueIndex][1]) ? DatatypeConstants.GREATER : "<".equals(partialOrder[valueIndex][1]) ? DatatypeConstants.LESSER : "==".equals(partialOrder[valueIndex][1]) ? DatatypeConstants.EQUAL : DatatypeConstants.INDETERMINATE; if (expected != cmp) { fail("returned " + cmp2str(cmp) + " for durations \'" + duration1 + "\' and " + duration2 + "\', but expected " + cmp2str(expected)); } else { success("Comparing " + duration1 + " and " + duration2 + ": INDETERMINATE"); } } }
Example 17
Source File: XMLGregorianCalendarImpl.java From JDKSourceCode1.8 with MIT License | 4 votes |
/** * <p>Compare two instances of W3C XML Schema 1.0 date/time datatypes * according to partial order relation defined in * <a href="http://www.w3.org/TR/xmlschema-2/#dateTime-order">W3C XML Schema 1.0 Part 2, Section 3.2.7.3, * <i>Order relation on dateTime</i></a>.</p> * * <p><code>xsd:dateTime</code> datatype field mapping to accessors of * this class are defined in * <a href="#datetimefieldmapping">date/time field mapping table</a>.</p> * * @param rhs instance of <code>XMLGregorianCalendar</code> to compare * * @return the relationship between <code>lhs</code> and <code>rhs</code> as * {@link DatatypeConstants#LESSER}, * {@link DatatypeConstants#EQUAL}, * {@link DatatypeConstants#GREATER} or * {@link DatatypeConstants#INDETERMINATE}. * * @throws NullPointerException if <code>lhs</code> or <code>rhs</code> * parameters are null. */ public int compare(XMLGregorianCalendar rhs) { XMLGregorianCalendar lhs = this; int result = DatatypeConstants.INDETERMINATE; XMLGregorianCalendarImpl P = (XMLGregorianCalendarImpl) lhs; XMLGregorianCalendarImpl Q = (XMLGregorianCalendarImpl) rhs; if (P.getTimezone() == Q.getTimezone()) { // Optimization: // both instances are in same timezone or // both are FIELD_UNDEFINED. // Avoid costly normalization of timezone to 'Z' time. return internalCompare(P, Q); } else if (P.getTimezone() != DatatypeConstants.FIELD_UNDEFINED && Q.getTimezone() != DatatypeConstants.FIELD_UNDEFINED) { // Both instances have different timezones. // Normalize to UTC time and compare. P = (XMLGregorianCalendarImpl) P.normalize(); Q = (XMLGregorianCalendarImpl) Q.normalize(); return internalCompare(P, Q); } else if (P.getTimezone() != DatatypeConstants.FIELD_UNDEFINED) { if (P.getTimezone() != 0) { P = (XMLGregorianCalendarImpl) P.normalize(); } // C. step 1 XMLGregorianCalendar MinQ = Q.normalizeToTimezone(DatatypeConstants.MIN_TIMEZONE_OFFSET); result = internalCompare(P, MinQ); if (result == DatatypeConstants.LESSER) { return result; } // C. step 2 XMLGregorianCalendar MaxQ = Q.normalizeToTimezone(DatatypeConstants.MAX_TIMEZONE_OFFSET); result = internalCompare(P, MaxQ); if (result == DatatypeConstants.GREATER) { return result; } else { // C. step 3 return DatatypeConstants.INDETERMINATE; } } else { // Q.getTimezone() != DatatypeConstants.FIELD_UNDEFINED // P has no timezone and Q does. if (Q.getTimezone() != 0) { Q = (XMLGregorianCalendarImpl) Q.normalizeToTimezone(Q.getTimezone()); } // D. step 1 XMLGregorianCalendar MaxP = P.normalizeToTimezone(DatatypeConstants.MAX_TIMEZONE_OFFSET); result = internalCompare(MaxP, Q); if (result == DatatypeConstants.LESSER) { return result; } // D. step 2 XMLGregorianCalendar MinP = P.normalizeToTimezone(DatatypeConstants.MIN_TIMEZONE_OFFSET); result = internalCompare(MinP, Q); if (result == DatatypeConstants.GREATER) { return result; } else { // D. step 3 return DatatypeConstants.INDETERMINATE; } } }
Example 18
Source File: XMLGregorianCalendarImpl.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * <p>Compare two instances of W3C XML Schema 1.0 date/time datatypes * according to partial order relation defined in * <a href="http://www.w3.org/TR/xmlschema-2/#dateTime-order">W3C XML Schema 1.0 Part 2, Section 3.2.7.3, * <i>Order relation on dateTime</i></a>.</p> * * <p><code>xsd:dateTime</code> datatype field mapping to accessors of * this class are defined in * <a href="#datetimefieldmapping">date/time field mapping table</a>.</p> * * @param rhs instance of <code>XMLGregorianCalendar</code> to compare * * @return the relationship between <code>lhs</code> and <code>rhs</code> as * {@link DatatypeConstants#LESSER}, * {@link DatatypeConstants#EQUAL}, * {@link DatatypeConstants#GREATER} or * {@link DatatypeConstants#INDETERMINATE}. * * @throws NullPointerException if <code>lhs</code> or <code>rhs</code> * parameters are null. */ public int compare(XMLGregorianCalendar rhs) { XMLGregorianCalendar lhs = this; int result = DatatypeConstants.INDETERMINATE; XMLGregorianCalendarImpl P = (XMLGregorianCalendarImpl) lhs; XMLGregorianCalendarImpl Q = (XMLGregorianCalendarImpl) rhs; if (P.getTimezone() == Q.getTimezone()) { // Optimization: // both instances are in same timezone or // both are FIELD_UNDEFINED. // Avoid costly normalization of timezone to 'Z' time. return internalCompare(P, Q); } else if (P.getTimezone() != DatatypeConstants.FIELD_UNDEFINED && Q.getTimezone() != DatatypeConstants.FIELD_UNDEFINED) { // Both instances have different timezones. // Normalize to UTC time and compare. P = (XMLGregorianCalendarImpl) P.normalize(); Q = (XMLGregorianCalendarImpl) Q.normalize(); return internalCompare(P, Q); } else if (P.getTimezone() != DatatypeConstants.FIELD_UNDEFINED) { if (P.getTimezone() != 0) { P = (XMLGregorianCalendarImpl) P.normalize(); } // C. step 1 XMLGregorianCalendar MinQ = Q.normalizeToTimezone(DatatypeConstants.MIN_TIMEZONE_OFFSET); result = internalCompare(P, MinQ); if (result == DatatypeConstants.LESSER) { return result; } // C. step 2 XMLGregorianCalendar MaxQ = Q.normalizeToTimezone(DatatypeConstants.MAX_TIMEZONE_OFFSET); result = internalCompare(P, MaxQ); if (result == DatatypeConstants.GREATER) { return result; } else { // C. step 3 return DatatypeConstants.INDETERMINATE; } } else { // Q.getTimezone() != DatatypeConstants.FIELD_UNDEFINED // P has no timezone and Q does. if (Q.getTimezone() != 0) { Q = (XMLGregorianCalendarImpl) Q.normalizeToTimezone(Q.getTimezone()); } // D. step 1 XMLGregorianCalendar MaxP = P.normalizeToTimezone(DatatypeConstants.MAX_TIMEZONE_OFFSET); result = internalCompare(MaxP, Q); if (result == DatatypeConstants.LESSER) { return result; } // D. step 2 XMLGregorianCalendar MinP = P.normalizeToTimezone(DatatypeConstants.MIN_TIMEZONE_OFFSET); result = internalCompare(MinP, Q); if (result == DatatypeConstants.GREATER) { return result; } else { // D. step 3 return DatatypeConstants.INDETERMINATE; } } }
Example 19
Source File: XMLGregorianCalendarImpl.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * <p>Compare two instances of W3C XML Schema 1.0 date/time datatypes * according to partial order relation defined in * <a href="http://www.w3.org/TR/xmlschema-2/#dateTime-order">W3C XML Schema 1.0 Part 2, Section 3.2.7.3, * <i>Order relation on dateTime</i></a>.</p> * * <p><code>xsd:dateTime</code> datatype field mapping to accessors of * this class are defined in * <a href="#datetimefieldmapping">date/time field mapping table</a>.</p> * * @param rhs instance of <code>XMLGregorianCalendar</code> to compare * * @return the relationship between <code>lhs</code> and <code>rhs</code> as * {@link DatatypeConstants#LESSER}, * {@link DatatypeConstants#EQUAL}, * {@link DatatypeConstants#GREATER} or * {@link DatatypeConstants#INDETERMINATE}. * * @throws NullPointerException if <code>lhs</code> or <code>rhs</code> * parameters are null. */ public int compare(XMLGregorianCalendar rhs) { XMLGregorianCalendar lhs = this; int result = DatatypeConstants.INDETERMINATE; XMLGregorianCalendarImpl P = (XMLGregorianCalendarImpl) lhs; XMLGregorianCalendarImpl Q = (XMLGregorianCalendarImpl) rhs; if (P.getTimezone() == Q.getTimezone()) { // Optimization: // both instances are in same timezone or // both are FIELD_UNDEFINED. // Avoid costly normalization of timezone to 'Z' time. return internalCompare(P, Q); } else if (P.getTimezone() != DatatypeConstants.FIELD_UNDEFINED && Q.getTimezone() != DatatypeConstants.FIELD_UNDEFINED) { // Both instances have different timezones. // Normalize to UTC time and compare. P = (XMLGregorianCalendarImpl) P.normalize(); Q = (XMLGregorianCalendarImpl) Q.normalize(); return internalCompare(P, Q); } else if (P.getTimezone() != DatatypeConstants.FIELD_UNDEFINED) { if (P.getTimezone() != 0) { P = (XMLGregorianCalendarImpl) P.normalize(); } // C. step 1 XMLGregorianCalendar MinQ = Q.normalizeToTimezone(DatatypeConstants.MIN_TIMEZONE_OFFSET); result = internalCompare(P, MinQ); if (result == DatatypeConstants.LESSER) { return result; } // C. step 2 XMLGregorianCalendar MaxQ = Q.normalizeToTimezone(DatatypeConstants.MAX_TIMEZONE_OFFSET); result = internalCompare(P, MaxQ); if (result == DatatypeConstants.GREATER) { return result; } else { // C. step 3 return DatatypeConstants.INDETERMINATE; } } else { // Q.getTimezone() != DatatypeConstants.FIELD_UNDEFINED // P has no timezone and Q does. if (Q.getTimezone() != 0) { Q = (XMLGregorianCalendarImpl) Q.normalizeToTimezone(Q.getTimezone()); } // D. step 1 XMLGregorianCalendar MaxP = P.normalizeToTimezone(DatatypeConstants.MAX_TIMEZONE_OFFSET); result = internalCompare(MaxP, Q); if (result == DatatypeConstants.LESSER) { return result; } // D. step 2 XMLGregorianCalendar MinP = P.normalizeToTimezone(DatatypeConstants.MIN_TIMEZONE_OFFSET); result = internalCompare(MinP, Q); if (result == DatatypeConstants.GREATER) { return result; } else { // D. step 3 return DatatypeConstants.INDETERMINATE; } } }
Example 20
Source File: XMLGregorianCalendarImpl.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * <p>Compare two instances of W3C XML Schema 1.0 date/time datatypes * according to partial order relation defined in * <a href="http://www.w3.org/TR/xmlschema-2/#dateTime-order">W3C XML Schema 1.0 Part 2, Section 3.2.7.3, * <i>Order relation on dateTime</i></a>.</p> * * <p><code>xsd:dateTime</code> datatype field mapping to accessors of * this class are defined in * <a href="#datetimefieldmapping">date/time field mapping table</a>.</p> * * @param rhs instance of <code>XMLGregorianCalendar</code> to compare * * @return the relationship between <code>lhs</code> and <code>rhs</code> as * {@link DatatypeConstants#LESSER}, * {@link DatatypeConstants#EQUAL}, * {@link DatatypeConstants#GREATER} or * {@link DatatypeConstants#INDETERMINATE}. * * @throws NullPointerException if <code>lhs</code> or <code>rhs</code> * parameters are null. */ public int compare(XMLGregorianCalendar rhs) { XMLGregorianCalendar lhs = this; int result = DatatypeConstants.INDETERMINATE; XMLGregorianCalendarImpl P = (XMLGregorianCalendarImpl) lhs; XMLGregorianCalendarImpl Q = (XMLGregorianCalendarImpl) rhs; if (P.getTimezone() == Q.getTimezone()) { // Optimization: // both instances are in same timezone or // both are FIELD_UNDEFINED. // Avoid costly normalization of timezone to 'Z' time. return internalCompare(P, Q); } else if (P.getTimezone() != DatatypeConstants.FIELD_UNDEFINED && Q.getTimezone() != DatatypeConstants.FIELD_UNDEFINED) { // Both instances have different timezones. // Normalize to UTC time and compare. P = (XMLGregorianCalendarImpl) P.normalize(); Q = (XMLGregorianCalendarImpl) Q.normalize(); return internalCompare(P, Q); } else if (P.getTimezone() != DatatypeConstants.FIELD_UNDEFINED) { if (P.getTimezone() != 0) { P = (XMLGregorianCalendarImpl) P.normalize(); } // C. step 1 XMLGregorianCalendar MinQ = Q.normalizeToTimezone(DatatypeConstants.MIN_TIMEZONE_OFFSET); result = internalCompare(P, MinQ); if (result == DatatypeConstants.LESSER) { return result; } // C. step 2 XMLGregorianCalendar MaxQ = Q.normalizeToTimezone(DatatypeConstants.MAX_TIMEZONE_OFFSET); result = internalCompare(P, MaxQ); if (result == DatatypeConstants.GREATER) { return result; } else { // C. step 3 return DatatypeConstants.INDETERMINATE; } } else { // Q.getTimezone() != DatatypeConstants.FIELD_UNDEFINED // P has no timezone and Q does. if (Q.getTimezone() != 0) { Q = (XMLGregorianCalendarImpl) Q.normalizeToTimezone(Q.getTimezone()); } // D. step 1 XMLGregorianCalendar MaxP = P.normalizeToTimezone(DatatypeConstants.MAX_TIMEZONE_OFFSET); result = internalCompare(MaxP, Q); if (result == DatatypeConstants.LESSER) { return result; } // D. step 2 XMLGregorianCalendar MinP = P.normalizeToTimezone(DatatypeConstants.MIN_TIMEZONE_OFFSET); result = internalCompare(MinP, Q); if (result == DatatypeConstants.GREATER) { return result; } else { // D. step 3 return DatatypeConstants.INDETERMINATE; } } }