Java Doc for BasePeriod.java in  » Development » Joda-Time » org » joda » time » base » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Development » Joda Time » org.joda.time.base 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.joda.time.base.AbstractPeriod
      org.joda.time.base.BasePeriod

All known Subclasses:   org.joda.time.Period,  org.joda.time.MutablePeriod,
BasePeriod
abstract public class BasePeriod extends AbstractPeriod implements ReadablePeriod,Serializable(Code)
BasePeriod is an abstract implementation of ReadablePeriod that stores data in a PeriodType and an int[].

This class should generally not be used directly by API users. The ReadablePeriod interface should be used when different kinds of period objects are to be referenced.

BasePeriod subclasses may be mutable and not thread-safe.
author:
   Brian S O'Neill
author:
   Stephen Colebourne
since:
   1.0




Constructor Summary
protected  BasePeriod(int years, int months, int weeks, int days, int hours, int minutes, int seconds, int millis, PeriodType type)
     Creates a period from a set of field values.
protected  BasePeriod(long startInstant, long endInstant, PeriodType type, Chronology chrono)
     Creates a period from the given interval endpoints.
protected  BasePeriod(ReadableInstant startInstant, ReadableInstant endInstant, PeriodType type)
     Creates a period from the given interval endpoints.
protected  BasePeriod(ReadablePartial start, ReadablePartial end, PeriodType type)
     Creates a period from the given duration and end point.

The two partials must contain the same fields, thus you can specify two LocalDate objects, or two LocalTime objects, but not one of each. As these are Partial objects, time zones have no effect on the result.

The two partials must also both be contiguous - see DateTimeUtils.isContiguous(ReadablePartial) for a definition.

protected  BasePeriod(ReadableInstant startInstant, ReadableDuration duration, PeriodType type)
     Creates a period from the given start point and duration.
protected  BasePeriod(ReadableDuration duration, ReadableInstant endInstant, PeriodType type)
     Creates a period from the given duration and end point.
protected  BasePeriod(long duration, PeriodType type, Chronology chrono)
     Creates a period from the given millisecond duration, which is only really suitable for durations less than one day.
protected  BasePeriod(Object period, PeriodType type, Chronology chrono)
     Creates a new period based on another using the ConverterManager .
protected  BasePeriod(int[] values, PeriodType type)
     Constructor used when we trust ourselves.

Method Summary
protected  voidaddField(DurationFieldType field, int value)
     Adds the value of a field in this period.
protected  voidaddFieldInto(int[] values, DurationFieldType field, int value)
     Adds the value of a field in this period.
protected  voidaddPeriod(ReadablePeriod period)
     Adds the fields from another period.
protected  int[]addPeriodInto(int[] values, ReadablePeriod period)
     Adds the fields from another period.
protected  PeriodTypecheckPeriodType(PeriodType type)
     Validates a period type, converting nulls to a default value and checking the type is suitable for this instance.
public  DurationFieldTypegetFieldType(int index)
     Gets the field type at the specified index.
public  PeriodTypegetPeriodType()
     Gets the period type.
public  intgetValue(int index)
     Gets the value at the specified index.
protected  voidmergePeriod(ReadablePeriod period)
     Merges the fields from another period.
protected  int[]mergePeriodInto(int[] values, ReadablePeriod period)
     Merges the fields from another period.
protected  voidsetField(DurationFieldType field, int value)
     Sets the value of a field in this period.
protected  voidsetFieldInto(int[] values, DurationFieldType field, int value)
     Sets the value of a field in this period.
protected  voidsetPeriod(ReadablePeriod period)
     Sets all the fields of this period from another.
protected  voidsetPeriod(int years, int months, int weeks, int days, int hours, int minutes, int seconds, int millis)
     Sets the eight standard the fields in one go.
protected  voidsetValue(int index, int value)
     Sets the value of the field at the specifed index.
protected  voidsetValues(int[] values)
     Sets the values of all fields.
public  intsize()
     Gets the number of fields that this period supports.
public  DurationtoDurationFrom(ReadableInstant startInstant)
     Gets the total millisecond duration of this period relative to a start instant.
public  DurationtoDurationTo(ReadableInstant endInstant)
     Gets the total millisecond duration of this period relative to an end instant.


Constructor Detail
BasePeriod
protected BasePeriod(int years, int months, int weeks, int days, int hours, int minutes, int seconds, int millis, PeriodType type)(Code)
Creates a period from a set of field values.
Parameters:
  years - amount of years in this period, which must be zero if unsupported
Parameters:
  months - amount of months in this period, which must be zero if unsupported
Parameters:
  weeks - amount of weeks in this period, which must be zero if unsupported
Parameters:
  days - amount of days in this period, which must be zero if unsupported
Parameters:
  hours - amount of hours in this period, which must be zero if unsupported
Parameters:
  minutes - amount of minutes in this period, which must be zero if unsupported
Parameters:
  seconds - amount of seconds in this period, which must be zero if unsupported
Parameters:
  millis - amount of milliseconds in this period, which must be zero if unsupported
