View Javadoc

1   package net.sf.tourviewer.lib.ciclo;
2   
3   import java.util.Formatter;
4   
5   
6   public abstract class AbstractBlock implements Block {
7   	
8   	private int[] data;
9   
10  	public AbstractBlock(int[] data) 
11  	{
12  		this.data = data;	
13  	}
14  	
15  	public int[] getData()
16  	{
17  		return null;
18  	}
19  
20  	public String getDataString()
21  	{
22  		StringBuilder sb = new StringBuilder(40);
23  		Formatter formatter = new Formatter(sb);		
24  		 
25  		for (int i = 0; i < data.length; i++) {
26  			formatter.format("%4H.", data[i]);
27  		}
28  		return sb.toString();
29  	}
30  	
31  	public int getHex(int offset)
32  	{
33  		return data[offset];
34  	}
35  
36  	public int getHexL(int offset)
37  	{
38  		return data[offset] & 0x00FF;
39  	}
40  
41  	public int getHexH(int offset)
42  	{
43  		return (data[offset] & 0xFF00) >> 8;
44  	}
45  
46  	public int getDec(int offset)
47  	{
48  		return Integer.parseInt(Integer.toHexString(getHex(offset)) + "");
49  	}
50  	
51  	public int getDecH(int offset)
52  	{
53  		return Integer.parseInt(Integer.toHexString(getHexH(offset)) + "");
54  	}
55  	
56  	public int getDecL(int offset)
57  	{
58  		return Integer.parseInt(Integer.toHexString(getHexL(offset)) + "");
59  	}
60  	
61  }