org.apache.commons.lang3.SerializationException源码实例Demo

类org.apache.commons.lang3.SerializationException源码实例Demo

下面列出了org.apache.commons.lang3.SerializationException 类实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: flow   文件: SerializeUIView.java
public SerializeUIView() {
    Div label = new Div();
    label.setId("message");

    NativeButton button = createButton("Serialize", "serialize", event -> {
        UI ui = UI.getCurrent();
        try {
            byte[] serialize = SerializationUtils.serialize(ui);

            String result = serialize.length > 0 ?
                    "Successfully serialized ui" :
                    "Serialization failed";
            label.setText(result);
        }catch(SerializationException se) {
            label.setText(se.getMessage());
        }
    });

    add(label, button);
}
 
源代码2 项目: hdw-dubbo   文件: ShiroRedisSerializer.java
public Object deserialize(byte[] bytes) {
    if (isEmpty(bytes)) {
        return null;
    }
    try {
        return deserializer.convert(bytes);
    } catch (Exception ex) {
        throw new SerializationException("Cannot deserialize", ex);
    }
}
 
源代码3 项目: rheem   文件: AtomicExecution.java
/**
 * Deserialize a {@link LoadProfileEstimator} according to {@link #serialize(LoadProfileEstimator, JSONArray)}.
 *
 * @param jsonObject that should be deserialized
 * @return the {@link LoadProfileEstimator}
 */
private LoadProfileEstimator deserializeEstimator(JSONObject jsonObject) {
    if (jsonObject.has("key")) {
        final String key = jsonObject.getString("key");
        final LoadProfileEstimator estimator = LoadProfileEstimators.createFromSpecification(key, this.configuration);
        if (estimator == null) {
            throw new SerializationException("Could not create estimator for key " + key);
        }
        return estimator;
    } else if (jsonObject.has("load")) {
        final LoadProfile load = JsonSerializables.deserialize(jsonObject.getJSONObject("load"), LoadProfile.class);
        return new ConstantLoadProfileEstimator(load);
    }
    throw new SerializationException(String.format("Cannot deserialize load estimator from %s.", jsonObject));
}
 
源代码4 项目: rheem   文件: JsonSerializer.java
/**
 * Deserializes an object.
 *
 * @param json that should be serialized
 * @return the deserialized object
 */
@SuppressWarnings("unchecked")
default T deserialize(JSONObject json) {
    if (JsonSerializables.isJsonNull(json)) return null;
    try {
        final Class<?> classTag = JsonSerializables.getClassTag(json);
        if (classTag == null) {
            throw new IllegalArgumentException(String.format("Cannot determine class from %s.", json));
        }
        return this.deserialize(json, (Class<? extends T>) classTag);
    } catch (ClassNotFoundException e) {
        throw new SerializationException("Could not load class.", e);
    }
}
 
源代码5 项目: RobotBuilder   文件: Utils.java
/**
 * Performs a deep copy of the given object. This method is preferable to
 * the more general version because that relies on the object having a
 * default (zero-argument) constructor; however, this method only works for
 * serializable objects.
 *
 * @param <T> the type of the object to copy and return
 * @param original the object to copy
 * @return a deep copy of the given object
 */
public static <T extends Serializable> T deepCopy(T original) {
    if (original == null) {
        return null;
    }
    try {
        return SerializationUtils.clone(original);
    } catch (SerializationException notSerializable) {
        return (T) deepCopy((Object) original);
    }
}
 
源代码6 项目: pravega   文件: RevisionImpl.java
public static Revision fromString(String scopedName) {
    String[] tokens = scopedName.split(":");
    if (tokens.length == 3) {
        return new RevisionImpl(Segment.fromScopedName(tokens[0]), Long.parseLong(tokens[1]), Integer.parseInt(tokens[2]));
    } else {
        throw new SerializationException("Not a valid segment name: " + scopedName);
    }
}
 
源代码7 项目: x-pipe   文件: MetaClone.java
public static <T extends Serializable> T clone(T obj){
	try {
		return SerializationUtils.clone(obj);
	}catch (SerializationException e){
		logger.error("[clone]", e);
		throw e;
	}
}
 
源代码8 项目: x-pipe   文件: CatTest.java
@Test
/**
 * -Dlog4j.configurationFile=log4j2cat.xml
 */
public void testException() throws IOException {

	logger.error("[testException]", new SerializationException("exception"));

	waitForAnyKeyToExit();

}
 
源代码9 项目: incubator-gobblin   文件: JavaSpecSerDe.java
@Override
public byte[] serialize(Spec spec) throws SpecSerDeException {
  try {
    return SerializationUtils.serialize(spec);
  } catch (SerializationException e) {
    throw new SpecSerDeException(spec, e);
  }
}
 
源代码10 项目: incubator-gobblin   文件: JavaSpecSerDe.java
@Override
public Spec deserialize(byte[] spec) throws SpecSerDeException {
  try {
    return SerializationUtils.deserialize(spec);
  } catch (SerializationException e) {
    throw new SpecSerDeException(e);
  }
}
 
源代码11 项目: localization_nifi   文件: TestServerAndClient.java
@Override
public void serialize(final String value, final OutputStream output) throws SerializationException, IOException {
    output.write(value.getBytes(StandardCharsets.UTF_8));
}
 
源代码12 项目: james-project   文件: SerializationUtilTest.java
@Test
void deserializeShouldThrowWhenNotBase64StringProvided() {
    assertThatExceptionOfType(SerializationException.class)
            .isThrownBy(() -> deserialize("abc"));
}
 
源代码13 项目: james-project   文件: SerializationUtilTest.java
@Test
void deserializeShouldThrowWhenNotSerializedBytesAreEncodedInBase64() {
    assertThatExceptionOfType(SerializationException.class)
            .isThrownBy(() -> deserialize(Base64.getEncoder().encodeToString("abc".getBytes(StandardCharsets.UTF_8))));
}
 
源代码14 项目: nifi   文件: TestServerAndClient.java
@Override
public void serialize(final String value, final OutputStream output) throws SerializationException, IOException {
    output.write(value.getBytes(StandardCharsets.UTF_8));
}
 
源代码15 项目: rheem   文件: JsonSerializables.java
/**
 * Deserialize a given JSON datatype. The following cases are supported:
 * <ul>
 * <li>{@code json} is a (JSON) {@code null} value;</li>
 * <li>{@code json} is a basic (JSON) datatype;</li>
 * <li>{@code json} is a {@link Class}-tagged {@link JSONObject} that corresponds to a {@link JsonSerializable};</li>
 * <li>{@code json} is a {@link JSONArray} with {@link Class}-tagged {@link JSONObject}s that correspond to a
 * {@link JsonSerializable}s - in this case, the result type is a {@link List}.</li>
 * </ul>
 *
 * @param json the JSON data
 * @return the deserialization result
 */
public static Object deserialize(Object json) {
    if (isJsonNull(json)) return null;
    else if (isUnconvertedInstance(json)) return json;
    else if (json instanceof JSONObject) return deserialize((JSONObject) json);
    else if (json instanceof JSONArray) return deserializeAllAsList((JSONArray) json);

    throw new SerializationException(String.format("Don't know how to deserialize %s.", json));
}
 
源代码评论
动弹
沙发等你来抢
 类所在包
 类方法
 同包方法