1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
|
/*
* Created on 15.02.2004
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package org.gnu.pilotlink;
/**
* @author stephan
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class AddressAppInfo extends AppInfo {
private String labels[]; //19+3
private boolean labelRenamed[];
private String phoneLabels[]; //whatever
private int country=0;
private int sortByCompany=0;
/**
*
*/
public AddressAppInfo() {
super();
}
/**
* @param ai
*/
public AddressAppInfo(AppInfo ai) {
super(ai);
}
/* (non-Javadoc)
* @see org.gnu.pilotlink.AppInfo#setBuffer(byte[])
*/
public void setBuffer(byte[] b) {
labels=new String[22];
labelRenamed=new boolean[22];
phoneLabels=new String[8];
buffer=b;
super.parseCategories();
long r=Record.getLongAt(buffer,dataOffset);
for (int i=0; i<22;i++) {
labelRenamed[i]=((r&(1<<i))!=0);
}
int offset=dataOffset+4;
for (int i=0;i<22; i++) {
labels[i]=Record.getStringAt(buffer,offset+i*16);
//System.out.println("Got label: "+labels[i]);
}
offset+=22*16;
country=Record.getIntAt(buffer,offset);
offset+=2;
sortByCompany=buffer[offset];
for (int i=3; i<8; i++) {
phoneLabels[i-3]=labels[i];
}
for (int i=19; i<22; i++) {
phoneLabels[i-19+5]=labels[i];
}
}
/* (non-Javadoc)
* @see org.gnu.pilotlink.AppInfo#getBuffer()
*/
public byte[] getBuffer() {
super.createDefaultBuffer();
long r=0;
for (int i=0; i<22;i++) {
if (labelRenamed[i]) {
r|=(1L<<i);
}
}
int offset=dataOffset+4;
for (int i=0; i<22;i++) {
Record.setStringAt(buffer,labels[i],offset+i*16);
}
offset+=22*16;
Record.setIntAt(buffer,country,offset);
offset+=2;
buffer[offset]=(byte)sortByCompany;
return buffer;
}
/**
* @return Returns the country.
*/
public int getCountry() {
return country;
}
/**
* @param country The country to set.
*/
public void setCountry(int country) {
this.country= country;
}
/**
* @return Returns the labelRenamed.
*/
public boolean getLabelRenamed(int i) {
return labelRenamed[i];
}
/**
* @param labelRenamed The labelRenamed to set.
*/
public void setLabelRenamed(int i, boolean labelRenamed) {
this.labelRenamed[i]= labelRenamed;
}
/**
* @return Returns the labels.
*/
public String getLabel(int i) {
return labels[i];
}
/**
* @param labels The labels to set.
*/
public void setLabel(int i, String labels) {
this.labels[i]= labels;
}
/**
* @return Returns the phoneLabels.
*/
public String getPhoneLabel(int i) {
return phoneLabels[i];
}
/**
* @param phoneLabels The phoneLabels to set.
*/
public void setPhoneLabels(int i, String phoneLabel) {
this.phoneLabels[i]= phoneLabel;
}
/**
* @return Returns the sortByCompany.
*/
public boolean isSortByCompany() {
return sortByCompany!=0;
}
/**
* @param sortByCompany The sortByCompany to set.
*/
public void setSortByCompany(boolean sortByCompany) {
if (sortByCompany) {
this.sortByCompany=1;
} else {
this.sortByCompany=0;
}
}
}
|