- private static class MirrorVectorHandler implements DBFieldHandler.SqlOp {
- public Object get(ResultSet rs, int index) throws Exception {
- String val = rs.getString(index);
- if (val == null) {
- return(null);
- }
- Set<ReplicationVector> rv = new HashSet<ReplicationVector>();
- for (String s: val.split(",")) {
- String[] f = s.split(";");
- if (f.length < 3) {
- continue;
- }
- rv.add(new ReplicationVector(DBFieldHandler.funesc(f[0]), DBFieldHandler.funesc(f[1]), DBFieldHandler.funesc(f[2])));
- }
- return(rv);
- }
- public void set(PreparedStatement ps, int index, Object val) throws Exception {
- if (val == null) {
- ps.setString(index, null);
- return;
- }
- Set xv = (Set)val;
- StringBuffer sb = new StringBuffer();
- String sep = "";
- for (Object o: xv) {
- ReplicationVector rv = (ReplicationVector)o;
- sb.append(sep).append(DBFieldHandler.fesc(rv.getFqtn())).append(';').append(DBFieldHandler.fesc(rv.getSourceCluster())).append(';').append(DBFieldHandler.fesc(rv.getTargetCluster()));
- sep = ",";
- }
- ps.setString(index, sb.toString());
- }
- }