2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.ccsdk.sli.core.sli;
24 public class SvcLogicAtom extends SvcLogicExpression {
26 public enum AtomType {
34 private AtomType atomType;
38 public SvcLogicAtom(String atomType, String atom)
40 this.atomType = AtomType.valueOf(atomType);
45 public SvcLogicAtom(String atom)
55 if (atom.startsWith("$"))
57 this.atomType = AtomType.CONTEXT_VAR;
58 this.atom = atom.substring(1);
62 if (Character.isDigit(atom.charAt(0)))
64 this.atomType = AtomType.NUMBER;
67 else if (atom.charAt(0) == '\'')
69 this.atomType = AtomType.STRING;
70 this.atom = atom.substring(1, atom.length()-1);
74 this.atomType = AtomType.IDENTIFIER;
83 public AtomType getAtomType() {
87 public void setAtomType(String newType)
89 atomType = AtomType.valueOf(newType);
92 public String getAtom() {
98 public void setAtomType(AtomType atomType) {
99 this.atomType = atomType;
102 public void setAtom(String atom) {
108 public String toString()
110 StringBuffer sbuff = new StringBuffer();
111 switch(getAtomType())
116 boolean needDot = false;
117 for (SvcLogicExpression term: this.getOperands())
123 sbuff.append(term.toString());
126 return(sbuff.toString());
134 public String asParsedExpr()
136 // simplify debugging output for NUMBER type
137 if (atomType == AtomType.NUMBER) {
141 StringBuffer sbuff = new StringBuffer();
143 sbuff.append("(atom");
145 sbuff.append(atomType.toString());
152 for (SvcLogicExpression term : getOperands())
155 sbuff.append(term.asParsedExpr());
165 return(sbuff.toString());