use of java.io.InvalidClassException in project mybatis-3 by mybatis.
the class AbstractSerialStateHolder method readResolve.
@SuppressWarnings("unchecked")
protected final Object readResolve() throws ObjectStreamException {
/* Second run */
if (this.userBean != null && this.userBeanBytes.length == 0) {
return this.userBean;
}
/* First run */
try {
final ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(this.userBeanBytes));
this.userBean = in.readObject();
this.unloadedProperties = (Map<String, ResultLoaderMap.LoadPair>) in.readObject();
this.objectFactory = (ObjectFactory) in.readObject();
this.constructorArgTypes = (Class<?>[]) in.readObject();
this.constructorArgs = (Object[]) in.readObject();
} catch (final IOException ex) {
throw (ObjectStreamException) new StreamCorruptedException().initCause(ex);
} catch (final ClassNotFoundException ex) {
throw (ObjectStreamException) new InvalidClassException(ex.getLocalizedMessage()).initCause(ex);
}
final Map<String, ResultLoaderMap.LoadPair> arrayProps = new HashMap<String, ResultLoaderMap.LoadPair>(this.unloadedProperties);
final List<Class<?>> arrayTypes = Arrays.asList(this.constructorArgTypes);
final List<Object> arrayValues = Arrays.asList(this.constructorArgs);
return this.createDeserializationProxy(userBean, arrayProps, objectFactory, arrayTypes, arrayValues);
}
use of java.io.InvalidClassException in project openhab1-addons by openhab.
the class EpsonProjectorGenericBindingProvider method getCommandTypeFromString.
private EpsonProjectorCommandType getCommandTypeFromString(String commandTypeString, Item item) throws BindingConfigParseException {
EpsonProjectorCommandType commandType = null;
try {
EpsonProjectorCommandType.validateBinding(commandTypeString, item.getClass());
commandType = EpsonProjectorCommandType.getCommandType(commandTypeString);
} catch (IllegalArgumentException e) {
throw new BindingConfigParseException("Invalid command type '" + commandTypeString + "'!");
} catch (InvalidClassException e) {
throw new BindingConfigParseException("Invalid item type for command type '" + commandTypeString + "'!");
}
return commandType;
}
use of java.io.InvalidClassException in project openhab1-addons by openhab.
the class AnelGenericBindingProvider method processBindingConfiguration.
/**
* {@inheritDoc}
*/
@Override
public void processBindingConfiguration(String context, Item item, String bindingConfig) throws BindingConfigParseException {
super.processBindingConfiguration(context, item, bindingConfig);
if (bindingConfig == null || bindingConfig.trim().isEmpty()) {
// empty binding - nothing to do
return;
}
final String[] segments = bindingConfig.trim().split(":");
if (segments.length != 2) {
throw new BindingConfigParseException("Invalid binding format '" + bindingConfig + "', expected: '<anelId>:<property>'");
}
final String deviceId = segments[0];
final String commandType = segments[1];
try {
AnelCommandType.validateBinding(commandType, item.getClass());
final AnelCommandType cmdType = AnelCommandType.getCommandType(commandType);
// if command type was validated successfully, add binding config
addBindingConfig(item, new AnelBindingConfig(item.getClass(), cmdType, deviceId));
} catch (IllegalArgumentException e) {
throw new BindingConfigParseException("'" + commandType + "' is not a valid Anel property");
} catch (InvalidClassException e) {
throw new BindingConfigParseException("Invalid class for Anel property '" + commandType + "'");
}
}
use of java.io.InvalidClassException in project openhab1-addons by openhab.
the class OceanicGenericBindingProvider method processBindingConfiguration.
/**
* {@inheritDoc}
*/
@Override
public void processBindingConfiguration(String context, Item item, String bindingConfig) throws BindingConfigParseException {
super.processBindingConfiguration(context, item, bindingConfig);
if (bindingConfig != null) {
OceanicBindingConfig config = new OceanicBindingConfig();
String valueSelectorString = null;
String pollingIntervalString = null;
String[] configParts = bindingConfig.trim().split(":");
if (configParts.length != 3) {
throw new BindingConfigParseException("RME binding must contain three parts separated by ':'");
}
config.serialPort = configParts[0].trim();
valueSelectorString = configParts[1].trim();
pollingIntervalString = configParts[2].trim();
try {
OceanicValueSelector.validateBinding(valueSelectorString, item);
config.valueSelector = valueSelectorString;
config.pollingInterval = Integer.parseInt(pollingIntervalString);
addBindingConfig(item, config);
} catch (IllegalArgumentException e1) {
throw new BindingConfigParseException("Invalid value selector '" + valueSelectorString + "'!");
} catch (InvalidClassException e1) {
throw new BindingConfigParseException("Invalid item type for value selector '" + valueSelectorString + "'!");
}
} else {
logger.warn("bindingConfig is NULL (item=" + item + ") -> processing bindingConfig aborted!");
}
}
use of java.io.InvalidClassException in project antlr4 by antlr.
the class ATNSerializer method decode.
public String decode(char[] data) {
data = data.clone();
// don't adjust the first value since that's the version number
for (int i = 1; i < data.length; i++) {
data[i] = (char) (data[i] - 2);
}
StringBuilder buf = new StringBuilder();
int p = 0;
int version = ATNDeserializer.toInt(data[p++]);
if (version != ATNDeserializer.SERIALIZED_VERSION) {
String reason = String.format("Could not deserialize ATN with version %d (expected %d).", version, ATNDeserializer.SERIALIZED_VERSION);
throw new UnsupportedOperationException(new InvalidClassException(ATN.class.getName(), reason));
}
UUID uuid = ATNDeserializer.toUUID(data, p);
p += 8;
if (!uuid.equals(ATNDeserializer.SERIALIZED_UUID)) {
String reason = String.format(Locale.getDefault(), "Could not deserialize ATN with UUID %s (expected %s).", uuid, ATNDeserializer.SERIALIZED_UUID);
throw new UnsupportedOperationException(new InvalidClassException(ATN.class.getName(), reason));
}
// skip grammarType
p++;
int maxType = ATNDeserializer.toInt(data[p++]);
buf.append("max type ").append(maxType).append("\n");
int nstates = ATNDeserializer.toInt(data[p++]);
for (int i = 0; i < nstates; i++) {
int stype = ATNDeserializer.toInt(data[p++]);
// ignore bad type of states
if (stype == ATNState.INVALID_TYPE)
continue;
int ruleIndex = ATNDeserializer.toInt(data[p++]);
if (ruleIndex == Character.MAX_VALUE) {
ruleIndex = -1;
}
String arg = "";
if (stype == ATNState.LOOP_END) {
int loopBackStateNumber = ATNDeserializer.toInt(data[p++]);
arg = " " + loopBackStateNumber;
} else if (stype == ATNState.PLUS_BLOCK_START || stype == ATNState.STAR_BLOCK_START || stype == ATNState.BLOCK_START) {
int endStateNumber = ATNDeserializer.toInt(data[p++]);
arg = " " + endStateNumber;
}
buf.append(i).append(":").append(ATNState.serializationNames.get(stype)).append(" ").append(ruleIndex).append(arg).append("\n");
}
// this code is meant to model the form of ATNDeserializer.deserialize,
// since both need to be updated together whenever a change is made to
// the serialization format. The "dead" code is only used in debugging
// and testing scenarios, so the form you see here was kept for
// improved maintainability.
// start
int numNonGreedyStates = ATNDeserializer.toInt(data[p++]);
for (int i = 0; i < numNonGreedyStates; i++) {
int stateNumber = ATNDeserializer.toInt(data[p++]);
}
int numPrecedenceStates = ATNDeserializer.toInt(data[p++]);
for (int i = 0; i < numPrecedenceStates; i++) {
int stateNumber = ATNDeserializer.toInt(data[p++]);
}
// finish
int nrules = ATNDeserializer.toInt(data[p++]);
for (int i = 0; i < nrules; i++) {
int s = ATNDeserializer.toInt(data[p++]);
if (atn.grammarType == ATNType.LEXER) {
int arg1 = ATNDeserializer.toInt(data[p++]);
buf.append("rule ").append(i).append(":").append(s).append(" ").append(arg1).append('\n');
} else {
buf.append("rule ").append(i).append(":").append(s).append('\n');
}
}
int nmodes = ATNDeserializer.toInt(data[p++]);
for (int i = 0; i < nmodes; i++) {
int s = ATNDeserializer.toInt(data[p++]);
buf.append("mode ").append(i).append(":").append(s).append('\n');
}
int numBMPSets = ATNDeserializer.toInt(data[p++]);
p = appendSets(buf, data, p, numBMPSets, 0, ATNDeserializer.getUnicodeDeserializer(ATNDeserializer.UnicodeDeserializingMode.UNICODE_BMP));
int numSMPSets = ATNDeserializer.toInt(data[p++]);
p = appendSets(buf, data, p, numSMPSets, numBMPSets, ATNDeserializer.getUnicodeDeserializer(ATNDeserializer.UnicodeDeserializingMode.UNICODE_SMP));
int nedges = ATNDeserializer.toInt(data[p++]);
for (int i = 0; i < nedges; i++) {
int src = ATNDeserializer.toInt(data[p]);
int trg = ATNDeserializer.toInt(data[p + 1]);
int ttype = ATNDeserializer.toInt(data[p + 2]);
int arg1 = ATNDeserializer.toInt(data[p + 3]);
int arg2 = ATNDeserializer.toInt(data[p + 4]);
int arg3 = ATNDeserializer.toInt(data[p + 5]);
buf.append(src).append("->").append(trg).append(" ").append(Transition.serializationNames.get(ttype)).append(" ").append(arg1).append(",").append(arg2).append(",").append(arg3).append("\n");
p += 6;
}
int ndecisions = ATNDeserializer.toInt(data[p++]);
for (int i = 0; i < ndecisions; i++) {
int s = ATNDeserializer.toInt(data[p++]);
buf.append(i).append(":").append(s).append("\n");
}
if (atn.grammarType == ATNType.LEXER) {
// this code is meant to model the form of ATNDeserializer.deserialize,
// since both need to be updated together whenever a change is made to
// the serialization format. The "dead" code is only used in debugging
// and testing scenarios, so the form you see here was kept for
// improved maintainability.
int lexerActionCount = ATNDeserializer.toInt(data[p++]);
for (int i = 0; i < lexerActionCount; i++) {
LexerActionType actionType = LexerActionType.values()[ATNDeserializer.toInt(data[p++])];
int data1 = ATNDeserializer.toInt(data[p++]);
int data2 = ATNDeserializer.toInt(data[p++]);
}
}
return buf.toString();
}
Aggregations