~ubuntu-branches/ubuntu/karmic/pilot-link/karmic

« back to all changes in this revision

Viewing changes to bindings/Java/org/gnu/pilotlink/DatebookRecord.java

  • Committer: Bazaar Package Importer
  • Author(s): Ludovic Rousseau
  • Date: 2006-09-22 11:51:36 UTC
  • mfrom: (3.1.8 edgy)
  • Revision ID: james.westby@ubuntu.com-20060922115136-qqmy17bx8j5x0y72
Tags: 0.12.1-5
* urgency medium since libpisock-dev was not usable to build any package
* libpisock-dev now depends on libusb-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
package org.gnu.pilotlink;
2
 
import java.util.*;
 
2
import java.util.Date;
 
3
import java.util.GregorianCalendar;
3
4
public class DatebookRecord extends Record {
4
5
    byte buffer[]=new byte[65535]; //max buffer
5
6
    //Statics
33
34
    private int repType;
34
35
    private int repDay;
35
36
    private int repWeekstart;
 
37
    private int dist;
 
38
    
36
39
    private Date repExceptions[];
37
 
    int repFreq=0;
38
 
    int dist=0;
39
40
    
40
41
    private boolean[] repDays;
41
42
    
87
88
        }
88
89
        GregorianCalendar cal=new GregorianCalendar();
89
90
        cal.setTime(sd);
90
 
        if (cal.get(cal.HOUR_OF_DAY)!=0 && cal.get(cal.MINUTE)!=0) {
 
91
        if (cal.get(GregorianCalendar.HOUR_OF_DAY)!=0 && cal.get(GregorianCalendar.MINUTE)!=0) {
91
92
            hasTime=true;
92
93
        }
93
94
        
94
95
        //CLUMSY: getting buffer once to calc size
95
 
        getBuffer();
 
96
        //getBuffer();
 
97
        setSize(getBuffer().length);
96
98
    }
97
99
    //Constructor
98
100
    public DatebookRecord(Record raw) {
99
101
        super(raw);        
100
102
    }
 
103
    public DatebookRecord() {
 
104
            startDate=new Date();
 
105
            resetVars();
 
106
            endDate=new Date();
 
107
    }
101
108
    
102
109
    private void resetVars() {
103
110
        description="";
112
119
        repDay=0;
113
120
        repWeekstart=0;
114
121
 
115
 
        repFreq=0;
 
122
        repAdvance=0;
116
123
        dist=0;
117
124
        repDays= new boolean[] { false, false ,false, false, false, false, false };
118
125
        hasNote=false;
174
181
                repeatEnd=Record.getDateAt(arr,idx);
175
182
            }
176
183
            idx+=2;
177
 
            repFreq=arr[idx];
 
184
            repAdvance=arr[idx];
178
185
            idx++;
179
186
            int on=arr[idx];
180
187
            if (repType==REP_MONTHLY_BY_DAY) {
212
219
        int bytecount=0;
213
220
        
214
221
        
215
 
        GregorianCalendar cal=new GregorianCalendar();
216
 
        cal.setTime(startDate);
217
222
        if (!hasTime) {
218
223
            buffer[0]=(byte)0xff;
219
224
            buffer[1]=(byte)0xff;
248
253
                Record.setIntAt(buffer,dist-1, bytecount);
249
254
            }
250
255
            bytecount+=2;
251
 
            buffer[bytecount]=(byte)repFreq;
 
256
            buffer[bytecount]=(byte)repAdvance;
252
257
            bytecount++;
253
258
            if (repType==REP_MONTHLY_BY_DAY) {
254
259
                buffer[bytecount]=(byte)repDay;
282
287
        for (int i=0; i<bytecount; i++) {
283
288
            ret[i]=buffer[i];
284
289
        }
285
 
        setSize(bytecount);
 
290
        
286
291
        return ret;
287
292
    }
288
293
    
332
337
    
333
338
    public void setStartDate(Date startDate) {
334
339
        this.startDate = startDate;
 
340
        
 
341
        setSize(getBuffer().length);
335
342
    }
336
343
    public void setEndDate(Date endDate) {
337
344
        this.endDate = endDate;
338
 
    }
 
345
        if (endDate!=null)
 
346
                hasTime=true;
 
347
    
 
348
        setSize(getBuffer().length);
 
349
    }
 
350
    
 
351
    public void setRepeated(boolean r) {
 
352
            isRepeated=r;
 
353
    }
 
354
    
 
355
    public void setRepeatForever(boolean r) {
 
356
            repeatForever=r;
 
357
    }
 
358
    
339
359
    public void setRepeatEnd(Date repeatEnd) {
340
360
        this.repeatEnd = repeatEnd;
 
361
        if (repeatEnd!=null) {
 
362
                setRepeatForever(false);
 
363
        }
 
364
        setSize(getBuffer().length);
341
365
    }
342
366
    public void setDescription(String description) {
343
367
        this.description = description;
 
368
        if (description!=null) {
 
369
                hasDescription=true;
 
370
        } else {
 
371
                hasDescription=false;
 
372
        }
 
373
        setSize(getBuffer().length);
344
374
    }
345
375
    public void setNote(String note) {
346
376
        this.note = note;
347
 
    }
 
377
        if (note!=null) {
 
378
                hasNote=true;
 
379
        } else {
 
380
                hasNote=false;
 
381
        }
 
382
        setSize(getBuffer().length);
 
383
    }
 
384
    
 
385
    public void setAlarm(boolean a) {
 
386
            hasAlarm=a;
 
387
    }
 
388
    
348
389
    public void setAlarmAdvance(int alarmAdvance) {
349
390
        this.alarmAdvance = alarmAdvance;
 
391
        setSize(getBuffer().length);
350
392
    }
351
393
    public void setAlarmUnits(int alarmUnits) {
352
394
        this.alarmUnits = alarmUnits;
 
395
        setSize(getBuffer().length);
353
396
    }
354
397
    public void setRepAdvance(int repAdvance) {
355
398
        this.repAdvance = repAdvance;
 
399
        setSize(getBuffer().length);
356
400
    }
357
401
    public void setRepType(int repType) {
358
402
        this.repType = repType;
 
403
        setSize(getBuffer().length);
359
404
    }
360
405
    public void setRepDay(int repDay) {
361
406
        this.repDay = repDay;
 
407
        setSize(getBuffer().length);
362
408
    }
363
409
    public void setRepWeekstart(int repWeekstart) {
364
410
        this.repWeekstart = repWeekstart;
 
411
        setSize(getBuffer().length);
365
412
    }
366
413
    public void setRepExceptions(Date repExceptions[]) {
367
414
        this.repExceptions = repExceptions;
 
415
        setSize(getBuffer().length);
368
416
    }
369
417
    public void setRepDays(boolean[] repDays) {
370
418
        this.repDays = repDays;
 
419
        setSize(getBuffer().length);
371
420
    }
372
421
    
373
422
}