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

com.github.uscexp.dotnotation.parser.attributedetail.AstAttributeTreeNode Maven / Gradle / Ivy

/*
 * Copyright (C) 2014 - 2018 by haui - all rights reserved
 */
package com.github.uscexp.dotnotation.parser.attributedetail;

import com.github.uscexp.dotnotation.parser.attributepath.AttributePathInterpreterResult;
import com.github.uscexp.dotnotation.parser.attributepath.AttributePathParser;
import com.github.uscexp.parboiled.extension.interpreter.ProcessStore;
import com.github.uscexp.parboiled.extension.nodes.AstCommandTreeNode;

/**
 * @author haui
 *
 */
public class AstAttributeTreeNode extends AstCommandTreeNode {

	public AstAttributeTreeNode(String node, String value) {
		super(node, value);
	}

	@Override
	protected void interpretAfterChilds(Long id) throws ReflectiveOperationException {
		ProcessStore processStore = ProcessStore.getInstance(id);
		AttributeDetailInterpreterResult attributeDetailInterpreterResult = (AttributeDetailInterpreterResult) processStore.getVariable(
				AttributeDetailParser.ATTRIBUTE_DETAIL_INTERPRETER_RESULT);
		AttributePathInterpreterResult attributePathInterpreterResult = (AttributePathInterpreterResult) processStore.getVariable(
				AttributePathParser.ATTRIBUTE_PATH_INTERPRETER_RESULT);
		
		if(attributePathInterpreterResult != null) {
			attributePathInterpreterResult.getAttributeDetailInterpreterResults().add(0, attributeDetailInterpreterResult);
			processStore.setVariable(AttributeDetailParser.ATTRIBUTE_DETAIL_INTERPRETER_RESULT, new AttributeDetailInterpreterResult());
		}
	}

	@Override
	protected void interpretBeforeChilds(Long id) throws Exception {
	}

}