I've had similar events happen to me twice in different settings over the course of a year.
First, I was at my local video store, using the bathroom, and when I was finished I went to exit the door. Lo and behold - there was no knob on the door. I was stuck. Or so I first thought. Luckily I had my Hinderer Rescue knife on my belt, and, using the small L-Bar that comes in the tool kit, I was able to put it in a hole on the knob housing that was left there and just turn it, allowing me to escape.
The second time was at work, and I got locked in the bathroom when the door jammed. The factory I work at has no cell reception either because of the concrete, and because it's so loud no one can hear you scream for help. I used the phillips on my Swisstool to unscrew a draft-dodger on the bottom of the door, put an Inova I have on "strobe" mode, slid it under the door, and waited.
I just sat on the toilet (lid down, and covered with the newspaper, of course, eww), and did some mini-crossword puzzles I have in my pocket sometimes. About 35 minutes later someone noticed the flashing light and helped get me out.