List of usage examples for org.apache.commons.collections.bidimap DualHashBidiMap DualHashBidiMap
public DualHashBidiMap()
HashBidiMap
. From source file:HashMapExampleV1.java
public static void main(String args[]) { BidiMap agentToCode = new DualHashBidiMap(); agentToCode.put("007", "Bond"); agentToCode.put("006", "Trevelyan"); agentToCode.put("002", "Fairbanks"); System.err.println("Agent name from code: " + agentToCode.get("007")); System.err.println("Code from Agent name: " + agentToCode.getKey("Bond")); }
From source file:BidiMapExample.java
public static void main(String args[]) { BidiMap agentToCode = new DualHashBidiMap(); agentToCode.put("007", "Bond"); agentToCode.put("006", "Joe"); agentToCode = UnmodifiableBidiMap.decorate(agentToCode); agentToCode.put("002", "Fairbanks"); // throws Exception agentToCode.remove("007"); // throws Exception agentToCode.removeValue("Bond"); // throws Exception }
From source file:de.fau.cs.osr.utils.SimpleTypeNameMapper.java
public SimpleTypeNameMapper() { typeToName = new DualHashBidiMap(); }
From source file:com.hs.mail.imap.mailbox.SelectedMailbox.java
/** * Constructor used to create a selected mailbox. * /*from w ww. j ava 2 s.co m*/ * @param sessionID * ID of the session who selected this mailbox * @param mailboxID * ID of the selected mailbox * @param readOnly * Is this mailbox is read-only? If selected via EXAMINE command * this mailbox is read-only. Otherwise if selected via SELECT * command this mailbox is not read-only. */ public SelectedMailbox(long sessionID, long mailboxID, boolean readOnly) { this.sessionID = sessionID; this.mailboxID = mailboxID; this.readOnly = readOnly; this.converter = new DualHashBidiMap(); }
From source file:de.fau.cs.osr.utils.NameAbbrevService.java
/** * The order of packages is vitally important to the process. If resolve() * is called with a different order of package names than abbrev(), some * abbreviated might get resolved to the wrong Class<?>! *///from w w w.j a v a2 s .c om public NameAbbrevService(boolean strict, String... packageNames) { this.strict = strict; packages.add("java.lang"); packages.addAll(Arrays.asList(packageNames)); cache = new DualHashBidiMap(); cache.put(byte.class, "byte"); cache.put(short.class, "short"); cache.put(int.class, "int"); cache.put(long.class, "long"); cache.put(float.class, "float"); cache.put(double.class, "double"); cache.put(boolean.class, "boolean"); cache.put(char.class, "char"); }
From source file:gov.nih.nci.lmp.mimGpml.CommonHelper.java
/** * Initialize the interaction types. This is the mapping from the GPML to * MIM-Vis interactions; not the MIM-Vis to MIM-Bio mapping. * //from ww w . j av a 2 s.c o m * @return the mapping of GPML to MIMVis arrowheads */ public static BidiMap getGpmlToMimVisArrowHeadMap() { BidiMap arrowHash = new DualHashBidiMap(); arrowHash.put("mim-necessary-stimulation", "NecessaryStimulation"); arrowHash.put("mim-stimulation", "Stimulation"); arrowHash.put("mim-inhibition", "Inhibition"); arrowHash.put("mim-absolute-inhibition", "AbsoluteInhibition"); arrowHash.put("mim-catalysis", "Catalysis"); arrowHash.put("mim-cleavage", "CovalentBondCleavage"); arrowHash.put("mim-binding", "NonCovalentReversibleBinding"); arrowHash.put("mim-covalent-bond", "CovalentIrreversibleBinding"); arrowHash.put("mim-modification", "CovalentModification"); arrowHash.put("mim-production-wo-loss", "ProductionWithoutLoss"); arrowHash.put("mim-conversion", "StochiometricConversion"); arrowHash.put("mim-transcription-translation", "TemplateReaction"); arrowHash.put("Line", "Line"); arrowHash.put("mim-next-feature", "NextFeature"); arrowHash.put("mim-first-feature", "FirstFeature"); arrowHash.put("mim-branching-right", "BranchingRight"); arrowHash.put("mim-branching-left", "BranchingLeft"); arrowHash.put("mim-state-combination", "StateCombination"); //TODO: To be added in a future MIM specification //arrowHash.put("mim-gap", ArrowHeadEnumType.GAP); return arrowHash; }
From source file:de.topicmapslab.majortom.server.topicmaps.TopicMapsHandler.java
/** * Constructor/*from ww w. j av a 2s.c o m*/ */ public TopicMapsHandler(IDatabaseConnectionDataDAO databaseConnectionDataDAO) { topicMapMap = new DualHashBidiMap(); this.databaseConnectionDataDAO = databaseConnectionDataDAO; }
From source file:com.urbancode.x2o.xml.NamespaceConfiguration.java
public void loadNameSpaceFromClassPath(String nameSpace) { BidiMap biMap = new DualHashBidiMap(); String filePath = nameSpace.replaceAll("\\.", Matcher.quoteReplacement("/")); String resourceName = filePath + "/" + NAMESPACE_FILE; ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); Properties props = new Properties(); log.debug("Looking for resource: " + resourceName); try {/*from ww w .j a v a 2 s . c om*/ props.load(classLoader.getResourceAsStream(resourceName)); } catch (IOException e) { log.error(e.getClass() + " caught in " + this.getClass()); // swallow } // build the biDirectionalMap for (Object prop : props.keySet()) { biMap.put(prop, props.getProperty((String) prop)); } log.debug("added following elements into map: " + biMap.keySet()); log.debug("Added following value: " + biMap.values()); nameSpaces.put(nameSpace, biMap); }
From source file:com.projity.field.StaticSelect.java
public void addOption(SelectOption option) { if (integerValues) option.value = Integer.valueOf(option.value.toString()); add(option.key, option.value);// w w w . j av a 2 s . c om Object staticObject = option.getStaticObject(); if (staticObject != null) { // if object associated, use it if (objectMap == null) objectMap = new DualHashBidiMap(); objectMap.put(option.value, staticObject); } }
From source file:br.ufal.cideei.soot.instrument.FeatureModelInstrumentorTransformer.java
@Override protected void internalTransform(Body body, String phase, Map options) { preTransform(body);/*w ww . j a va 2 s . c om*/ // #ifdef METRICS long startTransform = System.nanoTime(); // #endif /* * Iterate over all units, look up for their colors and add a new FeatureTag to each of them, and also compute * all the colors found in the whole body. Units with no colors receive an empty FeatureTag. */ Iterator<Unit> unitIt = body.getUnits().iterator(); /* * After the following loop, allPresentFeatures will hold all the colors found in the body. Used to calculate a * "local" power set. */ Set<String> allPresentFeatures = new HashSet<String>(); /* * The set of features are represented as bits, for a more compact representation. The mapping between a feature * and it's ID is stored in the FeatureTag of the body. * * This is necessary so that clients, such as r.d. analysis, can safely iterate over all configurations without * explicitly invoking Set operations like containsAll(); * * TODO: check redundancy between allPresentFeatures & allPresentFeaturesId */ // String->Integer BidiMap allPresentFeaturesId = new DualHashBidiMap(); FeatureTag emptyFeatureTag; // #ifdef LAZY BitVectorFeatureRep emptyBitVectorRep = new BitVectorFeatureRep(Collections.EMPTY_SET, allPresentFeaturesId); emptyFeatureTag = new FeatureTag(emptyBitVectorRep); // #else //@ emptyFeatureTag = new FeatureTag(new BitFeatureRep(Collections.EMPTY_SET, allPresentFeaturesId)); //@ // #endif // #ifdef LAZY /* * in the lazy approach, the representation can only be consolidate after all features have been discovery. All * IFeatureRep will stored so that it is possible to consolidate later. */ List<BitVectorFeatureRep> generateVectorLater = new ArrayList<BitVectorFeatureRep>(); // #endif int idGen = 1; while (unitIt.hasNext()) { Unit nextUnit = unitIt.next(); SourceLnPosTag lineTag = (SourceLnPosTag) nextUnit.getTag("SourceLnPosTag"); if (lineTag == null) { nextUnit.addTag(emptyFeatureTag); } else { int unitLine = lineTag.startLn(); Set<String> nextUnitColors = currentColorMap.get(unitLine); if (nextUnitColors != null) { for (String color : nextUnitColors) { if (!allPresentFeaturesId.containsKey(color)) { allPresentFeaturesId.put(color, idGen); idGen = idGen << 1; } } /* * increment local powerset with new found colors. */ allPresentFeatures.addAll(nextUnitColors); IFeatureRep featRep; FeatureTag featureTag; // #ifdef LAZY featRep = new BitVectorFeatureRep(nextUnitColors, allPresentFeaturesId); generateVectorLater.add((BitVectorFeatureRep) featRep); featureTag = new FeatureTag(featRep); nextUnit.addTag(featureTag); // #else //@ //@ featRep = new BitFeatureRep(nextUnitColors, allPresentFeaturesId); //@ // #endif featureTag = new FeatureTag(featRep); nextUnit.addTag(featureTag); } else { nextUnit.addTag(emptyFeatureTag); } } } UnmodifiableBidiMap unmodAllPresentFeaturesId = (UnmodifiableBidiMap) UnmodifiableBidiMap .decorate(allPresentFeaturesId); // #ifdef LAZY /* * generate vectors */ for (BitVectorFeatureRep featureRep : generateVectorLater) { featureRep.generateBitVector(idGen); } // #endif // #ifdef METRICS long transformationDelta = System.nanoTime() - startTransform; if (sink != null) { sink.flow(body, FeatureModelInstrumentorTransformer.INSTRUMENTATION, transformationDelta); } FeatureModelInstrumentorTransformer.transformationTime += transformationDelta; // #endif ConfigTag configTag; // #ifdef LAZY BitVectorConfigRep localConfigurations = BitVectorConfigRep.localConfigurations(idGen, unmodAllPresentFeaturesId // #ifdef FEATUREMODEL //@ , checker // #endif ); emptyBitVectorRep.generateBitVector(idGen); Set<IConfigRep> lazyConfig = new HashSet<IConfigRep>(); lazyConfig.add(localConfigurations); configTag = new ConfigTag(lazyConfig); body.addTag(configTag); // #else //@ //@ configTag = new ConfigTag(BitConfigRep.localConfigurations(idGen, unmodAllPresentFeaturesId // #ifdef FEATUREMODEL //@ , checker // #endif //@ ).getConfigs()); //@ body.addTag(configTag); //@ // #endif }