]> gerrit.simantics Code Review - simantics/r.git/blob - bundles/org.simantics.r.scl/src/org/simantics/r/scl/variable/RAttributeNode.java
Restructured R repository for Tycho POMless builds.
[simantics/r.git] / bundles / org.simantics.r.scl / src / org / simantics / r / scl / variable / RAttributeNode.java
1 /*******************************************************************************\r
2  * Copyright (c) 2014, 2016 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.r.scl.variable;\r
13 \r
14 import org.rosuda.REngine.REXP;\r
15 \r
16 public class RAttributeNode implements RVariableNode {\r
17         private String name;\r
18         private RVariableNode parent;\r
19 \r
20         public RAttributeNode(RVariableNode parent, String name) {\r
21                 this.name = name;\r
22                 this.parent = parent;\r
23         }\r
24 \r
25         @Override\r
26         public REXP getValue() {\r
27                 REXP parentValue = parent.getValue();\r
28                 if (parentValue == null)\r
29                         return null;\r
30                 \r
31                 return parentValue.getAttribute(name);\r
32         }\r
33 \r
34         @Override\r
35         public String getName() {\r
36                 return RNodeManager.ATTRIBUTE_NAME_PREFIX + name;\r
37         }\r
38 \r
39         @Override\r
40         public RVariableNode getParent() {\r
41                 return parent;\r
42         }\r
43 }\r