Parameters:
  type - which set of fields this period supports
throws:
  IllegalArgumentException - if period type is invalid
throws:
  IllegalArgumentException - if an unsupported field's value is non-zero



BasePeriod
protected BasePeriod(long startInstant, long endInstant, PeriodType type, Chronology chrono)(Code)
Creates a period from the given interval endpoints.
Parameters:
  startInstant - interval start, in milliseconds
Parameters:
  endInstant - interval end, in milliseconds
Parameters:
  type - which set of fields this period supports, null means standard
Parameters:
  chrono - the chronology to use, null means ISO default
throws:
  IllegalArgumentException - if period type is invalid



BasePeriod
protected BasePeriod(ReadableInstant startInstant, ReadableInstant endInstant, PeriodType type)(Code)
Creates a period from the given interval endpoints.
Parameters:
  startInstant - interval start, null means now
Parameters:
  endInstant - interval end, null means now
Parameters:
  type - which set of fields this period supports, null means standard
throws:
  IllegalArgumentException - if period type is invalid



BasePeriod
protected BasePeriod(ReadablePartial start, ReadablePartial end, PeriodType type)(Code)
Creates a period from the given duration and end point.

The two partials must contain the same fields, thus you can specify two LocalDate objects, or two LocalTime objects, but not one of each. As these are Partial objects, time zones have no effect on the result.

The two partials must also both be contiguous - see DateTimeUtils.isContiguous(ReadablePartial) for a definition. Both LocalDate and LocalTime are contiguous.
Parameters:
  start - the start of the period, must not be null
Parameters:
  end - the end of the period, must not be null
Parameters:
  type - which set of fields this period supports, null means standard
throws:
  IllegalArgumentException - if the partials are null or invalid
since:
   1.1




BasePeriod
protected BasePeriod(ReadableInstant startInstant, ReadableDuration duration, PeriodType type)(Code)
Creates a period from the given start point and duration.
Parameters:
  startInstant - the interval start, null means now
Parameters:
  duration - the duration of the interval, null means zero-length
Parameters:
  type - which set of fields this period supports, null means standard



BasePeriod
protected BasePeriod(ReadableDuration duration, ReadableInstant endInstant, PeriodType type)(Code)
Creates a period from the given duration and end point.
Parameters:
  duration - the duration of the interval, null means zero-length
Parameters:
  endInstant - the interval end, null means now
Parameters:
  type - which set of fields this period supports, null means standard



BasePeriod
protected BasePeriod(long duration, PeriodType type, Chronology chrono)(Code)
Creates a period from the given millisecond duration, which is only really suitable for durations less than one day.

Only fields that are precise will be used. Thus the largest precise field may have a large value.
Parameters:
  duration - the duration, in milliseconds
Parameters:
  type - which set of fields this period supports, null means standard
Parameters:
  chrono - the chronology to use, null means ISO default
throws:
  IllegalArgumentException - if period type is invalid




BasePeriod
protected BasePeriod(Object period, PeriodType type, Chronology chrono)(Code)
Creates a new period based on another using the ConverterManager .
Parameters:
  period - the period to convert
Parameters:
  type - which set of fields this period supports, null means use type from object
Parameters:
  chrono - the chronology to use, null means ISO default
throws:
  IllegalArgumentException - if period is invalid
throws:
  IllegalArgumentException - if an unsupported field's value is non-zero



BasePeriod
protected BasePeriod(int[] values, PeriodType type)(Code)
Constructor used when we trust ourselves. Do not expose publically.
Parameters:
  values - the values to use, not null, not cloned
Parameters:
  type - which set of fields this period supports, not null




Method Detail
addField
protected void addField(DurationFieldType field, int value)(Code)
Adds the value of a field in this period.
Parameters:
  field - the field to set
Parameters:
  value - the value to set
throws:
  IllegalArgumentException - if field is is null or not supported.



addFieldInto
protected void addFieldInto(int[] values, DurationFieldType field, int value)(Code)
Adds the value of a field in this period.
Parameters:
  values - the array of values to update
Parameters:
  field - the field to set
Parameters:
  value - the value to set
throws:
  IllegalArgumentException - if field is is null or not supported.



addPeriod
protected void addPeriod(ReadablePeriod period)(Code)
Adds the fields from another period.
Parameters:
  period - the period to add from, not null
throws:
  IllegalArgumentException - if an unsupported field's value is non-zero



addPeriodInto
protected int[] addPeriodInto(int[] values, ReadablePeriod period)(Code)
Adds the fields from another period.
Parameters:
  values - the array of values to update
Parameters:
  period - the period to add from, not null the updated values
throws:
  IllegalArgumentException - if an unsupported field's value is non-zero



checkPeriodType
protected PeriodType checkPeriodType(PeriodType type)(Code)
Validates a period type, converting nulls to a default value and checking the type is suitable for this instance.
Parameters:
  type - the type to check, may be null the validated type to use, not null
throws:
  IllegalArgumentException - if the period type is invalid



