Costello Wants to buy a Computer from Abbott and phones his store:
ABBOTT: Super Duper computer store. Can I help you?
COSTELLO: Thanks. I'm setting up an office in my den, and I'm thinking about buying a computer.
ABBOTT: Mac?
COSTELLO: No, the names Lou.
ABBOTT: Your computer?
COSTELLO: I don't own a computer. I want to buy one.
ABBOTT: Mac?
COSTELLO: I told you, my names Lou.
ABBOTT: What about Windows?
COSTELLO: Why? Will it get stuffy in here?
ABBOTT: Do you want a computer with windows?
COSTELLO: I don't know. What will I see when I look in the windows?
ABBOTT: Wallpaper.
COSTELLO: Never mind the windows. I need a computer and software.
ABBOTT: Software for windows?
COSTELLO: No. On the computer! I need something I can use to write proposals, track expenses and run my business. What have you got?
ABBOTT: Office.
COSTELLO: Yeah, for my office. Can you recommend anything?
ABBOTT: I just did.
COSTELLO: You just did what?
ABBOTT: Recommend something.
COSTELLO: You recommended something?
ABBOTT: Yes.
COSTELLO: For my office?
ABBOTT: Yes.
COSTELLO: OK, what did you recommend for my office?
ABBOTT: Office.
COSTELLO: Yes, for my office!
ABBOTT: I recommend office with windows.
COSTELLO: I already have an office and it has windows! OK, lets just say,I'm sitting at my computer and I want to type a proposal. What do I need?
ABBOTT: Word.
COSTELLO: What word?
ABBOTT: Word in Office.
COSTELLO: The only word in office is office.
ABBOTT: The Word in Office for Windows.
COSTELLO: Which word in office for windows?
ABBOTT: The Word you get when you click the blue "W."
COSTELLO: I'm going to click your blue "w" if you don't start with some straight answers. OK, forget that. Can I watch movies on the Internet?
ABBOTT: Yes, you want Real One.
COSTELLO: Maybe a real one, maybe a cartoon. What I watch is none of your business. Just tell me what I need!
ABBOTT: Real One.
COSTELLO: If its a long movie I also want to see reel 2, 3 & 4. Can I watch them?
ABBOTT: Of course.
COSTELLO: Great, with what?
ABBOTT: Real One.
COSTELLO; OK, I'm at my computer and I want to watch a movie. What do I do?
ABBOTT: You click the blue "1."
COSTELLO: I click the blue one what?
ABBOTT: The blue "1."
COSTELLO: Is that different from the blue w?
ABBOTT: The blue 1 is Real One and the blue W is Word.
COSTELLO: What word?
ABBOTT: The Word in Office for Windows.
COSTELLO: But there's three words in "office for windows"!
ABBOTT: No, just one. but its the most popular Word in the world.
COSTELLO: It is?
ABBOTT: Yes, but to be fair, there aren't many other Words left. It pretty much wiped out all the other Words out there.
COSTELLO: And that word is real one?
ABBOTT: Real One has nothing to do with Word. Real One isn't even part of Office.
COSTELLO: Stop! Don't start that again. What about financial bookkeeping you have anything I can track my money with?
ABBOTT: Money.
COSTELLO: That's right. What do you have?
ABBOTT: Money.
COSTELLO: I need money to track my money?
ABBOTT: It comes bundled with your computer.
COSTELLO: What's bundled to my computer?
ABBOTT: Money.
COSTELLO: Money comes with my computer?
ABBOTT: Yes. No extra charge.
COSTELLO: I get a bundle of money with my computer? How much?
ABBOTT: One copy.
COSTELLO: Isn't it illegal to copy money?
ABBOTT: Microsoft gave us a license to copy money.
COSTELLO: They can give you a license to copy money?
ABBOTT: Why not? THEY OWN IT!
(LATER ON)
COSTELLO: How do I turn my computer off??
ABBOTT: Click on "START"..........
Tuesday, August 02, 2005
Wednesday, June 29, 2005
Selecting specific objects on a Hibernate Query Join
I ran into a problem when I was trying to select specific columns from multiple tables in a join. I was having trouble casting the returned fields into an object type.
I thought that I would share the two different solutions that I came up with when I found in the Hibernate documentation.
Let me know if you have questions...since I just found this, I may or may not be able to answer it, but I'll try.
Queries may return multiple objects and/or properties as an array of type Object[]
When this is done, you have to iterate over the Object array and cast it back into the object type that each one is and call the constructor of
the item you are using.
or as an actual typesafe Java object
When this is done, you just have to cast it back to it's appropriate class when you iterate.
assuming that the class Family has an appropriate constructor.
I thought that I would share the two different solutions that I came up with when I found in the Hibernate documentation.
Let me know if you have questions...since I just found this, I may or may not be able to answer it, but I'll try.
Queries may return multiple objects and/or properties as an array of type Object[]
select mother, offspr, mate
from eg.DomesticCat as mother
inner join mother.mate as mate
left outer join mother.kittens as offsprWhen this is done, you have to iterate over the Object array and cast it back into the object type that each one is and call the constructor of
the item you are using.
for (Iterator lIterator=lFamilyList.iterator();lIterator.hasNext();){Object[] lObjectArray = (Object[]) lIterator.next();Family lFamily = new Family((String) lObjectArray [0],(String) lObjectArray [1],(String) lObjectArray [2]);System.out.println("Mother: " + lFamily.getMother());System.out.println("Mate: " + lFamily.getMate());System.out.println("Offspr: " + lFamily.getOffspr());}
or as an actual typesafe Java object
select new Family(mother, mate, offspr)
from eg.DomesticCat as mother
join mother.mate as mate
left join mother.kittens as offsprWhen this is done, you just have to cast it back to it's appropriate class when you iterate.
for (Iterator lIterator = lFamilyList.iterator();lIterator.hasNext();){Family lFamily = (Family) lIterator.next();System.out.println("Mother: " + lFamily.getMother());System.out.println("Mate: " + lFamily.getMate());System.out.println("Offspr: " + lFamily.getOffspr());}
assuming that the class Family has an appropriate constructor.
Wednesday, June 08, 2005
EL OR LA COMPUTER
A Spanish teacher was explaining to her class that in Spanish, unlike English, nouns are designated as either masculine or feminine.
"House" for instance, is feminine: "la casa."
"Pencil," however, is masculine: "el lapiz."
A student asked, "What gender is 'computer'?"
Instead of giving the answer, the teacher split the class into two groups, male and female, and asked them to decide for themselves whether "computer" should be a masculine or a feminine noun.
Each group was asked to give four reasons for its recommendation.
The men's group decided that "computer" should definitely be of the feminine gender ("la computadora"), because:
The women's group, however, concluded that computers should be Masculine ("el computador"), because:
The women won.
"House" for instance, is feminine: "la casa."
"Pencil," however, is masculine: "el lapiz."
A student asked, "What gender is 'computer'?"
Instead of giving the answer, the teacher split the class into two groups, male and female, and asked them to decide for themselves whether "computer" should be a masculine or a feminine noun.
Each group was asked to give four reasons for its recommendation.
The men's group decided that "computer" should definitely be of the feminine gender ("la computadora"), because:
- No one but their creator understands their internal logic
- The native language they use to communicate with "other computers" is incomprehensible to everyone else
- Even the smallest mistakes are stored in long term memory for retrieval later
- As soon as you make a commitment to one, you find yourself being changed by them "for the better".
The women's group, however, concluded that computers should be Masculine ("el computador"), because:
- In order to do anything with them, you have to first get their attention, and then turn them on
- They have a lot of data but still can't think for themselves
- They are supposed to help you solve problems, but half the time they ARE the problem
- As soon as you commit to one, you realize that if you had waited a little longer, you could have gotten a better model.
The women won.
Thursday, February 17, 2005
Limiting Characters entered in an html text field Part 2
This is another version of the checkKey() method in the previous posting. It is also usable on IE or Netscape. This function goes about comparing the current key to a string of allowed characters. If it is allowed, it returns true. Otherwise, it returns false. This function is allowing a-z, A-Z, 0-9, -, *, and a space. (Also the Home, End, Delete, and Arrow Keys.)
<script type="text/javascript">
function isValidKey(pEvent)
{
var key;
var keychar;
var lAllowedChars = "abcdefghijklmnopqrstuvwxyz0123456789-*' ";
if (window.event)
key = window.event.keyCode;
else if (pEvent)
key = pEvent.which;
else
return true;
keychar = String.fromCharCode(key).toLowerCase();
// control keys
if ((key==null) (key==0) (key==8)
(key==9) (key==13) (key==27))
return true;
// alphas, numbers, and allow characters
else if (((lAllowedChars).indexOf(keychar) > -1))
return true;
else
return false;
}
</script>
<script type="text/javascript">
function isValidKey(pEvent)
{
var key;
var keychar;
var lAllowedChars = "abcdefghijklmnopqrstuvwxyz0123456789-*' ";
if (window.event)
key = window.event.keyCode;
else if (pEvent)
key = pEvent.which;
else
return true;
keychar = String.fromCharCode(key).toLowerCase();
// control keys
if ((key==null) (key==0) (key==8)
(key==9) (key==13) (key==27))
return true;
// alphas, numbers, and allow characters
else if (((lAllowedChars).indexOf(keychar) > -1))
return true;
else
return false;
}
</script>
Limiting Characters entered in an html text field Part 1
This script allows numeric, & decimal. You also have to filter out the Home, End, & Arrow keys so they can be used. When you call the function, you must be sure to pass the event. The event to call when filtering keys is the onkeypress event. Notice that the function returns a true or false; and the onkeypress event in the html returns this value so that the body knows whether to allow the key or not. This function filters on IE or Netscape. The "evt.which" statement is the Netscape equivalent to IE's "evt.keyCode."
This is the script that should go in your <head></head>:
<script type="text/javascript">
//Allows only 0-9 & .(decimal)
//The Home, End, & Arrow Keys had to be filtered as well
function checkKey(evt)
{
evt = (evt) ? evt : event;
var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0));
if (evt.shiftKey)
{
return false;
}
if (charCode > 31 && (charCode < 48 charCode > 57))
{
if (charCode == 110 charCode == 190 charCode == 46 (charCode >= 35 && charCode <= 39))
{/*Do nothing...we want these characters allowed.*/}
else if (charCode < 96 charCode > 106)
{
return false;
}
}
return true;
}
</script>
This is an example of the html that should go in your <body></body>:
<body>
<input type="text" onkeypress="return checkKey(event);" id="number"/>
</body>
NOTE: The JavaScript used above uses the single line if-statement. Please see my posting about the single line if-statement for an explanation on how to use this.
This is the script that should go in your <head></head>:
<script type="text/javascript">
//Allows only 0-9 & .(decimal)
//The Home, End, & Arrow Keys had to be filtered as well
function checkKey(evt)
{
evt = (evt) ? evt : event;
var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0));
if (evt.shiftKey)
{
return false;
}
if (charCode > 31 && (charCode < 48 charCode > 57))
{
if (charCode == 110 charCode == 190 charCode == 46 (charCode >= 35 && charCode <= 39))
{/*Do nothing...we want these characters allowed.*/}
else if (charCode < 96 charCode > 106)
{
return false;
}
}
return true;
}
</script>
This is an example of the html that should go in your <body></body>:
<body>
<input type="text" onkeypress="return checkKey(event);" id="number"/>
</body>
NOTE: The JavaScript used above uses the single line if-statement. Please see my posting about the single line if-statement for an explanation on how to use this.
Subscribe to:
Posts (Atom)
