@Override public TabularData getConnectionList() throws JMException { CompositeType rowType = JdbcConnectionStat.Entry.getCompositeType(); String[] indexNames = rowType.keySet().toArray(new String[rowType.keySet().size()]); TabularType tabularType = new TabularType("ConnectionListStatistic", "ConnectionListStatistic", rowType, indexNames); TabularData data = new TabularDataSupport(tabularType); for (Map.Entry<Long, JdbcConnectionStat.Entry> entry : getConnections().entrySet()) { data.put(entry.getValue().getCompositeData()); } return data; }
@Override public TabularData getSqlList() throws JMException { Map<String, JdbcSqlStat> sqlStatMap = this.getSqlStatMap(); CompositeType rowType = JdbcSqlStat.getCompositeType(); String[] indexNames = rowType.keySet().toArray(new String[rowType.keySet().size()]); TabularType tabularType = new TabularType("SqlListStatistic", "SqlListStatistic", rowType, indexNames); TabularData data = new TabularDataSupport(tabularType); for (Map.Entry<String, JdbcSqlStat> entry : sqlStatMap.entrySet()) { data.put(entry.getValue().getCompositeData()); } return data; }
public TabularData getDataSourceList() throws JMException { CompositeType rowType = getDruidDataSourceCompositeType(); String[] indexNames = rowType.keySet().toArray(new String[rowType.keySet().size()]); TabularType tabularType = new TabularType("DruidDataSourceStat", "DruidDataSourceStat", rowType, indexNames); TabularData data = new TabularDataSupport(tabularType); final Set<Object> dataSources = getInstances().keySet(); for (Object dataSource : dataSources) { data.put(getCompositeData(dataSource)); } return data; }
protected static StringBuffer recurseCompositeData(StringBuffer buffer, String indent, String name, CompositeData data) { indent = addNameToBuffer(buffer, indent, name); for (Iterator i = data.getCompositeType().keySet().iterator(); i.hasNext();) { String key = (String) i.next(); Object o = data.get(key); if (o instanceof CompositeData) { recurseCompositeData(buffer, indent + " ", key, (CompositeData) o); } else if (o instanceof TabularData) { recurseTabularData(buffer, indent, key, (TabularData) o); } else { buffer.append(indent); buffer.append(key); buffer.append(": "); buffer.append(o); buffer.append("\n"); } } return buffer; }
private Map<String, Object> toNeo4jValue( CompositeData composite ) { HashMap<String,Object> properties = new HashMap<>(); for ( String key : composite.getCompositeType().keySet() ) { properties.put( key, toNeo4jValue(composite.get( key )) ); } return map( "description", composite.getCompositeType().getDescription(), "properties", properties ); }
/** * Recursively extracts simple numeric values from composite data objects. * The map {@code values} will be populated with a path to the value as * the key and the simple object as the value. */ private void extractValues(String path, Map<String, Object> values, CompositeData obj) { for (String key : obj.getCompositeType().keySet()) { String newPath = (path == null) ? key : path + "." + key; Object value = obj.get(key); if (value instanceof CompositeData) { extractValues(newPath, values, (CompositeData) value); } else if (value != null) { values.put(newPath, value); } } }
@Mapping( "value" ) public ListRepresentation getValue() { ArrayList<Representation> values = new ArrayList<>(); for ( Object key : data.getCompositeType().keySet() ) { String name = key.toString(); String description = data.getCompositeType().getDescription( name ); Representation value = REPRESENTATION_DISPATCHER.dispatch( data.get( name ), "" ); values.add( new NameDescriptionValueRepresentation( name, description, value ) ); } return new ListRepresentation( "value", values ); } }
@Override public TabularData getDataSourceList() throws JMException { CompositeType rowType = getDataSourceCompositeType(); String[] indexNames = rowType.keySet().toArray(new String[rowType.keySet().size()]); TabularType tabularType = new TabularType("DataSourceStat", "DataSourceStat", rowType, indexNames); TabularData data = new TabularDataSupport(tabularType); { final ConcurrentMap<String, DataSourceProxyImpl> dataSources = DruidDriver.getProxyDataSources(); for (DataSourceProxyImpl dataSource : dataSources.values()) { data.put(dataSource.getCompositeData()); } } final Set<DruidDataSource> dataSources = DruidDataSourceStatManager.getDruidDataSourceInstances(); for (DruidDataSource dataSource : dataSources) { data.put(dataSource.getCompositeData()); } return data; }
public TabularData getConnectionList() throws JMException { CompositeType rowType = JdbcConnectionStat.Entry.getCompositeType(); String[] indexNames = rowType.keySet().toArray(new String[rowType.keySet().size()]); TabularType tabularType = new TabularType("ConnectionList", "ConnectionList", rowType, indexNames); TabularData data = new TabularDataSupport(tabularType); final ConcurrentMap<String, DataSourceProxyImpl> dataSources = DruidDriver.getProxyDataSources(); for (DataSourceProxyImpl dataSource : dataSources.values()) { JdbcDataSourceStat dataSourceStat = dataSource.getDataSourceStat(); ConcurrentMap<Long, JdbcConnectionStat.Entry> connections = dataSourceStat.getConnections(); for (Map.Entry<Long, JdbcConnectionStat.Entry> entry : connections.entrySet()) { data.put(entry.getValue().getCompositeData()); } } for (DruidDataSource instance : DruidDataSourceStatManager.getDruidDataSourceInstances()) { JdbcDataSourceStat dataSourceStat = instance.getDataSourceStat(); ConcurrentMap<Long, JdbcConnectionStat.Entry> connections = dataSourceStat.getConnections(); for (Map.Entry<Long, JdbcConnectionStat.Entry> entry : connections.entrySet()) { data.put(entry.getValue().getCompositeData()); } } return data; }
public void output(String name, Object attr) { CompositeDataSupport cds; if (attr instanceof CompositeDataSupport) { cds = (CompositeDataSupport) attr; for (String key : cds.getCompositeType().keySet()) { log.info(name + "." + key + ".value " + format(cds.get(key))); } } else { log.info(name + ".value " + format(attr)); } }
CompositeData cds = (CompositeData)value; CompositeType comp = cds.getCompositeType(); Set<String> keys = comp.keySet(); jg.writeStartObject(); for (String key: keys) {
CompositeData cds = (CompositeData)value; CompositeType comp = cds.getCompositeType(); Set<String> keys = comp.keySet(); jg.writeStartObject(); for(String key: keys) {
private Object convertValueIfNeeded(Object value) { if (value instanceof CompositeData) { final CompositeData data = (CompositeData) value; final Map<String, Object> values = new TreeMap<String, Object>(); for (final String key : data.getCompositeType().keySet()) { values.put(key, convertValueIfNeeded(data.get(key))); } return values; } else if (value instanceof CompositeData[]) { final List<Object> list = new ArrayList<Object>(); for (final CompositeData data : (CompositeData[]) value) { list.add(convertValueIfNeeded(data)); } return list; } else if (value instanceof Object[]) { return Arrays.asList((Object[]) value); } else if (value instanceof TabularData) { final TabularData tabularData = (TabularData) value; return convertValueIfNeeded(tabularData.values()); } else if (value instanceof Collection) { final List<Object> list = new ArrayList<Object>(); for (final Object data : (Collection<?>) value) { list.add(convertValueIfNeeded(data)); } return list; } return convertJRockitValueIfNeeded(value); }
+ "items: " + ct.keySet(); throw new InvalidObjectException(msg);
/** * Add results from a value of type composite data. * This is a recursive function. */ private void add(String attributeName, ImmutableList.Builder<String> valuePath, CompositeData cds) { CompositeType t = cds.getCompositeType(); Set<String> keys = t.keySet(); for (String key : keys) { if (!query.getKeys().isEmpty() && !query.getKeys().contains(key)) { continue; } Object value = cds.get(key); add(attributeName, newValuePath(valuePath, key), value); } }
for(String f: td[0].getCompositeType().keySet()) { if (!header.contains(f)) { header.add(f); td.getTabularType().getIndexNames(); List<String> header = new ArrayList<String>(td.getTabularType().getIndexNames()); for(String f: td.getTabularType().getRowType().keySet()) { if (!header.contains(f)) { header.add(f); CompositeData cd = (CompositeData)v; List<String[]> content = new ArrayList<String[]>(); for(String field: cd.getCompositeType().keySet()) { String val = formatLine(cd.get(field), cd.getCompositeType().getType(field).getClassName()); content.add(new String[]{field + ": ", val});
public void writeCompositeData(CompositeData compositeData) { if (compositeData == null) { writeNull(); return; } int entryIndex = 0; write('{'); for (Object key : compositeData.getCompositeType().keySet()) { if (entryIndex != 0) { write(','); } writeString((String) key); write(':'); Object value = compositeData.get((String) key); writeObject(value); entryIndex++; } write('}'); }
CompositeData cds = (CompositeData)value; CompositeType comp = cds.getCompositeType(); Set<String> keys = comp.keySet(); jg.writeStartObject(); for(String key: keys) {
CompositeData cds = (CompositeData)value; CompositeType comp = cds.getCompositeType(); Set<String> keys = comp.keySet(); jg.writeStartObject(); for(String key: keys) {