getFieldType
public DurationFieldType getFieldType(int index)(Code)
Gets the field type at the specified index.
Parameters:
  index - the index to retrieve the field at the specified index
throws:
  IndexOutOfBoundsException - if the index is invalid



getPeriodType
public PeriodType getPeriodType()(Code)
Gets the period type. the period type



getValue
public int getValue(int index)(Code)
Gets the value at the specified index.
Parameters:
  index - the index to retrieve the value of the field at the specified index
throws:
  IndexOutOfBoundsException - if the index is invalid



mergePeriod
protected void mergePeriod(ReadablePeriod period)(Code)
Merges the fields from another period.
Parameters:
  period - the period to add from, not null
throws:
  IllegalArgumentException - if an unsupported field's value is non-zero



mergePeriodInto
protected int[] mergePeriodInto(int[] values, ReadablePeriod period)(Code)
Merges the fields from another period.
Parameters:
  values - the array of values to update
Parameters:
  period - the period to add from, not null the updated values
throws:
  IllegalArgumentException - if an unsupported field's value is non-zero



setField
protected void setField(DurationFieldType field, int value)(Code)
Sets the value of a field in this period.
Parameters:
  field - the field to set
Parameters:
  value - the value to set
throws:
  IllegalArgumentException - if field is is null or not supported.



setFieldInto
protected void setFieldInto(int[] values, DurationFieldType field, int value)(Code)
Sets the value of a field in this period.
Parameters:
  values - the array of values to update
Parameters:
  field - the field to set
Parameters:
  value - the value to set
throws:
  IllegalArgumentException - if field is null or not supported.



setPeriod
protected void setPeriod(ReadablePeriod period)(Code)
Sets all the fields of this period from another.
Parameters:
  period - the period to copy from, not null
throws:
  IllegalArgumentException - if an unsupported field's value is non-zero



setPeriod
protected void setPeriod(int years, int months, int weeks, int days, int hours, int minutes, int seconds, int millis)(Code)
Sets the eight standard the fields in one go.
Parameters:
  years - amount of years in this period, which must be zero if unsupported
Parameters:
  months - amount of months in this period, which must be zero if unsupported
Parameters:
  weeks - amount of weeks in this period, which must be zero if unsupported
Parameters:
  days - amount of days in this period, which must be zero if unsupported
Parameters:
  hours - amount of hours in this period, which must be zero if unsupported
Parameters:
  minutes - amount of minutes in this period, which must be zero if unsupported
Parameters:
  seconds - amount of seconds in this period, which must be zero if unsupported
Parameters:
  millis - amount of milliseconds in this period, which must be zero if unsupported
throws:
  IllegalArgumentException - if an unsupported field's value is non-zero



setValue
protected void setValue(int index, int value)(Code)
Sets the value of the field at the specifed index.
Parameters:
  index - the index
Parameters:
  value - the value to set
throws:
  IndexOutOfBoundsException - if the index is invalid



setValues
protected void setValues(int[] values)(Code)
Sets the values of all fields.
Parameters:
  values - the array of values



size
public int size()(Code)
Gets the number of fields that this period supports. the number of fields supported



toDurationFrom
public Duration toDurationFrom(ReadableInstant startInstant)(Code)
Gets the total millisecond duration of this period relative to a start instant.

This method adds the period to the specified instant in order to calculate the duration.

An instant must be supplied as the duration of a period varies. For example, a period of 1 month could vary between the equivalent of 28 and 31 days in milliseconds due to different length months. Similarly, a day can vary at Daylight Savings cutover, typically between 23 and 25 hours.
Parameters:
  startInstant - the instant to add the period to, thus obtaining the duration the total length of the period as a duration relative to the start instant
throws:
  ArithmeticException - if the millis exceeds the capacity of the duration




toDurationTo
public Duration toDurationTo(ReadableInstant endInstant)(Code)
Gets the total millisecond duration of this period relative to an end instant.

This method subtracts the period from the specified instant in order to calculate the duration.

An instant must be supplied as the duration of a period varies. For example, a period of 1 month could vary between the equivalent of 28 and 31 days in milliseconds due to different length months. Similarly, a day can vary at Daylight Savings cutover, typically between 23 and 25 hours.
Parameters:
  endInstant - the instant to subtract the period from, thus obtaining the duration the total length of the period as a duration relative to the end instant
throws:
  ArithmeticException - if the millis exceeds the capacity of the duration




Methods inherited from org.joda.time.base.AbstractPeriod
public boolean equals(Object period)(Code)(Java Doc)
public int get(DurationFieldType type)(Code)(Java Doc)
public DurationFieldType[] getFieldTypes()(Code)(Java Doc)
public int[] getValues()(Code)(Java Doc)
public int hashCode()(Code)(Java Doc)
public int indexOf(DurationFieldType type)(Code)(Java Doc)
public boolean isSupported(DurationFieldType type)(Code)(Java Doc)
public MutablePeriod toMutablePeriod()(Code)(Java Doc)
public Period toPeriod()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
public String toString(PeriodFormatter formatter)(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.