List of usage examples for java.util SortedMap get
V get(Object key);
From source file:io.wcm.caravan.commons.httpclient.impl.BeanUtil.java
/** * Get map with key/value pairs for properties of a java bean (using {@link BeanUtils#describe(Object)}). * An array of property names can be passed that should be masked with "***" because they contain sensitive * information./* w w w . ja v a 2s . c om*/ * @param beanObject Bean object * @param maskProperties List of property names * @return Map with masked key/value pairs */ public static SortedMap<String, Object> getMaskedBeanProperties(Object beanObject, String[] maskProperties) { try { SortedMap<String, Object> configProperties = new TreeMap<String, Object>( BeanUtils.describe(beanObject)); // always ignore "class" properties which is added by BeanUtils.describe by default configProperties.remove("class"); // Mask some properties with confidential information (if set to any value) if (maskProperties != null) { for (String propertyName : maskProperties) { if (configProperties.containsKey(propertyName) && configProperties.get(propertyName) != null) { configProperties.put(propertyName, "***"); } } } return configProperties; } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException ex) { throw new IllegalArgumentException("Unable to get properties from: " + beanObject, ex); } }
From source file:org.apache.hadoop.hbase.regionserver.ccindex.IndexMaintenanceUtils.java
public static Put createIndexUpdateWithoutUpdateIndex(final IndexSpecification indexSpec, final byte[] row, final SortedMap<byte[], byte[]> columnValues) { byte[] indexRow = indexSpec.getKeyGenerator().createIndexKey(row, columnValues); Put update = new Put(indexRow); // update.add(IndexedTable.INDEX_COL_FAMILY_NAME, // IndexedTable.INDEX_BASE_ROW, row); try {//from w ww.j av a 2 s . c o m for (byte[] col : indexSpec.getAdditionalColumns()) { byte[] val = columnValues.get(col); if (val != null) { byte[][] colSeperated = HStoreKey.parseColumn(col); update.add(colSeperated[0], colSeperated[1], val); } } } catch (ColumnNameParseException e) { throw new RuntimeException(e); } return update; }
From source file:org.apache.hadoop.hbase.regionserver.ccindex.IndexMaintenanceUtils.java
public static Put createIndexUpdate(final IndexSpecification indexSpec, final byte[] row, final SortedMap<byte[], byte[]> columnValues) { byte[] indexRow = indexSpec.getKeyGenerator().createIndexKey(row, columnValues); Put update = new Put(indexRow); // update.add(IndexedTable.INDEX_COL_FAMILY_NAME, // IndexedTable.INDEX_BASE_ROW, row); try {// w w w . j av a 2 s . c o m for (byte[] col : indexSpec.getIndexedColumns()) { byte[] val = columnValues.get(col); if (val == null) { throw new RuntimeException("Unexpected missing column value. [" + Bytes.toString(col) + "]"); } byte[][] colSeperated = HStoreKey.parseColumn(col); update.add(colSeperated[0], colSeperated[1], val); } for (byte[] col : indexSpec.getAdditionalColumns()) { byte[] val = columnValues.get(col); if (val != null) { byte[][] colSeperated = HStoreKey.parseColumn(col); update.add(colSeperated[0], colSeperated[1], val); } } } catch (ColumnNameParseException e) { throw new RuntimeException(e); } return update; }
From source file:org.apache.hadoop.hbase.regionserver.ccindex.IndexMaintenanceUtils.java
public static Put createBaseCCTUpdate(final byte[] row, final SortedMap<byte[], byte[]> columnValues, final IndexedTableDescriptor des) { Put update = new Put(row); // update.add(IndexedTable.INDEX_COL_FAMILY_NAME, // IndexedTable.INDEX_BASE_ROW, row); try {/*from w w w .j av a 2 s .c om*/ for (IndexSpecification spec : des.getIndexes()) { for (byte[] col : spec.getIndexedColumns()) { byte[] val = columnValues.get(col); if (val != null) { byte[][] colSeperated = HStoreKey.parseColumn(col); update.add(colSeperated[0], colSeperated[1], val); } } } } catch (ColumnNameParseException e) { throw new RuntimeException(e); } return update; }
From source file:com.espertech.esper.core.start.EPStatementStartMethodHelperPrior.java
private static void handlePrior(ViewUpdatedCollection viewUpdatedCollection, SortedMap<Integer, List<ExprPriorNode>> callbacksPerIndex, Map<ExprPriorNode, ExprPriorEvalStrategy> strategies) { // Since an expression such as "prior(2, price), prior(8, price)" translates // into {2, 8} the relative index is {0, 1}. // Map the expression-supplied index to a relative viewUpdatedCollection-known index via wrapper int relativeIndex = 0; for (int reqIndex : callbacksPerIndex.keySet()) { List<ExprPriorNode> priorNodes = callbacksPerIndex.get(reqIndex); for (ExprPriorNode callback : priorNodes) { ExprPriorEvalStrategy strategy; if (viewUpdatedCollection instanceof RelativeAccessByEventNIndex) { RelativeAccessByEventNIndex relativeAccess = (RelativeAccessByEventNIndex) viewUpdatedCollection; PriorEventViewRelAccess impl = new PriorEventViewRelAccess(relativeAccess, relativeIndex); strategy = new ExprPriorEvalStrategyRelativeAccess(impl); } else { if (viewUpdatedCollection instanceof RandomAccessByIndex) { strategy = new ExprPriorEvalStrategyRandomAccess( (RandomAccessByIndex) viewUpdatedCollection); } else { strategy = new ExprPriorEvalStrategyRelativeAccess( (RelativeAccessByEventNIndex) viewUpdatedCollection); }/*from ww w. ja v a 2s . c o m*/ } strategies.put(callback, strategy); } relativeIndex++; } }
From source file:org.apache.cassandra.tools.NodeTool.java
public static SortedMap<String, SetHostStat> getOwnershipByDc(NodeProbe probe, boolean resolveIp, Map<String, String> tokenToEndpoint, Map<InetAddress, Float> ownerships) { SortedMap<String, SetHostStat> ownershipByDc = Maps.newTreeMap(); EndpointSnitchInfoMBean epSnitchInfo = probe.getEndpointSnitchInfoProxy(); try {/*from ww w . j a v a2 s . co m*/ for (Entry<String, String> tokenAndEndPoint : tokenToEndpoint.entrySet()) { String dc = epSnitchInfo.getDatacenter(tokenAndEndPoint.getValue()); if (!ownershipByDc.containsKey(dc)) ownershipByDc.put(dc, new SetHostStat(resolveIp)); ownershipByDc.get(dc).add(tokenAndEndPoint.getKey(), tokenAndEndPoint.getValue(), ownerships); } } catch (UnknownHostException e) { throw new RuntimeException(e); } return ownershipByDc; }
From source file:org.apache.hadoop.hbase.regionserver.ccindex.IndexMaintenanceUtils.java
public static Put createCCTUpdate(final IndexSpecification indexSpec, final byte[] row, final SortedMap<byte[], byte[]> columnValues, final IndexedTableDescriptor des) { byte[] indexRow = indexSpec.getKeyGenerator().createIndexKey(row, columnValues); Put update = new Put(indexRow); // update.add(IndexedTable.INDEX_COL_FAMILY_NAME, // IndexedTable.INDEX_BASE_ROW, row); try {//from w w w . j av a 2s .com for (IndexSpecification spec : des.getIndexes()) { for (byte[] col : spec.getIndexedColumns()) { byte[] val = columnValues.get(col); if (val != null) { byte[][] colSeperated = HStoreKey.parseColumn(col); update.add(colSeperated[0], colSeperated[1], val); } } } } catch (ColumnNameParseException e) { throw new RuntimeException(e); } return update; }
From source file:org.kalypso.model.wspm.tuhh.schema.simulation.PolynomeProcessor.java
public static <S> S forStationAdjacent(final SortedMap<BigDecimal, S> stationIndex, final BigDecimal station, final boolean upstream) { final BigDecimal pred = NumberUtils.decrement(station); final BigDecimal succ = NumberUtils.increment(station); if (upstream) { final SortedMap<BigDecimal, ? extends Object> successors = stationIndex.tailMap(succ); if (!successors.isEmpty()) return stationIndex.get(successors.firstKey()); } else {/*from w w w . j av a 2 s. c o m*/ final SortedMap<BigDecimal, ? extends Object> predecessors = stationIndex.headMap(pred); if (!predecessors.isEmpty()) return stationIndex.get(predecessors.lastKey()); } return null; }
From source file:co.cask.cdap.logging.save.LogSaverPluginTest.java
private static Location getLatestFile(Location logBaseDir, String filePattern) throws Exception { String date = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); Location dir = logBaseDir.append(String.format(filePattern, date)); if (!dir.exists()) { return null; }//w w w.ja v a 2 s. c o m List<Location> files = dir.list(); if (files.isEmpty()) { return null; } SortedMap<Long, Location> map = Maps.newTreeMap(); for (Location file : files) { String filename = FilenameUtils.getBaseName(file.getName()); map.put(Long.parseLong(filename), file); } return map.get(map.lastKey()); }
From source file:org.eclipse.winery.common.Util.java
public static SortedMap<String, SortedSet<String>> convertQNameListToNamespaceToLocalNameList( List<QName> list) { SortedMap<String, SortedSet<String>> res = new TreeMap<>(); for (QName qname : list) { SortedSet<String> localNameSet = res.get(qname.getNamespaceURI()); if (localNameSet == null) { localNameSet = new TreeSet<>(); res.put(qname.getNamespaceURI(), localNameSet); }//from w w w . j ava2s. c o m localNameSet.add(qname.getLocalPart()); } return res; }