* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
package org.onap.ccsdk.sli.core.sli;
public class SvcLogicAtom extends SvcLogicExpression {
-
+
public enum AtomType {
NUMBER,
STRING,
CONTEXT_VAR
}
-
+
private AtomType atomType;
private String atom;
{
this.atomType = AtomType.valueOf(atomType);
this.atom = atom;
-
+
}
-
+
public SvcLogicAtom(String atom)
{
{
this.atomType = AtomType.IDENTIFIER;
this.atom = atom;
-
+
}
-
+
}
}
}
public AtomType getAtomType() {
return atomType;
}
-
+
public void setAtomType(String newType)
{
atomType = AtomType.valueOf(newType);
public String getAtom() {
return atom;
}
-
-
-
+
+
+
public void setAtomType(AtomType atomType) {
this.atomType = atomType;
}
StringBuffer sbuff = new StringBuffer();
switch(getAtomType())
{
- case CONTEXT_VAR:
- sbuff.append("$");
- case IDENTIFIER:
- boolean needDot = false;
- for (SvcLogicExpression term: this.getOperands())
- {
- if (needDot)
+ case CONTEXT_VAR:
+ sbuff.append("$");
+ case IDENTIFIER:
+ boolean needDot = false;
+ for (SvcLogicExpression term: this.getOperands())
{
- sbuff.append(".");
+ if (needDot)
+ {
+ sbuff.append(".");
+ }
+ sbuff.append(term.toString());
+ needDot = true;
}
- sbuff.append(term.toString());
- needDot = true;
- }
- return(sbuff.toString());
- case STRING:
- case NUMBER:
- default:
- return(atom);
+ return sbuff.toString();
+ case STRING:
+ case NUMBER:
+ default:
+ return atom;
}
}
-
+
public String asParsedExpr()
{
// simplify debugging output for NUMBER type
}
StringBuffer sbuff = new StringBuffer();
-
+
sbuff.append("(atom");
sbuff.append("<");
sbuff.append(atomType.toString());
sbuff.append(">");
-
+
switch(atomType)
{
- case IDENTIFIER:
- case CONTEXT_VAR:
- for (SvcLogicExpression term : getOperands())
- {
+ case IDENTIFIER:
+ case CONTEXT_VAR:
+ for (SvcLogicExpression term : getOperands())
+ {
+ sbuff.append(" ");
+ sbuff.append(term.asParsedExpr());
+
+ }
+ break;
+ default:
sbuff.append(" ");
- sbuff.append(term.asParsedExpr());
-
- }
- break;
- default:
- sbuff.append(" ");
- sbuff.append(atom);
+ sbuff.append(atom);
}
-
+
sbuff.append(")");
- return(sbuff.toString());
+ return sbuff.toString();
}
-
-
+
+
}
if (ctxVarName.indexOf('[') == -1) {
// Ctx variable contains no arrays
- return (this.getAttribute(ctxVarName));
+ return getAttribute(ctxVarName);
}
// Resolve any array references
if (endBracketLoc == -1) {
// Missing end bracket ... give up parsing
LOG.warn("Variable reference {} seems to be missing a ']'", ctxVarName);
- return (this.getAttribute(ctxVarName));
+ return getAttribute(ctxVarName);
}
String idxVarName = ctxVarParts[i].substring(1, endBracketLoc);
}
}
- return (this.getAttribute(sbuff.toString()));
+ return getAttribute(sbuff.toString());
}
}
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
}
try {
- return (getSvcLogicStore(new FileInputStream(propFile)));
+ return getSvcLogicStore(new FileInputStream(propFile));
} catch (Exception e) {
throw new ConfigurationException(
"Could load service store from properties file " + propfile,
throw new ConfigurationException("Could not get load properties from input stream", e);
}
- return(getSvcLogicStore(props));
+ return getSvcLogicStore(props);
}
public static SvcLogicStore getSvcLogicStore(Properties props)
}
- SvcLogicStore retval = null;
- LOG.debug(String.format("Using org.onap.ccsdk.sli.dbtype=%s", storeType));
+ SvcLogicStore retval;
+ LOG.debug("Using org.onap.ccsdk.sli.dbtype={}", storeType);
if ("jdbc".equalsIgnoreCase(storeType)) {
retval = new SvcLogicJdbcStore();
retval.init(props);
- return (retval);
+ return retval;
}
}