Skip to content

Commit d6c28b1

Browse files
committed
Update comment and nit changes
1 parent 9d6163b commit d6c28b1

File tree

6 files changed

+62
-41
lines changed

6 files changed

+62
-41
lines changed

Parse/src/main/java/com/parse/GetDataCallback.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ public interface GetDataCallback extends ParseCallback2<byte[], ParseException>
3737
@Override
3838
public void done(byte[] data, ParseException e);
3939
}
40+

Parse/src/main/java/com/parse/GetDataStreamCallback.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,5 @@ public interface GetDataStreamCallback extends ParseCallback2<InputStream, Parse
3939
@Override
4040
public void done(InputStream input, ParseException e);
4141
}
42+
43+

Parse/src/main/java/com/parse/GetFileCallback.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ public interface GetFileCallback extends ParseCallback2<File, ParseException> {
3838
*/
3939
@Override
4040
public void done(File file, ParseException e);
41-
}
41+
}

Parse/src/main/java/com/parse/ParseFile.java

Lines changed: 55 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -363,18 +363,20 @@ public void saveInBackground(SaveCallback callback) {
363363
}
364364

365365
/**
366-
* Synchronously gets the data for this object. You probably want to use
367-
* {@link #getDataInBackground()} instead unless you're already in a background thread.
366+
* Synchronously gets the data from cache if available or fetches its content from the network.
367+
* You probably want to use {@link #getDataInBackground()} instead unless you're already in a
368+
* background thread.
368369
*/
369370
public byte[] getData() throws ParseException {
370371
return ParseTaskUtils.wait(getDataInBackground());
371372
}
372373

