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


Java JsonReader.nextLong方法代码示例

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


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

示例1: longAdapter

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

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

示例3: 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 in.nextLong();
  } catch (NumberFormatException e) {
    throw new JsonSyntaxException(e);
  }
}
 
开发者ID:odoo-mobile-intern,项目名称:odoo-work,代码行数:13,代码来源:TypeAdapters.java

示例4: build

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
@Override
protected Page build(JsonReader reader) throws IOException {
  Page page = new Page();
  while (reader.hasNext()) {
    String key = reader.nextName();
    if (key.equals("pageid")) {
      page.id = reader.nextLong();
    } else if (key.equals("title")) {
      page.title = reader.nextString();
    } else {
      reader.skipValue();
    }
  }
  return page;
}
 
开发者ID:wenwu315,项目名称:XXXX,代码行数:16,代码来源:WikipediaExample.java

示例5: read

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
@Override
public ZonedDateTime read(JsonReader in) throws IOException {
    Long ts = in.nextLong();
    Instant i = Instant.ofEpochSecond(ts);
    ZonedDateTime z;
    z = ZonedDateTime.ofInstant(i, ZoneId.systemDefault());
    return z;
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:9,代码来源:WebConfig.java

示例6: read

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
@Override
public Date read(JsonReader in) throws IOException {
    if (in.peek() == JsonToken.NUMBER) {
        return new Date(in.nextLong()*1000);
    }
    return null;
}
 
开发者ID:pCloud,项目名称:pcloud-sdk-java,代码行数:8,代码来源:DateTypeAdapter.java

示例7: read

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
@Override
public Date read(JsonReader jsonReader) throws IOException {
  return new Date(jsonReader.nextLong());
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:5,代码来源:DateInMillisAdapter.java

示例8: read

import com.google.gson.stream.JsonReader; //导入方法依赖的package包/类
/**
 * the wikipedia api doesn't use json arrays, rather a series of nested objects.
 */
@Override
public WikipediaExample.Response<X> read(JsonReader reader) throws IOException {
  WikipediaExample.Response<X> pages = new WikipediaExample.Response<X>();
  reader.beginObject();
  while (reader.hasNext()) {
    String nextName = reader.nextName();
    if ("query".equals(nextName)) {
      reader.beginObject();
      while (reader.hasNext()) {
        if (query().equals(reader.nextName())) {
          reader.beginObject();
          while (reader.hasNext()) {
            // each element is in form: "id" : { object }
            // this advances the pointer to the value and skips the key
            reader.nextName();
            reader.beginObject();
            pages.add(build(reader));
            reader.endObject();
          }
          reader.endObject();
        } else {
          reader.skipValue();
        }
      }
      reader.endObject();
    } else if ("continue".equals(nextName)) {
      reader.beginObject();
      while (reader.hasNext()) {
        if ("gsroffset".equals(reader.nextName())) {
          pages.nextOffset = reader.nextLong();
        } else {
          reader.skipValue();
        }
      }
      reader.endObject();
    } else {
      reader.skipValue();
    }
  }
  reader.endObject();
  return pages;
}
 
开发者ID:wenwu315,项目名称:XXXX,代码行数:46,代码来源:ResponseAdapter.java

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

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

示例11: 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.nextLong方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。