本文整理匯總了Java中android.util.JsonReader.nextBoolean方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonReader.nextBoolean方法的具體用法?Java JsonReader.nextBoolean怎麽用?Java JsonReader.nextBoolean使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.util.JsonReader
的用法示例。
在下文中一共展示了JsonReader.nextBoolean方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: readValue
import android.util.JsonReader; //導入方法依賴的package包/類
/** Reads the next value in the {@link JsonReader}. */
private static Object readValue(JsonReader reader) throws IOException {
JsonToken token = reader.peek();
switch (token) {
case BEGIN_OBJECT:
return readerToMap(reader);
case BEGIN_ARRAY:
return readerToList(reader);
case BOOLEAN:
return reader.nextBoolean();
case NULL:
reader.nextNull(); // consume the null token
return null;
case NUMBER:
return reader.nextDouble();
case STRING:
return reader.nextString();
default:
throw new IllegalStateException("Invalid token " + token);
}
}
示例2: readOpeningHours
import android.util.JsonReader; //導入方法依賴的package包/類
OpenHours readOpeningHours(JsonReader reader) throws IOException {
boolean openNow = false;
List<OpenPeriod> periods = null;
reader.beginObject();
while (reader.hasNext()) {
switch (reader.nextName()) {
case "open_now":
openNow = reader.nextBoolean();
break;
case "periods":
periods = readOpenPeriodsArray(reader);
break;
default:
reader.skipValue();
break;
}
}
reader.endObject();
return new OpenHours(openNow, periods);
}
示例3: readMessage
import android.util.JsonReader; //導入方法依賴的package包/類
private RegistrationApiResponse readMessage(JsonReader reader) throws IOException {
boolean isRegistered = false;
Warranty warranty = null;
reader.beginObject();
while (reader.hasNext()) {
String name = reader.nextName();
if (name.equals("IsRegistered")) {
isRegistered = reader.nextBoolean();
} else if (name.equals("Warranty")) {
warranty = readWarranty(reader);
} else {
reader.skipValue();
}
}
return new RegistrationApiResponse(isRegistered, warranty);
}
示例4: readWarranty
import android.util.JsonReader; //導入方法依賴的package包/類
private Warranty readWarranty(JsonReader reader) throws IOException {
Boolean extensionEligible = false;
String description = null;
String expiration = null;
reader.beginObject();
while (reader.hasNext()) {
String name = reader.nextName();
if (name.equals("ExtensionEligible")) {
extensionEligible = reader.nextBoolean();
} else if (name.equals("Description")) {
description = reader.nextString();
} else if (name.equals("EndDate")) {
expiration = reader.nextString();
} else {
reader.skipValue();
}
}
reader.endObject();
return new Warranty(extensionEligible, description, expiration);
}
示例5: parsePeer
import android.util.JsonReader; //導入方法依賴的package包/類
private static Peer parsePeer(JsonReader jsonReader) throws IOException {
jsonReader.beginObject();
try {
String hostname = null;
Integer port = null;
Boolean secure = null;
Integer flowFileCount = null;
while (jsonReader.hasNext()) {
String name = jsonReader.nextName();
if (HOSTNAME.equals(name)) {
hostname = jsonReader.nextString();
} else if (PORT.equals(name)) {
port = jsonReader.nextInt();
} else if (SECURE.equals(name)) {
secure = jsonReader.nextBoolean();
} else if (FLOW_FILE_COUNT.equals(name)) {
flowFileCount = jsonReader.nextInt();
} else {
jsonReader.skipValue();
}
}
if (hostname == null) {
Log.w(CANONICAL_NAME, "Null hostname " + peerToString(hostname, port, secure, flowFileCount));
} else if (port == null) {
Log.w(CANONICAL_NAME, "Null port " + peerToString(hostname, port, secure, flowFileCount));
} else if (secure == null) {
Log.w(CANONICAL_NAME, "Null secure " + peerToString(hostname, port, secure, flowFileCount));
} else if (flowFileCount == null) {
Log.w(CANONICAL_NAME, "Null flowFileCount " + peerToString(hostname, port, secure, flowFileCount));
} else {
return new Peer(hostname, port, 0, secure, flowFileCount);
}
} finally {
jsonReader.endObject();
}
return null;
}
示例6: decodeTuple
import android.util.JsonReader; //導入方法依賴的package包/類
private static ShareTuple decodeTuple(JsonReader reader) throws IOException {
if (reader.peek() == JsonToken.NULL) {
reader.nextNull();
return ShareTuple.EMPTY_TUPLE;
}
String workgroup = null;
String username = null;
String password = null;
boolean mounted = true;
reader.beginObject();
while (reader.hasNext()) {
String name = reader.nextName();
switch (name) {
case WORKGROUP_KEY:
workgroup = reader.nextString();
break;
case USERNAME_KEY:
username = reader.nextString();
break;
case PASSWORD_KEY:
password = reader.nextString();
break;
case MOUNT_KEY:
mounted = reader.nextBoolean();
default:
Log.w(TAG, "Ignoring unknown key " + name);
}
}
reader.endObject();
return new ShareTuple(workgroup, username, password, mounted);
}
示例7: parse
import android.util.JsonReader; //導入方法依賴的package包/類
static ShapeFill parse(
JsonReader reader, LottieComposition composition) throws IOException {
AnimatableColorValue color = null;
boolean fillEnabled = false;
AnimatableIntegerValue opacity = null;
String name = null;
int fillTypeInt = 1;
while (reader.hasNext()) {
switch (reader.nextName()) {
case "nm":
name = reader.nextString();
break;
case "c":
color = AnimatableValueParser.parseColor(reader, composition);
break;
case "o":
opacity = AnimatableValueParser.parseInteger(reader, composition);
break;
case "fillEnabled":
fillEnabled = reader.nextBoolean();
break;
case "r":
fillTypeInt = reader.nextInt();
break;
default:
reader.skipValue();
}
}
Path.FillType fillType = fillTypeInt == 1 ? Path.FillType.WINDING : Path.FillType.EVEN_ODD;
return new ShapeFill(name, fillEnabled, fillType, color, opacity);
}
示例8: readMatch
import android.util.JsonReader; //導入方法依賴的package包/類
private static Match readMatch(JsonReader reader) throws IOException {
reader.beginObject();
String userId = "";
String fakeName = "";
String realName = "";
Boolean mutual = false;
while(reader.hasNext()) {
String name = reader.nextName();
if(name.equals("other")) {
userId = reader.nextString();
}
else if(name.equals("other_fake_name")) {
fakeName = reader.nextString();
}
else if(name.equals("other_real_name")) {
realName = reader.nextString();
}
else if(name.equals("mutual")) {
mutual = reader.nextBoolean();
}
else {
reader.skipValue();
}
}
reader.endObject();
User user = Controller.getInstance().getUser(userId);
if(user != null) {
return new Match(null, null, Controller.getInstance().getMyself(), user, mutual, realName, fakeName);
}
return null;
}
示例9: parseNextValue
import android.util.JsonReader; //導入方法依賴的package包/類
/**
* Determines what the next value is and returns it as the appropriate basic type or a custom
* object, a collection, a {@link JSONObject}, or {@link JSONArray}.
*
* @param reader The JsonReader to use. The next token ({@link JsonReader#peek()} must be a
* value.
* @param convertJsonTypes If {@code true}, and the next value is a JSONArray, it will be
* converted to a Collection, and if the next value is a JSONObject, it will be parsed into the
* appropriate object type. If {@code false}, a raw JSONArray or JSONObject will be returned.
*
* @return The next value. If the next value is {@link JsonToken#NULL}, then {@code null} is
* returned.
*/
public static Object parseNextValue(JsonReader reader, boolean convertJsonTypes)
throws IOException {
JsonToken nextToken = reader.peek();
switch (nextToken) {
case BEGIN_ARRAY:
if (convertJsonTypes) {
Collection<Object> collection = new ArrayList<>();
parseJsonArray(reader, collection, null, Object.class, null, null);
return collection;
} else {
return parseAsJsonArray(reader, null);
}
case BEGIN_OBJECT:
if (convertJsonTypes) {
return parseJsonObject(reader, null, null, null);
} else {
return parseAsJsonObject(reader, null);
}
case BOOLEAN:
return reader.nextBoolean();
case NUMBER:
case STRING:
return reader.nextString();
case NULL:
reader.nextNull();
return null;
default:
throw new IllegalStateException("Unexpected token: " + nextToken);
}
}
示例10: nextBoolean
import android.util.JsonReader; //導入方法依賴的package包/類
public static Boolean nextBoolean(JsonReader reader, String name) throws IOException {
if (handleNull(reader)) {
return false;
}
assertType(reader, name, JsonToken.BOOLEAN);
return reader.nextBoolean();
}
示例11: readOfflineEntry
import android.util.JsonReader; //導入方法依賴的package包/類
private Sample readOfflineEntry(JsonReader reader) throws IOException {
String sampleName = null;
String downloadUri = null;
String offlineUri = null;
String extension = null;
UUID drmUuid = null;
String drmLicenseUrl = null;
String[] drmKeyRequestProperties = null;
boolean preferExtensionDecoders = false;
reader.beginObject();
while (reader.hasNext()) {
String name = reader.nextName();
switch (name) {
case "name":
sampleName = reader.nextString();
break;
case "download_uri":
downloadUri = reader.nextString();
break;
case "offline_uri":
offlineUri = reader.nextString();
break;
case "extension":
extension = reader.nextString();
break;
case "drm_scheme":
drmUuid = getDrmUuid(reader.nextString());
break;
case "drm_license_url":
drmLicenseUrl = reader.nextString();
break;
case "drm_key_request_properties":
ArrayList<String> drmKeyRequestPropertiesList = new ArrayList<>();
reader.beginObject();
while (reader.hasNext()) {
drmKeyRequestPropertiesList.add(reader.nextName());
drmKeyRequestPropertiesList.add(reader.nextString());
}
reader.endObject();
drmKeyRequestProperties = drmKeyRequestPropertiesList.toArray(new String[0]);
break;
case "prefer_extension_decoders":
preferExtensionDecoders = reader.nextBoolean();
break;
default:
throw new ParserException("Unsupported attribute name: " + name);
}
}
reader.endObject();
return new OfflineSample(sampleName,drmUuid,drmLicenseUrl,drmKeyRequestProperties,
preferExtensionDecoders,offlineUri,downloadUri);
}
示例12: readEntry
import android.util.JsonReader; //導入方法依賴的package包/類
private Sample readEntry(JsonReader reader, boolean insidePlaylist) throws IOException {
String sampleName = null;
String uri = null;
String extension = null;
UUID drmUuid = null;
String drmLicenseUrl = null;
String[] drmKeyRequestProperties = null;
boolean preferExtensionDecoders = false;
ArrayList<UriSample> playlistSamples = null;
reader.beginObject();
while (reader.hasNext()) {
String name = reader.nextName();
switch (name) {
case "name":
sampleName = reader.nextString();
break;
case "uri":
uri = reader.nextString();
break;
case "extension":
extension = reader.nextString();
break;
case "drm_scheme":
Assertions.checkState(!insidePlaylist, "Invalid attribute on nested item: drm_scheme");
drmUuid = getDrmUuid(reader.nextString());
break;
case "drm_license_url":
Assertions.checkState(!insidePlaylist,
"Invalid attribute on nested item: drm_license_url");
drmLicenseUrl = reader.nextString();
break;
case "drm_key_request_properties":
Assertions.checkState(!insidePlaylist,
"Invalid attribute on nested item: drm_key_request_properties");
ArrayList<String> drmKeyRequestPropertiesList = new ArrayList<>();
reader.beginObject();
while (reader.hasNext()) {
drmKeyRequestPropertiesList.add(reader.nextName());
drmKeyRequestPropertiesList.add(reader.nextString());
}
reader.endObject();
drmKeyRequestProperties = drmKeyRequestPropertiesList.toArray(new String[0]);
break;
case "prefer_extension_decoders":
Assertions.checkState(!insidePlaylist,
"Invalid attribute on nested item: prefer_extension_decoders");
preferExtensionDecoders = reader.nextBoolean();
break;
case "playlist":
Assertions.checkState(!insidePlaylist, "Invalid nesting of playlists");
playlistSamples = new ArrayList<>();
reader.beginArray();
while (reader.hasNext()) {
playlistSamples.add((UriSample) readEntry(reader, true));
}
reader.endArray();
break;
default:
throw new ParserException("Unsupported attribute name: " + name);
}
}
reader.endObject();
if (playlistSamples != null) {
UriSample[] playlistSamplesArray = playlistSamples.toArray(
new UriSample[playlistSamples.size()]);
return new PlaylistSample(sampleName, drmUuid, drmLicenseUrl, drmKeyRequestProperties,
preferExtensionDecoders, playlistSamplesArray);
} else {
return new UriSample(sampleName, drmUuid, drmLicenseUrl, drmKeyRequestProperties,
preferExtensionDecoders, uri, extension);
}
}
示例13: parse
import android.util.JsonReader; //導入方法依賴的package包/類
@Override public DocumentData parse(JsonReader reader, float scale) throws IOException {
String text = null;
String fontName = null;
double size = 0;
int justification = 0;
int tracking = 0;
double lineHeight = 0;
double baselineShift = 0;
int fillColor = 0;
int strokeColor = 0;
int strokeWidth = 0;
boolean strokeOverFill = true;
reader.beginObject();
while (reader.hasNext()) {
switch (reader.nextName()) {
case "t":
text = reader.nextString();
break;
case "f":
fontName = reader.nextString();
break;
case "s":
size = reader.nextDouble();
break;
case "j":
justification = reader.nextInt();
break;
case "tr":
tracking = reader.nextInt();
break;
case "lh":
lineHeight = reader.nextDouble();
break;
case "ls":
baselineShift = reader.nextDouble();
break;
case "fc":
fillColor = JsonUtils.jsonToColor(reader);
break;
case "sc":
strokeColor = JsonUtils.jsonToColor(reader);
break;
case "sw":
strokeWidth = reader.nextInt();
break;
case "of":
strokeOverFill = reader.nextBoolean();
break;
default:
reader.skipValue();
}
}
reader.endObject();
return new DocumentData(text, fontName, size, justification, tracking, lineHeight,
baselineShift, fillColor, strokeColor, strokeWidth, strokeOverFill);
}
示例14: loadFilter
import android.util.JsonReader; //導入方法依賴的package包/類
public static Filter.FilterList loadFilter() {
Filter.FilterList list = new Filter.FilterList();
try {
InputStream in = SIAApp.SIA_APP.openFileInput("ggfilterV2");
JsonReader reader = new JsonReader(new InputStreamReader(in));
reader.beginArray();
while(reader.hasNext()) {
reader.beginObject();
Filter.IncludingFilter inc = new Filter.IncludingFilter();
list.including.add(inc);
while(reader.hasNext()) {
String name = reader.nextName();
switch(name) {
case "type":
inc.setType(Filter.FilterType.valueOf(reader.nextString()));
break;
case "filter":
inc.setFilter(reader.nextString());
break;
case "excluding":
reader.beginArray();
while(reader.hasNext()) {
reader.beginObject();
Filter.ExcludingFilter exc = new Filter.ExcludingFilter(Filter.FilterType.SUBJECT, "", inc);
inc.excluding.add(exc);
while(reader.hasNext()) {
String en = reader.nextName();
switch(en) {
case "type":
exc.setType(Filter.FilterType.valueOf(reader.nextString()));
break;
case "filter":
exc.setFilter(reader.nextString());
break;
case "contains":
exc.contains = reader.nextBoolean();
break;
default:
reader.skipValue();
break;
}
}
reader.endObject();
}
reader.endArray();
break;
default:
reader.skipValue();
break;
}
}
reader.endObject();
}
reader.endArray();
reader.close();
} catch(Exception e) {
list.clear();
return loadFilterFallback();
}
return list;
}
示例15: load
import android.util.JsonReader; //導入方法依賴的package包/類
public boolean load() {
clear();
try {
InputStream in = SIAApp.SIA_APP.openFileInput("exams");
JsonReader reader = new JsonReader(new InputStreamReader(in));
reader.beginArray();
while(reader.hasNext()) {
reader.beginObject();
ExamItem s = new ExamItem();
while(reader.hasNext()) {
String name = reader.nextName();
switch (name) {
case "date":
s.date = new Date(reader.nextLong());
break;
case "clazz":
s.clazz = reader.nextString();
break;
case "lesson":
s.lesson = reader.nextString();
break;
case "length":
s.length = reader.nextString();
break;
case "subject":
s.subject = reader.nextString();
break;
case "teacher":
s.teacher = reader.nextString();
break;
case "selected":
s.selected = reader.nextBoolean();
break;
default:
reader.skipValue();
break;
}
}
reader.endObject();
add(s);
}
reader.endArray();
reader.close();
} catch(Exception e) {
Log.w("ggvp", "Exams file does not exist");
return false;
}
return true;
}