Testing if an image is null

Hi guys,
Was wondering if you could help me out. I have a data block based on a table, and this table contains an image of type blob. Now, I have some items on my form that I only want to display if the image is not null and was wondering how I could accomplish this. I dont think the following will work:
if myblock.picture is not null then
end if
Am I correct in thinking that would not work because it cant check if an image is null or not?
I know I could create a view and add a column using a case statement as follows:
case when myblock.picture is null then 'N' else 'Y' end picture_present
However, I am reluctant to create such a view and change my form on it (as my datablock is simply based on a table). I was wondering could I create an item on my datablock which would effectively add the picture_present column I would have had on my view? ie using the formula property on an item? (I ask this because I have never used this column before). So basically, could I create an item and input to the formula property:
case when iph.picture is null then 'N' else 'Y' end picture_present
and then this item would evaluate to 'Y' if there was a picture and 'N' if there was not?
if this wont work could anyone suggest away around my problem.
Thanks for any time you may take in helping me.
Edited by: 786733 on 30-Jul-2012 02:44

You could check if the blob is empty in a post-query trigger like this
declare
  dummy number;
begin
  select 1
  into ndummy
  from your_table
  where your_pk = :block.your_pk
  and length(your_blob) > 0;
  do_something_when_not_empty;
exception
  when no_data_found then
    do_something_when_empty;
end;cheers

