001/*
002 * To change this template, choose Tools | Templates
003 * and open the template in the editor.
004 */
005package armyc2.c2sd.renderer.utilities;
006
007import java.io.DataInputStream;
008import java.io.IOException;
009
010/**
011 *
012 * @author michael.spinelli
013 */
014public class SinglePointLookupInfo {
015    
016    private String _SymbolID = "";
017    private String _Description = "";
018    private int _mappingP = 0;
019    private int _mappingA = 0;
020    private int _height = 0;
021    private int _width = 0;
022    
023    public SinglePointLookupInfo(String basicSymbolID, String description, 
024                                    String mappingP, String mappingA,String width,String height)
025    {
026            _SymbolID = basicSymbolID;
027            _Description = description;
028            if(mappingP != null && mappingP.equals("") == false)
029                    _mappingP = Integer.valueOf(mappingP);
030            if(mappingA != null && mappingA.equals("") == false)
031                    _mappingA = Integer.valueOf(mappingA);
032            if(height != null && height.equals("") == false)
033                    _height = Integer.valueOf(height);
034            if(width != null && width.equals("") == false)
035                    _width = Integer.valueOf(width);
036    }
037
038    private SinglePointLookupInfo(){
039
040    }
041    
042    public String getBasicSymbolID()
043    {
044            return _SymbolID;
045    }
046
047    public String getDescription()
048    {
049            return _Description;
050    }
051
052    public int getMappingP()
053    {
054            return _mappingP;
055    }
056
057    public int getMappingA()
058    {
059            return _mappingA;
060    }
061
062    public int getHeight()
063    {
064            return _height;
065    }
066
067    public int getWidth()
068    {
069            return _width;
070    }
071    
072      /**
073   * 
074   * @return The newly cloned SPSymbolDef
075   */
076  @Override
077  public SinglePointLookupInfo clone()
078  {
079    SinglePointLookupInfo defReturn;
080    defReturn = new SinglePointLookupInfo(_SymbolID, _Description, 
081            String.valueOf(getMappingP()), 
082            String.valueOf(getMappingA()),
083            String.valueOf(getWidth()), 
084            String.valueOf(getHeight()));
085    return defReturn;
086  }
087
088  public String toXML()
089  {
090    String symbolId = "<SYMBOLID>" +  getBasicSymbolID() + "</SYMBOLID>";
091    String mappingP = "<MAPPINGP>" + String.valueOf(getMappingP()) + "</MAPPINGP>";
092    String mappingA = "<MAPPINGA>" + String.valueOf(getMappingA()) + "</MAPPINGA>";
093    String description = "<DESCRIPTION>" + getDescription() + "</DESCRIPTION>";
094    String width = "<WIDTH>" + String.valueOf(getWidth()) + "</WIDTH>";
095    String height = "<HEIGHT>" + String.valueOf(getHeight()) + "</HEIGHT>";
096
097    String xml = symbolId + mappingP + mappingA + description + width + height;
098    return xml;
099  }
100
101    public static SinglePointLookupInfo readBinary(DataInputStream dis) throws IOException
102    {
103        SinglePointLookupInfo info = new SinglePointLookupInfo();
104        info._SymbolID = dis.readUTF();
105        info._Description = dis.readUTF();
106        info._mappingP = dis.readInt();
107        info._mappingA = dis.readInt();
108        info._height = dis.readInt();
109        info._width = dis.readInt();
110        return info;
111    }
112}