-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cdf0cf9
commit 2cc2a43
Showing
4 changed files
with
82 additions
and
59 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
gson/src/main/java/com/google/gson/internal/CurrentWrite.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.google.gson.internal; | ||
|
||
public class CurrentWrite implements CharSequence{ | ||
private char[] chars; | ||
private String cachedString; | ||
|
||
void setChars(char[] chars) { | ||
this.chars = chars; | ||
this.cachedString = null; | ||
} | ||
|
||
@Override | ||
public int length() { | ||
return chars.length; | ||
} | ||
|
||
@Override | ||
public char charAt(int i) { | ||
return chars[i]; | ||
} | ||
|
||
@Override | ||
public CharSequence subSequence(int start, int end) { | ||
return new String(chars, start, end - start); | ||
} | ||
|
||
// Must return string representation to satisfy toString() contract | ||
@Override | ||
public String toString() { | ||
if (cachedString == null) { | ||
cachedString = new String(chars); | ||
} | ||
return cachedString; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
gson/src/main/java/com/google/gson/internal/bind/BoundFieldCreationContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.google.gson.internal.bind; | ||
|
||
import com.google.gson.Gson; | ||
import com.google.gson.reflect.TypeToken; | ||
|
||
import java.lang.reflect.Field; | ||
import java.lang.reflect.Method; | ||
|
||
class BoundFieldCreationContext{ | ||
final Gson context; | ||
final Field field; | ||
final Method accessor; | ||
final String serializedName; | ||
final TypeToken<?> fieldType; | ||
|
||
BoundFieldCreationContext( | ||
final Gson context, | ||
final Field field, | ||
final Method accessor, | ||
final String serializedName, | ||
final TypeToken<?> fieldType){ | ||
|
||
this.context = context; | ||
this.field = field; | ||
this.accessor = accessor; | ||
this.serializedName = serializedName; | ||
this.fieldType = fieldType; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters