]> gerrit.simantics Code Review - simantics/r.git/blob - org.simantics.r.scl/src/org/rosuda/REngine/REXPNull.java
(refs #6833) Test RExp inheritance in SCL
[simantics/r.git] / org.simantics.r.scl / src / org / rosuda / REngine / REXPNull.java
1 package org.rosuda.REngine;
2
3 /** represents a NULL object in R.
4  <p>
5  Note: there is a slight asymmetry - in R NULL is represented by a zero-length pairlist. For this reason <code>REXPNull</code> returns <code>true</code> for {@link #isList()} and {@link #asList()} will return an empty list. Nonetheless <code>REXPList</code> of the length 0 will NOT return <code>true</code> in {@link #isNull()} (currently), becasue it is considered a different object in Java. These nuances are still subject to change, because it's not clear how it should be treated. At any rate use <code>REXPNull</code> instead of empty <code>REXPList</code> if NULL is the intended value.
6  */
7 public class REXPNull extends REXP {
8         public REXPNull() { super(); }
9         public REXPNull(REXPList attr) { super(attr); }
10         
11         public boolean isNull() { return true; }
12         public boolean isList() { return true; } // NULL is a list
13         public RList asList() { return new RList(); }
14         public Object asNativeJavaObject() { return null; }
15 }