當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。