/** * Create a table value * * @param type the type * @param value the value * @param mapping the mapping * @return the table value */ @SuppressWarnings("unchecked") public TableValue createTableValue(TableMetaType type, Map value, Map<Object, MetaValue> mapping) { if (value == null) return null; TableValueSupport table = new TableValueSupport(type); mapping.put(value, table); CompositeMetaType entryType = type.getRowType(); MetaType keyType = entryType.getType(DefaultMetaTypeFactory.MAP_KEY); MetaType valType = entryType.getType(DefaultMetaTypeFactory.MAP_VALUE); for (Iterator<Map.Entry> i = value.entrySet().iterator(); i.hasNext();) { Map.Entry entry = i.next(); MetaValue key = internalCreate(entry.getKey(), null, keyType); MetaValue val = internalCreate(entry.getValue(), null, valType); CompositeValueSupport data = new CompositeValueSupport(entryType, DefaultMetaTypeFactory.MAP_ITEM_NAMES, new MetaValue[] { key, val }); table.put(data); } return table; }
/** * Create a table value * * @param type the type * @param value the value * @param mapping the mapping * @return the table value */ @SuppressWarnings("unchecked") public TableValue createTableValue(TableMetaType type, Map value, Map<Object, MetaValue> mapping) { if (value == null) return null; TableValueSupport table = new TableValueSupport(type); mapping.put(value, table); CompositeMetaType entryType = type.getRowType(); MetaType keyType = entryType.getType(DefaultMetaTypeFactory.MAP_KEY); MetaType valType = entryType.getType(DefaultMetaTypeFactory.MAP_VALUE); for (Iterator<Map.Entry> i = value.entrySet().iterator(); i.hasNext();) { Map.Entry entry = i.next(); MetaValue key = internalCreate(entry.getKey(), null, keyType); MetaValue val = internalCreate(entry.getValue(), null, valType); CompositeValueSupport data = new CompositeValueSupport(entryType, DefaultMetaTypeFactory.MAP_ITEM_NAMES, new MetaValue[] { key, val }); table.put(data); } return table; }
/** * Create the table value. * * @param table the persisted table value * @param type the table meta type * @return the table value */ protected TableValue createTableValue(PersistedTableValue table, TableMetaType type) { TableValueSupport support = new TableValueSupport(type); if(table.getEntries() != null && table.getEntries().isEmpty() == false) { for(PersistedCompositeValue entry : table.getEntries()) { support.put(createCompositeValue(entry, type.getRowType())); } } return support; }