AT&T 2.0.19 Code drop, stage 1
[aaf/authz.git] / misc / xgen / src / main / java / org / onap / aaf / misc / xgen / html / Imports.java
1 /**
2  * ============LICENSE_START====================================================
3  * org.onap.aaf
4  * ===========================================================================
5  * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6  * ===========================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END====================================================
19  *
20  */
21
22 package org.onap.aaf.misc.xgen.html;
23
24 import java.util.ArrayList;
25 import java.util.List;
26
27 public class Imports implements Thematic{
28         List<String> css,js;
29         public final int backdots;
30 //      public final File webDir;
31         private String theme;
32         
33         public Imports(int backdots) {
34 //              this.webDir = webDir;
35                 
36                 css = new ArrayList<String>();
37                 js = new ArrayList<String>();
38                 this.backdots = backdots;
39                 theme = "";
40         }
41         
42         public Imports css(String str) {
43                 css.add(str);
44                 return this;
45         }
46         
47         public Imports js(String str) {
48                 js.add(str);
49                 return this;
50         }
51
52         public Imports theme(String str) {
53                 theme = str==null?"":str;
54                 return this;
55         }
56
57         /**
58          * Pass in a possible Theme.  If it is "" or null, it will resolve to default Theme set in Imports
59          * 
60          * @param theTheme
61          * @return
62          */
63         @Override
64         public String themePath(String theTheme) {
65                 StringBuilder src = dots(new StringBuilder());
66                 if(theTheme==null||theTheme.length()==0) {
67                         src.append(theme);
68                         if(theme.length()>0)src.append('/');
69                 } else {
70                         src.append(theTheme);
71                         src.append('/');
72                 }
73
74                 return src.toString();
75         }
76         
77         /**
78          * Pass in a possible Theme.  If it is "" or null, it will resolve to default Theme set in Imports
79          * 
80          * @param theTheme
81          * @return
82          */
83         @Override
84         public String themeResolve(String theTheme) {
85                 return (theTheme==null||theTheme.length()==0)
86                         ?theme
87                         :theTheme;
88         }
89
90         public StringBuilder dots(StringBuilder src) {
91                 for(int i=0;i<backdots;++i) {
92                         src.append("../");
93                 }
94                 return src;
95         }
96         
97 };
98