title: Java cast Long to Enum type issue
body: <p>I had a little problem with casting Java long type to Enum type and can't find a solution how to do that.</p>
  
  <p>Here is what I'm using :</p>
  
  <pre><code>public enum DataType {
      IMAGES(1),
      VIDEOS(2);
  
      private int value;
      private DataType(int i){
          this.value = i;
      }
  }
  </code></pre>
  
  <p>and I need to do  something like this:</p>
  
  <pre><code>DataType dataType;
  String thiz = "1";
  long numb = Long.parseLong(thiz);
  dataType = numb;
  </code></pre>
  
  <p>The error that I get says:</p>
  
  <blockquote>
    <p><em>Convert numb to DataType or convert dataType to long.</em></p>
  </blockquote>
  
  <p><strong>Second Scenario:</strong> </p>
  
  <p>I have this :</p>
  
  <pre><code>static String[] packetType;
  String tmp=incomingData.toString(); // where incomingData is byte[]
  int lastLoc = 0;
  int needsSize = packetFieldSizes[tmpCurrentField-1]; // where packetFieldSizes,tmpCurrentField are integers.
  thiz=tmp.substring(lastLoc, needsSize);    
  
  packetType=thiz;  // packetType = thiz copy; where thiz is the same as used above.
  </code></pre>
  
  <p>I tried to convert thiz to String[] and use valueOf,but</p>
  
  <p>Any suggestions how to get the thinks to work?</p>
  
  <p>Thanks in advance!</p>