It’s our mission to create a product that solves the huge challenges you face at work every day. In case you missed it, here are 7 delightful things we've added recently to monday to make it even more awesome.
public class BorderControl {
private static BorderControl instance = new BorderControl();
public static BorderControl getInstance() {
return instance;
}
boolean bc[] = new boolean[10];
double bidPx[] = new double[10];
double askPx[] = new double[10];
.............
public void borderControl(boolean[] bc, double[] bidPx, double[] askPx) {
if (bidPx[0] != 0 && askPx[0] != 0)
try {
formatter = new DecimalFormat("#0.0");
resist[0] = DCC.getInstance().getTextresistEURUSD();
rt[0] = Double.parseDouble(resist[0]);
drt[0] = (rt[0] - askPx[0]) * 10000;
dresist[0] = formatter.format(drt[0]);
DCC.getInstance().setEURUSD_resist(dresist[0]);
support[0] = DCC.getInstance().getTextsupportEURUSD();
st[0] = Double.parseDouble(support[0]);
srt[0] = (bidPx[0] - st[0]) * 10000;
dsupport[0] = formatter.format(srt[0]);
DCC.getInstance().setEURUSD_support(dsupport[0]);
if (drt[0] <= 5 || srt[0] <= 5) {
bc[0] = false;
} else {
bc[0] = true;
}
System.out.println(" bc[0] = " + bc[0]);
I have it here, but when I call it from other classpublic void businessLogic_EURUSD(double[] outY0) throws Exception {
System.out.println("%%%%%%%%%%%% BL outY0[0] = " + outY0[0] );
try {
if (outY0[0] < 0){
bl0 = false;
System.out.println(" bl0 = " + bl0 + "\n");
dc_EURUSD_S = new DecisionCenter_EURUSD_S();
dc_EURUSD_S.decisionCenter_EURUSD_S(bl0);
public void decisionCenter_EURUSD_S(boolean bl0) throws Exception {
System.out.println(" bl0 " + bl0);
System.out.println(" &&&&&&& flag0s " + flag0s);
System.out.println(" ^^^^^^^ mflag0s " + mflag0s);
BorderControl.getInstance().borderControl(bc, bidPx, askPx);
System.out.println(" DC bc[0] = " + bc[0]);
System.out.println(" DC bidPx[0] = " + bidPx[0]);
, I get error
%%%%%%%%%%%% BL outY0[0] = -47624.27
bl0 = false => Businesslogic
bl0 false => start DecisionCenter
&&&&&&& flag0s false
^^^^^^^ mflag0s false
=> start call getInstance BorderControl from DecisionCenter
28.02.2011 19:55:20 EURUSD.BusinessLogic_EURUSD businessLogic_EURUSD
SEVERE: null
java.lang.NullPointerException
at EURUSD.BorderControl.borderControl(BorderControl.java:37)
at EURUSD.DecisionCenter_EURUSD_S.decisionCenter_EURUSD_S(DecisionCenter_EURUSD_S.java:45)
at EURUSD.BusinessLogic_EURUSD.businessLogic_EURUSD(BusinessLogic_EURUSD.java:47)
at EURUSD.AlgoCalcY_EURUSD.outY(AlgoCalcY_EURUSD.java:33)
at algo.ArrayConverter.arrayConverter(ArrayConverter.java:81)
at connect.SelectData.run(SelectData.java:66)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
at EURUSD.BorderControl.bordepublic void borderControl(boolean[] bc, double[] bidPx, double[] askPx) {
for (int j = 0; j < bidPx.length; j++) {
this.bidPx[j] = bidPx[j];
this.askPx[j] = askPx[j];
}
if (bidPx[0] != 0 && askPx[0] != 0)
{
try {
bl0 false
&&&&&&& flag0s false
^^^^^^^ mflag0s false
28.02.2011 20:45:00 EURUSD.BusinessLogic_EURUSD businessLogic_EURUSD
SEVERE: null
java.lang.NullPointerException
at control.BorderControl.borderControl(BorderControl.java:35)
35. for (int j = 0; j < bidPx.length; j++) {public class BorderControl {
private static BorderControl instance = new BorderControl();
public static BorderControl getInstance() {
return instance;
}
String resist[] = new String[10];
String support[] = new String[10];
double rt[] = new double[10];
double st[] = new double[10];
double drt[] = new double[10];
double srt[] = new double[10];
String dresist[] = new String[10];
String dsupport[] = new String[10];
boolean bc[] = new boolean[10];
double bidPx[] = new double[10];
double askPx[] = new double[10];
NumberFormat formatter;
public void borderControl(boolean[] bc, double[] bidPx, double[] askPx) {
this.bidPx = bidPx;
this.askPx = askPx;
if (bidPx[0] != 0 && askPx[0] != 0)
{
try {
formatter = new DecimalFormat("#0.0");
resist[0] = DCC.getInstance().getTextresistEURUSD();
rt[0] = Double.parseDouble(resist[0]);
drt[0] = (rt[0] - askPx[0]) * 10000;
dresist[0] = formatter.format(drt[0]);
DCC.getInstance().setEURUSD_resist(dresist[0]);
support[0] = DCC.getInstance().getTextsupportEURUSD();
st[0] = Double.parseDouble(support[0]);
srt[0] = (bidPx[0] - st[0]) * 10000;
dsupport[0] = formatter.format(srt[0]);
DCC.getInstance().setEURUSD_support(dsupport[0]);
if (drt[0] <= 5 || srt[0] <= 5) {
bc[0] = false;
} else {
bc[0] = true;
}
System.out.println(" bc[0] = " + bc[0]);
} catch (Exception ex) {
Logger.getLogger(BorderControl.class.getName()).log(Level.SEVERE,
null, ex);
}
}
if (bidPx[1] != 0 && askPx[1] != 0)
try {
formatter = new DecimalFormat("#0.0");
resist[1] = DCC.getInstance().getTextresistEURCHF();
rt[1] = Double.parseDouble(resist[1]);
drt[1] = (rt[1] - askPx[1]) * 10000;
dresist[1] = formatter.format(drt[1]);
DCC.getInstance().setEURCHF_resist(dresist[1]);
support[1] = DCC.getInstance().getTextsupportEURCHF();
st[1] = Double.parseDouble(support[1]);
srt[1] = (bidPx[1] - st[1]) * 10000;
dsupport[1] = formatter.format(srt[1]);
DCC.getInstance().setEURCHF_support(dsupport[1]);
if (drt[1] <= 5 || srt[1] <= 5) {
bc[1] = false;
} else {
bc[1] = true;
}
System.out.println(" bc[1] = " + bc[1]);
} catch (Exception ex) {
Logger.getLogger(BorderControl.class.getName()).log(Level.SEVERE,
null, ex);
}
if (bidPx[2] != 0 && askPx[2] != 0)
try {
formatter = new DecimalFormat("#0.0");
resist[2] = DCC.getInstance().getTextresistEURGBP();
rt[2] = Double.parseDouble(resist[2]);
drt[2] = (rt[2] - askPx[2]) * 10000;
dresist[2] = formatter.format(drt[2]);
DCC.getInstance().setEURGBP_resist(dresist[2]);
support[2] = DCC.getInstance().getTextsupportEURGBP();
st[2] = Double.parseDouble(support[2]);
srt[2] = (bidPx[2] - st[2]) * 10000;
dsupport[2] = formatter.format(srt[2]);
DCC.getInstance().setEURGBP_support(dsupport[2]);
if (drt[2] <= 5 || srt[2] <= 5) {
bc[2] = false;
} else {
bc[2] = true;
}
// System.out.println(" bc[2] = " + bc[2]);
} catch (Exception ex) {
Logger.getLogger(BorderControl.class.getName()).log(Level.SEVERE,
null, ex);
}
if (bidPx[3] != 0 && askPx[3] != 0)
try {
formatter = new DecimalFormat("#0.0");
resist[3] = DCC.getInstance().getTextresistUSDCHF();
rt[3] = Double.parseDouble(resist[3]);
drt[3] = (rt[3] - askPx[3]) * 10000;
dresist[3] = formatter.format(drt[3]);
DCC.getInstance().setUSDCHF_resist(dresist[3]);
support[3] = DCC.getInstance().getTextsupportUSDCHF();
st[3] = Double.parseDouble(support[3]);
srt[3] = (bidPx[3] - st[3]) * 10000;
dsupport[3] = formatter.format(srt[3]);
DCC.getInstance().setUSDCHF_support(dsupport[3]);
if (drt[3] <= 5 || srt[3] <= 5) {
bc[3] = false;
} else {
bc[3] = true;
}
// System.out.println(" bc[3] = " + bc[3]);
} catch (Exception ex) {
Logger.getLogger(BorderControl.class.getName()).log(Level.SEVERE,
null, ex);
}
if (bidPx[4] != 0 && askPx[4] != 0)
try {
formatter = new DecimalFormat("#0.0");
resist[4] = DCC.getInstance().getTextresistGBPUSD();
rt[4] = Double.parseDouble(resist[4]);
drt[4] = (rt[4] - askPx[4]) * 10000;
dresist[4] = formatter.format(drt[4]);
DCC.getInstance().setGBPUSD_resist(dresist[4]);
support[4] = DCC.getInstance().getTextsupportGBPUSD();
st[4] = Double.parseDouble(support[4]);
srt[4] = (bidPx[4] - st[4]) * 10000;
dsupport[4] = formatter.format(srt[4]);
DCC.getInstance().setGBPUSD_support(dsupport[4]);
if (drt[4] <= 5 || srt[4] <= 5) {
bc[4] = false;
} else {
bc[4] = true;
}
// System.out.println(" bc[4] = " + bc[4]);
} catch (Exception ex) {
Logger.getLogger(BorderControl.class.getName()).log(Level.SEVERE,
null, ex);
}
if (bidPx[5] != 0 && askPx[5] != 0)
try {
formatter = new DecimalFormat("#0.0");
resist[5] = DCC.getInstance().getTextresistGBPCHF();
rt[5] = Double.parseDouble(resist[5]);
drt[5] = (rt[5] - askPx[5]) * 10000;
dresist[5] = formatter.format(drt[5]);
DCC.getInstance().setGBPCHF_resist(dresist[5]);
support[5] = DCC.getInstance().getTextsupportGBPCHF();
st[5] = Double.parseDouble(support[5]);
srt[5] = (bidPx[5] - st[5]) * 10000;
dsupport[5] = formatter.format(srt[5]);
DCC.getInstance().setGBPCHF_support(dsupport[5]);
if (drt[5] <= 5 || srt[5] <= 5) {
bc[5] = false;
} else {
bc[5] = true;
}
// System.out.println(" bc[5] = " + bc[5]);
} catch (Exception ex) {
Logger.getLogger(BorderControl.class.getName()).log(Level.SEVERE,
null, ex);
}
if (bidPx[6] != 0 && askPx[6] != 0)
try {
formatter = new DecimalFormat("#0.0");
resist[6] = DCC.getInstance().getTextresistEURJPY();
rt[6] = Double.parseDouble(resist[6]);
drt[6] = (rt[6] - askPx[6]) * 100;
dresist[6] = formatter.format(drt[6]);
DCC.getInstance().setEURJPY_resist(dresist[6]);
support[6] = DCC.getInstance().getTextsupportEURJPY();
st[6] = Double.parseDouble(support[6]);
srt[6] = (bidPx[6] - st[6]) * 100;
dsupport[6] = formatter.format(srt[6]);
DCC.getInstance().setEURJPY_support(dsupport[6]);
if (drt[6] <= 5 || srt[6] <= 5) {
bc[6] = false;
} else {
bc[6] = true;
}
// System.out.println(" bc[6] = " + bc[6]);
} catch (Exception ex) {
Logger.getLogger(BorderControl.class.getName()).log(Level.SEVERE,
null, ex);
}
if (bidPx[7] != 0 && askPx[7] != 0)
try {
formatter = new DecimalFormat("#0.0");
resist[7] = DCC.getInstance().getTextresistUSDJPY();
rt[7] = Double.parseDouble(resist[7]);
drt[7] = (rt[7] - askPx[7]) * 100;
dresist[7] = formatter.format(drt[7]);
DCC.getInstance().setUSDJPY_resist(dresist[7]);
support[7] = DCC.getInstance().getTextsupportUSDJPY();
st[7] = Double.parseDouble(support[7]);
srt[7] = (bidPx[7] - st[7]) * 100;
dsupport[7] = formatter.format(srt[7]);
DCC.getInstance().setUSDJPY_support(dsupport[7]);
if (drt[7] <= 5 || srt[7] <= 5) {
bc[7] = false;
} else {
bc[7] = true;
}
// System.out.println(" bc[7] = " + bc[7]);
} catch (Exception ex) {
Logger.getLogger(BorderControl.class.getName()).log(Level.SEVERE,
null, ex);
}
if (bidPx[8] != 0 && askPx[8] != 0)
try {
formatter = new DecimalFormat("#0.0");
resist[8] = DCC.getInstance().getTextresistGBPJPY();
rt[8] = Double.parseDouble(resist[8]);
drt[8] = (rt[8] - askPx[8]) * 100;
dresist[8] = formatter.format(drt[8]);
DCC.getInstance().setGBPJPY_resist(dresist[8]);
support[8] = DCC.getInstance().getTextsupportGBPJPY();
st[8] = Double.parseDouble(support[8]);
srt[8] = (bidPx[8] - st[8]) * 100;
dsupport[8] = formatter.format(srt[8]);
DCC.getInstance().setGBPJPY_support(dsupport[8]);
if (drt[8] <= 5 || srt[8] <= 5) {
bc[8] = false;
} else {
bc[8] = true;
}
// System.out.println(" bc[8] = " + bc[8]);
} catch (Exception ex) {
Logger.getLogger(BorderControl.class.getName()).log(Level.SEVERE,
null, ex);
}
if (bidPx[9] != 0 && askPx[9] != 0)
try {
formatter = new DecimalFormat("#0.0");
resist[9] = DCC.getInstance().getTextresistCHFJPY();
rt[9] = Double.parseDouble(resist[9]);
drt[9] = (rt[9] - askPx[9]) * 100;
dresist[9] = formatter.format(drt[9]);
DCC.getInstance().setCHFJPY_resist(dresist[9]);
support[9] = DCC.getInstance().getTextsupportCHFJPY();
st[9] = Double.parseDouble(support[9]);
srt[9] = (bidPx[9] - st[9]) * 100;
dsupport[9] = formatter.format(srt[9]);
DCC.getInstance().setCHFJPY_support(dsupport[9]);
if (drt[9] <= 5 || srt[9] <= 5) {
bc[9] = false;
} else {
bc[9] = true;
}
// System.out.println(" bc[9] = " + bc[9]);
} catch (Exception ex) {
Logger.getLogger(BorderControl.class.getName()).log(Level.SEVERE,
null, ex);
}
}
}
so, for each array member I have own try.
public void borderControl_eurusd (boolean bc, double bidPx, double askPx) {
if (bidPx != 0 && askPx != 0)
{
try {
formatter = new DecimalFormat("#0.0");
resist[0] = DCC.getInstance().getTextresistEURUSD();
rt[0] = Double.parseDouble(resist[0]);
drt[0] = (rt[0] - askPx) * 10000;
dresist[0] = formatter.format(drt[0]);
DCC.getInstance().setEURUSD_resist(dresist[0]);
support[0] = DCC.getInstance().getTextsupportEURUSD();
st[0] = Double.parseDouble(support[0]);
srt[0] = (bidPx - st[0]) * 10000;
dsupport[0] = formatter.format(srt[0]);
DCC.getInstance().setEURUSD_support(dsupport[0]);
if (drt[0] <= 5 || srt[0] <= 5) {
bc = false;
} else {
bc = true;
}
System.out.println(" EUR/USD bc = " + bc);
} catch (Exception ex) {
Logger.getLogger(BorderControl.class.getName()).log(Level.SEVERE,
null, ex);
}
}
}
But the question is why array doesn't work? I like it more because it's much elegant and professional solution.public void borderControl(double[] bidPx, double[] askPx) {
if (bidPx[0] != 0 && askPx[0] != 0) {
try {
formatter = new DecimalFormat("#0.0");
resist[0] = DCC.getInstance().getTextresistEURUSD();
rt[0] = Double.parseDouble(resist[0]);
drt[0] = (rt[0] - askPx[0]) * 10000;
dresist[0] = formatter.format(drt[0]);
DCC.getInstance().setEURUSD_resist(dresist[0]);
support[0] = DCC.getInstance().getTextsupportEURUSD();
st[0] = Double.parseDouble(support[0]);
srt[0] = (bidPx[0] - st[0]) * 10000;
dsupport[0] = formatter.format(srt[0]);
DCC.getInstance().setEURUSD_support(dsupport[0]);
if (drt[0] <= 10 || srt[0] <= 10) {
bc[0] = false;
DecisionCenter_EURUSD_S.getInstance().bControl(bc);
DecisionCenter_EURUSD_B.getInstance().bControl(bc);
} else {
bc[0] = true;
DecisionCenter_EURUSD_S.getInstance().bControl(bc);
DecisionCenter_EURUSD_B.getInstance().bControl(bc);
}
} catch (Exception ex) {
Logger.getLogger(BorderControl.class.getName()).log(Level.SEVERE,
null, ex);
}
}
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Join the community of 500,000 technology professionals and ask your questions.