Re: Java Image Query Problem
Upon making a query for the Term "panda" the following rresults are displayed
Code:
{"responseData": {"results":[{"GsearchResultClass":"GimageSearch","width":"640","height":"480","imageId":"ANd9GcQRrzUNljCTG8-I68KUD8-SI2uwG77AYHvCcA50IFu4cs9WDK2DV9zHgnc","tbWidth":"137","tbHeight":"103","unescapedUrl":"http://assets.worldwildlife.org/photos/144/images/hero_small/Giant_Panda_Hero_image_(c)_Michel_Gunther_WWF_Canon.jpg?1345515244","url":"http://assets.worldwildlife.org/photos/144/images/hero_small/Giant_Panda_Hero_image_(c)_Michel_Gunther_WWF_Canon.jpg%3F1345515244","visibleUrl":"worldwildlife.org","title":"Giant \u003cb\u003ePanda\u003c/b\u003e | Species | WWF","titleNoFormatting":"Giant Panda | Species | WWF","originalContextUrl":"http://worldwildlife.org/species/giant-panda","content":"Giant \u003cb\u003ePanda\u003c/b\u003e","contentNoFormatting":"Giant Panda","tbUrl":"http://t0.gstatic.com/images?q\u003dtbn:ANd9GcQRrzUNljCTG8-I68KUD8-SI2uwG77AYHvCcA50IFu4cs9WDK2DV9zHgnc"},{"GsearchResultClass":"GimageSearch","width":"606","height":"387","imageId":"ANd9GcSE2zijRhPrLfVHuzROQrMbd3AXdutJwWiUyqysnDnUK07UjOlWdDJHOZHU","tbWidth":"136","tbHeight":"87","unescapedUrl":"http://www.washingtonpost.com/rf/image_606w/WashingtonPost/Content/Blogs/in-the-loop/Images/2012-09-17T130533Z_01_TOR901_RTRIDSP_3_USA-PANDA-WASHINGTON-218.jpg","url":"http://www.washingtonpost.com/rf/image_606w/WashingtonPost/Content/Blogs/in-the-loop/Images/2012-09-17T130533Z_01_TOR901_RTRIDSP_3_USA-PANDA-WASHINGTON-218.jpg","visibleUrl":"articles.washingtonpost.com","title":"National Zoo welcomes baby \u003cb\u003epanda\u003c/b\u003e - Washington Post","titleNoFormatting":"National Zoo welcomes baby panda - Washington Post","originalContextUrl":"http://articles.washingtonpost.com/2012-09-17/local/35498108_1_panda-cub-panda-reproduction-baby-panda","content":"Zoo welcomes baby \u003cb\u003epanda\u003c/b\u003e","contentNoFormatting":"Zoo welcomes baby panda","tbUrl":"http://t1.gstatic.com/images?q\u003dtbn:ANd9GcSE2zijRhPrLfVHuzROQrMbd3AXdutJwWiUyqysnDnUK07UjOlWdDJHOZHU"},{"GsearchResultClass":"GimageSearch","width":"948","height":"964","imageId":"ANd9GcQnXahbarc0laLmKjf4Rz9JYwVdWPfsWlF1rb_ytZTIzcg2akZaoskVxcCT","tbWidth":"146","tbHeight":"148","unescapedUrl":"http://media.npr.org/assets/img/2012/01/04/ap99121501386_custom-feedbb6efa738efee47e7828e805758dc427fa60-s6-c10.jpg","url":"http://media.npr.org/assets/img/2012/01/04/ap99121501386_custom-feedbb6efa738efee47e7828e805758dc427fa60-s6-c10.jpg","visibleUrl":"www.npr.org","title":"What The \u003cb\u003ePanda\u003c/b\u003e Won\u0026#39;t Tell Us : Krulwich Wonders... : NPR","titleNoFormatting":"What The Panda Won\u0026#39;t Tell Us : Krulwich Wonders... : NPR","originalContextUrl":"http://www.npr.org/blogs/krulwich/2012/01/03/144633582/what-the-panda-won-t-tell-us","content":"Every giant \u003cb\u003epanda\u003c/b\u003e, said","contentNoFormatting":"Every giant panda, said","tbUrl":"http://t1.gstatic.com/images?q\u003dtbn:ANd9GcQnXahbarc0laLmKjf4Rz9JYwVdWPfsWlF1rb_ytZTIzcg2akZaoskVxcCT"},{"GsearchResultClass":"GimageSearch","width":"948","height":"711","imageId":"ANd9GcT3wJ6FzzTa01idfln9jm2pNKC8YJFAJGsMim0KjGR9fztzbIdFhZcvPAA","tbWidth":"148","tbHeight":"111","unescapedUrl":"http://media.npr.org/assets/news/2010/04/11/panda-f8a7c9331bbac776e52b26feeccc53de959f46d1-s6-c10.jpg","url":"http://media.npr.org/assets/news/2010/04/11/panda-f8a7c9331bbac776e52b26feeccc53de959f46d1-s6-c10.jpg","visibleUrl":"www.npr.org","title":"Why The Animal Critic Gives The \u003cb\u003ePanda\u003c/b\u003e An F : NPR","titleNoFormatting":"Why The Animal Critic Gives The Panda An F : NPR","originalContextUrl":"http://www.npr.org/templates/story/story.php?storyId\u003d125773728","content":"A \u003cb\u003epanda\u003c/b\u003e. iStockphoto.com","contentNoFormatting":"A panda. iStockphoto.com","tbUrl":"http://t3.gstatic.com/images?q\u003dtbn:ANd9GcT3wJ6FzzTa01idfln9jm2pNKC8YJFAJGsMim0KjGR9fztzbIdFhZcvPAA"}],"cursor":{"resultCount":"428,000,000","pages":[{"start":"0","label":1},{"start":"4","label":2},{"start":"8","label":3},{"start":"12","label":4},{"start":"16","label":5},{"start":"20","label":6},{"start":"24","label":7},{"start":"28","label":8}],"estimatedResultCount":"428000000","currentPageIndex":0,"moreResultsUrl":"http://www.google.com/images?oe\u003dutf8\u0026ie\u003dutf8\u0026source\u003duds\u0026start\u003d0\u0026hl\u003den\u0026q\u003dpanda","searchResultTime":"0.10"}}, "responseDetails": null, "responseStatus": 200}
"http://t0.gstatic.com/images?q\u003dtbn:ANd9GcQRrzUNljCTG8-I68KUD8-SI2uwG77AYHvCcA50IFu4cs9WDK2DV9zHgnc"},{"GsearchResultClass":"GimageSearch","width":"606","height":"387","imageId":"ANd9GcSE2zijRhPrLfVHuzROQrMbd3AXdutJwWiUyqysnDnUK07UjOlWdDJHOZHU","tbWidth":"136","tbHeight":"87","unescapedUrl":"http://www.washingtonpost.com/rf/image_606w/WashingtonPost/Content/Blogs/in-the-loop/Images/2012-09-17T130533Z_01_TOR901_RTRIDSP_3_USA-PANDA-WASHINGTON-218.jpg"
"http://www.washingtonpost.com/rf/image_606w/WashingtonPost/Content/Blogs/in-the-loop/Images/2012-09-17T130533Z_01_TOR901_RTRIDSP_3_USA-PANDA-WASHINGTON-218.jpg"
"http://t1.gstatic.com/images?q\u003dtbn:ANd9GcSE2zijRhPrLfVHuzROQrMbd3AXdutJwWiUyqysnDnUK07UjOlWdDJHOZHU"},{"GsearchResultClass":"GimageSearch","width":"948","height":"964","imageId":"ANd9GcQnXahbarc0laLmKjf4Rz9JYwVdWPfsWlF1rb_ytZTIzcg2akZaoskVxcCT","tbWidth":"146","tbHeight":"148","unescapedUrl":"http://media.npr.org/assets/img/2012/01/04/ap99121501386_custom-feedbb6efa738efee47e7828e805758dc427fa60-s6-c10.jpg"
"http://media.npr.org/assets/img/2012/01/04/ap99121501386_custom-feedbb6efa738efee47e7828e805758dc427fa60-s6-c10.jpg"
"http://t1.gstatic.com/images?q\u003dtbn:ANd9GcQnXahbarc0laLmKjf4Rz9JYwVdWPfsWlF1rb_ytZTIzcg2akZaoskVxcCT"},{"GsearchResultClass":"GimageSearch","width":"948","height":"711","imageId":"ANd9GcT3wJ6FzzTa01idfln9jm2pNKC8YJFAJGsMim0KjGR9fztzbIdFhZcvPAA","tbWidth":"148","tbHeight":"111","unescapedUrl":"http://media.npr.org/assets/news/2010/04/11/panda-f8a7c9331bbac776e52b26feeccc53de959f46d1-s6-c10.jpg"
"http://media.npr.org/assets/news/2010/04/11/panda-f8a7c9331bbac776e52b26feeccc53de959f46d1-s6-c10.jpg"
Code:
java.net.MalformedURLException: no protocol: "http://media.npr.org/assets/news/2010/04/11/panda-f8a7c9331bbac776e52b26feeccc53de959f46d1-s6-c10.jpg"
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at browser$1.actionPerformed(browser.java:140)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
java.lang.NullPointerException
at browser$1.actionPerformed(browser.java:140)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
java.lang.NullPointerException
at browser$1.actionPerformed(browser.java:140)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
java.lang.NullPointerException
at browser$1.actionPerformed(browser.java:140)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
java.lang.NullPointerException
at browser$1.actionPerformed(browser.java:140)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
//I have deleted one of the exceptions as i should limit myself to 20000 characters per post, but it's essentially the same as the other null-pointers
The first line is the raw query, the nest 6 are "potentially valid URLs" and the code following is a series of exceptions. You can observe that The first exception refers to a malformed URL exception, while all the others refer to null-pointer exceptions.
I am curious and seeking help about the following:
•Why is the sequence of exceptions like it is?
•Can you help me design a better RegEx to grab valid URLs?
•Is there a better, and not very complicated way of doing the same thing(making an image query) without all this trouble?
Thank you so much for your time!
-Cens