Sonar Fixes
[aaf/authz.git] / auth / auth-gui / src / main / java / org / onap / aaf / auth / gui / NamedCode.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.auth.gui;
23
24 public abstract class NamedCode implements ContentCode {
25     private final boolean noCache;
26     private String name;
27     private String[] idattrs;
28
29     /*
30      *  Mark whether this code should not be cached, and any attributes
31      */
32     public NamedCode(final boolean noCache, final String name) {
33         this.name = name;
34         idattrs = new String[] {name};
35         this.noCache = noCache;
36     }
37
38     public NamedCode(boolean noCache, NamedCode content) {
39         this.noCache = noCache;
40         name=content.name;
41         idattrs = content.idattrs;
42     }
43
44     /**
45      * Return ID and Any Attributes needed to create a "div" section of this code
46      * @return
47      */
48     public String[] idattrs() {
49         return idattrs;
50     }
51
52     public void addAttr(boolean first, String attr) {
53         String[] temp = new String[idattrs.length+1];
54         if (first) {
55             temp[0] = attr;
56             System.arraycopy(idattrs, 0, temp, 1, idattrs.length);
57         } else {
58             temp[idattrs.length] = attr;
59             System.arraycopy(idattrs, 0, temp, 0, idattrs.length);
60         }
61         idattrs = temp;
62     }
63
64     public boolean noCache() {
65         return noCache;
66     }
67 }