org.objectweb.fractal.mind.st.AbstractSTNode Maven / Gradle / Ivy
/**
* Copyright (C) 2009 STMicroelectronics
*
* This file is part of "Mind Compiler" is free software: you can redistribute
* it and/or modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Contact: [email protected]
*
* Authors: Matthieu Leclercq
* Contributors:
*/
package org.objectweb.fractal.mind.st;
import java.util.HashMap;
import java.util.Map;
import org.objectweb.fractal.adl.AbstractNode;
import org.objectweb.fractal.adl.Node;
/**
* Abstract node class that is suitable to access AST node attributes in
* StringTemplate. This class provides getter methods equivalent to
* astGet...
methods of the {@link Node} interface.
*/
public abstract class AbstractSTNode extends AbstractNode {
protected AbstractSTNode(final String type) {
super(type);
}
/**
* Returns the type of this node. This method allows to access the node type
* in a StringTemplate using the astType
attribute.
*
* @return the type of this node.
* @see #astGetType()
*/
public String getAstType() {
return astGetType();
}
/**
* Returns the source of this node. This method allows to access the node
* source in a StringTemplate using the astSource
attribute.
*
* @return the source of this node (such as a file name).
*/
public String getAstSource() {
return astGetSource();
}
/**
* Returns the attributes of this node. This method allows to access the node
* attributes in a StringTemplate using the astAttributes
* attribute.
*
* @return the attributes of this node.
*/
public Map getAstAttributes() {
return astGetAttributes();
}
/**
* Returns the decorations of this node. This method allows to access the node
* decorations in a StringTemplate using the astDecorations
* attribute.
*
* @return the decorations of this node.
*/
public Map getAstDecorations() {
return astGetDecorations();
}
/**
* Returns the types of the sub nodes that this node can have. This method
* allows to access the types of the sub nodes in a StringTemplate using the
* astNodeTypes
*
* @return the types of the sub nodes that this node can have.
*/
public Map getAstNodeTypes() {
final Map nodeTypes = new HashMap();
for (final String nodeType : astGetNodeTypes()) {
nodeTypes.put(nodeType, Boolean.TRUE);
}
return nodeTypes;
}
/**
* Returns the sub nodes of this node in a map that associates node types and
* an (eventually empty) array of the sub nodes of that given type. This
* method allows to access the sub nodes in a StringTemplate using the
* astSubNodes
*
* @return the sub nodes of this node in a map that associates node types and
* an (eventually empty) array of the sub nodes of that given type.
*/
public Map getAstSubNodes() {
final Map astSubNodes = new HashMap();
for (final String nodeType : astGetNodeTypes()) {
astSubNodes.put(nodeType, astGetNodes(nodeType));
}
return astSubNodes;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy