/** Initializes the group. */ public void initGroup(int size, boolean[] isGroupByFields) { _groupItem = _tempGroupItem; _groupItem.init(size, isGroupByFields); if (_groupMap == null) _groupMap = new HashMap<GroupItem, GroupItem>(); }
/** Initializes the query state. */ public void init(DbTransaction xa, TableIterator[] tableIterators, boolean isReadOnly) { if (_isLocked) throw new IllegalStateException(); Thread thread = Thread.currentThread(); if (_thread != null && _thread != thread) throw new IllegalStateException(toString() + " attempted query reuse without close"); _thread = thread; _xa = xa; _isWrite = !isReadOnly; _tableIterators = tableIterators; _blockLockLength = tableIterators.length; if (_blockLocks == null || _blockLocks.length < _blockLockLength) _blockLocks = new Block[_blockLockLength]; else { for (int i = _blockLockLength - 1; i >= 0; i--) _blockLocks[i] = null; } _rowUpdateCount = 0; _groupItem = _tempGroupItem; _groupItem.init(0, null); }
private JSONObject BouildGroupStatusMsg(GroupItem groupItem) { JSONObject JSONObj = new JSONObject(); try { JSONObj.put("name", groupItem.getName()); // JSONObj.put("state", groupItem.getStatus()); /* put all devices */ JSONArray arrayObjG = new JSONArray(); for (int dii = 0; dii < groupItem.Size(); dii++) { arrayObjG.put(BouildDeviceStatusMsg(groupItem.get(dii))); } JSONObj.put("devices", arrayObjG); } catch (JSONException e) { e.printStackTrace(); } return JSONObj; }
/** Selects the actual group item. */ public void selectGroup() { GroupItem item = _groupMap.get(_groupItem); if (item == null) { item = _groupItem.allocateCopy(); _groupMap.put(item, item); } _groupItem = item; }
public void addItem(Item item) { if (item == null) return; else if (item instanceof EmptyItem) { _allowEmpty = true; return; } else if (item instanceof ChoiceItem) { ChoiceItem choice = (ChoiceItem) item; if (choice._allowEmpty) _allowEmpty = true; for (int i = 0; i < choice._items.size(); i++) addItem(choice._items.get(i)); return; } for (int i = 0; i < _items.size(); i++) { Item subItem = _items.get(i); if (item.equals(subItem)) return; if (item instanceof InElementItem && subItem instanceof InElementItem) { InElementItem elt1 = (InElementItem) item; InElementItem elt2 = (InElementItem) subItem; if (elt1.getElementItem().equals(elt2.getElementItem())) { subItem = InElementItem.create( elt1.getElementItem(), create(elt1.getContinuationItem(), elt2.getContinuationItem())); _items.remove(i); addItem(subItem); return; } } if (item instanceof GroupItem && subItem instanceof GroupItem) { GroupItem group1 = (GroupItem) item; GroupItem group2 = (GroupItem) subItem; if (group1.getFirst().equals(group2.getFirst())) { subItem = GroupItem.create(group1.getFirst(), create(group1.getSecond(), group2.getSecond())); _items.remove(i); addItem(subItem); return; } } } _items.add(item); }
private Vector<GroupItem> ParseContent(JSONArray arrayObj) { Vector<GroupItem> GroupItems = new Vector<GroupItem>(); for (int ii = 0; ii < arrayObj.length(); ii++) { JSONObject obj_g = null; JSONArray arr_d = null; try { obj_g = arrayObj.getJSONObject(ii); GroupItem gi = GetGroupItemFromJSONObject(obj_g); arr_d = obj_g.getJSONArray("devices"); for (int jj = 0; jj < arr_d.length(); jj++) gi.add(GetDeviceItemFromJSONObject(arr_d.getJSONObject(jj))); GroupItems.add(gi); } catch (JSONException e) { e.printStackTrace(); } } return GroupItems; }
private QueryContext() { _tempGroupItem = GroupItem.allocate(new boolean[8]); }
/** Returns the indexed group field. */ public Data getGroupData(int index) { return _groupItem.getData(index); }
/** Sets the indexed group field as a double. */ public double getGroupDouble(int index) { return _groupItem.getDouble(index); }
/** Sets the indexed group field as a double. */ public void setGroupDouble(int index, double value) { _groupItem.setDouble(index, value); }
/** Sets the indexed group field as a long. */ public long getGroupLong(int index) { return _groupItem.getLong(index); }
/** Sets the indexed group field as a long. */ public void setGroupLong(int index, long value) { _groupItem.setLong(index, value); }
/** Sets the indexed group field. */ public String getGroupString(int index) { String value = _groupItem.getString(index); return value; }
/** Sets the indexed group field. */ public void setGroupString(int index, String value) { _groupItem.setString(index, value); }
/** Sets the indexed group field. */ public boolean isGroupNull(int index) { return _groupItem.isNull(index); }
/** {@inheritDoc} */ public int compare(GroupItem<?> group1, GroupItem<?> group2) { return nullSafeCompare( argument.evaluate(group1.getGroupKey()), argument.evaluate(group2.getGroupKey())); }