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.openecomp.sdnc.sli;
24 import java.io.Serializable;
25 import java.util.LinkedList;
26 import java.util.List;
28 public class SvcLogicAtom extends SvcLogicExpression {
30 public enum AtomType {
38 private AtomType atomType;
42 public SvcLogicAtom(String atomType, String atom)
44 this.atomType = AtomType.valueOf(atomType);
49 public SvcLogicAtom(String atom)
59 if (atom.startsWith("$"))
61 this.atomType = AtomType.CONTEXT_VAR;
62 this.atom = atom.substring(1);
66 if (Character.isDigit(atom.charAt(0)))
68 this.atomType = AtomType.NUMBER;
71 else if (atom.charAt(0) == '\'')
73 this.atomType = AtomType.STRING;
74 this.atom = atom.substring(1, atom.length()-1);
78 this.atomType = AtomType.IDENTIFIER;
87 public AtomType getAtomType() {
91 public void setAtomType(String newType)
93 atomType = AtomType.valueOf(newType);
96 public String getAtom() {
102 public void setAtomType(AtomType atomType) {
103 this.atomType = atomType;
106 public void setAtom(String atom) {
112 public String toString()
114 StringBuffer sbuff = new StringBuffer();
115 switch(getAtomType())
120 boolean needDot = false;
121 for (SvcLogicExpression term: this.getOperands())
127 sbuff.append(term.toString());
130 return(sbuff.toString());
138 public String asParsedExpr()
140 // simplify debugging output for NUMBER type
141 if (atomType == AtomType.NUMBER) {
145 StringBuffer sbuff = new StringBuffer();
147 sbuff.append("(atom");
149 sbuff.append(atomType.toString());
156 for (SvcLogicExpression term : getOperands())
159 sbuff.append(term.asParsedExpr());
169 return(sbuff.toString());