~team-java-connector/mariadb-java-client/mariadb_java_connector_gsoc

« back to all changes in this revision

Viewing changes to src/main/java/org/mariadb/jdbc/internal/common/query/parameters/ParameterWriter.java

  • Committer: Puneet Dewan
  • Date: 2014-08-11 05:54:44 UTC
  • Revision ID: puneetd30@gmail.com-20140811055444-rhhgixqueva5x6d9
Cleaned code, Added MariaDB Headers & added support for Additional datatypes

Show diffs side-by-side

added added

removed removed

Lines of Context:
246
246
                 length+=1;
247
247
         }
248
248
         if(length>0){
249
 
         writeIntAsBinary(out, length, 1);
250
 
         }
251
 
         if(year>0){
252
 
         writeIntAsBinary(out, year, 2);//year is 2 bytes
253
 
         }
254
 
         if(month>=0){
255
 
         writeIntAsBinary(out, month+1, 1);
256
 
         }
257
 
         if(dateNumber>0){
 
249
         writeIntAsBinary(out, length, 1);    
 
250
         writeIntAsBinary(out, year, 2);//year is 2 bytes       
 
251
         writeIntAsBinary(out, month+1, 1);       
258
252
         writeIntAsBinary(out, dateNumber, 1);
259
253
         }
260
254
        
262
256
    
263
257
    public static void writeTimeAsBinary(OutputStream out,Time time,Calendar cal,boolean writeFractionalSeconds) throws IOException{            
264
258
        int length=0;
265
 
        int days=4;
 
259
        int days=0;
266
260
        int hour=time.getHours();
267
261
        int minutes=time.getMinutes();
268
 
        int seconds=time.getSeconds();System.out.println(minutes);
269
 
        //int microseconds=(int)(time.getTime()*1000)%1000;
 
262
        int seconds=time.getSeconds();
 
263
        int microseconds=(int)(time.getTime()*1000)%1000;
270
264
        if(hour!=0){
271
265
                length+=1;
272
266
        }
276
270
        if(seconds!=0){
277
271
                length+=1;
278
272
        }
279
 
//      if(microseconds!=0){
280
 
                length+=4;
281
 
//      }
282
 
        if(days!=0){
 
273
        if(microseconds!=0){
283
274
                length+=4;
284
275
        }
285
 
        length+=1;
286
 
        System.out.println(length);
287
276
        if(length>0){
 
277
        length+=4;  //days length
 
278
        length+=1;//isNegative
 
279
        
288
280
         writeIntAsBinary(out, length, 1);
289
 
         writeIntAsBinary(out, 0, 1);//currently positive
290
 
        }
291
 
        if(days>0){
292
 
         writeIntAsBinary(out, days, 3);
293
 
         writeIntAsBinary(out,'d',1);
294
 
        }
295
 
        if(hour>0){
296
 
         writeIntAsBinary(out, hour, 1);//hour is 1 byte
297
 
        }
298
 
        if(minutes>0){
299
 
         writeIntAsBinary(out, minutes, 1);//minute is 1 byte
300
 
        }
301
 
        if(seconds>0){
302
 
         writeIntAsBinary(out, seconds, 1);//second is 1 byte
303
 
        }
304
 
//       if(microseconds>0){
305
 
         writeIntAsBinary(out,'.', 1);
306
 
         writeIntAsBinary(out, 0,3 );
307
 
//       }
308
 
//      int length=0;
309
 
//    
310
 
//      int seconds=time.getSeconds();
311
 
//      int hour=time.getHours();
312
 
//      int minutes=time.getMinutes();
313
 
//    
314
 
//      
315
 
//    
316
 
//       if(hour!=0){
317
 
//              length+=1;
318
 
//      }
319
 
//      if(minutes!=0){
320
 
//              length+=1;
321
 
//      }
322
 
//      if(seconds!=0){
323
 
//              length+=1;
324
 
//      }
325
 
//     
326
 
//       if(length>0){
327
 
//       writeIntAsBinary(out, length, 1);//year is 2 bytes
328
 
//       }
329
 
//       
330
 
//      if(hour>0){
331
 
//       writeIntAsBinary(out, hour, 1);//hour is 1 byte
332
 
//      }
333
 
//      if(minutes>0){
334
 
//       writeIntAsBinary(out, minutes, 1);//minute is 1 byte
335
 
//      }
336
 
//      if(seconds>0){
337
 
//       writeIntAsBinary(out, seconds, 1);//second is 1 byte
338
 
//      }
339
 
         
340
 
        }
 
281
         writeIntAsBinary(out, 0, 1);//currently positive               
 
282
         writeIntAsBinary(out, days, 4);                    
 
283
         writeIntAsBinary(out, hour, 1);//hour is 1 byte            
 
284
         writeIntAsBinary(out, minutes, 1);//minute is 1 byte               
 
285
         writeIntAsBinary(out, seconds, 1);//second is 1 byte           
 
286
         writeIntAsBinary(out,microseconds, 4);         
 
287
         }else{
 
288
         writeIntAsBinary(out, 01, 1);
 
289
         }       
 
290
    }
341
291
    
342
292
    public static void writeTimeStampAsBinary(OutputStream out,Timestamp ts,boolean writeFractionalSeconds) throws IOException{
343
293
        int length=0;
370
320
                length+=4;
371
321
        }
372
322
         if(length>0){
373
 
         writeIntAsBinary(out, length, 1);//length is 1 byte
374
 
         }
375
 
         if(year>0){
376
 
         writeIntAsBinary(out, year, 2);//year is 2 bytes
377
 
         }
378
 
         if(month>=0){
379
 
         writeIntAsBinary(out, month+1, 1);
380
 
         }
381
 
         if(day>0){
382
 
         writeIntAsBinary(out, day, 1);
383
 
         }
384
 
        if(hour>0){
385
 
         writeIntAsBinary(out, hour, 1);//hour is 1 byte
386
 
        }
387
 
        if(minutes>0){
388
 
         writeIntAsBinary(out, minutes, 1);//minute is 1 byte
389
 
        }
390
 
        if(seconds>0){
391
 
         writeIntAsBinary(out, seconds, 1);//second is 1 byte
392
 
        }
393
 
         if(microseconds>0){
 
323
         writeIntAsBinary(out, length, 1);//length is 1 byte     
 
324
         writeIntAsBinary(out, year, 2);//year is 2 bytes               
 
325
         writeIntAsBinary(out, month+1, 1);             
 
326
         writeIntAsBinary(out, day, 1);                 
 
327
         writeIntAsBinary(out, hour, 1);//hour is 1 byte        
 
328
         writeIntAsBinary(out, minutes, 1);//minute is 1 byte                   
 
329
         writeIntAsBinary(out, seconds, 1);//second is 1 byte                   
394
330
         writeIntAsBinary(out,'.', 1);
395
331
         writeIntAsBinary(out, microseconds,3 );
396
332
         }