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


Java JsonReader.nextDouble方法代码示例

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


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

示例1: doubleAdapter

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
private TypeAdapter<Number> doubleAdapter(boolean serializeSpecialFloatingPointValues) {
  if (serializeSpecialFloatingPointValues) {
    return TypeAdapters.DOUBLE;
  }
  return new TypeAdapter<Number>() {
    @Override public Double read(JsonReader in) throws IOException {
      if (in.peek() == JsonToken.NULL) {
        in.nextNull();
        return null;
      }
      return in.nextDouble();
    }
    @Override public void write(JsonWriter out, Number value) throws IOException {
      if (value == null) {
        out.nullValue();
        return;
      }
      double doubleValue = value.doubleValue();
      checkValidFloatingPoint(doubleValue);
      out.value(value);
    }
  };
}
 
开发者ID:odoo-mobile-intern,项目名称:odoo-work,代码行数:24,代码来源:Gson.java

示例2: floatAdapter

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
private TypeAdapter<Number> floatAdapter(boolean serializeSpecialFloatingPointValues) {
  if (serializeSpecialFloatingPointValues) {
    return TypeAdapters.FLOAT;
  }
  return new TypeAdapter<Number>() {
    @Override public Float read(JsonReader in) throws IOException {
      if (in.peek() == JsonToken.NULL) {
        in.nextNull();
        return null;
      }
      return (float) in.nextDouble();
    }
    @Override public void write(JsonWriter out, Number value) throws IOException {
      if (value == null) {
        out.nullValue();
        return;
      }
      float floatValue = value.floatValue();
      checkValidFloatingPoint(floatValue);
      out.value(value);
    }
  };
}
 
开发者ID:odoo-mobile-intern,项目名称:odoo-work,代码行数:24,代码来源:Gson.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: read

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
@Override public Object read(JsonReader in) throws IOException {
  JsonToken token = in.peek();
  switch (token) {
  case BEGIN_ARRAY:
    List<Object> list = new ArrayList<Object>();
    in.beginArray();
    while (in.hasNext()) {
      list.add(read(in));
    }
    in.endArray();
    return list;

  case BEGIN_OBJECT:
    Map<String, Object> map = new LinkedTreeMap<String, Object>();
    in.beginObject();
    while (in.hasNext()) {
      map.put(in.nextName(), read(in));
    }
    in.endObject();
    return map;

  case STRING:
    return in.nextString();

  case NUMBER:
    return in.nextDouble();

  case BOOLEAN:
    return in.nextBoolean();

  case NULL:
    in.nextNull();
    return null;

  default:
    throw new IllegalStateException();
  }
}
 
开发者ID:odoo-mobile-intern,项目名称:odoo-work,代码行数:39,代码来源:ObjectTypeAdapter.java

示例5: 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;
  }
  return (float) in.nextDouble();
}
 
开发者ID:odoo-mobile-intern,项目名称:odoo-work,代码行数:9,代码来源:TypeAdapters.java

示例6: read

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
@Override
public Location read(JsonReader in) throws IOException {
    in.beginObject();
    Double x = null, y = null, z = null, pitch = null, yaw = null;
    World world = null;
    while (in.hasNext()) {
        String s = in.nextName();
        if (s.equals(WORLD_KEY)) {
            UUID uuid = UUID.fromString(in.nextString());
            world = Bukkit.getWorld(uuid);
            if (world == null)
                throw new JsonParseException("Could not find the world by the UUID: " + uuid.toString());
            continue;
        }
        double v = in.nextDouble();
        switch (s) {
            case X_KEY:
                x = v;
                break;
            case Y_KEY:
                y = v;
                break;
            case Z_KEY:
                z = v;
                break;
            case PITCH:
                pitch = v;
                break;
            case YAW:
                yaw = v;
                break;
        }
    }
    in.endObject();

    if (world == null || x == null || y == null || z == null || pitch == null || yaw == null)
        throw new JsonParseException("Could not read Location object, missing a critical value (expecting world, x, y, z, p, ya)");

    return new Location(world, x, y, z, yaw.floatValue(), pitch.floatValue());
}
 
开发者ID:Twister915,项目名称:pl,代码行数:41,代码来源:LocationTypeAdapter.java

示例7: read

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
@Override
public Car3 read(JsonReader reader) throws IOException {

    Car3 car = new Car3();
    reader.beginObject();
    while (reader.hasNext()) {
        String name = reader.nextName();
        if (name.equals("mark")) {
            car.setMark(reader.nextString());
        } else if (name.equals("model")) {
            car.setModel(reader.nextInt());
        } else if (name.equals("type")) {
            car.setType(reader.nextString());
        } else if (name.equals("maker")) {
            car.setType(reader.nextString());
        } else if (name.equals("cost")) {
            double cost = reader.nextDouble();
            double costExcludingVAT = cost / 1.21;
            car.setCost(costExcludingVAT);  //Remove VAT 21%
        } else if (name.equals("colors") && reader.peek() != JsonToken.NULL) {
            car.setColors(readStringArray(reader));
        } else {
            reader.skipValue();
        }
    }
    reader.endObject();
    return car;
}
 
开发者ID:LightSun,项目名称:data-mediator,代码行数:29,代码来源:Car3TypeAdapter.java

