public Object get(Object key) { return at((String)key); }
public Object get(Object key) { return at((String)key); }
public String toDebugString() { StringBuffer sb = new StringBuffer(super.toDebugString()+"{"); int i = 0; while (i < payload.size() && i < maxDebugItems) { if (i>0) sb.append(",\n"); sb.append(payload.at(i).toDebugString()); i++; } if (i < payload.size()) sb.append(",.."); return sb.toString()+"}"; } }
public String toDebugString() { StringBuffer sb = new StringBuffer(super.toDebugString()+"{"); int i = 0; while (i < payload.size() && i < maxDebugItems) { if (i>0) sb.append(",\n"); sb.append(payload.at(i).toDebugString()); i++; } if (i < payload.size()) sb.append(",.."); return sb.toString()+"}"; } }
public String toDebugString() { StringBuffer sb = new StringBuffer(super.toDebugString()+"{"); int i = 0; while (i < payload.size() && i < maxDebugItems) { if (i>0) sb.append(",\n"); String name = payload.keyAt(i); if (name!=null) sb.append(name+"="); sb.append(payload.at(i).toDebugString()); i++; } if (i < payload.size()) sb.append(",.."); return sb.toString()+"}"; } }
public String toDebugString() { StringBuffer sb = new StringBuffer(super.toDebugString()+"{"); int i = 0; while (i < payload.size() && i < maxDebugItems) { if (i>0) sb.append(",\n"); String name = payload.keyAt(i); if (name!=null) sb.append(name+"="); sb.append(payload.at(i).toDebugString()); i++; } if (i < payload.size()) sb.append(",.."); return sb.toString()+"}"; } }
/** retrieve an attribute of the given name from this object * @param name attribute name * @return attribute value or <code>null</code> if the attribute does not exist */ public REXP getAttribute(String name) { final REXPList a = _attr(); if (a==null || !a.isList()) return null; return a.asList().at(name); }
/** retrieve an attribute of the given name from this object * @param name attribute name * @return attribute value or <code>null</code> if the attribute does not exist */ public REXP getAttribute(String name) { final REXPList a = _attr(); if (a==null || !a.isList()) return null; return a.asList().at(name); }
/** checks whether this obejct has a given attribute * @param name attribute name * @return <code>true</code> if the attribute exists, <code>false</code> otherwise */ public boolean hasAttribute(String name) { final REXPList a = _attr(); return (a!=null && a.isList() && a.asList().at(name)!=null); }
/** checks whether this obejct has a given attribute * @param name attribute name * @return <code>true</code> if the attribute exists, <code>false</code> otherwise */ public boolean hasAttribute(String name) { final REXPList a = _attr(); return (a!=null && a.isList() && a.asList().at(name)!=null); }
public void putAll(Map t) { if (t==null) return; // NOTE: this if branch is dead since RList cannot inherit from Map if (t instanceof RList) { // we need some more sophistication for RLists as they may have null-names which we append RList l = (RList) t; if (names==null) { addAll(l); return; } int n = l.size(); int i = 0; while (i < n) { String key = l.keyAt(i); if (key==null) add(l.at(i)); else put(key, l.at(i)); i++; } } else { Set ks = t.keySet(); Iterator i = ks.iterator(); while (i.hasNext()) { Object key = i.next(); put(key, t.get(key)); } } }
public void putAll(Map t) { if (t==null) return; // NOTE: this if branch is dead since RList cannot inherit from Map if (t instanceof RList) { // we need some more sophistication for RLists as they may have null-names which we append RList l = (RList) t; if (names==null) { addAll(l); return; } int n = l.size(); int i = 0; while (i < n) { String key = l.keyAt(i); if (key==null) add(l.at(i)); else put(key, l.at(i)); i++; } } else { Set ks = t.keySet(); Iterator i = ks.iterator(); while (i.hasNext()) { Object key = i.next(); put(key, t.get(key)); } } }
/** returns dimensions of the object (as determined by the "<code>dim</code>" attribute) * @return an array of integers with corresponding dimensions or <code>null</code> if the object has no dimension attribute */ public int[] dim() { try { return hasAttribute("dim")?_attr().asList().at("dim").asIntegers():null; } catch (REXPMismatchException me) { } return null; }
/** returns dimensions of the object (as determined by the "<code>dim</code>" attribute) * @return an array of integers with corresponding dimensions or <code>null</code> if the object has no dimension attribute */ public int[] dim() { try { return hasAttribute("dim")?_attr().asList().at("dim").asIntegers():null; } catch (REXPMismatchException me) { } return null; }
REXP tempREXP = dataList.at(i); Object convertedREXP = convertResult(tempREXP);
/** creates a data frame object from a list object using integer row names * @param l a (named) list of vectors ({@link REXPVector} subclasses), each element corresponds to a column and all elements must have the same length * @return a data frame object * @throws REXPMismatchException if the list is empty or any of the elements is not a vector */ public static REXP createDataFrame(RList l) throws REXPMismatchException { if (l == null || l.size() < 1) throw new REXPMismatchException(new REXPList(l), "data frame (must have dim>0)"); if (!(l.at(0) instanceof REXPVector)) throw new REXPMismatchException(new REXPList(l), "data frame (contents must be vectors)"); REXPVector fe = (REXPVector) l.at(0); return new REXPGenericVector(l, new REXPList( new RList( new REXP[] { new REXPString("data.frame"), new REXPString(l.keys()), new REXPInteger(new int[] { REXPInteger.NA, -fe.length() }) }, new String[] { "class", "names", "row.names" }))); }
/** creates a data frame object from a list object using integer row names * @param l a (named) list of vectors ({@link REXPVector} subclasses), each element corresponds to a column and all elements must have the same length * @return a data frame object * @throws REXPMismatchException if the list is empty or any of the elements is not a vector */ public static REXP createDataFrame(RList l) throws REXPMismatchException { if (l==null || l.size()<1) throw new REXPMismatchException(new REXPList(l), "data frame (must have dim>0)"); if (!(l.at(0) instanceof REXPVector)) throw new REXPMismatchException(new REXPList(l), "data frame (contents must be vectors)"); REXPVector fe = (REXPVector) l.at(0); return new REXPGenericVector(l, new REXPList( new RList( new REXP[] { new REXPString("data.frame"), new REXPString(l.keys()), new REXPInteger(new int[] { REXPInteger.NA, -fe.length() }) }, new String[] { "class", "names", "row.names" }))); }