public GraphAttribute[] getAllAttrs(){ Field[] fields=element.getClass().getFields(); GraphAttribute[] result=new GraphAttribute[fields.length]; Vector v=new Vector(); int k=0; boolean found=false; while (k<fields.length){ try { result[k]=new GraphAttributeImp(fields[k].getName(),fields[k].get(this.element),graph,ids); } catch (IllegalAccessException iae){ iae.printStackTrace(); } k=k+1; } return result; }
public boolean isSimpleValue(){ return !isCollectionValue() && !isEntityValue(); }
public void setAttribute(GraphAttribute ga) throws InvalidAttribute{ try { GraphAttribute oldga=this.getAttributeByName(ga.getName()); ((GraphAttributeImp)oldga).setValue(((GraphAttributeImp)ga).getValue()); Object nvalue=((GraphAttributeImp)ga).getValue(); if (nvalue instanceof GraphCollection){ nvalue=((GraphCollectionImp)nvalue).getValue();
public GraphAttribute createAttribute(String name, Object value, Graph graph ){ GraphAttribute ga=new GraphAttributeImp(name,value,((GraphImp)graph).getGraph(),ids); return ga; }
public GraphAttribute getAttributeByName(String name) throws NotFound{ Field[] fields=element.getClass().getFields(); GraphAttribute result=null; int k=0; boolean found=false; String availableFields=""; while (k<fields.length && !found){ try { availableFields=availableFields+fields[k].getName()+"="+fields[k].get(element)+","; } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } found=fields[k].getName().equalsIgnoreCase(name); if (!found) k++; } if (!found) throw new NotFound("Field "+name+" not found in entity "+ element+":"+element.getClass().getName()+".Available fields in "+element.getClass()+" are "+availableFields); try { result=new GraphAttributeImp(name,fields[k].get(this.element),graph,ids); } catch (IllegalAccessException iae){ iae.printStackTrace(); } return result; }
public GraphAttribute createAttribute(String name, GraphCollection value, Graph graph ){ GraphAttribute ga=new GraphAttributeImp(name,((GraphCollectionImp)value).getValue(),((GraphImp)graph).getGraph(),ids); return ga; }