Class |
Line # |
Actions |
|||||
---|---|---|---|---|---|---|---|
FrameContext | 36 | 10 | 0% | 6 | 4 |
1 | /* | |
2 | * Licensed to the Apache Software Foundation (ASF) under one | |
3 | * or more contributor license agreements. See the NOTICE file | |
4 | * distributed with this work for additional information | |
5 | * regarding copyright ownership. The ASF licenses this file | |
6 | * to you under the Apache License, Version 2.0 (the | |
7 | * "License"); you may not use this file except in compliance | |
8 | * with the License. You may obtain a copy of the License at | |
9 | * | |
10 | * http://www.apache.org/licenses/LICENSE-2.0 | |
11 | * | |
12 | * Unless required by applicable law or agreed to in writing, | |
13 | * software distributed under the License is distributed on an | |
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
15 | * KIND, either express or implied. See the License for the | |
16 | * specific language governing permissions and limitations | |
17 | * under the License. | |
18 | */ | |
19 | package org.devacfr.maven.skins.reflow.context; | |
20 | ||
21 | import javax.annotation.Nonnull; | |
22 | ||
23 | import org.devacfr.maven.skins.reflow.ISkinConfig; | |
24 | import org.devacfr.maven.skins.reflow.SkinConfigTool; | |
25 | import org.devacfr.maven.skins.reflow.model.Toc; | |
26 | import org.devacfr.maven.skins.reflow.model.TocSidebar; | |
27 | ||
28 | import static java.util.Objects.requireNonNull; | |
29 | ||
30 | /** | |
31 | * The context associate to page of frame page. | |
32 | * | |
33 | * @author Christophe Friederich | |
34 | * @since 2.0 | |
35 | */ | |
36 | public class FrameContext extends Context<FrameContext> { | |
37 | ||
38 | /** */ | |
39 | private final String documentParent; | |
40 | ||
41 | /** */ | |
42 | private final Toc<?> toc; | |
43 | ||
44 | /** | |
45 | * @param config | |
46 | * a config (can not be {@code null}). | |
47 | * @param documentParent | |
48 | * name of parent. | |
49 | */ | |
50 | 1 | public FrameContext(final @Nonnull ISkinConfig config, @Nonnull final String documentParent) { |
51 | 1 | super(config, ContextType.frame); |
52 | 1 | final String type = config.getPropertyValue(Toc.COMPONENT, String.class, "sidebar"); |
53 | // enforce sidebar | |
54 | 1 | if ("top".equals(type) || "sidebar".equals(type)) { |
55 | 1 | toc = new TocSidebar(config); |
56 | } else { | |
57 | 0 | toc = new Toc<Toc<?>>("", "") {}; |
58 | } | |
59 | ||
60 | 1 | this.documentParent = requireNonNull(documentParent); |
61 | ||
62 | 1 | this.addChildren(this.toc); |
63 | } | |
64 | ||
65 | /** | |
66 | * @return Returns a {@link String} representing the name of parent page. | |
67 | */ | |
68 | 1 | public String getDocumentParent() { |
69 | 1 | return documentParent; |
70 | } | |
71 | ||
72 | /** | |
73 | * @return Returns a {@link String} representing the slugged name(pageId) of parent page. | |
74 | */ | |
75 | 0 | public String getSlugDocumentParent() { |
76 | 0 | return SkinConfigTool.slugFilename(documentParent); |
77 | } | |
78 | ||
79 | /** | |
80 | * @return returns the {@link Toc}. | |
81 | */ | |
82 | 2 | public Toc<?> getToc() { |
83 | 2 | return toc; |
84 | } | |
85 | } |