本文整理匯總了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 ();
}
}