T
tolu45
Hi all,
I am having some problems with my implementation. what i want to do is
this, i have some class called nodes, edges and selection graph. I
instantiated a node in the selection graph in order to create a
selection graph with only one node and no edges. When i to run the
program so that the output will be this selection graph i got a null
pointerexception error. Could anyone tell me how to solve this problem?
I have include the code for the class below. of es make up a selection
graph. here are the codes:
Nodes class:
public class Node {
private double nodeID = 0;
private String tableName = null;
private String primaryKey = null;
private Vector condition = new Vector();
private boolean sFlag = false;
private boolean fFlag = false;
/** Creates a new instance of SelGrapNode
public Node(String table_name, Vector condition, boolean node_flag,
String primary_key) {
this.tableName = table_name;
this.condition = condition;
this.sFlag = sFlag;
this.fFlag = fFlag;
}
*/
public Node(){
//nodeID = 0;
}
//modifier methods
public double getNodeID () { return nodeID; }
public void setNodeID(double node ) {
nodeID = node;
}
public String getTableName () { return tableName; }
public void setTableName(String tName ) {
tableName = tName;
}
public Vector getCondition () { return condition; }
public void addCondition(String cond){
condition.addElement(cond);
}
public void remCondition(String indx){
condition.remove(indx);
}
public boolean getSFlag () { return sFlag;}
public void setSFlag(boolean sFlag){
sFlag = sFlag;
}
public boolean getFFlag () { return fFlag;}
public void setFFlag(boolean fFlag){
fFlag= fFlag;
}
public String getPrimaryKey()
{
return primaryKey;
}
public void setPrimaryKey(String name)
{
primaryKey = name;
}
}
Selection graph class:
public class SelGraph {
public Node[] Nodes;
public Edge[] Edges;
public SelGraph() {
Nodes = new Node[10];
for (int i =0; i<10; i++)
{
Nodes.setNodeID(i);
Nodes.setFFlag(false);
Nodes.setPrimaryKey("");
Nodes.setSFlag(false);
Nodes.setTableName("");
}
//Edges[] = new Edge[100];
}
//public jarray getNodes(){
//}
public void addNode(double node, String tblname, String prKey,
boolean sFlg, boolean fFlg, String cdt){
// always add new node to the end of array
int lastIndex = Nodes.length;
Nodes[lastIndex].setNodeID(node);
Nodes[lastIndex].setTableName(tblname);
Nodes[lastIndex].setPrimaryKey(prKey);
Nodes[lastIndex].setSFlag(sFlg);
Nodes[lastIndex].setFFlag(fFlg);
Nodes[lastIndex].addCondition(cdt);
}
public void addNode(int idx, double node, String tblname, String
prKey, boolean sFlg, boolean fFlg, String cdt){
Nodes[idx].setNodeID(node);
Nodes[idx].setTableName(tblname);
Nodes[idx].setPrimaryKey(prKey);
Nodes[idx].setSFlag(sFlg);
Nodes[idx].setFFlag(fFlg);
Nodes[idx].addCondition(cdt);
}
public void addEdge(double fNode, double bNode, String fColNm,
String bColNm, boolean eFlg) {
int lastIndex = Edges.length;
Edges[lastIndex].setFrontNode(fNode);
Edges[lastIndex].setBackNode(bNode);
Edges[lastIndex].setFrontColName(fColNm);
Edges[lastIndex].setBackColName(bColNm);
Edges[lastIndex].setEFlag(eFlg);
}
public void addEdge(int idx, double fNode, double bNode, String
fColNm, String bColNm, boolean eFlg) {
Edges[idx].setFrontNode(fNode);
Edges[idx].setBackNode(bNode);
Edges[idx].setFrontColName(fColNm);
Edges[idx].setBackColName(bColNm);
Edges[idx].setEFlag(eFlg);
}
public void addNodeAndEdge(double node, String tblname, String
prKey, boolean sFlg, boolean fFlg, String cdt, double fNode, double
bNode, String fColNm, String bColNm, boolean eFlg){
this.addNode(node, tblname, prKey, sFlg, fFlg, cdt);
this.addEdge(fNode, bNode, fColNm, bColNm, eFlg);
}
public void addPositiveCondition(int idx, String cdt){
this.Nodes[idx].addCondition(cdt);
}
// FIXME: This Are the remaining Methods for the refinement: We need
to know where to include them
public void addNegativeCondition(int idx,String cdt){
int size = Nodes.length;
for (int i =0; i < size; i++) {
if (Nodes.getNodeID()==0)
{
this.Nodes.addCondition(cdt);
}
if (Nodes[idx].getNodeID()!=0){
this.Edges[idx].setBackNode(idx-1);
this.Nodes[idx].addCondition(cdt);
this.Nodes[idx].setSFlag(false);
}
}
}
public void addPresentEdgeAndOpenNode(int idx, String cdt){
int size = Edges.length;
for (int i = 0; i< size; i++){
for (int j = 0 ; j < i; j++){
if(Edges[j].getBackColName()== Edges.getFrontColName()) {
Edges[j].setFrontNode(i);
Edges.setEFlag(true);
}
}
}
}
public void addAbsentEdgeAndclosesNode(int idx){
int size = Edges.length;
for (int i = 0; i< size; i++){
for (int j = 0 ; j < i; j++){
if(Edges[j].getBackColName()== Edges.getFrontColName()) {
Edges[j].setFrontNode(i);
Edges.setEFlag(false);
}
}
}
}
public Vector refinement(){
Vector entropyVec = new Vector();
return entropyVec;
}
}
edge class:
package DMengine;
/**
*
* @author Adesola + Jorge + Tu Ba
*/
public class Edge {
private double frontNode = 0;
private double backNode = 0;
private String frontColName = new String();
private String backColName = new String();
private boolean eFlag = false;
/**
* Creates a new instance of Edge
public Edge(double frontNode, double backNode, String frontColName,
String backColName, boolean eFlag ) {
this.frontNode = frontNode;
this.backNode = backNode;
this.frontColName = frontColName;
this.backColName = backColName;
this.eFlag = eFlag;
}
*/
public Edge(){
}
public double getFronNode() {
return this.frontNode;
}
public void setFrontNode(double fNode){
this.frontNode = fNode;
}
public double getBackNode() {
return this.backNode;
}
public void setBackNode(double bNode){
this.backNode = bNode;
}
public String getFrontColName() {
return this.frontColName;
}
public void setFrontColName(String fColname){
this.frontColName = fColname;
}
public String getBackColName() {
return this.backColName;
}
public void setBackColName(String bColname){
this.backColName = bColname;
}
public boolean getEFlag () {
return eFlag;
}
public void setEFlag(boolean eFl){
eFlag = eFl;
}
}
I am having some problems with my implementation. what i want to do is
this, i have some class called nodes, edges and selection graph. I
instantiated a node in the selection graph in order to create a
selection graph with only one node and no edges. When i to run the
program so that the output will be this selection graph i got a null
pointerexception error. Could anyone tell me how to solve this problem?
I have include the code for the class below. of es make up a selection
graph. here are the codes:
Nodes class:
public class Node {
private double nodeID = 0;
private String tableName = null;
private String primaryKey = null;
private Vector condition = new Vector();
private boolean sFlag = false;
private boolean fFlag = false;
/** Creates a new instance of SelGrapNode
public Node(String table_name, Vector condition, boolean node_flag,
String primary_key) {
this.tableName = table_name;
this.condition = condition;
this.sFlag = sFlag;
this.fFlag = fFlag;
}
*/
public Node(){
//nodeID = 0;
}
//modifier methods
public double getNodeID () { return nodeID; }
public void setNodeID(double node ) {
nodeID = node;
}
public String getTableName () { return tableName; }
public void setTableName(String tName ) {
tableName = tName;
}
public Vector getCondition () { return condition; }
public void addCondition(String cond){
condition.addElement(cond);
}
public void remCondition(String indx){
condition.remove(indx);
}
public boolean getSFlag () { return sFlag;}
public void setSFlag(boolean sFlag){
sFlag = sFlag;
}
public boolean getFFlag () { return fFlag;}
public void setFFlag(boolean fFlag){
fFlag= fFlag;
}
public String getPrimaryKey()
{
return primaryKey;
}
public void setPrimaryKey(String name)
{
primaryKey = name;
}
}
Selection graph class:
public class SelGraph {
public Node[] Nodes;
public Edge[] Edges;
public SelGraph() {
Nodes = new Node[10];
for (int i =0; i<10; i++)
{
Nodes.setNodeID(i);
Nodes.setFFlag(false);
Nodes.setPrimaryKey("");
Nodes.setSFlag(false);
Nodes.setTableName("");
}
//Edges[] = new Edge[100];
}
//public jarray getNodes(){
//}
public void addNode(double node, String tblname, String prKey,
boolean sFlg, boolean fFlg, String cdt){
// always add new node to the end of array
int lastIndex = Nodes.length;
Nodes[lastIndex].setNodeID(node);
Nodes[lastIndex].setTableName(tblname);
Nodes[lastIndex].setPrimaryKey(prKey);
Nodes[lastIndex].setSFlag(sFlg);
Nodes[lastIndex].setFFlag(fFlg);
Nodes[lastIndex].addCondition(cdt);
}
public void addNode(int idx, double node, String tblname, String
prKey, boolean sFlg, boolean fFlg, String cdt){
Nodes[idx].setNodeID(node);
Nodes[idx].setTableName(tblname);
Nodes[idx].setPrimaryKey(prKey);
Nodes[idx].setSFlag(sFlg);
Nodes[idx].setFFlag(fFlg);
Nodes[idx].addCondition(cdt);
}
public void addEdge(double fNode, double bNode, String fColNm,
String bColNm, boolean eFlg) {
int lastIndex = Edges.length;
Edges[lastIndex].setFrontNode(fNode);
Edges[lastIndex].setBackNode(bNode);
Edges[lastIndex].setFrontColName(fColNm);
Edges[lastIndex].setBackColName(bColNm);
Edges[lastIndex].setEFlag(eFlg);
}
public void addEdge(int idx, double fNode, double bNode, String
fColNm, String bColNm, boolean eFlg) {
Edges[idx].setFrontNode(fNode);
Edges[idx].setBackNode(bNode);
Edges[idx].setFrontColName(fColNm);
Edges[idx].setBackColName(bColNm);
Edges[idx].setEFlag(eFlg);
}
public void addNodeAndEdge(double node, String tblname, String
prKey, boolean sFlg, boolean fFlg, String cdt, double fNode, double
bNode, String fColNm, String bColNm, boolean eFlg){
this.addNode(node, tblname, prKey, sFlg, fFlg, cdt);
this.addEdge(fNode, bNode, fColNm, bColNm, eFlg);
}
public void addPositiveCondition(int idx, String cdt){
this.Nodes[idx].addCondition(cdt);
}
// FIXME: This Are the remaining Methods for the refinement: We need
to know where to include them
public void addNegativeCondition(int idx,String cdt){
int size = Nodes.length;
for (int i =0; i < size; i++) {
if (Nodes.getNodeID()==0)
{
this.Nodes.addCondition(cdt);
}
if (Nodes[idx].getNodeID()!=0){
this.Edges[idx].setBackNode(idx-1);
this.Nodes[idx].addCondition(cdt);
this.Nodes[idx].setSFlag(false);
}
}
}
public void addPresentEdgeAndOpenNode(int idx, String cdt){
int size = Edges.length;
for (int i = 0; i< size; i++){
for (int j = 0 ; j < i; j++){
if(Edges[j].getBackColName()== Edges.getFrontColName()) {
Edges[j].setFrontNode(i);
Edges.setEFlag(true);
}
}
}
}
public void addAbsentEdgeAndclosesNode(int idx){
int size = Edges.length;
for (int i = 0; i< size; i++){
for (int j = 0 ; j < i; j++){
if(Edges[j].getBackColName()== Edges.getFrontColName()) {
Edges[j].setFrontNode(i);
Edges.setEFlag(false);
}
}
}
}
public Vector refinement(){
Vector entropyVec = new Vector();
return entropyVec;
}
}
edge class:
package DMengine;
/**
*
* @author Adesola + Jorge + Tu Ba
*/
public class Edge {
private double frontNode = 0;
private double backNode = 0;
private String frontColName = new String();
private String backColName = new String();
private boolean eFlag = false;
/**
* Creates a new instance of Edge
public Edge(double frontNode, double backNode, String frontColName,
String backColName, boolean eFlag ) {
this.frontNode = frontNode;
this.backNode = backNode;
this.frontColName = frontColName;
this.backColName = backColName;
this.eFlag = eFlag;
}
*/
public Edge(){
}
public double getFronNode() {
return this.frontNode;
}
public void setFrontNode(double fNode){
this.frontNode = fNode;
}
public double getBackNode() {
return this.backNode;
}
public void setBackNode(double bNode){
this.backNode = bNode;
}
public String getFrontColName() {
return this.frontColName;
}
public void setFrontColName(String fColname){
this.frontColName = fColname;
}
public String getBackColName() {
return this.backColName;
}
public void setBackColName(String bColname){
this.backColName = bColname;
}
public boolean getEFlag () {
return eFlag;
}
public void setEFlag(boolean eFl){
eFlag = eFl;
}
}