long days
PlainTime time
private void readObject(ObjectInputStream in) throws IOException
InvalidObjectException - (always)IOExceptionprivate Object writeReplace()
6 and as
least significant bit the value 1 if long should be used
for transferring the item amounts (else using int). Then
the data bytes for the duration items follow. The byte
sequence optionally ends with the sign information.
Schematic algorithm:
boolean useLong = ...;
byte header = (6 << 4);
if (useLong) header |= 1;
out.writeByte(header);
out.writeInt(getTotalLength().size());
for (Item<U> item : getTotalLength()) {
if (useLong) {
out.writeLong(item.getAmount());
} else {
out.writeInt((int) item.getAmount());
}
out.writeObject(item.getUnit());
}
if (getTotalLength().size() > 0) {
out.writeBoolean(isNegative());
}
private void readObject(ObjectInputStream in) throws IOException
InvalidObjectException - (always)IOExceptionprivate Object writeReplace()
4. The lowest bit is 1 if this
instance is a positive leap second. The bit (2) will be
set if there is a non-zero nanosecond part. After this
header byte eight bytes follow containing the unix time
(as long) and optional four bytes with the fraction part.
Schematic algorithm:
int header = 4;
header <<= 4;
if (isLeapSecond()) {
header |= 1;
}
int fraction = getNanosecond();
if (fraction > 0) {
header |= 2;
}
out.writeByte(header);
out.writeLong(getPosixTime());
if (fraction > 0) {
out.writeInt(fraction);
}
Timezone tz
private void readObject(ObjectInputStream in) throws IOException
InvalidObjectException - (always)IOExceptionprivate Object writeReplace()
1. The following
bits 4-7 contain the month. The second byte contains
at the bits 1-2 a year mark: 1 = year in the range
1850-2100, 2 = four-digit-year, 3 = year number with more
than four digits. The five least significant bits of second
byte contain the day of month. Then the year will be written
dependent on the year mark. Is the mark 1 then the year
will be written as byte, if the mark is 2 then the year
will be written as short else as int with four bytes.
Schematic algorithm:
int range;
if (year >= 1850 && year <= 2100) {
range = 1;
} else if (Math.abs(year) < 10000) {
range = 2;
} else {
range = 3;
}
int header = 1;
header <<= 4;
header |= month;
out.writeByte(header);
int header2 = range;
header2 <<= 5;
header2 |= dayOfMonth;
out.writeByte(header2);
if (range == 1) {
out.writeByte(year - 1850 - 128);
} else if (range == 2) {
out.writeShort(year);
} else {
out.writeInt(year);
}
private void readObject(ObjectInputStream in) throws IOException
InvalidObjectException - (always)IOExceptionprivate Object writeReplace()
2. Then
the data bytes for hour, minute, second and nanosecond
follow (in last case int instead of byte). Is the precision
limited to seconds, minutes or hours then the last non-zero
byte will be bit-inverted by the operator (~), and the
following bytes will be left out. The hour byte however
is always written.
Schematic algorithm:
out.writeByte(2 << 4);
if (time.nano == 0) {
if (time.second == 0) {
if (time.minute == 0) {
out.writeByte(~time.hour);
} else {
out.writeByte(time.hour);
out.writeByte(~time.minute);
}
} else {
out.writeByte(time.hour);
out.writeByte(time.minute);
out.writeByte(~time.second);
}
} else {
out.writeByte(time.hour);
out.writeByte(time.minute);
out.writeByte(time.second);
out.writeInt(time.nano);
}
private void readObject(ObjectInputStream in) throws IOException
InvalidObjectException - (always)IOExceptionprivate Object writeReplace()
8. Then
the data bytes for date and time component follow.
Schematic algorithm:
int range;
if (year >= 1850 && year <= 2100) {
range = 1;
} else if (Math.abs(year) < 10000) {
range = 2;
} else {
range = 3;
}
int header = 8; // type-id
header <<= 4;
header |= month;
out.writeByte(header);
int header2 = range;
header2 <<= 5;
header2 |= dayOfMonth;
out.writeByte(header2);
if (range == 1) {
out.writeByte(year - 1850 - 128);
} else if (range == 2) {
out.writeShort(year);
} else {
out.writeInt(year);
}
if (time.nano == 0) {
if (time.second == 0) {
if (time.minute == 0) {
out.writeByte(~time.hour);
} else {
out.writeByte(time.hour);
out.writeByte(~time.minute);
}
} else {
out.writeByte(time.hour);
out.writeByte(time.minute);
out.writeByte(~time.second);
}
} else {
out.writeByte(time.hour);
out.writeByte(time.minute);
out.writeByte(time.second);
out.writeInt(time.nano);
}
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
Implementation method of interface Externalizable.
IOException - in any case of IO-failuresClassNotFoundException - if class-loading failspublic void writeExternal(ObjectOutput out) throws IOException
Implementation method of interface Externalizable.
The first byte contains within the 4 most-significant bits the type of the object to be serialized. Then the data bytes follow in a bit-compressed representation.
writeReplace()-method of object
to be serializedIOException - in any case of IO-failuresprivate Object readResolve() throws ObjectStreamException
ObjectStreamExceptionprivate void readObject(ObjectInputStream in) throws IOException
InvalidObjectException - (always)IOExceptionprivate Object writeReplace()
3. If the weekend
is not saturday and sunday then the four least significant
bits will be set to 1. The second byte has in the
four most significant bits the first day of week, in the
other four bits the minimum days of first calendar week.
If there is no standard weekend then a third byte follows
which contains in the four most significant bits the start
and the four least significant bits the end of weekend.
Schematic algorithm:
boolean isoWeekend = (
(getStartOfWeekend() == Weekday.SATURDAY)
&& (getEndOfWeekend() == Weekday.SUNDAY)
);
int header = 3;
header <<= 4;
if (!isoWeekend) {
header |= 1;
}
out.writeByte(header);
int state = getFirstDayOfWeek().getValue();
state <<= 4;
state |= getMinimalDaysInFirstWeek();
out.writeByte(state);
if (!isoWeekend) {
state = getStartOfWeekend().getValue();
state <<= 4;
state |= getEndOfWeekend().getValue();
out.writeByte(state);
}
String name
int identity
int hash
long days
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
InvalidObjectException - if the state is inconsistentClassNotFoundException - if class-loading failsIOExceptionObject unit
long amount
> 0private void readObject(ObjectInputStream in) throws IOException
InvalidObjectException - (always)IOExceptionprivate Object writeReplace()
12. Then the
data bits for the id and the fallback timezone follow.
Schematic algorithm:
int header = (12 << 4);
out.writeByte(header);
out.writeObject(getID());
out.writeObject(getFallback());
private void readObject(ObjectInputStream in) throws IOException
InvalidObjectException - (always)IOExceptionprivate Object writeReplace()
14. If there is
a non-default transition strategy then the lowest bit is
set to 1 else to 0. After that the data bits
for the id, history and optionally the special strategy
follow.
Schematic algorithm:
boolean specialStrategy = (getStrategy() != Timezone.DEFAULT_CONFLICT_STRATEGY);
int header = (14 << 4);
if (specialStrategy) {
header |= 1;
}
out.writeByte(header);
out.writeObject(tz.getID());
out.writeObject(tz.getHistory());
if (specialStrategy) {
out.writeObject(tz.getStrategy());
}
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
InvalidObjectException - in case of inconsistenciesClassNotFoundException - if class-loading failsIOExceptionZonalOffset offset
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
Implementation method of interface Externalizable.
IOException - in case of I/O-problemsClassNotFoundException - if class-loading failspublic void writeExternal(ObjectOutput out) throws IOException
Implementation method of interface Externalizable.
The first byte contains within the 4 most-significant bits the type of the object to be serialized. Then the data bytes follow in a bit-compressed representation.
writeReplace()-method of object
to be serializedIOException - in case of I/O-problemsprivate void readObject(ObjectInputStream in) throws IOException
InvalidObjectException - (always)IOExceptionprivate Object writeReplace()
13. The lower
4 bits contain the concrete value of this strategy.
Schematic algorithm:
int key =
getGapResolver().ordinal() * 2 + getOverlapResolver().ordinal();
int header = (13 << 4);
header |= key;
out.writeByte(header);
private void readObject(ObjectInputStream in) throws IOException
InvalidObjectException - (always)IOExceptionprivate Object writeReplace()
15. If there is
any fractional part then the four least significant bits
are 1 else 0. After that the data bits
for the integral total shift and optionally the fractional
part follow.
Schematic algorithm:
boolean hasFraction = (this.getFractionalAmount() != 0);
int header = (15 << 4);
if (hasFraction) {
header |= 1;
}
out.writeByte(header);
out.writeInt(this.getIntegralAmount());
if (hasFraction) {
out.writeInt(this.getFractionalAmount());
}
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
IOException - in any case of inconsistenciesClassNotFoundException - if class-loading failslong posix
int previous
int total
int dst
Copyright © 2014–2017. All rights reserved.