当前位置: 首页>>代码示例>>Java>>正文


Java JsonReader.nextInt方法代码示例

本文整理汇总了Java中com.google.gson.stream.JsonReader.nextInt方法的典型用法代码示例。如果您正苦于以下问题:Java JsonReader.nextInt方法的具体用法?Java JsonReader.nextInt怎么用?Java JsonReader.nextInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gson.stream.JsonReader的用法示例。


在下文中一共展示了JsonReader.nextInt方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setLogInfo

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
public void setLogInfo(JsonReader reader) throws IOException {
	reader.beginObject();
	while (reader.hasNext()) {
		String name = reader.nextName();
		if (name.equals("screen_size")) {
			reader.beginObject();
			while(reader.hasNext()) {
				String name2 = reader.nextName();
				if (name2.equals("width")) {
					width = reader.nextInt();
				} else if (name2.equals("height")) {
					height = reader.nextInt();
				} else {
					reader.skipValue();
				}
			}
			reader.endObject();
		} else {
			reader.skipValue();
		}
	}
	reader.endObject();
}
 
开发者ID:SERESLab,项目名称:iTrace-Archive,代码行数:24,代码来源:OldJSONBasicFixationFilter.java

示例2: read

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
@Override
public Boolean read(JsonReader in) throws IOException {
    JsonToken peek = in.peek();
    switch (peek) {
        case BOOLEAN:
            return in.nextBoolean();
        case NULL:
            in.nextNull();
            return null;
        case NUMBER:
            return in.nextInt() != 0;
        case STRING:
            return in.nextString().equalsIgnoreCase("1");
        default:
            throw new IllegalStateException("Expected BOOLEAN or NUMBER but was " + peek);
    }
}
 
开发者ID:GrenderG,项目名称:Protestr,代码行数:18,代码来源:WebService.java

示例3: readPrimitiveOrItsBox

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
public static Object readPrimitiveOrItsBox(JsonReader reader, Property p) throws IOException {
    Class<?> type = p.getType();
    if (type == void.class || type == Void.class) {
        return null;
    } else if (type == boolean.class || type == Boolean.class) {
        return reader.nextBoolean();
    } else if (type == byte.class || type == Byte.class) {
        return (byte)reader.nextInt();
    } else if (type == short.class || type == Short.class) {
        return (short)reader.nextInt();
    } else if (type == int.class || type == Integer.class) {
        return reader.nextInt();
    } else if (type == long.class || type == Long.class) {
        return reader.nextLong();
    } else if (type == char.class || type == Character.class) {
        return (char)reader.nextLong();
    } else if (type == float.class || type == Float.class) {
        return (float)reader.nextDouble();
    } else if (type == double.class || type == Double.class) {
        return reader.nextDouble();
    } else {
        throw new IllegalStateException();
    }
}
 
开发者ID:LightSun,项目名称:data-mediator,代码行数:25,代码来源:SupportUtils.java

示例4: parseResponse

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
/**
 * 太绕,还是直接用Json解析吧
 *
 * @param response
 * @throws IOException
 */
private void parseResponse(Reader response) throws IOException {
    JsonReader reader = new JsonReader(response);
    reader.beginObject();
    String name;
    while (reader.hasNext()) {
        name = reader.nextName();
        if (TextUtils.equals(Field.ERROR, name)) {
            reader.nextInt();
        } else if (TextUtils.equals(Field.MESSAGE, name)) {
            reader.nextString();
        } else if (TextUtils.equals(Field.DATA, name)) {
            reader.beginObject();
            while (reader.hasNext()) {
                reader.nextName();
                reader.beginArray();
                while (reader.hasNext()) {
                    reader.beginObject();
                    String itemObjKey;
                    while (reader.hasNext()) {
                        itemObjKey = reader.nextName();
                        if (TextUtils.equals(Field.TOKEN, itemObjKey)) {
                            reader.nextString();
                        } else {
                            reader.skipValue();
                        }
                    }
                    reader.endObject();
                }
                reader.endArray();
            }
            reader.endObject();
        } else {
            reader.skipValue();
        }
    }
    reader.endObject();
    reader.close();
}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:45,代码来源:TicketDetailPresenter.java

