long days
PlainTime time
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
InvalidObjectException - (always)IOExceptionClassNotFoundExceptionprivate Object writeReplace() throws ObjectStreamException
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());
}
ObjectStreamExceptionprivate void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
InvalidObjectException - (always)IOExceptionClassNotFoundExceptionprivate Object writeReplace() throws ObjectStreamException
7 and as
least significant bit the value 1 if this instance uses
the UTC-scale. Then the bytes for the seconds and fraction
follow. The fraction bytes are only written if the fraction
is not zero. In that case, the second least significant bit
of the header is set, too.
Schematic algorithm:
byte header = (7 << 4);
if (scale == TimeScale.UTC) header |= 1;
if (this.getFraction() > 0) header |= 2;
out.writeByte(header);
out.writeLong(getSeconds());
if (this.getFraction() > 0) {
out.writeInt(getFraction());
}
ObjectStreamExceptionprivate void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
InvalidObjectException - (always)IOExceptionClassNotFoundExceptionprivate Object writeReplace() throws ObjectStreamException
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);
}
ObjectStreamExceptionprivate void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
InvalidObjectException - (always)IOExceptionClassNotFoundExceptionprivate Object writeReplace() throws ObjectStreamException
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);
}
ObjectStreamExceptionprivate void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
InvalidObjectException - (always)IOExceptionClassNotFoundExceptionprivate Object writeReplace() throws ObjectStreamException
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);
}
ObjectStreamExceptionprivate void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
InvalidObjectException - (always)IOExceptionClassNotFoundExceptionprivate Object writeReplace() throws ObjectStreamException
5. Then
the data bytes for date and time component follow.
Schematic algorithm:
out.writeByte(5 << 4);
out.writeObject(timestamp.getCalendarDate());
out.writeObject(timestamp.getWallTime());
ObjectStreamExceptionpublic void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
Implementierungsmethode des Interface Externalizable.
IOExceptionClassNotFoundExceptionpublic void writeExternal(ObjectOutput out) throws IOException
Implementierungsmethode des Interface Externalizable.
Das erste Byte enthält um 4 Bits nach links verschoben den Typ des zu serialisierenden Objekts. Danach folgen die Daten-Bits in einer bit-komprimierten Darstellung.
writeReplace()-method of object
to be serializedIOExceptionprivate void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
InvalidObjectException - (always)IOExceptionClassNotFoundExceptionprivate Object writeReplace() throws ObjectStreamException
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);
}
ObjectStreamExceptionString name
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
IOExceptionClassNotFoundExceptionObject unit
long amount
> 0private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
InvalidObjectException - (always)IOExceptionClassNotFoundExceptionprivate Object writeReplace() throws ObjectStreamException
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());
}
ObjectStreamExceptionprivate void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
IOExceptionClassNotFoundExceptionlong posix
int previous
int total
int dst
Copyright © 2014. All rights reserved.