List of usage examples for java.io InvalidClassException InvalidClassException
public InvalidClassException(String cname, String reason)
From source file:hd3gtv.mydmam.db.orm.CassandraOrm.java
public void pushColumn(String rowkey, Integer ttl, String name, Object o) throws InvalidClassException, ConnectionException { if (rowkey == null) { return;// w w w.j av a2 s . co m } if (rowkey.equals("")) { return; } if (mutator == null) { mutator = CassandraDb.prepareMutationBatch(); } if (ttl == 0) { ttl = null; } if (o == null) { mutator.withRow(columnfamily, rowkey).putColumn(name, null_value, ttl); } else if (o instanceof String) { if (((String) o).equals(null_value)) { StringBuffer sb = new StringBuffer(); sb.append("String value equals to null String reference : security problem ?"); sb.append("["); sb.append(rowkey); sb.append("]"); sb.append(name); throw new InvalidClassException(o.getClass().getName(), sb.toString()); } mutator.withRow(columnfamily, rowkey).putColumn(name, (String) o, ttl); } else if (o instanceof byte[]) { mutator.withRow(columnfamily, rowkey).putColumn(name, (byte[]) o, ttl); } else if (o instanceof Integer) { mutator.withRow(columnfamily, rowkey).putColumn(name, (Integer) o, ttl); } else if (o instanceof Long) { mutator.withRow(columnfamily, rowkey).putColumn(name, (Long) o, ttl); } else if (o instanceof Boolean) { if ((Boolean) o) { mutator.withRow(columnfamily, rowkey).putColumn(name, "true", ttl); } else { mutator.withRow(columnfamily, rowkey).putColumn(name, "false", ttl); } } else if (o instanceof Date) { mutator.withRow(columnfamily, rowkey).putColumn(name, (Date) o, ttl); } else if (o instanceof Float) { mutator.withRow(columnfamily, rowkey).putColumn(name, String.valueOf((Float) o), ttl); } else if (o instanceof Double) { mutator.withRow(columnfamily, rowkey).putColumn(name, String.valueOf((Double) o), ttl); } else if (o instanceof UUID) { mutator.withRow(columnfamily, rowkey).putColumn(name, (UUID) o, ttl); } else if (o instanceof JSONObject) { mutator.withRow(columnfamily, rowkey).putColumn(name, ((JSONObject) o).toJSONString(), ttl); } else if (o instanceof JSONArray) { mutator.withRow(columnfamily, rowkey).putColumn(name, ((JSONArray) o).toJSONString(), ttl); } else if (o instanceof InetAddress) { mutator.withRow(columnfamily, rowkey).putColumn(name, ((InetAddress) o).getHostAddress(), ttl); } else if (o instanceof StringBuffer) { mutator.withRow(columnfamily, rowkey).putColumn(name, ((StringBuffer) o).toString(), ttl); } else if (o instanceof Calendar) { mutator.withRow(columnfamily, rowkey).putColumn(name, ((Calendar) o).getTimeInMillis(), ttl); } else if (o instanceof String[]) { JSONArray ja = new JSONArray(); String[] o_str = (String[]) o; for (int pos = 0; pos < o_str.length; pos++) { ja.add(o_str[pos]); } mutator.withRow(columnfamily, rowkey).putColumn(name, ja.toJSONString(), ttl); } else if (o instanceof Serializable) { mutator.withRow(columnfamily, rowkey).putColumn(name, serialize(o), ttl); } else if (o instanceof Enum) { mutator.withRow(columnfamily, rowkey).putColumn(name, serialize(o), ttl); } else { StringBuffer sb = new StringBuffer(); sb.append("Class type is not managed for this record "); sb.append("["); sb.append(rowkey); sb.append("]"); sb.append(name); throw new InvalidClassException(o.getClass().getName(), sb.toString()); } }