@Override public Long deserialize( JsonValue json, BiFunction<JsonValue, ValueType, Object> deserialize ) { switch( json.getValueType() ) { case NULL: return null; case NUMBER: return ( (JsonNumber) json ).longValueExact(); case STRING: String string = ( (JsonString) json ).getString(); return string.isEmpty() ? 0L : Long.parseLong( string ); default: throw new SerializationException( "Don't know how to deserialize Long from " + json ); } } }
@Override public Long deserialize( JsonValue json, BiFunction<JsonValue, ValueType, Object> deserialize ) { switch( json.getValueType() ) { case NULL: return null; case NUMBER: return ( (JsonNumber) json ).longValueExact(); case STRING: String string = ( (JsonString) json ).getString(); return string.isEmpty() ? 0L : Long.parseLong( string ); default: throw new SerializationException( "Don't know how to deserialize Long from " + json ); } } }
/** {@inheritDoc} */ @Override @Nonnull public SPSession deserialize(final long version, @Nonnull @NotEmpty final String context, @Nonnull @NotEmpty final String key, @Nonnull @NotEmpty final String value, @Nullable final Long expiration) throws IOException { if (expiration == null) { throw new IOException("SPSession objects must have an expiration"); } try { final JsonReader reader = Json.createReader(new StringReader(value)); final JsonStructure st = reader.read(); if (!(st instanceof JsonObject)) { throw new IOException("Found invalid data structure while parsing SPSession"); } final JsonObject obj = (JsonObject) st; final String serviceId = obj.getString(SERVICE_ID_FIELD); final long creation = obj.getJsonNumber(CREATION_INSTANT_FIELD).longValueExact(); return doDeserialize(obj, serviceId, creation, expiration - expirationOffset); } catch (final NullPointerException | ClassCastException | ArithmeticException | JsonException e) { log.error("Exception while parsing SPSession", e); throw new IOException("Found invalid data structure while parsing SPSession", e); } }
if (number.isIntegral()) { try { long l = number.longValueExact(); if (l < Integer.MIN_VALUE || l > Integer.MAX_VALUE) { return longConverter;
if (number.isIntegral()) { try { long l = number.longValueExact(); if (l < Integer.MIN_VALUE || l > Integer.MAX_VALUE) { return longConverter;
if (number.isIntegral()) { try { long l = number.longValueExact(); if (l < Integer.MIN_VALUE || l > Integer.MAX_VALUE) { return longConverter;
msg = "customInteger value is null or not integral, FAIL"; else if(customValue.longValueExact() == value) { msg = "customInteger PASS"; pass = true;
Long exp = null; if (fields.containsKey("x")) { exp = fields.getJsonNumber("x").longValueExact();
msg = "customInteger value is null or not integral, FAIL"; else if(customValue.longValueExact() == value) { msg = "customInteger PASS"; pass = true;
final JsonObject to = reader.readObject(); final String service = to.getString(SERVICE_FIELD); final Instant expiry = new Instant(to.getJsonNumber(EXPIRATION_FIELD).longValueExact()); final JsonObject so = to.getJsonObject(STATE_FIELD); final TicketState state; so.getString(SESSION_FIELD), so.getString(PRINCIPAL_FIELD), new Instant(so.getJsonNumber(AUTHN_INSTANT_FIELD).longValueExact()), so.getString(AUTHN_METHOD_FIELD)); } else {
write(name, number.longValueExact()); } else { write(name, number.bigDecimalValue());
write(name, number.longValueExact()); } else { write(name, number.bigDecimalValue());
write(number.longValueExact()); } else { write(number.bigDecimalValue());
write(name, number.longValueExact()); } else { write(name, number.bigDecimalValue());
write(number.longValueExact()); } else { write(number.bigDecimalValue());
write(number.longValueExact()); } else { write(number.bigDecimalValue());
write(number.longValueExact()); } else { write(number.bigDecimalValue());
if (number.isIntegral()) { try { long l = number.longValueExact(); if (l < Integer.MIN_VALUE || l > Integer.MAX_VALUE) { return l;
private EntityState fetchCachedState( EntityReference reference, ModuleDescriptor module, Instant currentTime ) { CacheState cacheState = cache.get( reference.identity().toString() ); if( cacheState != null ) { JsonObject state = jsonFactories.readerFactory().createReader( new StringReader( cacheState.string ) ) .readObject(); try { String type = state.getString( JSONKeys.TYPE ); EntityDescriptor entityDescriptor = module.entityDescriptor( type ); String version = state.getString( JSONKeys.VERSION ); Instant modified = Instant.ofEpochMilli( state.getJsonNumber( JSONKeys.MODIFIED ).longValueExact() ); return new JSONEntityState( entityDescriptor.module(), serialization, jsonFactories, version, modified, reference, EntityStatus.LOADED, entityDescriptor, state ); } catch( Exception e ) { // Should not be able to happen, unless internal error in the cache system. throw new EntityStoreException( e ); } } return null; }
private EntityState fetchCachedState( EntityReference reference, ModuleDescriptor module, Instant currentTime ) { CacheState cacheState = cache.get( reference.identity().toString() ); if( cacheState != null ) { JsonObject state = jsonFactories.readerFactory().createReader( new StringReader( cacheState.string ) ) .readObject(); try { String type = state.getString( JSONKeys.TYPE ); EntityDescriptor entityDescriptor = module.entityDescriptor( type ); String version = state.getString( JSONKeys.VERSION ); Instant modified = Instant.ofEpochMilli( state.getJsonNumber( JSONKeys.MODIFIED ).longValueExact() ); return new JSONEntityState( entityDescriptor.module(), serialization, jsonFactories, version, modified, reference, EntityStatus.LOADED, entityDescriptor, state ); } catch( Exception e ) { // Should not be able to happen, unless internal error in the cache system. throw new EntityStoreException( e ); } } return null; }