Package mina

Source Code of mina.Messages

package mina;

import java.util.HashMap;

import struct.StructException;

public class Messages {
  public static final int IMAGE_REQUEST = 1;
  public static final int IMAGE_RESPONSE = 2;
 
  public static HashMap<Integer, Class>types = new HashMap<Integer, Class>();
  static{
    types.put(IMAGE_REQUEST, ImageRequest.class);
    types.put(IMAGE_RESPONSE, ImageResponse.class);
  }
 
  public static StructMessage getMessage(int type) throws StructException{
    try {
      Class c = types.get(type);
      if(c != null){
        return  (StructMessage)c.newInstance();
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    throw new StructException("Failed");
  }
 
 
}
TOP

Related Classes of mina.Messages

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.