@Override public Iterator<Object> iterator() { return new Iterator<Object>() { Object[] ids = getIds(); Object key; int index = 0; public boolean hasNext() { return index < ids.length; } public Object next() { return get((key = ids[index++])); } public void remove() { if (key == null) { throw new IllegalStateException(); } NativeObject.this.remove(key); key = null; } }; }
@Override public Iterator<Object> iterator() { return new Iterator<Object>() { Object[] ids = getIds(); Object key; int index = 0; public boolean hasNext() { return index < ids.length; } public Object next() { return get((key = ids[index++])); } public void remove() { if (key == null) { throw new IllegalStateException(); } NativeObject.this.remove(key); key = null; } }; }
@Override public Iterator<Object> iterator() { return new Iterator<Object>() { Object[] ids = getIds(); Object key; int index = 0; public boolean hasNext() { return index < ids.length; } public Object next() { try { return (key = ids[index++]); } catch(ArrayIndexOutOfBoundsException e) { key = null; throw new NoSuchElementException(); } } public void remove() { if (key == null) { throw new IllegalStateException(); } NativeObject.this.remove(key); key = null; } }; }
@Override public Iterator<Object> iterator() { return new Iterator<Object>() { Object[] ids = getIds(); Object key; int index = 0; public boolean hasNext() { return index < ids.length; } public Object next() { return get((key = ids[index++])); } public void remove() { if (key == null) { throw new IllegalStateException(); } NativeObject.this.remove(key); key = null; } }; }
@Override public Iterator<Object> iterator() { return new Iterator<Object>() { Object[] ids = getIds(); Object key; int index = 0; public boolean hasNext() { return index < ids.length; } public Object next() { return get((key = ids[index++])); } public void remove() { if (key == null) { throw new IllegalStateException(); } NativeObject.this.remove(key); key = null; } }; }
@Override public Iterator<Object> iterator() { return new Iterator<Object>() { Object[] ids = getIds(); Object key; int index = 0; public boolean hasNext() { return index < ids.length; } public Object next() { try { return (key = ids[index++]); } catch(ArrayIndexOutOfBoundsException e) { key = null; throw new NoSuchElementException(); } } public void remove() { if (key == null) { throw new IllegalStateException(); } NativeObject.this.remove(key); key = null; } }; }
@Override public Iterator<Object> iterator() { return new Iterator<Object>() { Object[] ids = getIds(); Object key; int index = 0; public boolean hasNext() { return index < ids.length; } public Object next() { try { return (key = ids[index++]); } catch(ArrayIndexOutOfBoundsException e) { key = null; throw new NoSuchElementException(); } } public void remove() { if (key == null) { throw new IllegalStateException(); } NativeObject.this.remove(key); key = null; } }; }
@Override public Iterator<Object> iterator() { return new Iterator<Object>() { Object[] ids = getIds(); Object key; int index = 0; public boolean hasNext() { return index < ids.length; } public Object next() { try { return (key = ids[index++]); } catch(ArrayIndexOutOfBoundsException e) { key = null; throw new NoSuchElementException(); } } public void remove() { if (key == null) { throw new IllegalStateException(); } NativeObject.this.remove(key); key = null; } }; }
/** * javascript helper for binding parameters. * See: {@link Pig#bind(Map)} * @param o a javascript object to be converted into a Map * @return the bound script * @throws IOException if {@link Pig#bind(Map)} throws an IOException */ public BoundScript bind(Object o) throws IOException { NativeObject vars = (NativeObject)o; Map<String, Object> params = new HashMap<String, Object>(); Object[] ids = vars.getIds(); for (Object id : ids) { if (id instanceof String) { String name = (String) id; Object value = vars.get(name, vars); if (!(value instanceof NativeFunction) && value != null) { params.put(name, value.toString()); } } } return pig.bind(params); }
private void getPrefValues(NativeObject currentObject, String currentKey, Map<String, Serializable> values) { Object[] ids = currentObject.getIds(); for (Object id : ids) { String key = getAppendedKey(currentKey, id.toString()); Object value = currentObject.get(id.toString(), currentObject); if (value instanceof NativeObject) { getPrefValues((NativeObject)value, key, values); } else { values.put(key, (Serializable)value); } } }
private void getPrefValues(NativeObject currentObject, String currentKey, Map<String, Serializable> values) { Object[] ids = currentObject.getIds(); for (Object id : ids) { String key = getAppendedKey(currentKey, id.toString()); Object value = currentObject.get(id.toString(), currentObject); if (value instanceof NativeObject) { getPrefValues((NativeObject)value, key, values); } else { values.put(key, (Serializable)value); } } }
json.append("{"); NativeObject o = (NativeObject) obj; Object[] ids = o.getIds(); boolean first = true; for (Object id : ids) {
out.write('{'); NativeObject o = (NativeObject) obj; Object[] ids = o.getIds(); boolean first = true; for (Object id : ids) {
DBObject getObject(NativeObject no) { DBObject ret = new BasicDBObject(); Object[] propIds = no.getIds(); for (Object propId : propIds) { String key = Context.toString(propId); Object value = NativeObject.getProperty(no, key); if (value instanceof NativeObject) { ret.put(key, getObject((NativeObject) value)); } else { ret.put(key, value); } } return ret; }
/** * Build a JSON string for a native object * * @param nativeObject NativeObject * @param writer JSONWriter * @throws IOException */ private void nativeObjectToJSONString(NativeObject nativeObject, JSONWriter writer) throws IOException { writer.startObject(); final Object[] ids = nativeObject.getIds(); for (final Object id : ids) { String key = id.toString(); writer.startValue(key); final Object value = nativeObject.get(key, nativeObject); valueToJSONString(value, writer); } writer.endObject(); }
/** * Build a JSON string for a native object * * @param nativeObject NativeObject * @param writer JSONWriter * @throws IOException */ private void nativeObjectToJSONString(NativeObject nativeObject, JSONWriter writer) throws IOException { writer.startObject(); final Object[] ids = nativeObject.getIds(); for (final Object id : ids) { String key = id.toString(); writer.startValue(key); final Object value = nativeObject.get(key, nativeObject); valueToJSONString(value, writer); } writer.endObject(); }
/** * Build a JSON string for a native object * * @param nativeObject * @param writer * @throws IOException */ private void nativeObjectToJSONString(NativeObject nativeObject, JSONWriter writer) throws IOException { writer.startObject(); final Object[] ids = nativeObject.getIds(); for (final Object id : ids) { String key = id.toString(); writer.startValue(key); final Object value = nativeObject.get(key, nativeObject); valueToJSONString(value, writer); } writer.endObject(); }