示例5: read

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
public Calendar read(JsonReader in) throws IOException {
    if (in.peek() == JsonToken.NULL) {
        in.nextNull();
        return null;
    }
    in.beginObject();
    int year = 0;
    int month = 0;
    int dayOfMonth = 0;
    int hourOfDay = 0;
    int minute = 0;
    int second = 0;
    while (in.peek() != JsonToken.END_OBJECT) {
        String name = in.nextName();
        int value = in.nextInt();
        if (YEAR.equals(name)) {
            year = value;
        } else if (MONTH.equals(name)) {
            month = value;
        } else if (DAY_OF_MONTH.equals(name)) {
            dayOfMonth = value;
        } else if (HOUR_OF_DAY.equals(name)) {
            hourOfDay = value;
        } else if (MINUTE.equals(name)) {
            minute = value;
        } else if (SECOND.equals(name)) {
            second = value;
        }
    }
    in.endObject();
    return new GregorianCalendar(year, month, dayOfMonth, hourOfDay, minute, second);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:33,代码来源:TypeAdapters.java

示例6: read

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
@Override
public Color read(JsonReader i) throws IOException {
    int red = 0;
    int green = 0;
    int blue = 0;
    int alpha = 0;

    i.beginObject();
    while (i.hasNext()) {
        switch (i.nextName()) {
            case "red":
                red = i.nextInt();
                break;
            case "green":
                green = i.nextInt();
                break;
            case "blue":
                blue = i.nextInt();
                break;
            case "alpha":
                alpha = i.nextInt();
                break;
        }
    }
    i.endObject();

    if (red > 255) red = 255;
    if (green > 255) green = 255;
    if (blue > 255) blue = 255;
    if (alpha > 255) alpha = 255;

    Color c = new Color(red, green, blue, alpha);

    return c;
}
 
开发者ID:gabixdev,项目名称:Kyoko,代码行数:36,代码来源:ColorTypeAdapter.java

示例7: read

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
public MutantStatus read(JsonReader in) throws IOException {
    int value = in.nextInt();
    for (MutantStatus mutantStatus : MutantStatus.values()) {
        if (mutantStatus.getValue() == value){
            return mutantStatus;
        }
    }
    throw new JsonParseException(String.format("Cannot convert %s to a MutantStatus", value));
}
 
开发者ID:stryker-mutator,项目名称:sonar-stryker-plugin,代码行数:10,代码来源:MutantStatusAdapter.java

示例8: read

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
@Override
public Number read(JsonReader in) throws IOException {
  if (in.peek() == JsonToken.NULL) {
    in.nextNull();
    return null;
  }
  try {
    return (short) in.nextInt();
  } catch (NumberFormatException e) {
    throw new JsonSyntaxException(e);
  }
}
 
开发者ID:odoo-mobile-intern,项目名称:odoo-work,代码行数:13,代码来源:TypeAdapters.java

示例9: read

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
public BitSet read(JsonReader in) throws IOException {
  if (in.peek() == JsonToken.NULL) {
    in.nextNull();
    return null;
  }

  BitSet bitset = new BitSet();
  in.beginArray();
  int i = 0;
  JsonToken tokenType = in.peek();
  while (tokenType != JsonToken.END_ARRAY) {
    boolean set;
    switch (tokenType) {
    case NUMBER:
      set = in.nextInt() != 0;
      break;
    case BOOLEAN:
      set = in.nextBoolean();
      break;
    case STRING:
      String stringValue = in.nextString();
      try {
        set = Integer.parseInt(stringValue) != 0;
      } catch (NumberFormatException e) {
        throw new JsonSyntaxException(
            "Error: Expecting: bitset number value (1, 0), Found: " + stringValue);
      }
      break;
    default:
      throw new JsonSyntaxException("Invalid bitset value type: " + tokenType);
    }
    if (set) {
      bitset.set(i);
    }
    ++i;
    tokenType = in.peek();
  }
  in.endArray();
  return bitset;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:41,代码来源:TypeAdapters.java

示例10: read

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
@Override
public DProductType read(JsonReader reader) throws IOException {
    if (reader.peek() == JsonToken.NULL) {
        reader.nextNull();
        return null;
    }
    int value = reader.nextInt();

    return DProductType.getProductTypeByValue(value);

}
 
开发者ID:indiketa,项目名称:degiro-java-client,代码行数:12,代码来源:DUtils.java

示例11: getRawGaze

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
public OldRawGaze getRawGaze(JsonReader reader) throws IOException {
	String file = null;
	String type = null;
	double x = -1;
	double y = -1;
	double leftValidity = -1;
	double rightValidity = -1;
	double leftPupilDiam = -1;
	double rightPupilDiam = -1;
	long trackerTime = -1;
	long systemTime = -1;
	long nanoTime = -1;
	int lineBaseX = -1;
	int line = -1;
	int col = -1;
	String hows = new String();
	String types = new String();
	String fullyQualifiedNames = new String();
	int lineBaseY = -1;
	
	reader.beginObject();
	while (reader.hasNext()) {
		String name = reader.nextName();
		if (name.equals("file")) {
			file = reader.nextString();
		} else if (name.equals("type")) {
			type = reader.nextString();
		} else if (name.equals("x")) {
			x = reader.nextDouble();
		} else if (name.equals("y")) {
			y = reader.nextDouble();
		} else if (name.equals("left_validation")) {
			leftValidity = reader.nextDouble();
		} else if (name.equals("right_validation")) {
			rightValidity = reader.nextDouble();
		} else if (name.equals("left-pupil-diameter")) {
			leftPupilDiam = reader.nextDouble();
		} else if (name.equals("right-pupil-diameter")) {
			rightPupilDiam = reader.nextDouble();
		} else if (name.equals("tracker_time")) {
			trackerTime = reader.nextLong();
		} else if (name.equals("system_time")) {
			systemTime = reader.nextLong();
		} else if (name.equals("nano_time")) {
			nanoTime = reader.nextLong();
		} else if (name.equals("line_base_x")) {
			lineBaseX = reader.nextInt();
		} else if (name.equals("line")) {
			line = reader.nextInt();
		} else if (name.equals("col")) {
			col = reader.nextInt();
		} else if (name.equals("hows")) {
			hows = reader.nextString();
		} else if (name.equals("types")) {
			types = reader.nextString();
		} else if (name.equals("fullyQualifiedNames")) {
			fullyQualifiedNames = reader.nextString();
		} else if (name.equals("line_base_y")) {
			lineBaseY = reader.nextInt();
		} else {
			reader.skipValue();
		}
	}
	reader.endObject();
	return new OldRawGaze(file, type, x, y, leftValidity, rightValidity,
			leftPupilDiam, rightPupilDiam, trackerTime, systemTime,
			nanoTime, lineBaseX, line, col, hows, types, fullyQualifiedNames,
			lineBaseY);
}
 
开发者ID:SERESLab,项目名称:iTrace-Archive,代码行数:70,代码来源:OldJSONBasicFixationFilter.java

示例12: read

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
@Override
public CloudAppConfiguration read(final JsonReader in) throws IOException {
    String appURL = "";
    String appName = "";
    String bootstrapScript = "";
    double cpuCount = 1.0d;
    double memoryMB = 128.0d;
    boolean appCacheEnable = true;
    int eventTraceSamplingCount = 0;
    in.beginObject();
    while (in.hasNext()) {
        String jsonName = in.nextName();
        switch (jsonName) {
            case APP_NAME:
                appName = in.nextString();
                break;
            case APP_URL:
                appURL = in.nextString();
                break;
            case BOOTSTRAP_SCRIPT:
                bootstrapScript = in.nextString();
                break;
            case CPU_COUNT:
                cpuCount = in.nextDouble();
                break;
            case MEMORY_MB:
                memoryMB = in.nextDouble();
                break;
            case APP_CACHE_ENABLE:
                appCacheEnable = in.nextBoolean();
                break;
            case EVENT_TRACE_SAMPLING_COUNT:
                eventTraceSamplingCount = in.nextInt();
                break;
            default:
                break;
        }
    }
    in.endObject();
    return new CloudAppConfiguration(appName, appURL, bootstrapScript, cpuCount, memoryMB, appCacheEnable, eventTraceSamplingCount);
}
 
开发者ID:elasticjob,项目名称:elastic-job-cloud,代码行数:42,代码来源:CloudAppConfigurationGsonFactory.java

示例13: read

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
@Override
public T read(final JsonReader in) throws IOException {
    String jobName = "";
    String cron = "";
    int shardingTotalCount = 0;
    String shardingItemParameters = "";
    String jobParameter = "";
    boolean failover = false;
    boolean misfire = failover;
    String description = "";
    JobProperties jobProperties = new JobProperties();
    JobType jobType = null;
    String jobClass = "";
    boolean streamingProcess = false;
    String scriptCommandLine = "";
    Map<String, Object> customizedValueMap = new HashMap<>(32, 1);
    in.beginObject();
    while (in.hasNext()) {
        String jsonName = in.nextName();
        switch (jsonName) {
            case "jobName":
                jobName = in.nextString();
                break;
            case "cron":
                cron = in.nextString();
                break;
            case "shardingTotalCount":
                shardingTotalCount = in.nextInt();
                break;
            case "shardingItemParameters":
                shardingItemParameters = in.nextString();
                break;
            case "jobParameter":
                jobParameter = in.nextString();
                break;
            case "failover":
                failover = in.nextBoolean();
                break;
            case "misfire":
                misfire = in.nextBoolean();
                break;
            case "description":
                description = in.nextString();
                break;
            case "jobProperties":
                jobProperties = getJobProperties(in);
                break;
            case "jobType":
                jobType = JobType.valueOf(in.nextString());
                break;
            case "jobClass":
                jobClass = in.nextString();
                break;
            case "streamingProcess":
                streamingProcess = in.nextBoolean();
                break;
            case "scriptCommandLine":
                scriptCommandLine = in.nextString();
                break;
            default:
                addToCustomizedValueMap(jsonName, in, customizedValueMap);
                break;
        }
    }
    in.endObject();
    JobCoreConfiguration coreConfig = getJobCoreConfiguration(jobName, cron, shardingTotalCount, shardingItemParameters,
            jobParameter, failover, misfire, description, jobProperties);
    JobTypeConfiguration typeConfig = getJobTypeConfiguration(coreConfig, jobType, jobClass, streamingProcess, scriptCommandLine);
    return getJobRootConfiguration(typeConfig, customizedValueMap);
}
 
开发者ID:elasticjob,项目名称:elastic-job-cloud,代码行数:71,代码来源:AbstractJobConfigurationGsonTypeAdapter.java

示例14: read

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
@Override
public ItemStack read(JsonReader in) throws IOException {
    Material material = null;
    Integer amount = null;
    Short dataValue = null;
    String name = null;
    List<String> lore = new ArrayList<>();
    Map<Enchantment, Integer> enchantments = new HashMap<>();

    if (in.peek() == JsonToken.NULL) {
        in.skipValue();
        return null;
    }

    in.beginObject();

    while (in.hasNext())
        switch (in.nextName()) {
            case MATERIAL:
                material = Material.getMaterial(in.nextString());
                break;
            case DATA_VALUE:
                dataValue = (short) in.nextInt();
                break;
            case AMOUNT:
                amount = in.nextInt();
                break;
            case LORE:
                in.beginArray();
                while (in.hasNext()) {
                    lore.add(in.nextString());
                }
                in.endArray();
                break;
            case NAME:
                name = in.nextString();
                break;
            case ENCHANTS:
                in.beginObject();
                while (in.hasNext())
                    enchantments.put(Enchantment.getByName(in.nextName()), in.nextInt());
                in.endObject();
                break;
    }

    if (material == null)
        throw new JsonParseException("An ItemStack must have a material field!");

    ItemStack stack = new ItemStack(material);
    if (amount != null) stack.setAmount(amount);
    if (dataValue != null) stack.setDurability(dataValue);
    if (name != null || !lore.isEmpty()) {
        ItemMeta itemMeta = stack.getItemMeta();
        if (name != null) itemMeta.setDisplayName(name);
        if (!lore.isEmpty()) itemMeta.setLore(lore);
        stack.setItemMeta(itemMeta);
    }
    if (!enchantments.isEmpty())
        for (Map.Entry<Enchantment, Integer> enchantmentIntegerEntry : enchantments.entrySet()) {
            stack.addUnsafeEnchantment(enchantmentIntegerEntry.getKey(), enchantmentIntegerEntry.getValue());
        }
    in.endObject();

    return stack;
}
 
开发者ID:Twister915,项目名称:pl,代码行数:66,代码来源:ItemStackTypeAdapter.java


注:本文中的com.google.gson.stream.JsonReader.nextInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。