All Downloads are FREE. Search and download functionalities are using the official Maven repository.

iot.jcypher.query.values.ValueElement Maven / Gradle / Ivy

Go to download

Provides seamlessly integrated Java access to graph databases (Neo4J) at different levels of abstraction.

There is a newer version: 4.2.0
Show newest version
/************************************************************************
 * Copyright (c) 2014-2015 IoT-Solutions e.U.
 * 
 * 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.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ************************************************************************/

package iot.jcypher.query.values;

import java.util.HashMap;
import java.util.Map;

import iot.jcypher.domainquery.api.IPredicateOperand1;
import iot.jcypher.domainquery.internal.QueryRecorder;
import iot.jcypher.query.values.functions.FUNCTION;

public class ValueElement implements IFragment, IPredicateOperand1 {

	private ValueElement predecessor;
	private IOperatorOrFunction operatorOrFunction;
	// allows to maintain additional info
	private Map hint;

	ValueElement() {
		super();
	}
	
	protected ValueElement(ValueElement pred, IOperatorOrFunction opf) {
		super();
		this.predecessor = pred;
		this.operatorOrFunction = opf;
	}
	
	/**
	 * 
JCYPHER
*
convert to a string, return a JcString
*
*/ public JcString str() { JcString ret = new JcString(null, this, new FunctionInstance(FUNCTION.Common.STR, 1)); QueryRecorder.recordInvocationConditional(this, "str", ret); return ret; } /** *
JCYPHER
*
convert the argument to an integer, return a JcNumber, if the conversion fails return NULL
*
*/ public JcNumber toInt() { JcNumber ret = new JcNumber(null, this, new FunctionInstance(FUNCTION.Common.TOINT, 1)); QueryRecorder.recordInvocationConditional(this, "toInt", ret); return ret; } /** *
JCYPHER
*
convert the argument to a float, return a JcNumber, if the conversion fails return NULL
*
*/ public JcNumber toFloat() { JcNumber ret = new JcNumber(null, this, new FunctionInstance(FUNCTION.Common.TOFLOAT, 1)); QueryRecorder.recordInvocationConditional(this, "toFloat", ret); return ret; } ValueElement getPredecessor() { return predecessor; } void setPredecessor(ValueElement predecessor) { this.predecessor = predecessor; } IOperatorOrFunction getOperatorOrFunction() { return operatorOrFunction; } void setOperatorOrFunction(IOperatorOrFunction operatorOrFunction) { this.operatorOrFunction = operatorOrFunction; } Object getHint(String key) { if (this.hint != null) return this.hint.get(key); return null; } void setHint(String key, Object value) { if (this.hint == null) this.hint = new HashMap(); this.hint.put(key, value); } ValueElement cloneShallow() { try { ValueElement ret = getClass().newInstance(); copyShallowTo(ret); return ret; } catch (Throwable e) { throw new RuntimeException(e); } } protected void copyShallowTo(ValueElement target) { target.operatorOrFunction = this.operatorOrFunction; target.hint = this.hint; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy