Can't check for nulls in a conditional?
Hey everyone. Trying my hand at a text based game but I'm encountering many problems:
I have this method in one class that (as you can see) has a conditional that checks to see if 'check' is null, this throws a null pointer exception whenever it is called.
private void placeChars()
String check = currentItem.getItemString();
if(check.equals(null) && currentRoom.getShortDescription().equals("in the cafeteria"))
josh.getSentence(0);
}Here is the method that it is calling from:
public String getItemString()
String returnString = null;
if(haveItems != 0 ){
returnString = "Items:";
Set<String> keys = items.keySet();
for(String item : keys) {
returnString += " " + item;
return returnString;
}I'm not sure what I am doing wrong here :/ and yes I know the code is extremely ugly :)
if check is null, you can't invoke any methods on it, including equals.
To check for null:
if (check == null)
Similar Messages
-
Check for null values in conditional formatting when no rows returned.
I have a report that is showing facts for different months.
For some months there is no row in the facts table.
But in the report, I have to show a * when there is no data.
If there is a row in the facts table with null value for data, the conditional formatting successfully shows a * when data is null.
But when no row is present in the facts for a particular month , conditional formatting is unable to detect any null, as none exist.
How we can check that no rews returned for a particular month and then show *?
thanksHi,
which obiee version r u using?
My Blog ref:
http://obieeelegant.blogspot.com/2011/06/replacing-null-as-0-in-obiee.html
in obiee10g its working fine.expect obiee11g
also see the bug reference
How to replace null as 0 in obiee11g pivot table view?
obiee11.1.1.6.0 also have the same issues.
Thanks
Deva -
Page Validation - Function Returning Boolean - Check for NULL
I have 3 Page Validations which all fire on "When Button Pressed" = "Submit".
<br><br>
Number 1 is of type "Item specified is NOT NULL" for "P199_BUSINESS_UNIT1".
<br>
Number 2 is of type "Item specified is NOT NULL" for "P199_BUSINESS_UNIT2".
<br>
Number 3 is of type "Function Returning Boolean" and has the following code:
<br><br>
IF :P199_BUSINESS_UNIT1 IS NULL AND
:P199_BUSINESS_UNIT2 IS NULL THEN
RETURN FALSE ;
ELSE
RETURN TRUE ;
END IF ;<br>
When P199_BUSINESS_UNIT1 is NULL and P199_BUSINESS_UNIT2 is NOT NULL, I get the Error from Validation 1. Perfect.
<br>
When P199_BUSINESS_UNIT1 is NOT NULL and P199_BUSINESS_UNIT2 is NULL, I get the Error from Validation 2. Perfect.
<br>
When P199_BUSINESS_UNIT1 is NOT NULL and P199_BUSINESS_UNIT2 is NOT NULL, I don't get an Error Message. Perfect.
<br><br>
When P199_BUSINESS_UNIT1 is NULL and P199_BUSINESS_UNIT2 is NULL, I get Error Message 1 & 2, <strong>but nothing from 3.</strong>
<br><br>
If I change the code to:
<br><br>
IF :P199_BUSINESS_UNIT1 = '01' AND
:P199_BUSINESS_UNIT2 = '01' THEN
RETURN FALSE ;
ELSE
RETURN TRUE ;
END IF ;<br>
and change both values to '01', I get the appropriate Error Message.
<br><br>
What is going on? Is there some reason I can't check for NULL in a Function Returning Boolean?Scott,
<br><br>
Instead of adding the Validations, I changed my code from:
<br><br>
IF :P199_BUSINESS_UNIT1 IS NULL AND
:P199_BUSINESS_UNIT2 IS NULL THEN
RETURN FALSE ;
ELSE
RETURN TRUE ;
END IF ;
<br>to the following and got the desired results:
<br><br>
IF REPLACE(:P199_BUSINESS_UNIT1,<strong>'%null'</strong> || '%',NULL) IS NULL AND
REPLACE(:P199_BUSINESS_UNIT2,<strong>'%null'</strong> || '%',NULL) IS NULL THEN
RETURN FALSE ;
ELSE
RETURN TRUE ;
END IF ;<br>
Note that I changed the word REPLACE to upper case and the second occurrence of the word NULL to upper case to accentuate the fact that the '%null' is case sensitive, using "%NULL' does not work, it has to be "%null' in lower case.
<br><br>
<strong>Thanks for your help.</strong> -
Check for null and empty - Arraylist
Hello all,
Can anyone tell me the best procedure to check for null and empty for an arraylist in a jsp using JSTL. I'm trying something like this;
<c:if test="${!empty sampleList}">
</c:if>
Help is greatly appreciated.
Thanks,
Greeshma...A null check might not be you best option. If your requirement is you must have both the date and time component supplied in order to populate EventDate, then I would use a Script Functoid that takes data and time as parameters.
In the C# method, first check if either is an empty string, if so return an empty string.
If not, TryParse the data, if successful, return a valid data string for EventDate. If not, error or return empty string, whichever satsifies the requirement. -
How do I check for null date entires using custom JScript on a SharePoint NewForm.aspx?
Hi,
I have the below JScript:
/*Function to convert the US Date format to UK date format */
function parseDate(input) {
var parts = input.split('/');
// new Date(year, month [, date [, hours[, minutes[, seconds[, ms]]]]])
return new Date(parts[2], parts[1]-1, parts[0]); // months are 0-based
/*Function to check if end date is before the start date */
function checkDates(){
var sd = parseDate($("input[title='From']").val());
var ed = parseDate($("input[title='Until']").val());
if(sd > ed) {
alert("Please check From and Until Date");
$("input[value$='Save']").attr('disabled', true); //hide save button
else
$("input[value$='Save']").attr('disabled', false); //show save button
The above works fine for checking sd > ed but I can't seem to check for null's, I have attempted the below which doesn't work:
/*Function to convert the US Date format to UK date format */
function parseDate(input) {
var parts = input.split('/');
// new Date(year, month [, date [, hours[, minutes[, seconds[, ms]]]]])
return new Date(parts[2], parts[1]-1, parts[0]); // months are 0-based
/*Function to check if end date is before the start date */
function checkDates(){
var sd = parseDate($("input[title='From']").val());
var ed = parseDate($("input[title='Until']").val());
if( (sd > ed) || (sd == null) || (ed == Null) ) {
alert("Please check From and Until Date");
$("input[value$='Save']").attr('disabled', true); //hide save button
else
$("input[value$='Save']").attr('disabled', false); //show save button
Any help appreciated.Hi aspnet-scotland,
Please post ASP.NET related questions in
ASP.NET forums where you could receive better responses.
Thanks for your understanding.
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
ViewCriteriaRow attribute to check for null or not null
I Want to apply a view criteria to check for null or not null on a column , i see examples on how to set for value like
vcRow.setAttribute("Sal", "> 2500")but i need to check for Sal is null or not null ,
tried vcRow.setAttribute("Sal", null) and it is not working
and vcRow.setAttribute("Sal", "is null") gives me error .
can somebody help with correct syntax for this
Thanks for your timelooks like vcRow.setAttribute("Sal", "null") works
-
How does APEX check for null values in Text Fields on the forms?
Hello all,
How does APEX check for null values in Text Fields on the forms? This might sound trivial but I have a problem with a PL/SQL Validation that I have written.
I have one select list (P108_CLUSTER_ID) and one Text field (P108_PRIVATE_IP). I made P108_CLUSTER_ID to return null value when nothing is selected and assumed P108_PRIVATE_IP to return null value too when nothign is entered in the text field.
All that I need is to validate if P108_PRIVATE_IP is entered when a P108_CLUSTER_ID is selected. i.e it is mandatory to enter Private IP when a cluster is seelcted and following is my Pl/SQL code
Declare
v_valid boolean;
Begin
IF :P108_CLUSTER_ID is NULL and :P108_PRIVATE_IP is NULL THEN
v_valid := TRUE;
ELSIF :P108_CLUSTER_ID is NOT NULL and :P108_PRIVATE_IP is NOT NULL THEN
v_valid := TRUE;
ELSIF :P108_CLUSTER_ID is NOT NULL and :P108_PRIVATE_IP is NULL THEN
v_valid := FALSE;
ELSIF :P108_CLUSTER_ID is NULL and :P108_PRIVATE_IP is NOT NULL THEN
v_valid := FALSE;
END IF;
return v_valid;
END;
My problem is it is returning FALSE for all the cases.It works fine in SQL Command though..When I tried to Debug and use Firebug, I found that Text fields are not stored a null by default but as empty strings "" . Now I tried modifying my PL/SQL to check Private_IP against an empty string. But doesn't help. Can someone please tell me how I need to proceed.
ThanksSee SQL report for LIKE SEARCH I have just explained how Select list return value works..
Cheers,
Hari -
How to check for null values in bpel?? Please Help! very urgent!!!
Hello Guys,
I have a problem. I have an external webservice to which I have to post my request. My task is to create an Webservice and Service Assembly to which others would post request and get response. I have to create SA to deploy onto the bus.
The problem is that there are optional elements in the request and response xsd's. In the Response sometimes certain feilds may come or they may not. for Example:- my response could contain a tag like this <firstName></firstName>
I have to copy these feilds in my bpel process from one variable to another.(like in the mapper).
My Question is , Is there any way in BPEL process or BPEL mapper where I could Check for null values in the request or response???
Your inputs would be very helpful.
Thanks
RajeshThanks for replying man :)
Ok I will be more clear.
Here is a snippet of one of the xsd's that I am using.
<xs:element name="returnUrl" nillable="false" minOccurs="0">
<xs:annotation>
<xs:documentation>Partner specifies the return URL to which responses need to be sent to, in case of
Async message model.
</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:anyURI">
<xs:maxLength value="300"/>
<xs:whiteSpace value="collapse"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
This means that the return URL field can be there or it may not be there. But if it is there it cant be null because nillable=false. But the whole <returnURL> </returnURL> can be there or it may not be there because minOccurs=0.
My requirement is , if returnURL is there in the response with a value, then in my BPEL mapper I should map it else I should not map it.
Thats the issue.
and Yes kiran, the node be non-existant.
So can you please help me with this.
Thanks
Rajesh -
Checking for null value in arraylist
Hi
i have an excel file which i i am reading into an arraylist row by row but not necesarrily that all columns in the row mite be filled. So how do i check for null values in the array list.
try
int cellCount = 0;
int emptyRow = 0;
HSSFWorkbook workbook = new HSSFWorkbook(new FileInputStream(file));
HSSFSheet sheet = workbook.getSheetAt(0);
Iterator rows = sheet.rowIterator();
myRow = new ArrayList();
int r = 1;
while (rows.hasNext())
System.out.println("Row # " + r);
HSSFRow row = (HSSFRow) rows.next();
Iterator cells = row.cellIterator();
cellCount = 0;
boolean isValid = false;
while (cells.hasNext())
HSSFCell cell = (HSSFCell) cells.next();
switch (cell.getCellType())
case HSSFCell.CELL_TYPE_NUMERIC:
double num = cell.getNumericCellValue();
DecimalFormat pattern = new DecimalFormat("###,###,###,###");
NumberFormat testNumberFormat = NumberFormat.getNumberInstance();
String mob = testNumberFormat.format(num);
Number n = null;
try
n = pattern.parse(mob);
catch ( ParseException e )
e.printStackTrace();
System.out.println(n);
myRow.add(n);
//myRow.add(String.valueOf(cell.getNumericCellValue()).trim());
//System.out.println("numeric: " +cell.getNumericCellValue());
break;
case HSSFCell.CELL_TYPE_STRING:
myRow.add(cell.getStringCellValue().trim());
System.out.println("string: " + cell.getStringCellValue().trim());
break;
case HSSFCell.CELL_TYPE_BLANK:
myRow.add(" ");
System.out.println("add empty:");
break;
} // end switch
cellCount++;
} // end while
r++;
}// end while
} myRow is the arrayList i am adding the cells of the excel file to. I have checked for blank spaces in my coding so please help with how to check for the black spaces that has been added to my arraylist.
I have tried checking by looping through the ArrayList and then checking for null values like this
if(myRow.get(i)!=null)
// do something
// i have tried this also
if(myRow.get(i)!="")
//do something
}Edited by: nb123 on Feb 3, 2008 11:23 PMFrom your post I see you are using a 3rd party package to access the Excel SpreadSheets, you will have to look in your API for you 3rd party package and see if there is a method that will identify a blank row, if there is and it does not work, then you have to take that problem up with them. I know this is a pain, but it is the price we pay for 3rd party object use.
In the mean time, you can make a workaround by checking every column in your row and seeing if it is null, or perhaps even better: check and see if the trimmed value of each cell has a lenth of 0. -
I have a string variable and I need to check for null.
What is the best way to do this?
Thanks.You can also do it like this:
} catch (NullPointerException e) {or like this:
s==null ? <...> : <...> -
Check for null or empty in the functoid
I want to check for null and empty values on input source node. If there exists a null or empty in the input source node, I should not pass that to output destination node. Does the
following attachment work? I want to check for null or empty in the date and time and then concatenate them to send to output. If any of them is null or empty, the other should not fail. In the Not Equal Functoid I am checking for blank, but how to check for
null?A null check might not be you best option. If your requirement is you must have both the date and time component supplied in order to populate EventDate, then I would use a Script Functoid that takes data and time as parameters.
In the C# method, first check if either is an empty string, if so return an empty string.
If not, TryParse the data, if successful, return a valid data string for EventDate. If not, error or return empty string, whichever satsifies the requirement. -
Check for null in IF statement
Hi,
I have a variable of type char(8).
I want to check if this field is empty. This is the logic I use right now:
condense lv_date no-gaps.
if lv_date eq ''.
*then some default value
endif.
Is this the correct approach or there is a way to directly check for null values in a variable.
Thanks,
CDHello,
You have to check IS INITIAL.
condense lv_date no-gaps.
if lv_date IS INITIAL.
*then some default value
endif.
BR,
Suhas -
How can I check for VSearch trojan?
how can I check for VSearch trojan? And then remove it if found?
Helpful Links Regarding Malware Problems
If you are having an immediate problem with ads popping up see The Safe Mac » Adware Removal Guide, AdwareMedic, or Remove unwanted adware that displays pop-up ads and graphics on your Mac - Apple Support.
Open Safari, select Preferences from the Safari menu. Click on Extensions icon in the toolbar. Disable all Extensions. If this stops your problem, then re-enable them one by one until the problem returns. Now remove that extension as it is causing the problem. -
How can I check for the existence of an XML file in Illustrator Javascript??
I'm writing a Javascript to run at startup. I want to check for the existence of XML files and process them, if they are available. How can I check for their existence?
Your first line just sets a variable to a string value… getFiles() is a method of Folder… so
var InputXMLDir = Folder( "D:/Brackets/Create_Bracket_Graphics/Input/XML-n-Templates/" );
Not a PC user so I can't remember if the colon is OK…? As you appear to know the file name why bother with a folder get files anyhow you could just check if the file exists then do some thing…
alert( File( "D:/Brackets/Create_Bracket_Graphics/Input/XML-n-Templates/brackets_men_web.xml" ).exists ); -
Hi, The computer in my MacBook Pro 10.6.8 isn't showing up in Skype (the indicator light doesn't show and it doesn't show in Skype preferences). Also Photo Booth doesn't recognize a camera. What can I check for please?
Hi Lee again..
Please do not startup duplicate topics. I responded to you here > Hi, The camera in my MacBook Pro 10.6.8...: Apple Support Communities
Sometimes navigating the forums can be difficult.. we understand that.
Maybe you are looking for
-
How do I get the encashment date to populate in table PAYR when using FB05
All, The client here is using transaction FCKR to upload their checks for posting. The process submits transaction FB05 which works for everything except the encashment date, which is not being populated on table PAYR. I have walked through the tra
-
How do I download my 2nd library to my ipod
How do I download my 2nd library to my ipod
-
Export pdf with completely flattened linked images/tables
Hello I am trying to export my thesis as pdf so that the illustrator images which are linked in, are flattened including their text labels. This document needs to be submitted to examiners who want to scan the word-count of the body text, not the ima
-
Adobe Reader 9.2 and AIR hotfix
I'm running into an Adobe reader 9.2 and AIR compatibility problem. I developed an AIR App with browser panel that invokes a PDF doc using Adobe Reader. When I update to the latest Adobe Reader (9.2), I start having errors with a dialog saying errors
-
Any help with this?