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