Similar Messages

  • Image.getWidth(null) and image..getHeight(null)  returns -1

    Hi ,
    Plz tell me whats wrong with code
    import java.awt.Image;
    import java.awt.Toolkit;
    public class ImgSize {
        public static void main(String args[]) {
            Image image = Toolkit.getDefaultToolkit().getImage("Picture.jpg");
            double width = image.getWidth(null);
            double height = image.getHeight(null);
            System.out.println("width :" + width + "-- height :" + height);
            getImageDimesion("Picture.jpg");
        public static void getImageDimesion(String abc) {
            Image image = Toolkit.getDefaultToolkit().getImage(abc);
            double width = image.getWidth(null);
            double height = image.getHeight(null);
            System.out.println("width :" + width + "-- height :" + height);
    }output:
    width :-1.0-- height :-1.0
    width :2592.0-- height :1944.0
    There is no difference in main function getWidth/ getHeight and function getImageDimension getWidth/ getHeight
    If u remove getWidth and getHeigth in the main function i.e comment the 1st four lines in main function then the output is
    Output
    width :-1.0-- height :-1.0
    Plz help in understanding this.
    Thanks
    Venkat

    Toolkit images are not loaded until they are first drawn or you request a property from it (such as getWidth). To force the image to load and wait for it to finish loading, you can use the MediaTracker class. The ImageIcon class has one built in.
    Image image = Toolkit.getDefaultToolkit().getImage("Picture.jpg");
    new ImageIcon(image); //loads the image

  • Attached image is null

    <?xml version="1.0" encoding="UTF-8"?>
    <definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
         xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
         xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
         xmlns:soapbind="http://schemas.xmlsoap.org/wsdl/soap/"
         xmlns:tns="http://www.example.org/SOAPAttReceiverWithMessage/"
         xmlns:xsd="http://www.w3.org/2001/XMLSchema"
         targetNamespace="http://www.example.org/SOAPAttReceiverWithMessage/">
         <types>
              <xsd:schema
                   targetNamespace="http://www.example.org/SOAPAttReceiverWithMessage/"
                   xmlns:tns="http://www.example.org/SOAPAttReceiverWithMessage/"
                   xmlns:xsd="http://www.w3.org/2001/XMLSchema">
                   <xsd:element name="InfoMessage" type="xsd:string" />
              </xsd:schema>
         </types>
         <message name="imageMsg">
              <part element="tns:InfoMessage" name="body" />
              <part name="image" type="xsd:hexBinary" />
         </message>
         <message name="empty" />
         <portType name="AttachmentWithMessage">
              <operation name="sendImageAndMessage">
                   <input message="tns:imageMsg" />
                   <output message="tns:empty" />
              </operation>
         </portType>
         <binding name="AttachmentWithMessageBinding"
              type="tns:AttachmentWithMessage">
              <soap:binding style="rpc"
                   transport="http://schemas.xmlsoap.org/soap/http" />
              <operation name="sendImageAndMessage">
                   <soap:operation soapAction="" />
                   <input>
                        <soap:body parts="body" use="literal" />
                        <mime:multipartRelated>
                             <mime:part>
                                  <mime:content part="image" type="image/gif" />
                             </mime:part>
                        </mime:multipartRelated>
                   </input>
                   <output>
                        <soap:body use="literal" />
                   </output>
              </operation>
         </binding>
         <service name="AttachmentWithMessageService">
              <port binding="tns:AttachmentWithMessageBinding"
                   name="AttachmentWithMessage">
                   <soap:address
                        location="URL" />
              </port>
         </service>
    </definitions>Endpoint generated form WSDL
    public class AttachmentWithMessageBindingImpl implements org.example.www.AttachmentWithMessage{
        public void sendImageAndMessage(java.lang.String body, java.awt.Image image) throws java.rmi.RemoteException {}
             Client
      Name bodyName = soapFactory.createName(
                      "sendImageAndMessage", "tns",
                      "http://www.example.org/SOAPAttReceiverWithMessage/");
                    SOAPBodyElement bodyElement =
                      body.addBodyElement(bodyName);
                    Name name = soapFactory.createName("InfoMessage");
                    SOAPElement info =
                      bodyElement.addChildElement(name);
                    info.addTextNode("This is a info message!");
                    AttachmentPart attachment = message.createAttachmentPart();
                    URL url = new URL("file:///C:/temp/pic.gif");
                    URLDataSource fds = new URLDataSource(url);
                    DataHandler dataHandler = new DataHandler(fds);
                    AttachmentPart attachmentPart =
                      message.createAttachmentPart(dataHandler);
                    attachment.setContentId("image");
                    attachment.setContentType("image/gif");
                    message.addAttachmentPart(attachmentPart);
                    URL endpoint = new URL
                      ("URL");
                   // SOAPMessage response =
                      connection.call(message, endpoint);
                    connection.close();I get the body part right but image is null. SOAP message seems to have this image attached but when I try to access it at the enpoint it's null.
    SOAP message:
    ------=_Part_0_394663814.1176981061039
    Content-Type: text/xml; charset=UTF-8
    Content-Transfer-Encoding: binary
    Content-Id: <841848929844.1176981061039.***>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><tns:sendImageAndMessage xmlns:tns="http://www.example.org/SOAPAttReceiverWithMessage/"><InfoMessage>This is a info message!</InfoMessage></tns:sendImageAndMessage></soapenv:Body></soapenv:Envelope>
    ------=_Part_0_394663814.1176981061039
    Content-Type: image/gif
    Content-Transfer-Encoding: binary
    Content-Id: <83287838504.1176981059055.***>
    GIF89a�h�Any suggestions?

    try {
                   MessageContext context = MessageContext.getCurrentThreadsContext();
                   SOAPMessageContext soapContext = (SOAPMessageContext)context;
                   SOAPMessage msg = soapContext.getMessage();
                   SOAPPart soapPart =     msg.getSOAPPart();
                   SOAPEnvelope envelope = soapPart.getEnvelope();
                   Iterator i = msg.getAttachments();
                   while(i.hasNext())
                        System.out.println("Attachment");
                        AttachmentPart ap = (AttachmentPart)i.next();
                        System.out.println(ap.getContentId());
                        System.out.println(ap.getContentType());
                        System.out.println(ap.getContentLocation());
                        System.out.println(ap.getSize());
                        Object oo = ap.getContent();
                        if(oo==null){
                             System.out.println("oo is nul");
                        DataHandler dh = (DataHandler)ap.getDataHandler();
                        if(dh==null){
                             System.out.println("dh is null");
                        else{
                             Image o = (Image)dh.getContent();
                   }When I try to cast DataHandler.getContent() to java awt.Image I get following exception:
    com.ibm.ws.webservices.engine.attachments.ManagedMemoryDataSource$Instream incompatible with java.awt.Image
    [23.4.2007 16:37:05:862 EEST] 0000002e SystemErr     R java.lang.ClassCastException: com.ibm.ws.webservices.engine.attachments.ManagedMemoryDataSource$Instream incompatible with java.awt.Image
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at org.example.www.AttachmentWithMessageBindingImpl.sendImageAndMessage(AttachmentWithMessageBindingImpl.java:65)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at java.lang.reflect.Method.invoke(Method.java:615)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at com.ibm.ws.webservices.engine.dispatchers.java.JavaDispatcher.invokeMethod(JavaDispatcher.java:178)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at com.ibm.ws.webservices.engine.dispatchers.java.JavaDispatcher.invokeOperation(JavaDispatcher.java:141)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at com.ibm.ws.webservices.engine.dispatchers.SoapRPCProcessor.processRequestResponse(SoapRPCProcessor.java:447)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at com.ibm.ws.webservices.engine.dispatchers.SoapRPCProcessor.processMessage(SoapRPCProcessor.java:412)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at com.ibm.ws.webservices.engine.dispatchers.BasicDispatcher.processMessage(BasicDispatcher.java:134)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at com.ibm.ws.webservices.engine.dispatchers.java.SessionDispatcher.invoke(SessionDispatcher.java:204)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at com.ibm.ws.webservices.engine.PivotHandlerWrapper.invoke(PivotHandlerWrapper.java:227)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at com.ibm.ws.webservices.engine.handlers.jaxrpc.JAXRPCHandler.invoke(JAXRPCHandler.java:152)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at com.ibm.ws.webservices.engine.handlers.WrappedHandler.invoke(WrappedHandler.java:64)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at com.ibm.ws.webservices.engine.PivotHandlerWrapper.invoke(PivotHandlerWrapper.java:227)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at com.ibm.ws.webservices.engine.PivotHandlerWrapper.invoke(PivotHandlerWrapper.java:227)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at com.ibm.ws.webservices.engine.WebServicesEngine.invoke(WebServicesEngine.java:332)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at com.ibm.ws.webservices.engine.transport.http.WebServicesServlet.doPost(WebServicesServlet.java:736)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at com.ibm.ws.webservices.engine.transport.http.WebServicesServletBase.service(WebServicesServletBase.java:341)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:966)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:463)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3129)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:238)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:811)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1433)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:93)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:465)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:394)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:290)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:152)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:213)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at com.ibm.io.async.AbstractAsyncFuture.fireCompletionActions(AbstractAsyncFuture.java:195)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:194)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:741)
    [23.4.2007 16:37:05:893 EEST] 0000002e SystemErr     R      at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:863)
    [23.4.2007 16:37:05:909 EEST] 0000002e SystemErr     R      at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1510)When sending I print size of the attachment
    Attachment size = 45233
    Size is same when receiving message at server but still it's null.

  • Image is NULL exception, problems displaying a png file

    Hi people,
    I want to display a simple image using j2me on my siemens sl45i emu.
    I'm using the following code to load my png 8x8(created with photoshop, 2bpp) image:
    public void load()
    try
    testImage = Image.createImage("res/enemy1.png");
    catch (Exception e)
    System.err.print("Ladefehler: " + e);
    when I want to display the image using the follwing code:
    private void render(Graphics g)
    g.drawImage(testImage,0,0,0);
    g.drawString("**** you!", 0, 0, Graphics.TOP|Graphics.LEFT);
    I'm getting the following exception:
    java.lang.NullPointerException: Image is null.
    Why do I get this exception when I want to display the image and not when I'm loading the image(something like "couldn't load image..." )....
    I've placed enemy1.png in a folder called "res" in my jar file. Displaying text does work so I don't understand why I can't display an image...
    Any help would be great!
    Thanx in advance, alex

    This can't be possible!
    private void load()
         GameGraphics.getInstance().load();
         Player.getInstance().load();
    I'm printing debug messages in both load()-methods and I'm getting an exception in the player class because gamegraphics didn't finish loading (I can see it from the debugging messages)

  • Error : CGImageCreate: invalid image colorspace: NULL.

    Hi,
    I am unable to launch Intellij IDEA from command line using ./idea.sh on my Mac (OS 10.7.4). The intellij IDEA flash screen comes up after which I am seeing the following error and the application hangs -- the IDEA does not open. I have been trying to get over this for a long time but no help. Any help is appreciated.
    bash-3.2$ ./idea.sh
    Dec  7 17:37:28 rahusrivastava.ariba.com java[1789] <Error>: CGImageCreate: invalid image colorspace: NULL.
    Dec  7 17:37:28 rahusrivastava.ariba.com java[1789] <Error>: CGImageCreate: invalid image colorspace: NULL.
    Dec  7 17:37:28 rahusrivastava.ariba.com java[1789] <Error>: CGImageCreate: invalid image colorspace: NULL.
    Dec  7 17:37:28 rahusrivastava.ariba.com java[1789] <Error>: CGImageCreate: invalid image colorspace: NULL.
    Dec  7 17:37:31 rahusrivastava.ariba.com java[1789] <Error>: CGContextGetCTM: invalid context 0x0
    Dec  7 17:37:31 rahusrivastava.ariba.com java[1789] <Error>: CGContextSetBaseCTM: invalid context 0x0
    Dec  7 17:37:31 rahusrivastava.ariba.com java[1789] <Error>: CGContextGetCTM: invalid context 0x0
    Dec  7 17:37:31 rahusrivastava.ariba.com java[1789] <Error>: CGContextSetBaseCTM: invalid context 0x0
    Dec  7 17:37:34 rahusrivastava.ariba.com java[1789] <Error>: CGImageCreate: invalid image colorspace: NULL.
    Dec  7 17:37:34 rahusrivastava.ariba.com java[1789] <Error>: CGImageCreate: invalid image colorspace: NULL.
    Dec  7 17:37:34 rahusrivastava.ariba.com java[1789] <Error>: CGImageCreate: invalid image colorspace: NULL.
    Dec  7 17:37:34 rahusrivastava.ariba.com java[1789] <Error>: CGImageCreate: invalid image colorspace: NULL.
    Dec  7 17:37:34 rahusrivastava.ariba.com java[1789] <Error>: CGImageCreate: invalid image colorspace: NULL.
    2012-12-07 17:37:34.623 java[1789:c07] CWindow's _nativeShow encountered error: *** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]
    Dec  7 17:37:34 rahusrivastava.ariba.com java[1789] <Error>: CGImageCreate: invalid image colorspace: NULL.
    Dec  7 17:37:34 rahusrivastava.ariba.com java[1789] <Error>: CGImageCreate: invalid image colorspace: NULL.
    bash-3.2$
    Thanks,
    Rahul.

    My input certainly wasn't intended to ba sarcastic, so please forgive me if it seemed so.
    Seroiusly, always do a search before updating, http://discussions.apple.com/search.jspa?objID=f1201&search=Go&q=update+problem, NI is flaky at best IMHO, did you heck with them yet to see if a patch is available?
    Always wait a few weeks before updating, a reinstall is a headache, goodluck!

  • Error - Rendered Image is NULL

    Hello !
    I am trying to work on animated objects. I have imported XMII Dynamic Graphics from sdn website and imported the same in my project.
    Now when I am tyring to use HorizLEDMeter or any of its object I am getting the error as  "Rendered Image is null".
    Can anyone please tell me what can be the solution for this ??
    Thanks.

    Please use the latest service pack. I was facing the same problem and after application of service pack, the problem was resolved
    Regards,
    Musarrat

  • PNG image returning null

    I can't for the life of me figure out what is wrong with the following code:
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.IOException;
    import javax.imageio.ImageIO;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    public class CTFMain extends JPanel
        BufferedImage tileset;
        CTFMain()
            super();
            int width = 400;
         int height = 400;
         setPreferredSize(new Dimension(width, height));
            try
                //tileset = Toolkit.getDefaultToolkit().createImage("images\\EnvironmentTile.png");
                tileset = ImageIO.read(new File("images\\EnvironmentTile.png"));
            catch(IOException e)
        public void tic()
            repaint();
            System.out.println(tileset.toString());
        @Override
        public void paintComponent(Graphics g)
            g.setColor(Color.white);
            g.fillRect(0, 0, getWidth(), getHeight());
            g.setColor(Color.red);
            g.fill3DRect(20, 30, 150, 350, true);
            if(tileset == null)
                System.out.println("it's null");
            else
                g.drawImage(tileset, 0, 0, this);
        public static void main(String[] args)
            JFrame frame = new JFrame("Capture the Flag");
            CTFMain game = new CTFMain();
            frame.add(game);
            frame.pack();
            frame.setResizable(true);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setVisible(true);
            while(true)
                game.tic();
                try
                    Thread.sleep(1000/33);
                catch(Exception e)
    }Whenever I run the program, tileset gets assigned a null value, even though the path file is there, so when it calls drawImage, it draws a blank picture. What am I doing wrong?
    Note: The println and fill3DRect statements are there to test if those methods are working, and they are.

    Abion47 wrote:
    Do you need that? <DWS>No, I just made that comment because I like reading back what I wrote. It amuses me.</DWS>
    Yes, I need the information.
    .. Because I don't know how to do that...Then it looks like you are stuffed, unless you can either do some research into the 'Java SDK Jar tool' and/or ask a smart question.

  • Unit testing: Mocking custom classes with null

    Hi,
    I was trying to save time on testing the usual hashCode() and equals() methods so I got this class: http://www.cornetdesign.com/files/BeanTestCase.java.txt
    I altered it a bit as it wasn't handling standard classes only primitives.
    Anyway, I got to the point to include my own custom classes.
    I have to create a 'mock' object for my class properties, e.g. field.getType().newInstance()
    Fine, but there are some tricky instances. E.g. when I'd like to create an instance of java.net.URL which takes a URL as String in the constructor.
    This is almost impossible to automate as it has to be a valid URL format not just a random String.
    So, I thought I set them to null, e.g.
    assertTrue(o1.equals(o2))
    as both properties are null.
    Is this the right approach you think?
    I welcome any suggestions.
    My initial idea was to save enormous amount of time automating the hashCode() and equals() method tests as they took so long to write.
    Thanks

    Trouble would be that you are only testing the null branch of the equals or hashCode, which typically have to check for null, then if not null do an actual comparison.
    It's worth the effort of learning to use a package such as EasyMock to create and program mock objects. It's tidiier if you are progamming to interfaces, however, but it will mock ordinary objects, though probably not if they are final.
    What you could do is to define a factory interface, and have a table of anonymous classes wich generate various types. In effect create a library of dumy object factories.
    Something like:
    private interface DummyGenerator {
          Object generate(int idx);
          Class<?> getType();
    private final static DummyGenerator[] generatorsTable {
        new DummyGenerator() {
               public Object generate(int idx) {
                 return new URL("http://nowhere.com/" + idx);
         public Class<?> getType() { return URL.class; }
    .. generators for other classes
    private final static Map<Class<?>, DummyGenerator> genMap = new HashMap<Class<?>, DummyGenerator>(generatiorsTable.length);
    static {
        for(DummyGenerator gen : generatorsTable)
            genMap.put(gen.getType(), gen);
    }

  • Kit Kat Restore Image - 4400US - NULL?

    Dear HP,
    Just curious as to why the Kit Kat Restore Image is now NULL, and that only the Jelly Bean Image is the only available option for download for the Slate 7 Extreme?
    ZiCott
    This question was solved.
    View Solution.

    Hello,
    We are performing some updates to the Kit Kat image.  Please stay tuned for additional information.
    -Chris
    I work for HP.
    Support Forums are now on your mobile phone: http://m.hp.com/supportforum

  • How to test if a image file exists???

    Hi ppl,
    heres my problem...im using servlets and jsp and i only ever want to access the jsp file from a redirect in the servlet. Problem arises however if the user trys to access the jsp file directly in which case all the relative links on the page are no longer in the same context as if they were accessed via the servlet.
    i wanna have some kind of test on my jsp page which displays an error page if the user has access the page directly but im not sure the best way to go about this.
    i was thinkin about tryin to determine if an image file exists using a relative link...in which case if the relative links where off then it wouldnt.
    Any suggestions on the best way to do this...or if there might be a better way to test such a case?
    any advice much appreaciated.
    Mycall

    I would suggest moving all jsp's that you dont want the user to have direct access to under the WEB-INF directory. This way they would only be able to access it through your servlet.
    Hope this helps

  • Lots of garbage generated when Image is bound to a property that is null

    I noticed something odd -- I've written a program that displays some huge images in the background (1920x1200), but not all the items that are in the database actually have an image. Now, when an item is selected where the background image is null, and I simply set this image, I get a nice fade to black (so far so good).
    However, I noticed that as long as this "image" is being displayed something is generating about 1 MB of garbage on the heap every second. As soon as I switch to a real image again, this stops... and it starts again when I switch to the null image.
    Anybody notice the same? This seems like it might be a bug -- I'm thinking somekind of stacktrace is generated somewhere in the core but being swallowed.
    Workaround is to not set 'null' images I suppose :)

    That does seem very odd. Better follow this to make it know:
    https://forums.oracle.com/forums/ann.jspa?annID=1713

  • Null pointer exception- with array of images

    Hi , i am having some problems with my program. I am trying to create an array of images( which i dont really know how to do) and i keep getting this error
    Exception in thread "main" java.lang.NullPointerException
    at DiceRoller.<init>(DiceRoller.java:35)
    at RollDice.main(RollDice.java:19)
    Here is my code, any help would be appreciated, i have switched things around and i still can't figure out what is wrong
    * @(#)RollDice.java
    * RollDice application
    * @author
    * @version 1.00 2009/3/23
    import java.util.Scanner;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class RollDice {
        public static void main(String[] args) {
             DiceRoller diceroller  = new DiceRoller();
             //Default Close operations
             diceroller.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
             //Size
            diceroller.setSize( 121, 121 ); // set frame size
            //Dont want anyone to mess with it
            diceroller.setResizable(false); // Cant resize
            diceroller.setVisible( true ); // display frame
    * Dice.java
    //Main dice Class
    import java.util.Random;
    import java.io.*;
    public class Dice
         public      Random r = new Random();
         private int sides;
         private int rolls;
         public int x;
         public Dice()
         Roll method
         public int roll()
              x=0;
              x = (r.nextInt(6)+1);
              return x;
    /** DiceRoller.java
    * Roll, print, Gui
    import javax.swing.*;
    public class DiceRoller extends JFrame
         private ImageIcon[] image = null ;
         public String[] images = { "empty", "dice1.jpg",
                   "dice2.jpg", "dice3.jpg", "dice4.jpg",
                   "dice5.jpg", "dice6.jpg" };
         public Dice die;
         private int rollVal;
         public int rollNum;
         private JLabel j1;
         public DiceRoller(){
           die =new Dice();
           int rollVal = 0;
           rollVal = die.roll();     
           //Images     
           image = new ImageIcon[images.length];
          for(int i = 0; i < images.length; i++){
          image[i] = new ImageIcon(images);
    }//end for
    // setImage(rollVal);
         if (image!=null){
              j1.setIcon(image[rollVal]);
         System.out.println("Roll = "+die.roll());

    max_wallace wrote:
    Do you think you could please elaborate on your answer, and what does borked mean?One of my favourite words that; [b0rked|http://www.urbandictionary.com/define.php?term=b0rked] / borked

  • Dropdown List Value Test For Null || " "

         I wrote a pre-sign script to test a for a value in a dropdown list before allowing signature of the document. However I want to test for a value of null in addtion to one space aka " ". I added a value in the dropdown list of " " along with the choices of names so users could erase an accidental selection in this list before they were ready. However when I place the or ( || ) operator in the if statement of the script the script doesn't work. If I remove the || " " statement the script works as it is supposed to. How do I test for this value of " " along with the null test so I don't have to write another if statement?
    if (form1.Page3.Author.Reviewed.Admin.rawValue == null || " ")
    xfa.event.cancelAction = 1
    xfa.host.messageBox("You did not select your name on the dropdown list before trying sign the document .");
    else

    Your if statement is incomplete. You need to put the test in again for the other value:
    if (form1.Page3.Author.Reviewed.Admin.rawValue == null || form1.Page3.Author.Reviewed.Admin.rawValue == " ")

  • WebServiceContext is null in Unit Tests

    I'm trying to write Unit Tests for a service which defines a webservice context thus :
    @Resource protected WebServiceContext wsContext = null;
    public void foo() {
          messageContext = wsContext.getMessageContext();
          List<Header> headerList = (List<Header>) messageContext.get(Header.HEADER_LIST);
    }This works fine on the Server (Websphere). However, calling the same in a Unit Test fails as wsContext is null.I'm using Spring as the backbone for the entire service framework. I checked the spring configuration for this bean and nowhere does it declare a wsContext as a property setter. It seems to just work when deployed on the AppServer!
    However, the same injection fails to happen while running Unit Tests. I'm trying to figure out if there is a way I can stub it out, to no avail. Any help would be appreciated!
    Jim
    Edited by: Titan1978 on Jul 20, 2010 6:45 AM

    I found that I was not receiving a null on the WebServiceContext. My problem was that I was trying to use it in the class constructor, but it is not available there.
    The following:
    MessageContext ctxt = wsc.getMessageContext();
    ServletContext req = (ServletContext) ctxt.get(ctxt.SERVLET_CONTEXT);
    works fine when used in a web service method.
    My second issue was with getInitParameter() method. To use getInitParameter(), the elements must by defined in the context-param section of the web.xml, not in the init-param.
    Bruce.

  • WANTED: Test Engineer for CCD/CMOS image sensors and cameras...

    TEST ENGINEER
    Education:  BSEE or equivalent
    Experience:  5+ years experience in Test Engineering.  Preferred experience with Imaging and CCD cameras.  Must have programming experience with labview, and experience with other languages is a plus.  Must be familiar with standard test equipment such as an oscilloscope, parameter analyzer, etc.  Working knowledge of electronic circuits, and familiar with camera parameters.  Experience as a technical lead is a plus. 
    Duties:  Characterize and test CCD/CMOS image sensors and cameras.  Develop test plans, and create automated test systems.  Provide documentation, training and support for systems engineering efforts.  Develop quick solutions for engineering camera development efforts to aid in root cause analysis.
    Located in Milpitas, California, in the heart of the Silicon Valley, Fairchild Imaging is a pioneer in the CCD industry.  We recognize our products are only as good as our people who develop them. We are therefore looking for passionate, innovative people who enjoy the challenges of technology.  We offer competitive salaries, outstanding benefits, a 9/80 work schedule and a fun and creative working environment.
    U.S. Citizenship or permanent residency required. Fairchild Imaging is an equal opportunity employer.

    Visit the Fairchild Imaging Website for details on the company and the products.  Fairchild Imaging makes a wide spectrum of cameras including Aerospace, scientific and  medical and Fairchild Imaging has been producing CCDs since 1975.   Our cameras range in pixels size from below 1meg to over 81 meg with pixels down to 8.75u.  One of our CCDs was used in the Deep Impact project where a camera was fired into a comet which is one of many interesting projects.
    You will be working on a team of 10 dealing with testing of camera systems with responsiblity for test at the wafer level to finished camera.  This is a great opportunity to work with a talented staff with a interesting mix of products.

Maybe you are looking for