View Javadoc
1   /*
2    * The contents of this file are subject to the terms of the Common Development and
3    * Distribution License (the License). You may not use this file except in compliance with the
4    * License.
5    *
6    * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
7    * specific language governing permission and limitations under the License.
8    *
9    * When distributing Covered Software, include this CDDL Header Notice in each file and include
10   * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
11   * Header, with the fields enclosed by brackets [] replaced by your own identifying
12   * information: "Portions copyright [year] [name of copyright owner]".
13   *
14   * Copyright 2014 ForgeRock AS
15   */
16  package org.forgerock.doc.maven.utils.helper;
17  
18  import freemarker.template.SimpleScalar;
19  import freemarker.template.TemplateMethodModelEx;
20  import freemarker.template.TemplateModelException;
21  import org.forgerock.doc.maven.utils.NameUtils;
22  
23  import java.util.List;
24  
25  /**
26   * FreeMarker method for getting a single document name.
27   */
28  public class NameMethod implements TemplateMethodModelEx {
29  
30      @Override
31      public Object exec(List args) throws TemplateModelException {
32          if (args.size() != 4) {
33              throw new TemplateModelException("Bad arguments list");
34          }
35  
36          return NameUtils.renameDoc(
37                  ((SimpleScalar) args.get(0)).getAsString(),
38                  ((SimpleScalar) args.get(1)).getAsString(),
39                  ((SimpleScalar) args.get(2)).getAsString(),
40                  ((SimpleScalar) args.get(3)).getAsString());
41      }
42  }