Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 9E4BA200AF7 for ; Tue, 31 May 2016 00:10:29 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 9CFEB160A3C; Mon, 30 May 2016 22:10:29 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id E6D09160A19 for ; Tue, 31 May 2016 00:10:28 +0200 (CEST) Received: (qmail 35863 invoked by uid 500); 30 May 2016 22:10:28 -0000 Mailing-List: contact notifications-help@freemarker.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@freemarker.incubator.apache.org Delivered-To: mailing list notifications@freemarker.incubator.apache.org Received: (qmail 35854 invoked by uid 99); 30 May 2016 22:10:28 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 30 May 2016 22:10:28 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id BFA941804DE for ; Mon, 30 May 2016 22:10:27 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.646 X-Spam-Level: X-Spam-Status: No, score=-4.646 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-1.426] autolearn=disabled Received: from mx2-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id AsouSDaby7ID for ; Mon, 30 May 2016 22:10:26 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx2-lw-eu.apache.org (ASF Mail Server at mx2-lw-eu.apache.org) with SMTP id D03555F237 for ; Mon, 30 May 2016 22:10:25 +0000 (UTC) Received: (qmail 35841 invoked by uid 99); 30 May 2016 22:10:25 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 30 May 2016 22:10:25 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B119FE0252; Mon, 30 May 2016 22:10:24 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ddekany@apache.org To: notifications@freemarker.incubator.apache.org Message-Id: <4b400a4dc2034a0982f946de3490f812@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: incubator-freemarker git commit: TemplateHashModelEx2 JavaDoc Date: Mon, 30 May 2016 22:10:24 +0000 (UTC) archived-at: Mon, 30 May 2016 22:10:29 -0000 Repository: incubator-freemarker Updated Branches: refs/heads/2.3-gae 59f7d4667 -> 7e08ebc1d TemplateHashModelEx2 JavaDoc Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/7e08ebc1 Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/7e08ebc1 Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/7e08ebc1 Branch: refs/heads/2.3-gae Commit: 7e08ebc1dc8ee049cdbe0c0c08675ea84a292f87 Parents: 59f7d46 Author: ddekany Authored: Tue May 31 00:10:17 2016 +0200 Committer: ddekany Committed: Tue May 31 00:10:17 2016 +0200 ---------------------------------------------------------------------- .../template/TemplateHashModelEx2.java | 43 ++++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7e08ebc1/src/main/java/freemarker/template/TemplateHashModelEx2.java ---------------------------------------------------------------------- diff --git a/src/main/java/freemarker/template/TemplateHashModelEx2.java b/src/main/java/freemarker/template/TemplateHashModelEx2.java index 9e7a8d7..11be6cd 100644 --- a/src/main/java/freemarker/template/TemplateHashModelEx2.java +++ b/src/main/java/freemarker/template/TemplateHashModelEx2.java @@ -18,25 +18,62 @@ */ package freemarker.template; +import java.util.Iterator; +import java.util.NoSuchElementException; + /** * Adds key-value pair listing capability to {@link TemplateHashModelEx}. While in many cases that can also be achieved * with {@link #keys()} and then {@link #get(String)}, that has some problems. One is that {@link #get(String)} only - * accepts string keys, while {@link #keys()} can return non-string keys too. The other is that {@link #keys()} and then - * {@link #get(String)} for each key can be slower than listing the key-value pairs in one go. + * accepts string keys, while {@link #keys()} can return non-string keys too. The other is that calling {@link #keys()} + * and then {@link #get(String)} for each key can be slower than listing the key-value pairs in one go. * - * @since 2.3.25 + * @since 2.3.25 */ public interface TemplateHashModelEx2 extends TemplateHashModelEx { + /** + * @return The iterator that walks through the key-value pairs in the hash. Not {@code null}. + */ KeyValuePairIterator keyValuePairIterator(); + /** + * A key-value pair in a hash; used for {@link KeyValuePairIterator}. + * + * @since 2.3.25 + */ interface KeyValuePair { + + /** + * @return Any type of {@link TemplateModel}, maybe {@code null} (if the hash entry key is {@code null}). + */ TemplateModel getKey() throws TemplateModelException; + + /** + * @return Any type of {@link TemplateModel}, maybe {@code null} (if the hash entry value is {@code null}). + */ TemplateModel getValue() throws TemplateModelException; } + /** + * Iterates over the key-value pairs in a hash. This is very similar to an {@link Iterator}, but has a fixed item + * type, can throw {@link TemplateModelException}-s, and has no {@code remove()} method. + * + * @since 2.3.25 + */ interface KeyValuePairIterator { + + /** + * Similar to {@link Iterator#hasNext()}. + */ boolean hasNext() throws TemplateModelException; + + /** + * Similar to {@link Iterator#next()}. + * + * @return Not {@code null} + * + * @throws NoSuchElementException + */ KeyValuePair next() throws TemplateModelException; }