Getting objects to move between PCs

After CS 150, I find myself back in the world of Java. I recently learned a neat language called Processing (a.k.a. Proce55ing), and I am one of the coders (and am way rusty to be of much use at this point) for a really cool project.
I'm wondering if I can nag you with some questions on java.net.*. I need to get some objects passed around between 3 PCs. I need to know about latency issues. Basically, we've got Java doing OpenGL graphics on 6 projectors powered by 3 computers. Imagine each PC having a really wide screen... when a autonomous creature gets to the edge of one PC, it needs to continue its thang on the next PC... move fluidly.
I've checked out some Java.net.* sample code on sun's site. Specifically their KnockKnock Server. However, its multithread support is for interacting with clients on a one-on-one basis... not like a chat-room style environment. So, I don't even have any sample code for a ultra-basic Java Chat Room.... nor do I know how to pass anything but a string to the server, or to the client.
There are ways to use my limited knowledge to do what I want to do... just pass a string, and have the server store that into a variable which is accessible by every server thread. Then, create a loop in main that keeps searching through that array of strings to pass them off to the PC... the string would have the coordinate information of the autonomous creature, and create a new one of that object with those Vec3f point. However, latency is a key issue, and it would be easiest if I could just pass an object to the server (in this case: a SimpleVehicle) along with an intended target computer, and then that computer would get that vehicle to add to its array of SimpleVehicles. The important thing is speed, so it might be best to have every computer have a client<->server connection with each other... I get utterly baffled reading the Java Docs. But, I seem to understand code when I see it (I can only reverse engineer). I especially understand the KnockKnock Server and MultiClient code on the Sun's Java Networking Tutorial.
Any pointers to which methods I need to learn (I already realize I'm going to need to downcast the SimpleVehicle object back into a SimpleVehicle after it gets sent). Thanks a million.

Ok, try this.
The simplistic application sends colored balls between instances of itself which can be on any machine on your network.
As a ball reaches the left side of the window it is in, it gets sent to the machine on it's left (if any), likewise if it reaches the right side of the window it gets sent to the machine on it's right. If there is no machine on the side the ball is trying to go, it rebounds within the window it is in.
So, a simple test is to run three instances on the same machine, one is regarded as one the left on as on the right and one as in the middle
To start the one on the left:
java Ziniman1 8000 -right localhost:8001
To start the one in the middle:
java Ziniman1 8001 -left localhost:8000 -right localhost:8002
To start the one on the right:
java Ziniman1 8002 -left localhost:8001
Note: You need to start these pretty quickly one after the other or the socket creation will time out. I'll leave that to you to fix ;)
Once the apps are running, move them so they are next to each other, left to right (the port numbers used as the server port are in the JFrame title).
To get create a ball, just click on one of the white panels, use the radio buttons at the bottom to change size/color/direction of the new balls.
Once you've got the hang of the thing, try moving some instances to other machnes.
Enjoy!
import java.io.*;
import java.net.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
public class Ziniman1
     static final String LEFT= "Left";
     static final String RIGHT= "Right";
     static class Ball
          implements Serializable
          public int x= -1;
          public int y;
          public int size= 10;
          private Color mColor;
          public Ball(Color color) { mColor= color; }
          public Ball(Color color, int y) { mColor= color; this.y= y; }
          public Color getColor() { return mColor; }
          public String toString() { return "(" +x +"," +y +") x " +size; }
     static interface DirectionalListener
          public void left(Ball ball);
          public void right(Ball ball);
     static class Directional
          private DirectionalListener mListener= null;
          public final void setListener(DirectionalListener listener) {
               mListener= listener;
          protected final void fireLeft(Ball ball)
               if (mListener != null)
                    mListener.left(ball);
          protected final void fireRight(Ball ball)
               if (mListener != null)
                    mListener.right(ball);
     static class Server
          extends Directional
          public Server(final int port)
               new Thread() {
                    public void run() {
                         try {
                              ServerSocket listenSocket= new ServerSocket(port);
                              System.err.println("Server listening on port " +port);
                              while (true)
                                   connect(listenSocket.accept());
                         catch (Exception e) {
                              e.printStackTrace();
               }.start();
          private synchronized void connect(final Socket socket)
               Thread thread= new Thread() {
                    public void run() {
                         try {
                              ObjectInputStream is=
                                   new ObjectInputStream(socket.getInputStream());
                              while (true) {
                                   String side= (String) is.readObject();
                                   Ball ball= (Ball) is.readObject();
                                   if (side.equals(RIGHT))
                                        fireLeft(ball);
                                   else
                                        fireRight(ball);
                         catch (Exception e) {
                              e.printStackTrace();
               thread.setDaemon(true);
               thread.start();
     static class Client
          private ObjectOutputStream mOs;
          private String mSide;
          public Client(String host, int port, String side)
               throws Exception
               mSide= side;
               Socket socket= new Socket(host, port);
               mOs= new ObjectOutputStream(socket.getOutputStream());
               System.err.println(
                    mSide +" client connected to " +host +":" +port);
          private void send(Ball ball)
               try {
                    mOs.writeObject(mSide);
                    mOs.writeObject(ball);
               catch (Exception e) {
                    e.printStackTrace();
     static abstract class BallPanel
          extends JPanel
          public void paint(Graphics g)
               g.setColor(Color.WHITE);
               g.fillRect(0, 0, getSize().width, getSize().height);
               Iterator balls= getBalls();
               while (balls.hasNext()) {
                    Ball ball= (Ball) balls.next();
                    g.setColor(ball.getColor());
                    g.fillOval(ball.x, ball.y, ball.size, ball.size);
          public Dimension getPreferredSize() {
               return new Dimension(300, 240);
          public abstract Iterator getBalls();
     static class Gui
          extends Directional
          private Runnable mUpdater= new Runnable() {
               public void run() { mBallPanel.repaint(); }
          private ArrayList mLeft= new ArrayList();
          private ArrayList mRight= new ArrayList();
          private ArrayList mBalls= new ArrayList();
          private BallPanel mBallPanel= new BallPanel() {
               public Iterator getBalls() {
                    return mBalls.iterator();
          public Gui(String title)
               final JRadioButton red= new JRadioButton("Red");
               final JRadioButton green= new JRadioButton("Green");
               final JRadioButton blue= new JRadioButton("Blue");
               ButtonGroup group= new ButtonGroup();
               group.add(red);
               group.add(blue);
               group.add(green);
               final JRadioButton large= new JRadioButton("Large");
               final JRadioButton small= new JRadioButton("Small");
               group= new ButtonGroup();
               group.add(large);
               group.add(small);
               final JRadioButton left= new JRadioButton("Left");
               final JRadioButton right= new JRadioButton("Right");
               group= new ButtonGroup();
               group.add(left);
               group.add(right);
               red.setSelected(true);
               small.setSelected(true);
               right.setSelected(true);
               mBallPanel.addMouseListener(new MouseAdapter() {
                    public void mousePressed(MouseEvent e) {
                         Ball ball= new Ball(
                              red.isSelected() ? Color. RED :
                              blue.isSelected() ? Color.BLUE : Color.GREEN);
                         ball.x= e.getX();
                         ball.y= e.getY();
                         ball.size= large.isSelected() ? 20 : 10;
                         if (left.isSelected())
                              left(ball);
                         else
                              right(ball);
               JPanel panel= new JPanel(new FlowLayout(FlowLayout.LEFT, 4, 4));
               panel.add(red);
               panel.add(blue);
               panel.add(green);
               panel.add(large);
               panel.add(small);
               panel.add(left);
               panel.add(right);
               JFrame frame= new JFrame(title);
               frame.getContentPane().add(mBallPanel, BorderLayout.CENTER);
               frame.getContentPane().add(panel, BorderLayout.SOUTH);
               frame.pack();
               frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
               frame.setVisible(true);
          public synchronized void move(int delta)
               Iterator left= mLeft.iterator();
               while (left.hasNext()) {
                    Ball ball= (Ball) left.next();
                    ball.x -= delta;
                    if (ball.x <= 0) {
                         left.remove();
                         mBalls.remove(ball);
                         fireLeft(ball);
               Iterator right= mRight.iterator();
               while (right.hasNext()) {
                    Ball ball= (Ball) right.next();
                    ball.x += delta;
                    if (ball.x >= (mBallPanel.getSize().width -ball.size)) {
                         right.remove();
                         mBalls.remove(ball);
                         fireRight(ball);
               SwingUtilities.invokeLater(mUpdater);
          public synchronized void left(Ball ball)
               mLeft.add(ball);
               mBalls.add(ball);
               if (ball.x < 0)
                    ball.x= mBallPanel.getSize().width -(ball.size/2);
               SwingUtilities.invokeLater(mUpdater);
          public synchronized void right(Ball ball)
               mRight.add(ball);
               mBalls.add(ball);
               if (ball.x < 0)
                    ball.x= ball.size/2;
               SwingUtilities.invokeLater(mUpdater);
     static class Controller
          public Controller(
               final Gui gui, final Server server,
               final Client left, final Client right)
               gui.setListener(new DirectionalListener() {
                    // Ball reached the left
                    public void left(Ball ball)
                         ball.x= -1;
                         if (left == null)
                              gui.right(ball);
                         else
                              left.send(ball);
                    // Ball reached the right
                    public void right(Ball ball)
                         ball.x= -1;
                         if (right == null)
                              gui.left(ball);
                         else
                              right.send(ball);
               server.setListener(new DirectionalListener() {
                    // Ball came from the left
                    public void left(Ball ball) {
                         gui.right(ball);
                    // Ball came from the right
                    public void right(Ball ball) {
                         gui.left(ball);
               Thread thread= new Thread() {
                    public void run() {
                         while (true) {
                              try { sleep(100); }
                              catch (InterruptedException e) { }
                              gui.move(10);
               thread.setDaemon(true);
               thread.start();
     private static final String USAGE=
          "Usage: java Ziniman1 " +
          "<server port> [-left <host:port>] [-right <host:port>]";
        public static void main(String[] argv)
          throws Exception
          if (argv.length < 1)
               barf();
          int leftPort= -1;
          int rightPort= -1;
          String leftHost= "localhost";
          String rightHost= "localhost";
          int serverPort= Integer.parseInt(argv[0]);
          for (int i= 1; i< argv.length; i += 2) {
               if (argv.equals("-left")) {
                    if (argv.length == i+1)
                         barf();
                    String url= argv[i+1];
                    if (url.indexOf(":") < 0)
                         barf();
                    leftHost= url.substring(0, url.indexOf(":"));
                    leftPort= Integer.parseInt(url.substring(url.indexOf(":")+1));
               else if (argv[i].equals("-right")) {
                    if (argv.length == i+1)
                         barf();
                    String url= argv[i+1];
                    if (url.indexOf(":") < 0)
                         barf();
                    rightHost= url.substring(0, url.indexOf(":"));
                    rightPort= Integer.parseInt(url.substring(url.indexOf(":")+1));
          new Controller(
               new Gui("Balls @ " +serverPort),
               new Server(serverPort),
               leftPort > 0 ? new Client(leftHost, leftPort, LEFT) : null,
               rightPort > 0 ? new Client(rightHost, rightPort, RIGHT) : null);
     private static void barf()
          System.err.println(USAGE);
          System.exit(-1);

Similar Messages

  • Help, How do i get objects to move with the click of a mouse button?

    I am developing a game where by an object can move around the screen by either using the keyboard or the mouse. I have figured out how to control the object using the keyboard. But the mouse control is proving difficult. Can anyone give me some suggestions on how to tackle this?

    This is better !:
    import java.awt.*;
    import java.awt.geom.*;
    import java.awt.event.*;
    public class MoveO extends Frame implements MouseListener
         Label obj = new Label("@");
    public MoveO()
         setBackground(Color.pink);
         addWindowListener(new WindowAdapter()
        {     public void windowClosing(WindowEvent ev)
              {     dispose();
                   System.exit(0);}});
         setLayout(null);
         add(obj);
         obj.setBounds(110,130,20,20);
         obj.setBackground(Color.red);
           setBounds(1,1,600,460);
         setVisible(true);
         addMouseListener(this);
    public void mouseEntered(MouseEvent m){}
    public void mouseExited(MouseEvent m) {}
    public void mouseClicked(MouseEvent m){}
    public void mousePressed(MouseEvent m){}
    public void mouseReleased(MouseEvent m)
         move2(m.getPoint());
    private void move2(Point mto)
         Point ofr = obj.getLocation();
         Line2D.Double line = new Line2D.Double(ofr.x,ofr.y,mto.x,mto.y);
         Rectangle2D.Double r = new Rectangle2D.Double();
         r.setRect(line.getBounds2D());
         if (mto.x >= ofr.x) 
              for (double x=0; x <= r.width; x++)
                   for (double y=0; y <= r.height; y++)
                        if (line.ptSegDist(r.x+x,r.y+y) < 0.25)          
                             obj.setLocation((int)(r.x+x),(int)(r.y+y));
         else
              for (double x=r.width; x >= 0; x--)
                   for (double y=r.height; y >= 0; y--)
                        if (line.ptSegDist(r.x+x,r.y+y) < 0.25)          
                             obj.setLocation((int)(r.x+x),(int)(r.y+y));                
    public static void main (String[] args) 
         new MoveO();
    }Noah

  • Getting objects to move fluidly between PCs

    question regarding this thread:
    http://forum.java.sun.com/thread.jsp?forum=54&thread=468867
    would RMI be a faster solution than using Java.net's object serialization?

    this thread has been resolved. thanks anyway.

  • User control ActiveX cannot move between objects using TAB

    I created a simple ActiveX control with 3 text boxes.
    I added it as an ActiveX object to a SAP form.
    It apears good on the screen but it seems like SAP is "stealing" the TAB keypress and therefore I cannot move between the ActiveX controls accrdinf to their Tabindex property
    It happed both in VB6 and VB.NET user control
    How it can be solved ?
    Tx Yaron

    I'm assuming you're not using a BusinessObjects reporting solution, which would mean you're posting to the wrong forum.
    Sincerely,
    Ted Ueda

  • How to get a HD movie on to a DVD to use on a TV and keep the integrity of the video

    I made a high quality movie in aperture which I exported to the desktop as a Quicktime movie.   Then I created a One Step DVD from the movie.  The movie is 12 gb and the disk and it plays well on a HD TV through an HDMI cable.  I have been trying to export this movie to a DVD that can be played through a regular DVD player onto a tv.  I am exporting to an 8+gb disk.   There are 1028 files in  the movie and for some reason there are two places for about 4 to 8 pictures each where the movie flickers or shakes.  There also seems to be some electrical "noise " interferance as well.   Is there some other way to make a HD movie onto a disk and still keep the integrity of the original movie?   Hopefully someone has an answer.   Thanks for the help and Merry Christmas.

    welcome to my world... i could see the difference in my movies between original by hooking camera up to tv direct vs the dvd i burned put into tv. it took me a while to find out/understand... first answer above is right.  from experience [i am not professional] i learned some terminology.  burning dvd = only standard definition quality [even if you import from a high definition camera]... like first answer above said... you would have to get a blu-ray BURNER to get hi def dvd.  i take the pains to shoot as high quality photo/video then am forced to preserve in a lower quality.  so the  best viewing of high quality is to play the movie from your camera to tv direct... but then you need to clear your camera.  I am hoping that i can hold videos imported into iMove/Final cut then maybe one day i will have a blu-ray burner and redo the burning process in hi def [i wonder if there is a catch here?].  I also was advised that final cut pro with dvd studio would be a little improvement over iMovie [still burns standard def unless have bluray burner].    FLICKERS/SHAKES.... are you viewing the dvd from the dvd disc itself???  you have to drag the movie off the dvd to the desktop then play it.  iDvd or final cut will set up the conversion to the tv dvd format. I can empathize with you greatly.

  • Edit Object then saving back causes the object to move??

    Hi,
    I'm using Acrobat X 10.1.6 updated today. When editing PDF documents by right clicking then selecting "Edit Object", I get my usual Illustrator window pop up, change my colour or whatever, Save, back to Acrobat, and the object in question moves! This has only started happening recently and I have been using Acrobat daily in my job, as a PrePress operative, since Acrobat 7 Professional and never had this issue.
    Please advise what is causing the object to move?! I have re-installed Acrobat today and re-updated and no change. I also have several colleagues on various versions of Acrobat ranging from 9.5.3 to 10.1.6 who cannot replicate this issue, even on the same PDF file?
    Many thanks in advance.
    Tom.

    Re-installing Illustrator seemed to work, even though it was fully up to date and now technically it's not, it works better now. I guess I'll be pausing the "updates" from now on.
    Thanks!

  • Help!  How do I trim clips to smaller size so I can move between movies?

    Help! I am editing a wedding video with a lot of footage. If I try to clip out a very small part of the video, even if it's only 10 seconds long, it still stays the same size of the original clip - 5 gb! I can't create a video like this - I've already deleted everything off of my computer as it is just to make room for the clips. Please tell me there's a way to trim down clips so they're smaller in size so I can move between movies and edit this. I really appreciate your help - thank you!!

    This has been answered in your duplicate post, but just to clarify:
    Non-destructive editing is an important feature of iMovie.
    iMovie preserves the entire copy of every clip you place into your movie in case you change your mind at a later stage.
    So, if you have cut out one minute from a 45 minute clip, iMovie will have stored two complete copies of that clip. This is why is helps to set import as 3-5 minute clips rather than one huge chunk. As DV runs at 13GB per hour your project files can get very big.
    One workaround is to complete the editing of a section of the movie, then export that to Quicktime: highlight the clip/s, choose Share-Quicktime, turn on Share selected clips only, and choose Full Quality from the pop-ip menu.
    Once you have saved the stand-alone clip to your hard drive, you can re-import it into your project using the File/Import command, and delete the original long clip/s from the project.

  • Why can't I get my 122min movie on a DVD-DL

    Hi everyone. I am new to FCPX, but I was a quite confortable user to iMovie.
    As I have to get a 122min movie on a DVD, I am obviously using dual layers.
    First, I tried to do it with FCPX itself, using the Share > DVD... menu.
    Setting it to Double layers, I was happy to use this function compressing my movie to 7 Go - everything works fine and the time left was in good relation with the job done. Until..
    When it gets to 47% the estimated time left grows up to 38 hours or so, and it just either takes 12 hours to get to 52% or the "time left" itself gets even longer !
    So I decided to get Compressor and try to work with the right thing... but it just seems to do exactly the same thing.
    Is there any way I could be told what's wrong in my process? I've learned and read on so many forums Compressor was the right way to do this.
    What are the setup I gotta use?
    My movie is a 1080p - HD - 1920x1080 - 23,98p
    I am working on a iMac, quadcore, 10.6.8
    Thank you for your time

    Actually, the only difference between Compressor and FCPX DVD disk authoring capabilities is that Compressor offers you the ability to set chapter markers.
    The typical advice one reads on these and other Compresssion-related forums is to take a short section of the source file and test it to determine quality and to verify workflow. Unfortunately, with DL DVD, things are trickier and that approach isn't really possible…we don't know whether we have a successful project until we actually burn it and it plays on DVD players.
    A couple of things:
    What codec is your movie sequence in? If it's H.264, consider transcoding to Pro Res. FCPX and Compressor both will probably be happier if not given a delivery codec l to down-scale from 1080 to 480, encode to DVD standards and also try to determine a break poiny in one fell swoop.
    Also, consider down-scaling the movie to SD 16:9 as one stand-alone job. Then take the SD QuickTime output file and use the DVD share preset as a second stand-alone job. If you do that, use Frame Controls for the down-rez job and set the Resize filter to Better or Best.
    Another point: be aware that regardless of whether you use the Compressor or FCPX Share>DVD function, you'll get only a single disk. It's not like DVDSP or iDVD where you can sequentially churn out multiple copies. (You can, of course, make copies of your disk when you have burned one successfully.)
    Finally, since you have iMovie>DVD experience, I'm assuming you have iDVD installed. Were it my project, and if I didn't have DVD Studio Pro as an authoring option, I would definitely consider going the iDVD route.
    Good luck.
    Russ

  • Comparison of ESR Object ID/Object Version ID between PI Environments

    Does anyone know how can I compare ESR Object ID/Object Version ID between PI Environments (lets say PI-DEV vs. PI-QA)?
    Is there a way to do it in mass?
    This is to make sure that actually all the correct object versions have been transported.
    May be there a way to run a report to get all ESR Object ID/Object Version ID in one environment, download it, download for the other environment an compare them outside PI.
    Thanks for your help.

    Enrique,
    The best thing would be compare manually.  For this you need to go to ES Builder menu bar>choose Tools>Find Transports. Like this open in all systems and you need to do manually.  Also I think you can compare manually the ESR content in CMS. Please see this help:
    http://help.sap.com/saphelp_nwpi71/helpdata/en/81/4c6753bb6d478ba9f8fa30eb4d4079/content.htm
    Regards,
    ---Satish

  • Weird movement between keyframes? (not boomerang)

    I'm using CS3 and I'm getting some wierd movement occasionally between keyframes in "position" and it's not the boomerang effect. The frames aren't identical, but the z position SHOULD be the same and not change (the x and/or y do). I've looked at every angle I can find and used the graph editor and can't figure it out. In the preview screen I can't see the movement in the path but when I use the graph editor and use the value view I can see the odd random jerky movement in the z line. It's almost like a wiggle (which I've never actually used) and not a smooth continuous motion like the boomerang effect. :-/
    I can't find anything on google about it, although I might just not know the write phrasing. Does anyone know what might be causing this??? It's driving me crazy!

    Without screenshots, system info and details about your project nobody can know. That said, quite often AE's crappy graph editor will draw jittery lines when zoomed in due to how it iteratively quantizes the curve drawing and there is actually nothing going on. So unless this is an issue with final rendering, I wouldn't go crazy over it.
    Mylenium

  • How can i get number of days between two dates represented by two dates?

    how can i get number of days between two dates represented by two date objects. One is java.sql.Date, the other is java.util.Date?

    tej_222 wrote:
    But how do I do that conversion. from java.sql.date and java.util.date to calender?
    -thanks for the quick response.You may find the following utility code samples useful:
    [http://balusc.blogspot.com/2007/09/calendarutil.html]
    [http://balusc.blogspot.com/2007/09/dateutil.html]
    ganeshmb wrote:
    (date1.getTime() - date2.getTime())/(1000*60*60*24) should do.
    getTime returns millsecond value of date object and the difference divided by no of milliseconds in a day should fetch you the difference in terms of days.This doesn't respect the DST. Use java.util.Calendar.

  • I don't no much, but I can follow instructions. How can I get my rental movie from my iPhone to my iPad.... And I've rentented another movie, now I want to get it from pc to iPad....help be much appreciated...

    I don't know much, but I can follow instructions. How can I get my rental movie from my iPhone to my iPad.... And I've rented another movie, now I want to get it from pc to iPad....help be much appreciated...

    Did you rent the film directly on the iPhone ? I've never rented films, but from : http://support.apple.com/kb/HT1415 :
    You can move the rental between devices as many times as you wish during the rental period. However, the movie can only be played on one device at a time. If you rent a movie on an iPhone, iPad, iPod touch, or Apple TV, it is not transferable to any other device and you must watch it on that device.
    If you've rented a film on your computer's iTunes then you should be able to sync it to your iPad from your computer's iTunes via the Movies tab that shows on the right-hand side of iTunes when you've selected the iPad 'device' on its left-hand side

  • How can I get an itunes movie from macbook to apple tv via airplay, how can I get an itunes movie from macbook to apple tv via airplay

    how can I get an itunes movie from macbook to apple tv via airplay?

    You don't use Airplay.  You set up Home Sharing on both and under the Computers section of AppleTV you'll then find it under Movies (or Rentals if rented), assuming it's in a compatible format.
    AC

  • Nulls from HashMap.get(Object)

    I understand that I get the nulls because the Object is not in the map. But is there some elegant way to have it default to the empty String?
    Right now, after I grab all my data into variable with HashMap.get(Object), I go and check each once for null, and assign it the empty String instead. This is a lot of lines of code for something that is so basic.
    I know i could initialize them all to the empty string, and then for each variable, check the HashMap with containsKey(Object) before assigning with HashMap.get(Object). Now, would I be correct in assuming the compiler would optimize this for me and not actually check the HashMap twice for the same Object? And... even if that is the case, its still just as many lines of code.
    Is there perhaps some more elegant way?
    String exchange = parameterMap.get("exchange");
    String messageType = parameterMap.get("messagetype");
    String traderTimeStamp = parameterMap.get("traderTimeStamp");
    String exchangeTimeStamp = parameterMap.get("exchangeTimeStamp");
    String sequence = parameterMap.get("sequence");
    String product = parameterMap.get("product");
    String quantity = parameterMap.get("quantity");
    String price = parameterMap.get("price");
    if (exchange == null)
    exchange = "";
    if (messageType == null)
    messageType = "";
    if (traderTimeStamp == null)
    traderTimeStamp = "";
    if (exchangeTimeStamp == null)
    exchangeTimeStamp = "";
    if (sequence == null)
    sequence = "";
    if (product == null)
    product = "";
    if (quantity == null)
    quantity = "";
    if (price == null)
    price = "";

    You could first put "" for all potential keys.
    Or you could create a helper method
    public String nonNull(String s) {
      return (s != null) ? s : "";
    String exchange = nonNull(parameterMap.get("exchange"));

  • I just noticed that some of the movies I had in iTunes did not get transferred to the iPhone. The missing movies are shown as generic movie icons in the iTunes panel. How do I get the original movies to show up again and transfer to the iPhone?

    I just noticed that some of the movies I had in iTunes did not get transferred to the iPhone 5. The missing movies are shown as generic movie icons in the iTunes panel and are checked to select them. But they do not show up in iPhone Videos. How do I get the original movies to show up again and transfer to the iPhone? I recently upgraded Mac OS to 10.6.8

    1. iTunes won't offer cloud downloads for songs that it "thinks" are in your library, even if it "knows" the files are missing. If you've exhaustively searched for the missing files and there is no prospect of repair by restoring to them to their original locations, or connecting to new ones, then delete that tracks that display both the missing exclamation mark and are of media kind Purchased/Protected AAC audio file. Don't hide from iTunes in the cloud when asked, close iTunes, then reopen. You can download from the cloud links or iTunes Store > Quicklinks > Purchased > Music > Not on this computer > All songs > Download all.
    2. Why? Not sure, perhaps 3rd party tools or accidental key presses combined with previously hidden warning messages when trying to organize the library. There is a hint that using the feature to downsample media as it is synced to a device may also be involved, though I've not replicated it. Whatever the reason a backup would protect your media.
    tt2

Maybe you are looking for

  • Safari keeps crashing each time I try and open it

    i can't open Safari anymore. It keeps crashing each time I try. it says Safari quit unexpectedly here are the details, please help. Process:               Safari [1204] Path:                  /Applications/Safari.app/Contents/MacOS/Safari Identifier:

  • Receipt For AT Bat 14 Puchase

    I have not received a receipt  for my purchase "AT BAT 14" App today. I have not purchased an app for some time and if I recall correctly they email to you upon purchase.  As I qualify for a rebate on this App purchase through MLB as I have their pre

  • Double Email Setting Accts

    Hello! I need help to close one of my 2 email setting accounts with blackberry server. Thank you Eleuterio Solved! Go to Solution.

  • How can I modify the new Hebrew language icon (א) to revert back to the Israeli Flag ?

    The Hebrew language icon in Mac has always been , at least for the last 20 years! However, in Yosemite, it's now א. How can I modify the icon? There must be a library of images somewhere in the System, where I can replace the icon... Thanks for your

  • MP3 download to computer from broken phone

    How does one get the data and MP3's off a broken phone to my computer???     -nigel