< prev index next >

src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/datatype/DurationImpl.java

Print this page




  78  * subtract 15 days from 1 month. See the javadoc of those methods
  79  * for detailed conditions where this could happen.</p>
  80  *
  81  * <p>Also, division of a duration by a number is not provided because
  82  * the {@link Duration} class can only deal with finite precision
  83  * decimal numbers. For example, one cannot represent 1 sec divided by 3.</p>
  84  *
  85  * <p>However, you could substitute a division by 3 with multiplying
  86  * by numbers such as 0.3 or 0.333.</p>
  87  *
  88  *
  89  *
  90  * <h2>Range of allowed values</h2>
  91  * <p>
  92  * Because some operations of {@link Duration} rely on {@link Calendar}
  93  * even though {@link Duration} can hold very large or very small values,
  94  * some of the methods may not work correctly on such {@link Duration}s.
  95  * The impacted methods document their dependency on {@link Calendar}.
  96  *
  97  *
  98  * @author <a href="mailto:Kohsuke.Kawaguchi@Sun.com">Kohsuke Kawaguchi</a>
  99  * @author <a href="mailto:Joseph.Fialli@Sun.com">Joseph Fialli</a>
 100 
 101  * @see XMLGregorianCalendar#add(Duration)
 102  */
 103 class DurationImpl
 104         extends Duration
 105         implements Serializable {
 106 
 107 
 108     /**
 109      * <p>Internal array of value Fields.</p>
 110      */
 111     private static final DatatypeConstants.Field[] FIELDS = new DatatypeConstants.Field[]{
 112         DatatypeConstants.YEARS,
 113         DatatypeConstants.MONTHS,
 114         DatatypeConstants.DAYS,
 115         DatatypeConstants.HOURS,
 116         DatatypeConstants.MINUTES,
 117         DatatypeConstants.SECONDS
 118     };
 119 
 120 


1846      *
1847      * <p>Serialization uses the lexical form returned by toString().</p>
1848      */
1849     private static final long serialVersionUID = 1L;
1850 
1851     /**
1852      * Writes {@link Duration} as a lexical representation
1853      * for maximum future compatibility.
1854      *
1855      * @return
1856      *      An object that encapsulates the string
1857      *      returned by <code>this.toString()</code>.
1858      */
1859     private Object writeReplace() throws IOException {
1860         return new DurationStream(this.toString());
1861     }
1862 
1863     /**
1864      * Representation of {@link Duration} in the object stream.
1865      *
1866      * @author Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
1867      */
1868     private static class DurationStream implements Serializable {
1869         private final String lexical;
1870 
1871         private DurationStream(String _lexical) {
1872             this.lexical = _lexical;
1873         }
1874 
1875         private Object readResolve() throws ObjectStreamException {
1876             return new DurationImpl(lexical);
1877         }
1878 
1879         private static final long serialVersionUID = 1L;
1880     }
1881 
1882 }


  78  * subtract 15 days from 1 month. See the javadoc of those methods
  79  * for detailed conditions where this could happen.</p>
  80  *
  81  * <p>Also, division of a duration by a number is not provided because
  82  * the {@link Duration} class can only deal with finite precision
  83  * decimal numbers. For example, one cannot represent 1 sec divided by 3.</p>
  84  *
  85  * <p>However, you could substitute a division by 3 with multiplying
  86  * by numbers such as 0.3 or 0.333.</p>
  87  *
  88  *
  89  *
  90  * <h2>Range of allowed values</h2>
  91  * <p>
  92  * Because some operations of {@link Duration} rely on {@link Calendar}
  93  * even though {@link Duration} can hold very large or very small values,
  94  * some of the methods may not work correctly on such {@link Duration}s.
  95  * The impacted methods document their dependency on {@link Calendar}.
  96  *
  97  *
  98  * @author Kohsuke Kawaguchi
  99  * @author Joseph Fialli

 100  * @see XMLGregorianCalendar#add(Duration)
 101  */
 102 class DurationImpl
 103         extends Duration
 104         implements Serializable {
 105 
 106 
 107     /**
 108      * <p>Internal array of value Fields.</p>
 109      */
 110     private static final DatatypeConstants.Field[] FIELDS = new DatatypeConstants.Field[]{
 111         DatatypeConstants.YEARS,
 112         DatatypeConstants.MONTHS,
 113         DatatypeConstants.DAYS,
 114         DatatypeConstants.HOURS,
 115         DatatypeConstants.MINUTES,
 116         DatatypeConstants.SECONDS
 117     };
 118 
 119 


1845      *
1846      * <p>Serialization uses the lexical form returned by toString().</p>
1847      */
1848     private static final long serialVersionUID = 1L;
1849 
1850     /**
1851      * Writes {@link Duration} as a lexical representation
1852      * for maximum future compatibility.
1853      *
1854      * @return
1855      *      An object that encapsulates the string
1856      *      returned by <code>this.toString()</code>.
1857      */
1858     private Object writeReplace() throws IOException {
1859         return new DurationStream(this.toString());
1860     }
1861 
1862     /**
1863      * Representation of {@link Duration} in the object stream.
1864      *
1865      * @author Kohsuke Kawaguchi
1866      */
1867     private static class DurationStream implements Serializable {
1868         private final String lexical;
1869 
1870         private DurationStream(String _lexical) {
1871             this.lexical = _lexical;
1872         }
1873 
1874         private Object readResolve() throws ObjectStreamException {
1875             return new DurationImpl(lexical);
1876         }
1877 
1878         private static final long serialVersionUID = 1L;
1879     }
1880 
1881 }
< prev index next >