373374
/**
374-
* Gets the data for this object in a background thread.
375+
* Asynchronously gets the data from cache if available or fetches its content from the network.
376+
* A {@code ProgressCallback} will be called periodically with progress updates.
375377
*
376378
* @param progressCallback
377-
* A ProgressCallback that is called periodically with progress updates.
379+
* A {@code ProgressCallback} that is called periodically with progress updates.
378380
* @return A Task that is resolved when the data has been fetched.
379381
*/
380382
public Task<byte[]> getDataInBackground(final ProgressCallback progressCallback) {
@@ -421,7 +423,7 @@ public Task<byte[]> then(Task<byte[]> task) throws Exception {
421423
}
422424

423425
/**
424-
* Gets the data for this object in a background thread.
426+
* Asynchronously gets the data from cache if available or fetches its content from the network.
425427
*
426428
* @return A Task that is resolved when the data has been fetched.
427429
*/
@@ -430,41 +432,46 @@ public Task<byte[]> getDataInBackground() {
430432
}
431433

432434
/**
433-
* Gets the data for this object in a background thread.
435+
* Asynchronously gets the data from cache if available or fetches its content from the network.
436+
* A {@code ProgressCallback} will be called periodically with progress updates.
437+
* A {@code GetDataCallback} will be called when the get completes.
434438
*
435439
* @param dataCallback
436-
* A GetDataCallback that is called when the get completes.
440+
* A {@code GetDataCallback} that is called when the get completes.
437441
* @param progressCallback
438-
* A ProgressCallback that is called periodically with progress updates.
442+
* A {@code ProgressCallback} that is called periodically with progress updates.
439443
*/
440444
public void getDataInBackground(GetDataCallback dataCallback,
441445
final ProgressCallback progressCallback) {
442446
ParseTaskUtils.callbackOnMainThreadAsync(getDataInBackground(progressCallback), dataCallback);
443447
}
444448

445449
/**
446-
* Gets the data for this object in a background thread.
450+
* Asynchronously gets the data from cache if available or fetches its content from the network.
451+
* A {@code GetDataCallback} will be called when the get completes.
447452
*
448453
* @param dataCallback
449-
* A GetDataCallback that is called when the get completes.
454+
* A {@code GetDataCallback} that is called when the get completes.
450455
*/
451456
public void getDataInBackground(GetDataCallback dataCallback) {
452457
ParseTaskUtils.callbackOnMainThreadAsync(getDataInBackground(), dataCallback);
453458
}
454459

455460
/**
456-
* Synchronously gets the file pointer for this object. You probably want to use
457-
* {@link #getFileInBackground()} instead unless you're already in a background thread.
461+
* Synchronously gets the file pointer from cache if available or fetches its content from the
462+
* network. You probably want to use {@link #getFileInBackground()} instead unless you're already
463+
* in a background thread.
458464
*/
459465
public File getFile() throws ParseException {
460466
return ParseTaskUtils.wait(getFileInBackground());
461467
}
462468

463469
/**
464-
* Gets the file pointer for this object in a background thread.
470+
* Asynchronously gets the file pointer from cache if available or fetches its content from the
471+
* network. The {@code ProgressCallback} will be called periodically with progress updates.
465472
*
466473
* @param progressCallback
467-
* A ProgressCallback that is called periodically with progress updates.
474+
* A {@code ProgressCallback} that is called periodically with progress updates.
468475
* @return A Task that is resolved when the file pointer of this object has been fetched.
469476
*/
470477
public Task<File> getFileInBackground(final ProgressCallback progressCallback) {
@@ -487,7 +494,8 @@ public Task<File> then(Task<File> task) throws Exception {
487494
}
488495

489496
/**
490-
* Gets the file pointer for this object in a background thread.
497+
* Asynchronously gets the file pointer from cache if available or fetches its content from the
498+
* network.
491499
*
492500
* @return A Task that is resolved when the data has been fetched.
493501
*/
@@ -496,42 +504,50 @@ public Task<File> getFileInBackground() {
496504
}
497505

498506
/**
499-
* Gets the file pointer for this object in a background thread. `progressCallback` is guaranteed
500-
* to be called with 100 before `fileCallback` is called.
507+
* Asynchronously gets the file pointer from cache if available or fetches its content from the
508+
* network. The {@code GetFileCallback} will be called when the get completes.
509+
* The {@code ProgressCallback} will be called periodically with progress updates.
510+
* The {@code ProgressCallback} is guaranteed to be called with 100 before the
511+
* {@code GetFileCallback} is called.
501512
*
502513
* @param fileCallback
503-
* A GetFileCallback that is called when the get completes.
514+
* A {@code GetFileCallback} that is called when the get completes.
504515
* @param progressCallback
505-
* A ProgressCallback that is called periodically with progress updates.
516+
* A {@code ProgressCallback} that is called periodically with progress updates.
506517
*/
507518
public void getFileInBackground(GetFileCallback fileCallback,
508519
final ProgressCallback progressCallback) {
509520
ParseTaskUtils.callbackOnMainThreadAsync(getFileInBackground(progressCallback), fileCallback);
510521
}
511522

512523
/**
513-
* Gets the file pointer for this object in a background thread.
524+
* Asynchronously gets the file pointer from cache if available or fetches its content from the
525+
* network. The {@code GetFileCallback} will be called when the get completes.
514526
*
515527
* @param fileCallback
516-
* A GetFileCallback that is called when the get completes.
528+
* A {@code GetFileCallback} that is called when the get completes.
517529
*/
518530
public void getFileInBackground(GetFileCallback fileCallback) {
519531
ParseTaskUtils.callbackOnMainThreadAsync(getFileInBackground(), fileCallback);
520532
}
521533

522534
/**
523-
* Synchronously gets the data stream for this object. You probably want to use
524-
* {@link #getDataStreamInBackground} instead unless you're already in a background thread.
535+
* Synchronously gets the data stream from cached file if available or fetches its content from
536+
* the network, saves the content as cached file and returns the data stream of the cached file.
537+
* You probably want to use {@link #getDataStreamInBackground} instead unless you're already in a
538+
* background thread.
525539
*/
526540
public InputStream getDataStream() throws ParseException {
527541
return ParseTaskUtils.wait(getDataStreamInBackground());
528542
}
529543

530544
/**
531-
* Gets the data stream for this object in a background thread.
545+
* Asynchronously gets the data stream from cached file if available or fetches its content from
546+
* the network, saves the content as cached file and returns the data stream of the cached file.
547+
* The {@code ProgressCallback} will be called periodically with progress updates.
532548
*
533549
* @param progressCallback
534-
* A ProgressCallback that is called periodically with progress updates.
550+
* A {@code ProgressCallback} that is called periodically with progress updates.
535551
* @return A Task that is resolved when the data stream of this object has been fetched.
536552
*/
537553
public Task<InputStream> getDataStreamInBackground(final ProgressCallback progressCallback) {
@@ -559,7 +575,8 @@ public Task<InputStream> then(Task<InputStream> task) throws Exception {
559575
}
560576

561577
/**
562-
* Gets the data stream for this object in a background thread.
578+
* Asynchronously gets the data stream from cached file if available or fetches its content from
579+
* the network, saves the content as cached file and returns the data stream of the cached file.
563580
*
564581
* @return A Task that is resolved when the data stream has been fetched.
565582
*/
@@ -568,13 +585,17 @@ public Task<InputStream> getDataStreamInBackground() {
568585
}
569586

570587
/**
571-
* Gets the data stream for this object in a background thread. `progressCallback` is guaranteed
572-
* to be called with 100 before `dataStreamCallback` is called.
588+
* Asynchronously gets the data stream from cached file if available or fetches its content from
589+
* the network, saves the content as cached file and returns the data stream of the cached file.
590+
* The {@code GetDataStreamCallback} will be called when the get completes. The
591+
* {@code ProgressCallback} will be called periodically with progress updates. The
592+
* {@code ProgressCallback} is guaranteed to be called with 100 before
593+
* {@code GetDataStreamCallback} is called.
573594
*
574595
* @param dataStreamCallback
575-
* A GetDataCallback that is called when the get completes.
596+
* A {@code GetDataStreamCallback} that is called when the get completes.
576597
* @param progressCallback
577-
* A ProgressCallback that is called periodically with progress updates.
598+
* A {@code ProgressCallback} that is called periodically with progress updates.
578599
*/
579600
public void getDataStreamInBackground(GetDataStreamCallback dataStreamCallback,
580601
final ProgressCallback progressCallback) {
@@ -583,10 +604,12 @@ public void getDataStreamInBackground(GetDataStreamCallback dataStreamCallback,
583604
}
584605

585606
/**
586-
* Gets the data stream for this object in a background thread.
607+
* Asynchronously gets the data stream from cached file if available or fetches its content from
608+
* the network, saves the content as cached file and returns the data stream of the cached file.
609+
* The {@code GetDataStreamCallback} will be called when the get completes.
587610
*
588611
* @param dataStreamCallback
589-
* A GetDataCallback that is called when the get completes.
612+
* A {@code GetDataStreamCallback} that is called when the get completes.
590613
*/
591614
public void getDataStreamInBackground(GetDataStreamCallback dataStreamCallback) {
592615
ParseTaskUtils.callbackOnMainThreadAsync(getDataStreamInBackground(), dataStreamCallback);

Parse/src/main/java/com/parse/ParseFileUtils.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -519,11 +519,6 @@ public static String readFileToString(File file, String encoding) throws IOExcep
519519
return readFileToString(file, Charset.forName(encoding));
520520
}
521521

522-
public static void writeStringToFile(File file, String string)
523-
throws IOException {
524-
writeByteArrayToFile(file, string.getBytes());
525-
}
526-
527522
public static void writeStringToFile(File file, String string, Charset encoding)
528523
throws IOException {
529524
writeByteArrayToFile(file, string.getBytes(encoding));

Parse/src/test/java/com/parse/ParseFileTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public void testSaveAsyncCancelled() throws Exception {
175175
public void testGetDataAsyncSuccess() throws Exception {
176176
String content = "content";
177177
File file = temporaryFolder.newFile("test");
178-
ParseFileUtils.writeStringToFile(file, content);
178+
ParseFileUtils.writeStringToFile(file, content, "UTF-8");
179179
ParseFileController controller = mock(ParseFileController.class);
180180
when(controller.fetchAsync(
181181
any(ParseFile.State.class),
@@ -209,7 +209,7 @@ public void testGetDataAsyncSuccess() throws Exception {
209209
public void testGetDataStreamAsyncSuccess() throws Exception {
210210
String content = "content";
211211
File file = temporaryFolder.newFile("test");
212-
ParseFileUtils.writeStringToFile(file, content);
212+
ParseFileUtils.writeStringToFile(file, content, "UTF-8");
213213
ParseFileController controller = mock(ParseFileController.class);
214214
when(controller.fetchAsync(
215215
any(ParseFile.State.class),
@@ -243,7 +243,7 @@ public void testGetDataStreamAsyncSuccess() throws Exception {
243243
public void testGetFileAsyncSuccess() throws Exception {
244244
String content = "content";
245245
File file = temporaryFolder.newFile("test");
246-
ParseFileUtils.writeStringToFile(file, content);
246+
ParseFileUtils.writeStringToFile(file, content, "UTF-8");
247247
ParseFileController controller = mock(ParseFileController.class);
248248
when(controller.fetchAsync(
249249
any(ParseFile.State.class),

0 commit comments

Comments
 (0)