本文整理汇总了Java中javax.json.JsonValue.TRUE属性的典型用法代码示例。如果您正苦于以下问题:Java JsonValue.TRUE属性的具体用法?Java JsonValue.TRUE怎么用?Java JsonValue.TRUE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.json.JsonValue
的用法示例。
在下文中一共展示了JsonValue.TRUE属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: load
public void load(final Trie s) {
try (InputStream in = Files.newInputStream(filePath);
BufferedReader reader = new BufferedReader(new InputStreamReader(in))) {
String line;
final Set<Fact> facts = new TreeSet<Fact>();
while ((line = reader.readLine()) != null) {
if (line.compareTo(" ") > 0) {
try (JsonReader json = Json.createReader(new StringReader(line))) {
final JsonObject o = json.readObject();
final Fact f = new Fact(o, context);
if (o.get("deleted") == JsonValue.TRUE) {
facts.remove(f);
} else {
facts.add(f);
}
}
}
}
facts.parallelStream().forEach((f) -> s.insertAll(f, context));
context.commit();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
示例2: deserialize
@Override
public JsonValue deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) {
final JsonParser.Event next = ((JsonbRiParser)parser).getLastEvent();
switch (next) {
case VALUE_TRUE:
return JsonValue.TRUE;
case VALUE_FALSE:
return JsonValue.FALSE;
case VALUE_NULL:
return JsonValue.NULL;
case VALUE_STRING:
case VALUE_NUMBER:
return parser.getValue();
default:
throw new JsonbException(Messages.getMessage(MessageKeys.INTERNAL_ERROR, "Unknown JSON value: "+next));
}
}
示例3: getValue
@Override
public JsonValue getValue ()
{
switch (m_event)
{
case START_ARRAY:
case START_OBJECT:
return Utils.getStructure (this);
case END_ARRAY:
case END_OBJECT:
case KEY_NAME:
throw stateError ("getValue()");
case VALUE_TRUE:
return JsonValue.TRUE;
case VALUE_FALSE:
return JsonValue.FALSE;
case VALUE_NULL:
return JsonValue.NULL;
case VALUE_NUMBER:
return new CookJsonBigDecimal (getBigDecimal ());
case VALUE_STRING:
return new CookJsonString (getString ());
}
throw stateError ("getValue()");
}
示例4: mapValue
private static Boolean mapValue(JsonValue value) {
if (value == JsonValue.TRUE) {
return Boolean.TRUE;
} else if (value == JsonValue.FALSE) {
return Boolean.FALSE;
} else {
return null;
}
}
示例5: wrapValue
private JsonValue wrapValue(Object value) {
JsonValue jsonValue = null;
if (value instanceof Number) {
Number number = (Number) value;
if ((number instanceof Long) || (number instanceof Integer)) {
jsonValue = Json.createObjectBuilder()
.add(TMP, number.longValue())
.build()
.getJsonNumber(TMP);
} else {
jsonValue = Json.createObjectBuilder()
.add(TMP, number.doubleValue())
.build()
.getJsonNumber(TMP);
}
} else if (value instanceof Boolean) {
Boolean flag = (Boolean) value;
jsonValue = flag ? JsonValue.TRUE : JsonValue.FALSE;
} else if (value instanceof List) {
JsonArrayBuilder arrayBuilder = Json.createArrayBuilder();
List list = (List) value;
for (Object element : list) {
if (element instanceof String) {
arrayBuilder.add(element.toString());
} else {
JsonValue jvalue = wrapValue(element);
arrayBuilder.add(jvalue);
}
}
jsonValue = arrayBuilder.build();
}
return jsonValue;
}
示例6: getValue
@Override
public JsonValue getValue ()
{
if (m_event == null)
throw new IllegalStateException ();
switch (m_event)
{
case START_ARRAY:
case START_OBJECT:
return Utils.getStructure (this);
case VALUE_STRING:
{
if (m_value instanceof byte[])
{
CookJsonBinary v = new CookJsonBinary ((byte[]) m_value);
v.setBinaryFormat (m_binaryFormat);
return v;
}
return new CookJsonString ((String) m_value);
}
case VALUE_NUMBER:
{
if (m_value instanceof Integer)
return new CookJsonInt ((Integer)m_value);
if (m_value instanceof Long)
return new CookJsonLong ((Long)m_value);
return new CookJsonDouble ((Double) m_value);
}
case VALUE_NULL:
return JsonValue.NULL;
case VALUE_TRUE:
return JsonValue.TRUE;
case VALUE_FALSE:
return JsonValue.FALSE;
default:
throw new IllegalStateException ();
}
}