use of android.icu.impl.TimeZoneGenericNames in project j2objc by google.
the class TimeZoneFormat method setTimeZoneNames.
/**
* Sets the time zone display name data to this instance.
*
* @param tznames the time zone display name data.
* @return this object.
* @throws UnsupportedOperationException when this object is frozen.
* @see #getTimeZoneNames()
*/
public TimeZoneFormat setTimeZoneNames(TimeZoneNames tznames) {
if (isFrozen()) {
throw new UnsupportedOperationException("Attempt to modify frozen object");
}
_tznames = tznames;
// TimeZoneGenericNames must be changed to utilize the new TimeZoneNames instance.
_gnames = new TimeZoneGenericNames(_locale, _tznames);
return this;
}
use of android.icu.impl.TimeZoneGenericNames in project j2objc by google.
the class TimeZoneFormat method readObject.
/**
* @param ois the object input stream
* @throws ClassNotFoundException
* @throws IOException
*/
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
ObjectInputStream.GetField fields = ois.readFields();
_locale = (ULocale) fields.get("_locale", null);
if (_locale == null) {
throw new InvalidObjectException("Missing field: locale");
}
_tznames = (TimeZoneNames) fields.get("_tznames", null);
if (_tznames == null) {
throw new InvalidObjectException("Missing field: tznames");
}
_gmtPattern = (String) fields.get("_gmtPattern", null);
if (_gmtPattern == null) {
throw new InvalidObjectException("Missing field: gmtPattern");
}
String[] tmpGmtOffsetPatterns = (String[]) fields.get("_gmtOffsetPatterns", null);
if (tmpGmtOffsetPatterns == null) {
throw new InvalidObjectException("Missing field: gmtOffsetPatterns");
} else if (tmpGmtOffsetPatterns.length < 4) {
throw new InvalidObjectException("Incompatible field: gmtOffsetPatterns");
}
_gmtOffsetPatterns = new String[6];
if (tmpGmtOffsetPatterns.length == 4) {
for (int i = 0; i < 4; i++) {
_gmtOffsetPatterns[i] = tmpGmtOffsetPatterns[i];
}
_gmtOffsetPatterns[GMTOffsetPatternType.POSITIVE_H.ordinal()] = truncateOffsetPattern(_gmtOffsetPatterns[GMTOffsetPatternType.POSITIVE_HM.ordinal()]);
_gmtOffsetPatterns[GMTOffsetPatternType.NEGATIVE_H.ordinal()] = truncateOffsetPattern(_gmtOffsetPatterns[GMTOffsetPatternType.NEGATIVE_HM.ordinal()]);
} else {
_gmtOffsetPatterns = tmpGmtOffsetPatterns;
}
_gmtOffsetDigits = (String[]) fields.get("_gmtOffsetDigits", null);
if (_gmtOffsetDigits == null) {
throw new InvalidObjectException("Missing field: gmtOffsetDigits");
} else if (_gmtOffsetDigits.length != 10) {
throw new InvalidObjectException("Incompatible field: gmtOffsetDigits");
}
_gmtZeroFormat = (String) fields.get("_gmtZeroFormat", null);
if (_gmtZeroFormat == null) {
throw new InvalidObjectException("Missing field: gmtZeroFormat");
}
_parseAllStyles = fields.get("_parseAllStyles", false);
if (fields.defaulted("_parseAllStyles")) {
throw new InvalidObjectException("Missing field: parseAllStyles");
}
// instance.
if (_tznames instanceof TimeZoneNamesImpl) {
_tznames = TimeZoneNames.getInstance(_locale);
// will be created by _locale later when necessary
_gnames = null;
} else {
// Custom TimeZoneNames implementation is used. We need to create
// a new instance of TimeZoneGenericNames here.
_gnames = new TimeZoneGenericNames(_locale, _tznames);
}
// Transient fields requiring initialization
initGMTPattern(_gmtPattern);
initGMTOffsetPatterns(_gmtOffsetPatterns);
}
Aggregations