List of usage examples for org.apache.commons.collections4.bidimap DualHashBidiMap DualHashBidiMap
public DualHashBidiMap(final Map<? extends K, ? extends V> map)
HashBidiMap
and copies the mappings from specified Map
. From source file:com.jins_meme.bridge.VDJMenuFragment.java
public VDJMenuFragment() { HashMap<String, Integer> rootMap = new HashMap<>(); rootMap.put("trackA", R.string.trackA); rootMap.put("trackB", R.string.trackB); rootMap.put("trackC", R.string.trackC); rootMap.put("trackD", R.string.trackD); rootMap.put("trackE", R.string.trackE); rootMap.put("trackF", R.string.trackF); rootMap.put("effectA", R.string.effectA); rootMap.put("effectB", R.string.effectB); rootMap.put("effectC", R.string.effectC); rootMap.put("effectD", R.string.effectD); rootMap.put("effectE", R.string.effectE); rootMap.put("effectF", R.string.effectF); rootMap.put("logoA", R.string.logoA); rootMap.put("logoB", R.string.logoB); rootMap.put("logoC", R.string.logoC); rootMap.put("logoD", R.string.logoD); rootMap.put("logoE", R.string.logoE); rootMap.put("logoF", R.string.logoF); rootMap.put("subgrpA", R.string.subgrpA); rootMap.put("subgrpB", R.string.subgrpB); rootMap.put("subgrpC", R.string.subgrpC); rootMap.put("subgrpD", R.string.subgrpD); rootMap.put("subgrpE", R.string.subgrpE); rootMap.put("subgrpF", R.string.subgrpF); rootMap.put("subgrpG", R.string.subgrpG); rootMap.put("subgrpH", R.string.subgrpH); rootMap.put("subgrpI", R.string.subgrpI); rootMap.put("subgrpJ", R.string.subgrpJ); rootMap.put("subgrpK", R.string.subgrpK); rootMap.put("subgrpL", R.string.subgrpL); rootMap.put("subgrpM", R.string.subgrpM); rootMap.put("subgrpN", R.string.subgrpN); rootMap.put("subgrpO", R.string.subgrpO); rootMap.put("subgrpP", R.string.subgrpP); rootMap.put("subgrpQ", R.string.subgrpQ); rootMap.put("subgrpR", R.string.subgrpR); rootMap.put("track1", R.string.track1); rootMap.put("track2", R.string.track2); rootMap.put("track3", R.string.track3); rootMap.put("track4", R.string.track4); rootMap.put("track5", R.string.track5); rootMap.put("track6", R.string.track6); rootMap.put("track7", R.string.track7); rootMap.put("track8", R.string.track8); rootMap.put("track9", R.string.track9); rootMap.put("track10", R.string.track10); rootMap.put("track11", R.string.track11); rootMap.put("track12", R.string.track12); rootMap.put("track13", R.string.track13); rootMap.put("track14", R.string.track14); rootMap.put("track15", R.string.track15); rootMap.put("track16", R.string.track16); rootMap.put("track17", R.string.track17); rootMap.put("track18", R.string.track18); rootMap.put("effect1", R.string.effect1); rootMap.put("effect2", R.string.effect2); rootMap.put("effect3", R.string.effect3); rootMap.put("effect4", R.string.effect4); rootMap.put("effect5", R.string.effect5); rootMap.put("effect6", R.string.effect6); rootMap.put("effect7", R.string.effect7); rootMap.put("effect8", R.string.effect8); rootMap.put("effect9", R.string.effect9); rootMap.put("effect10", R.string.effect10); rootMap.put("effect11", R.string.effect11); rootMap.put("effect12", R.string.effect12); rootMap.put("effect13", R.string.effect13); rootMap.put("effect14", R.string.effect14); rootMap.put("effect15", R.string.effect15); rootMap.put("effect16", R.string.effect16); rootMap.put("logo1", R.string.logo1); rootMap.put("logo2", R.string.logo2); rootMap.put("logo3", R.string.logo3); rootMap.put("logo4", R.string.logo4); rootMap.put("logo5", R.string.logo5); rootMap.put("logo6", R.string.logo6); rootMap.put("logo7", R.string.logo7); rootMap.put("logo8", R.string.logo8); rootMap.put("logo9", R.string.logo9); rootMap.put("logo10", R.string.logo10); rootMap.put("logo11", R.string.logo11); rootMap.put("logo12", R.string.logo12); rootMap.put("logo13", R.string.logo13); rootMap.put("logo14", R.string.logo14); rootMap.put("logo15", R.string.logo15); bidiMap = new DualHashBidiMap<>(rootMap); }
From source file:it.matjaz.jnumerus.RomanCharMapFactory.java
/** * Constructs an unmodifiable DualHashBidiMap with 13 entries <roman * character, its integer value>. * <p>//from w w w . j a v a 2s.c o m * The BidiMap correlates roman characters stored as Strings and their * integer values. Those entries are used for conversions of whole Strings * of roman numerals. The Map is unmodifiable. * <p> * The map returned by this method is a * <a href="http://commons.apache.org/proper/commons-collections/javadocs/api-release/org/apache/commons/collections4/bidimap/package-summary.html">BidiMap</a> * from the * <a href="http://commons.apache.org/proper/commons-collections/">Apache * Commons Collection 4.0</a>, which means it can be accessed by its keys * with {@code get(Object)} or by its values with {@code getKey(Object)}. * The Map is filled by inserting values from the {@link #generateCharMap() * }. * <p> * The followind table offers a representation of the content of the * generated structure: * * <pre> * key val * rom int * ------- * M 1000 * CM 900 * D 500 * CD 400 * C 100 * XC 90 * L 50 * XL 40 * X 10 * IX 9 * V 5 * IV 4 * I 1 * </pre> * * @return DualHashBidiMap<String, Integer> containing roman * characters as and the respective integer values. * @see * <a href="http://commons.apache.org/proper/commons-collections/javadocs/api-release/org/apache/commons/collections4/bidimap/package-summary.html"> * org.apache.commons.collections4.bidimap</a> */ public static BidiMap generateBidiCharMap() { DualHashBidiMap bidiMap = new DualHashBidiMap(generateCharMap()); return UnmodifiableBidiMap.unmodifiableBidiMap(bidiMap); }
From source file:org.efaps.esjp.common.history.AbstractUpdateHistoryTrigger_Base.java
/** * Gets the attributes./*w w w. j a v a 2s . c o m*/ * * @param _parameter the _parameter * @param _instance the _instance * @return the attributes * @throws EFapsException the eFaps exception */ protected List<AttributeValue> getAttributes(final Parameter _parameter, final Instance _instance) throws EFapsException { final List<AttributeValue> ret = new ArrayList<>(); @SuppressWarnings("unchecked") final Map<Object, Object> values = (Map<Object, Object>) _parameter.get(ParameterValues.NEW_VALUES); if (values != null) { final Collection<String> always = analyseProperty(_parameter, "AlwaysAttribute").values(); final BidiMap<Integer, String> selectAttributes = new DualHashBidiMap<>( analyseProperty(_parameter, "SelectAttribute")); final BidiMap<Integer, String> phraseAttributes = new DualHashBidiMap<>( analyseProperty(_parameter, "PhraseAttribute")); final Map<Integer, String> selects = analyseProperty(_parameter, "Select"); final Map<Integer, String> phrases = analyseProperty(_parameter, "Phrase"); // ensure that their is a value for the always Attributes for (final String attrName : always) { boolean exists = false; for (final Entry<?, ?> entry : values.entrySet()) { if (((Attribute) entry.getKey()).getName().equals(attrName)) { exists = true; break; } } if (!exists) { Object value = null; // if no select or phrase is given add the value her also if (!selectAttributes.containsValue(attrName) && !phraseAttributes.containsValue(attrName)) { final PrintQuery print = new PrintQuery(_instance); print.addAttribute(attrName); print.executeWithoutAccessCheck(); value = print.getAttribute(attrName); } values.put(_instance.getType().getAttributes().get(attrName), value); } } final Collection<String> ignore = analyseProperty(_parameter, "IgnoreAttribute").values(); for (final Entry<?, ?> entry : values.entrySet()) { final Attribute attr = (Attribute) entry.getKey(); if (!attr.getAttributeType().isAlwaysUpdate() && !attr.getAttributeType().isCreateUpdate() && !ignore.contains(attr.getName())) { final AttributeValue attrValue = new AttributeValue(); attrValue.setName(attr.getName()); if (attr.getAttributeType().getDbAttrType() instanceof PasswordType) { attrValue.setValue("****************"); } else if (attr.getAttributeType().getDbAttrType() instanceof StatusType) { final Object objArr = entry.getValue(); if (objArr instanceof Object[]) { final Object obj = ((Object[]) objArr)[0]; final Long id; if (obj instanceof String) { id = Long.valueOf((String) obj); } else { id = (Long) obj; } attrValue.setValue(Status.get(id).getKey()); } } else if (attr.getAttributeType().getDbAttrType() instanceof BitEnumType) { final Object objArr = entry.getValue(); if (objArr instanceof Object[]) { final Object val = attr.getAttributeType().getDbAttrType().readValue(attr, Arrays.asList((Object[]) objArr)); if (val == null) { attrValue.setValue(val); } else { final StringBuilder strBldr = new StringBuilder(); boolean first = true; for (final Object obj : (List<?>) val) { if (first) { first = false; } else { strBldr.append(", "); } if (obj instanceof List) { strBldr.append(((List<?>) obj).get(0)); } else { strBldr.append(obj); } } attrValue.setValue(strBldr.toString()); } } } else if (attr.getAttributeType().getDbAttrType() instanceof EnumType) { final Object objArr = entry.getValue(); if (objArr instanceof Object[]) { final Object val = attr.getAttributeType().getDbAttrType().readValue(attr, Arrays.asList((Object[]) objArr)); if (val == null) { attrValue.setValue(val); } else { attrValue.setValue(val.toString()); } } } else { // check is a select exists if (selectAttributes.containsValue(attr.getName())) { final String select = selects.get(selectAttributes.getKey(attr.getName())); final PrintQuery print = new PrintQuery(_instance); print.addSelect(select); print.executeWithoutAccessCheck(); attrValue.setValue(print.getSelect(select)); } else if (phraseAttributes.containsValue(attr.getName())) { final String phrase = phrases.get(phraseAttributes.getKey(attr.getName())); final PrintQuery print = new PrintQuery(_instance); print.addPhrase("SelectPhrase", phrase); print.executeWithoutAccessCheck(); attrValue.setValue(print.getPhrase("SelectPhrase")); } else { final Object obj = entry.getValue(); if (obj instanceof Object[]) { final Object tmpObj = ((Object[]) obj)[0]; if (tmpObj instanceof DateTime) { attrValue.setValue(((DateTime) tmpObj).toString()); } else { attrValue.setValue(tmpObj); } } else { attrValue.setValue(obj); } } } ret.add(attrValue); } } } return ret; }
From source file:org.lockss.util.OneToOneNamespaceContext.java
/** * <p>//from w w w.j av a 2s . co m * Builds a new instance that initially has the same mappings as the given * map, and adds a mapping from {@link XMLConstants#DEFAULT_NS_PREFIX} to * {@link XMLConstants#NULL_NS_URI} if there is no mapping for it initially. * </p> * * @param map * An initial mapping of prefixes to namespace URIs. * @since 1.67.5 */ public OneToOneNamespaceContext(Map<String, String> map) { this.bidiMap = new DualHashBidiMap<String, String>(map); if (!bidiMap.containsKey(XMLConstants.DEFAULT_NS_PREFIX)) { put(XMLConstants.DEFAULT_NS_PREFIX, XMLConstants.NULL_NS_URI); } }