public JSONArray getJSONArrayRepresentation(RepFactory f) throws JSONException { JSONArray arr = new JSONArray(); Stack<HNode> st = new Stack<HNode>(); st.push(this); HTable t = f.getHTable(hTableId); HNode parentNode = t.getParentHNode(); while (parentNode != null) { st.push(parentNode); t = f.getHTable(parentNode.getHTableId()); parentNode = t.getParentHNode(); } while (!st.isEmpty()) { HNode node = st.pop(); JSONObject obj = new JSONObject(); obj.put("columnName", node.getColumnName()); arr.put(obj); } return arr; }
/** * Returns the HNodePath for this node. * * @param factory * @return the HNodePath for this node. */ public HNodePath getHNodePath(RepFactory factory) { HNodePath p1 = new HNodePath(this); // get the table that it belongs to HTable t = factory.getHTable(hTableId); HNode parentNode = t.getParentHNode(); if (parentNode != null) { HNodePath p2 = parentNode.getHNodePath(factory); p1 = HNodePath.concatenate(p2, p1); } return p1; }