List of usage examples for java.util EnumMap put
public V put(K key, V value)
From source file:org.apache.asterix.common.config.ConfigUsageTest.java
@Test public void generateUsage() { final EnumMap<Column, Boolean> align = new EnumMap<>(Column.class); align.put(Column.SECTION, true); align.put(Column.PARAMETER, true);// www. j a v a2 s . c o m System.err.println(); generateUsage("| ", " | ", " |", align, System.err); }
From source file:com.linroid.pushapp.ui.home.DeviceTokenDialog.java
private Bitmap generateQrcode(String content, int size) { QRCodeWriter writer = new QRCodeWriter(); try {// w w w .j a v a 2 s.c om EnumMap<EncodeHintType, Object> hint = new EnumMap<>(EncodeHintType.class); hint.put(EncodeHintType.CHARACTER_SET, "UTF-8"); BitMatrix bitMatrix = writer.encode(content, BarcodeFormat.QR_CODE, size, size, hint); int width = bitMatrix.getWidth(); int height = bitMatrix.getHeight(); int[] pixels = new int[width * height]; for (int y = 0; y < height; y++) { int offset = y * width; for (int x = 0; x < width; x++) { // pixels[offset + x] = bitMatrix.get(x, y) ? 0xFF000000 // : 0xFFFFFFFF; pixels[offset + x] = bitMatrix.get(x, y) ? 0xFF000000 : 0xFFFFFFFF; } } Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); bitmap.setPixels(pixels, 0, width, 0, 0, width, height); return bitmap; } catch (Exception e) { return null; } }
From source file:com.adobe.acs.commons.mcp.impl.processes.DataImporter.java
@SuppressWarnings("squid:S2445") protected void incrementCount(EnumMap<ReportColumns, Object> row, int amt) { synchronized (row) { row.put(ReportColumns.count, (int) row.getOrDefault(ReportColumns.count, 0) + amt); }/*from w w w. j ava2 s. c o m*/ }
From source file:com.adobe.acs.commons.mcp.impl.processes.DataImporter.java
protected synchronized EnumMap<ReportColumns, Object> trackActivity(String item, String action, Integer count) { if (reportRows == null) { reportRows = Collections.synchronizedList(new ArrayList<>()); }//from w w w .jav a2 s . c o m EnumMap<ReportColumns, Object> reportRow = new EnumMap<>(ReportColumns.class); reportRow.put(ReportColumns.item, item); reportRow.put(ReportColumns.action, action); reportRow.put(ReportColumns.count, count); reportRows.add(reportRow); return reportRow; }
From source file:org.janusgraph.graphdb.database.log.TransactionLogHeader.java
public StaticBuffer serializeUserLog(Serializer serializer, Entry sourceTxEntry, StandardTransactionId sourceTxId) { Preconditions.checkArgument(sourceTxEntry != null && sourceTxEntry.status == LogTxStatus.PRECOMMIT && sourceTxEntry.header.transactionId == sourceTxId.getTransactionId()); StaticBuffer sourceContent = sourceTxEntry.content; Preconditions.checkArgument(sourceContent != null && sourceContent.length() > 0); EnumMap<LogTxMeta, Object> meta = new EnumMap<LogTxMeta, Object>(LogTxMeta.class); meta.put(LogTxMeta.SOURCE_TRANSACTION, sourceTxId); DataOutput out = serializeHeader(serializer, 50 + sourceContent.length(), LogTxStatus.USER_LOG, meta); out.putBytes(sourceContent);//from w w w .j ava 2 s.c o m return out.getStaticBuffer(); }
From source file:it.unimi.di.big.mg4j.index.Index.java
/** Returns a new index using the given URI. * /*from w w w.j av a 2 s. co m*/ * @param ioFactory the factory that will be used to perform I/O, or <code>null</code> (implying the {@link IOFactory#FILESYSTEM_FACTORY} for disk-based indices). * @param uri the URI defining the index. * @param randomAccess whether the index should be accessible randomly. * @param documentSizes if true, document sizes will be loaded (note that sometimes document sizes * might be loaded anyway because the compression method for positions requires it). * @param maps if true, {@linkplain StringMap term} and {@linkplain PrefixMap prefix} maps will be guessed and loaded (this * feature might not be available with some kind of index). */ public static Index getInstance(IOFactory ioFactory, final CharSequence uri, final boolean randomAccess, final boolean documentSizes, final boolean maps) throws IOException, ConfigurationException, URISyntaxException, ClassNotFoundException, SecurityException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { /* If the scheme is mg4j, then we are creating a remote * index. If it is null, we assume it is a property file and load it. Otherwise, we * assume it is a valid property file URI and try to download it. */ final String uriString = uri.toString(); /*if ( uriString.startsWith( "mg4j:" ) ) { if ( ioFactory != null ) throw new IllegalAccessError( "You cannot specify a factory for a remote index" ); final URI u = new URI( uriString ); return IndexServer.getIndex( u.getHost(), u.getPort(), randomAccess, documentSizes ); }*/ final String basename, query; if (ioFactory == null) ioFactory = IOFactory.FILESYSTEM_FACTORY; if (uriString.startsWith("file:")) { final URI u = new URI(uriString); basename = u.getPath(); query = u.getQuery(); } else { final int questionMarkPos = uriString.indexOf('?'); basename = questionMarkPos == -1 ? uriString : uriString.substring(0, questionMarkPos); query = questionMarkPos == -1 ? null : uriString.substring(questionMarkPos + 1); } LOGGER.debug("Searching for an index with basename " + basename + "..."); final Properties properties = IOFactories.loadProperties(ioFactory, basename + DiskBasedIndex.PROPERTIES_EXTENSION); LOGGER.debug("Properties: " + properties); // We parse the key/value pairs appearing in the query part. final EnumMap<UriKeys, String> queryProperties = new EnumMap<UriKeys, String>(UriKeys.class); if (query != null) { String[] keyValue = query.split(";"); for (int i = 0; i < keyValue.length; i++) { String[] piece = keyValue[i].split("="); if (piece.length != 2) throw new IllegalArgumentException("Malformed key/value pair: " + keyValue[i]); // Convert to standard keys boolean found = false; for (UriKeys key : UriKeys.values()) if (found = PropertyBasedDocumentFactory.sameKey(key, piece[0])) { queryProperties.put(key, piece[1]); break; } if (!found) throw new IllegalArgumentException("Unknown key: " + piece[0]); } } // Compatibility with previous versions String className = properties.getString(Index.PropertyKeys.INDEXCLASS, "(missing index class)") .replace(".dsi.", ".di."); Class<?> indexClass = Class.forName(className); // It is a cluster. if (IndexCluster.class.isAssignableFrom(indexClass)) return IndexCluster.getInstance(basename, randomAccess, documentSizes, queryProperties); // It is a disk-based index. return DiskBasedIndex.getInstance(ioFactory, basename, properties, randomAccess, documentSizes, maps, queryProperties); }
From source file:com.adobe.acs.commons.mcp.impl.processes.TagCreator.java
private void record(ReportRowSatus status, String tagId, String path, String title) { final EnumMap<ReportColumns, Object> row = new EnumMap<>(ReportColumns.class); row.put(ReportColumns.STATUS, StringUtil.getFriendlyName(status.name())); row.put(ReportColumns.TAG_ID, tagId); row.put(ReportColumns.TAG_PATH, path); row.put(ReportColumns.TAG_TITLE, title); reportRows.add(row);//from www . ja va 2s. co m }
From source file:com.adobe.acs.commons.mcp.impl.processes.RefreshFolderTumbnails.java
private void record(String path, String action, String description) { EnumMap<ReportColumns, String> row = new EnumMap<ReportColumns, String>(ReportColumns.class); row.put(ReportColumns.PATH, path); row.put(ReportColumns.ACTION, action); row.put(ReportColumns.DESCRIPTION, description); reportData.add(row);//from ww w. j a v a 2 s. c o m }
From source file:com.adobe.acs.commons.mcp.impl.processes.cfi.ContentFragmentImport.java
private synchronized EnumMap<ReportColumns, Object> trackActivity(String item, String action, String description) {//ww w . j a v a2 s . c om if (reportRows == null) { reportRows = Collections.synchronizedList(new ArrayList<>()); } EnumMap<ReportColumns, Object> reportRow = new EnumMap<>(ReportColumns.class); reportRow.put(ReportColumns.ITEM, item); reportRow.put(ReportColumns.ACTION, action); reportRow.put(ReportColumns.DESCRIPTION, description); reportRow.put(ReportColumns.COUNT, 0L); reportRows.add(reportRow); return reportRow; }
From source file:cc.aileron.accessor.PojoAccessorMixerImpl.java
@Override public PojoAccessor<?> mixin(final List<PojoAccessor<?>> accessors, final List<Object> parents) { final InstanceManager i = accessors.get(0).instanceManager(); final HashMap<String, PojoAccessor<?>> map = new HashMap<String, PojoAccessor<?>>(); final EnumMap<PojoAccessorMethod, List<String>> keys = new EnumMap<PojoAccessorMethod, List<String>>( PojoAccessorMethod.class); keys.put(PojoAccessorMethod.GET, new SkipList<String>()); keys.put(PojoAccessorMethod.SET, new SkipList<String>()); final HashMap<String, PojoAccessor<?>> setmap = new HashMap<String, PojoAccessor<?>>(); for (final PojoAccessor<?> accessor : accessors) { for (final PojoAccessorMethod method : PojoAccessorMethod.values()) { final List<String> methodKeys = accessor.keys(method); keys.get(method).addAll(methodKeys); }/*w w w.j a v a 2s . c o m*/ for (final String key : accessor.keys(PojoAccessorMethod.GET)) { map.put(key, accessor); } for (final String key : accessor.keys(PojoAccessorMethod.SET)) { setmap.put(key, accessor); } } final PojoAccessorManagerLocal manager = this.manager; return new PojoAccessor<Object>() { @Override public boolean exist(final String key) { for (final PojoAccessor<?> accessor : accessors) { if (accessor.exist(key)) { return true; } } return false; } @Override public InstanceManager instanceManager() { return i; } @Override public List<String> keys(final PojoAccessorMethod method) { return keys.get(method); } @Override public PojoAccessor<?> mixin(final Object... objects) { final SkipList<PojoAccessor<?>> list = new SkipList<PojoAccessor<?>>(); list.add(this); for (final Object object : objects) { list.add(manager.from(object, parents)); } return PojoAccessorMixerImpl.this.mixin(list, parents); } @Override public Iterable<PojoAccessorValue> set(final PojoAccessorMethod method) { final HashMap<String, PojoAccessor<?>> m = method == PojoAccessorMethod.GET ? map : setmap; return new Iterable<PojoAccessorValue>() { @Override public Iterator<PojoAccessorValue> iterator() { final Iterator<Entry<String, PojoAccessor<?>>> ite = m.entrySet().iterator(); return new Iterator<PojoAccessorValue>() { @Override public boolean hasNext() { return ite.hasNext(); } @Override public PojoAccessorValue next() { final Entry<String, PojoAccessor<?>> e = ite.next(); try { return e.getValue().to(e.getKey()); } catch (final PojoAccessorValueNotFoundException e1) { throw new Error(e1); } catch (final PojoPropertiesNotFoundException e1) { throw new Error(e1); } } @Override public void remove() { throw new UnsupportedOperationException(); } }; } }; } @Override public PojoAccessorValue to(final String key) throws PojoAccessorValueNotFoundException, PojoPropertiesNotFoundException { { final PojoAccessor<?> a = map.get(key); if (a != null) { return a.to(key); } } for (final PojoAccessor<?> a : accessors) { if (a.exist(key)) { return a.to(key); } } for (final PojoAccessor<?> a : accessors) { try { final PojoAccessorValue result = a.to(key); if (result != null) { return result; } } catch (final PojoAccessorValueNotFoundException e) { } catch (final PojoPropertiesNotFoundException e) { } } throw new PojoAccessorValueNotFoundException(accessors, key); } @Override public String toString() { return ReflectionToStringBuilder.toString(this); } @Override public Object toTarget() { throw new UnsupportedOperationException(); } }; }