This is an automated email from the ASF dual-hosted git repository. ddekany pushed a commit to branch FREEMARKER-35 in repository https://gitbox.apache.org/repos/asf/freemarker.git
commit cbdb2e4a322879cff939c5c80fd820f1294cc4ad Author: ddekany <[email protected]> AuthorDate: Wed Dec 29 18:25:31 2021 +0100 [FREEMARKER-35] Deleted now unused classes. --- .../core/ToStringTemplateTemporalFormat.java | 70 ---------------------- .../ToStringTemplateTemporalFormatFactory.java | 49 --------------- 2 files changed, 119 deletions(-) diff --git a/src/main/java/freemarker/core/ToStringTemplateTemporalFormat.java b/src/main/java/freemarker/core/ToStringTemplateTemporalFormat.java deleted file mode 100644 index 0ee291c..0000000 --- a/src/main/java/freemarker/core/ToStringTemplateTemporalFormat.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package freemarker.core; - -import java.time.Instant; -import java.time.ZoneId; -import java.time.temporal.Temporal; -import java.util.TimeZone; - -import freemarker.template.TemplateModelException; -import freemarker.template.TemplateTemporalModel; - -/** - * See {@link ToStringTemplateTemporalFormatFactory}. - * - * @Deprected TODO [FREEMARKER-35] I guess we shouldn't need this. - * - * @since 2.3.32 - */ -class ToStringTemplateTemporalFormat extends TemplateTemporalFormat { - - private final ZoneId timeZone; - - ToStringTemplateTemporalFormat(TimeZone timeZone) { - this.timeZone = timeZone.toZoneId(); - } - - @Override - public String formatToPlainText(TemplateTemporalModel temporalModel) throws TemplateValueFormatException, - TemplateModelException { - Temporal temporal = TemplateFormatUtil.getNonNullTemporal(temporalModel); - // TODO [FREEMARKER-35] This is not right, but for now we mimic what TemporalUtils did - if (temporal instanceof Instant) { - temporal = ((Instant) temporal).atZone(timeZone); - } - return temporal.toString(); - } - - @Override - public boolean isLocaleBound() { - return false; - } - - @Override - public boolean isTimeZoneBound() { - return true; - } - - @Override - public String getDescription() { - return "toString()"; - } -} diff --git a/src/main/java/freemarker/core/ToStringTemplateTemporalFormatFactory.java b/src/main/java/freemarker/core/ToStringTemplateTemporalFormatFactory.java deleted file mode 100644 index a2e53df..0000000 --- a/src/main/java/freemarker/core/ToStringTemplateTemporalFormatFactory.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package freemarker.core; - -import java.time.temporal.Temporal; -import java.util.Locale; -import java.util.TimeZone; - -/** - * Gives a {@link TemplateTemporalFormat} that simply calls {@link Object#toString()} - * - * @Deprected TODO [FREEMARKER-35] I guess we shouldn't need this. - * - * @since 2.3.32 - */ -class ToStringTemplateTemporalFormatFactory extends TemplateTemporalFormatFactory { - - static final ToStringTemplateTemporalFormatFactory INSTANCE = new ToStringTemplateTemporalFormatFactory(); - - private ToStringTemplateTemporalFormatFactory() { - // Not meant to be called from outside - } - - @Override - public TemplateTemporalFormat get(String params, Class<? extends Temporal> temporalClass, Locale locale, TimeZone timeZone, Environment env) throws - TemplateValueFormatException { - if (!params.isEmpty()) { - throw new InvalidFormatParametersException("toString format doesn't support parameters"); - } - return new ToStringTemplateTemporalFormat(timeZone); - } -}