示例8: read

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
@Override
public Location read(JsonReader in) throws IOException {
    World w = null;
    String worldString = "";
    double x = 0, y = 0, z = 0;
    float yaw = 0, pitch = 0;
    in.beginObject();
    while (in.hasNext()) {
        switch (in.nextName()) {
            case "x":
                x = in.nextDouble();
                break;
            case "y":
                y = in.nextDouble();
                break;
            case "z":
                z = in.nextDouble();
                break;
            case "yaw":
                yaw = (float) in.nextDouble();
                break;
            case "pitch":
                pitch = (float) in.nextDouble();
                break;
            case "worldString":
                worldString = in.nextString();
                break;
        }
    }
    in.endObject();
    w = SakiCore.plugin.getServer().getWorld(worldString);
    if (w == null)
        throw new IOException("Invalid world in JSON: " + worldString + ".");
    return new Location(w, x, y, z, yaw, pitch);
}
 
开发者ID:edasaki,项目名称:ZentrelaCore,代码行数:36,代码来源:LocationAdapter.java

示例9: read

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
@Override
public Location read(JsonReader in) throws IOException
{
    in.beginObject();

    in.nextName();
    double x = in.nextDouble();

    in.nextName();
    double y = in.nextDouble();

    in.nextName();
    double z = in.nextDouble();

    in.nextName();
    float pitch = Float.valueOf(String.valueOf(in.nextDouble()));

    in.nextName();
    float yaw = Float.valueOf(String.valueOf(in.nextDouble()));

    in.nextName();
    World world = Bukkit.getWorld(in.nextString());

    in.endObject();

    return new Location(world, x, y, z, pitch, yaw);
}
 
开发者ID:WoutDev,项目名称:Mega-Walls,代码行数:28,代码来源:LocationAdapter.java

示例10: 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

示例11: getRawGaze

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
public RawGaze 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;
	String path = new String();
	int lineHeight = -1;
	int fontHeight = -1;
	int lineBaseX = -1;
	int line = -1;
	int col = -1;
	int lineBaseY = -1;
	ArrayList<SourceCodeEntity> sces = new ArrayList<SourceCodeEntity>();
	
	reader.beginObject();
	while (reader.hasNext()) {
		String name = reader.nextName();
		if (name.equals("name")) {
			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("path")) {
			path = reader.nextString();
		} else if (name.equals("line_height")) {
			lineHeight = reader.nextInt();
		} else if (name.equals("font_height")) {
			fontHeight = reader.nextInt();
		} 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("line_base_y")) {
			lineBaseY = reader.nextInt();
		} else if (name.equals("sces")) {
			reader.beginArray();
			while (reader.hasNext()) {
				sces.add(getSce(reader));
			}
			reader.endArray();
		} else {
			reader.skipValue();
		}
	}
	reader.endObject();
	return new NewRawGaze(file, type, x, y, leftValidity, rightValidity,
			leftPupilDiam, rightPupilDiam, trackerTime, systemTime,
			nanoTime, path, lineHeight, fontHeight, lineBaseX, line, col,
			lineBaseY, sces);
}
 
开发者ID:SERESLab,项目名称:iTrace-Archive,代码行数:77,代码来源:JSONBasicFixationFilter.java

示例12: 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

示例13: read

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
@Override
public Location read(JsonReader in) throws IOException {
    if (in.peek() != JsonToken.BEGIN_OBJECT)
        return null;

    World world = null;
    Double x = null;
    Double y = null;
    Double z = null;
    Double yaw = null;
    Double pitch = null;

    in.beginObject();
    while (in.hasNext()) {
        String name = in.nextName();
        switch (name) {
            case "world":
                world = Bukkit.getWorld(in.nextString());
                break;
            case "x":
                x = in.nextDouble();
                break;
            case "y":
                y = in.nextDouble();
                break;
            case "z":
                z = in.nextDouble();
                break;
            case "yaw":
                yaw = in.nextDouble();
                break;
            case "pitch":
                pitch = in.nextDouble();
                break;
            default:
                Static.log("Unknown type, " + name);
        }
    }
    in.endObject();

    return world != null && x != null && y != null && z != null &&
            pitch != null && yaw != null
            ? new Location(world, x, y, z, yaw.floatValue(), pitch.floatValue())
            : null;
}
 
开发者ID:EntryPointKR,项目名称:MCLibrary,代码行数:46,代码来源:LocationTypeAdapter.java

示例14: read

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
        public T read(JsonReader in) throws IOException {
            Object res;
            in.beginObject();
            LOG.info(in.nextName());
            String clazzName = in.nextString();
            LOG.info(clazzName);
            LOG.info(in.nextName());
            try {
                Class<?> typeOfT = Class.forName(clazzName);
//                 TypeAdapter<?> del = gson.getDelegateAdapter(new ObjectTypeAdapterFactory(),
//                 );
                TypeAdapter<?> del = gson.getAdapter(TypeToken.get(typeOfT));
                LOG.info("ta: " + del + " taDel: " + delegate + " tt: " + TypeToken.get(typeOfT));
                if (typeOfT.isArray()) {
                    del = com.google.gson.internal.bind.ArrayTypeAdapter.FACTORY.create(gson, TypeToken.get(typeOfT));
                } else {
                    del = delegate; 
                }
                
                JsonToken peek = in.peek();
                switch (peek) {
                    case STRING:
                        res = in.nextString();
                        break;
                    case BOOLEAN:
                        res = in.nextBoolean();
                        break;
                    case NUMBER:
                        if (Long.class.equals(typeOfT)) {
                            res = in.nextLong();
                        } else if (Integer.class.equals(typeOfT)) {
                            res = in.nextInt();
                        } else {
                            res = in.nextDouble();
                        }
                        break;

                    default:
                        res = (T) del.read(in);
                }

            } catch (ClassNotFoundException e) {
                throw new JsonParseException(e);
            }
            // res = delegate.read(in);
            in.endObject();
            return (T) res;
        }
 
开发者ID:sap-nocops,项目名称:Jerkoff,代码行数:50,代码来源:ObjectTypeAdapterFactory.java


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