public void testDescendingSubMapContents2() { ConcurrentNavigableMap map = dmap5(); SortedMap sm = map.subMap(m2, m3); assertEquals(1, sm.size()); assertEquals(m2, sm.firstKey()); assertEquals(m2, sm.lastKey()); assertFalse(sm.containsKey(m1)); assertTrue(sm.containsKey(m2)); assertFalse(sm.containsKey(m3)); assertFalse(sm.containsKey(m4)); assertFalse(sm.containsKey(m5)); Iterator i = sm.keySet().iterator(); Object k; k = (Integer) (i.next()); assertEquals(m2, k); assertFalse(i.hasNext()); Iterator j = sm.keySet().iterator(); j.next(); j.remove(); assertFalse(map.containsKey(m2)); assertEquals(4, map.size()); assertEquals(0, sm.size()); assertTrue(sm.isEmpty()); assertSame(sm.remove(m3), null); assertEquals(4, map.size()); }
public void testSubMapContents2() { ConcurrentNavigableMap map = map5(); SortedMap sm = map.subMap(two, three); assertEquals(1, sm.size()); assertEquals(two, sm.firstKey()); assertEquals(two, sm.lastKey()); assertFalse(sm.containsKey(one)); assertTrue(sm.containsKey(two)); assertFalse(sm.containsKey(three)); assertFalse(sm.containsKey(four)); assertFalse(sm.containsKey(five)); Iterator i = sm.keySet().iterator(); Object k; k = (Integer) (i.next()); assertEquals(two, k); assertFalse(i.hasNext()); Iterator j = sm.keySet().iterator(); j.next(); j.remove(); assertFalse(map.containsKey(two)); assertEquals(4, map.size()); assertEquals(0, sm.size()); assertTrue(sm.isEmpty()); assertSame(sm.remove(three), null); assertEquals(4, map.size()); }
/** * Return a set of the variables in the supplied expression. Note: Substitutions which are in the * constant table are not included. */ public Set<String> getVariablesWithin(String exp) { Set<String> all = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER); String add = null; if (separators == null) { StringBuilder sep = new StringBuilder(10); for (char chr = 0; chr < operators.length; chr++) { if (operators[chr] != null && !operators[chr].internal) { sep.append(chr); } } sep.append("()"); separators = sep.toString(); } for (StringTokenizer tkz = new StringTokenizer(exp, separators, true); tkz.hasMoreTokens(); ) { String tkn = tkz.nextToken().trim(); if (tkn.length() != 0 && Character.isLetter(tkn.charAt(0))) { add = tkn; } else if (tkn.length() == 1 && tkn.charAt(0) == '(') { add = null; } else if (add != null && !constants.containsKey(add)) { all.add(add); } } if (add != null && !constants.containsKey(add)) { all.add(add); } return all; }
private void nastavPatterned() { if (blokujEventy) { return; } final RenderSettings.Patterned p = patterned.copy(); final int index = getSelectedIndex(); // aby tam vůbec vešel if (index >= 0) { final String key = keys.get(index); if (!geotaggingPatterns.isEmpty()) { // mame data geotaggingu p.setPatternNumberCilovy(key); if (souradnicovePatterns.containsKey(key)) { p.setPatternNumberPredbezny(key); } } else { // mame jen zakladni data p.setPatternNumberPredbezny(key); if (p.getPatternNumberCilovy() != null && souradnicovePatterns.containsKey(p.getPatternNumberCilovy())) { p.setPatternNumberCilovy(key); } } } p.setText((String) getSelectedItem()); setPatterned(p); }
/** * Construct a Strategy that parses a TimeZone * * @param locale The Locale */ TimeZoneStrategy(final Locale locale) { final String[][] zones = DateFormatSymbols.getInstance(locale).getZoneStrings(); for (String[] zone : zones) { if (zone[ID].startsWith("GMT")) { continue; } final TimeZone tz = TimeZone.getTimeZone(zone[ID]); if (!tzNames.containsKey(zone[LONG_STD])) { tzNames.put(zone[LONG_STD], tz); } if (!tzNames.containsKey(zone[SHORT_STD])) { tzNames.put(zone[SHORT_STD], tz); } if (tz.useDaylightTime()) { if (!tzNames.containsKey(zone[LONG_DST])) { tzNames.put(zone[LONG_DST], tz); } if (!tzNames.containsKey(zone[SHORT_DST])) { tzNames.put(zone[SHORT_DST], tz); } } } final StringBuilder sb = new StringBuilder(); sb.append("(GMT[+\\-]\\d{0,1}\\d{2}|[+\\-]\\d{2}:?\\d{2}|"); for (final String id : tzNames.keySet()) { escapeRegex(sb, id, false).append('|'); } sb.setCharAt(sb.length() - 1, ')'); validTimeZoneChars = sb.toString(); }
@Override protected void reportInContext( MetricContext context, SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters, SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters, SortedMap<String, Timer> timers) { Assert.assertEquals(context.getName(), CONTEXT_NAME); Assert.assertEquals(gauges.size(), 1); Assert.assertTrue(gauges.containsKey(QUEUE_SIZE)); Assert.assertEquals(counters.size(), 1); Assert.assertTrue(counters.containsKey(RECORDS_PROCESSED)); Assert.assertEquals(histograms.size(), 1); Assert.assertTrue(histograms.containsKey(RECORD_SIZE_DISTRIBUTION)); Assert.assertEquals(meters.size(), 1); Assert.assertTrue(meters.containsKey(RECORD_PROCESS_RATE)); Assert.assertEquals(timers.size(), 2); Assert.assertTrue(timers.containsKey(TOTAL_DURATION)); }
StringBuilder addCanonicalHeaders(HttpUriRequest request, StringBuilder builder) { SortedMap<String, String> sortedHeaders = sortedFormattedHeaders(request.getAllHeaders()); if (!sortedHeaders.containsKey(DATE_HEADER_NAME)) { String timestamp = timestamp(); sortedHeaders.put(DATE_HEADER_NAME, timestamp); request.addHeader(DATE_HEADER_NAME, timestamp); } if (!sortedHeaders.containsKey(HOST_HEADER_NAME)) { sortedHeaders.put(HOST_HEADER_NAME, request.getURI().getHost()); request.addHeader(HOST_HEADER_NAME, request.getURI().getHost()); } addCanonicalHeaders(sortedHeaders, builder).append('\n'); return addSignedHeaders(sortedHeaders, builder); }
@Override public Object getAsObject(FacesContext fc, UIComponent uic, String string) { try { if (string == null) { return null; } String qstr = string.trim(); if (qstr.isEmpty()) { return null; } if (timeZoneMap.containsKey(qstr)) { return timeZoneMap.get(qstr); } return timeZoneMap .entrySet() .stream() .filter(it -> it.getKey().equalsIgnoreCase(qstr)) .map(it -> it.getValue()) .findFirst() .orElse(TimeZone.getTimeZone(string)); } catch (Exception ex) { ex.printStackTrace(); throw new ConverterException(ex); } }
public Construct get(Construct index, Target t) { if (!associative_mode) { try { return array.get(Static.getInt32(index, t)); } catch (IndexOutOfBoundsException e) { throw new ConfigRuntimeException( "The element at index \"" + index.val() + "\" does not exist", ExceptionType.IndexOverflowException, t); } } else { if (associative_array.containsKey(normalizeConstruct(index))) { Construct val = associative_array.get(normalizeConstruct(index)); if (val instanceof CEntry) { return ((CEntry) val).construct(); } return val; } else { throw new ConfigRuntimeException( "The element at index \"" + index.val() + "\" does not exist", ExceptionType.IndexOverflowException, t); } } }
/** * 1st column is Element (Sequence/OTU/tree leaf), 2nd is taxid * * @param inFilePath * @return * @throws IOException */ public static SortedMap<String, Taxon> importElementTaxonomyMap(Path inFilePath) throws IOException, XMLStreamException { SortedMap<String, Taxon> otuTaxaMap = new TreeMap<>(); BufferedReader reader = getReader(inFilePath, "Element taxonomy mapping"); Separator lineSeparator = new Separator("\t"); String line = reader.readLine(); while (line != null) { if (hasContent(line)) { // not comments or empty String[] items = lineSeparator.parse(line); if (items.length < 2) throw new IllegalArgumentException( "Invalid file format for Element taxonomy mapping, line : " + line); if (otuTaxaMap.containsKey(items[0])) throw new IllegalArgumentException("Find duplicate name for " + items[0]); Taxon taxon = TaxonomyPool.getAndAddTaxIdByMemory(items[1]); otuTaxaMap.put(items[0], taxon); } line = reader.readLine(); } reader.close(); if (otuTaxaMap.size() < 1) throw new IllegalArgumentException("OTU taxonomy map is empty !"); return otuTaxaMap; }
@NotNull public Map<String, SortedMap<Integer, Integer>> getMergedDartFileCoverageData() { Map<String, SortedMap<Integer, Integer>> mergedCoverageData = new HashMap<String, SortedMap<Integer, Integer>>(); List<DartFileCoverageData> coverageData = getCoverage(); if (coverageData != null) { for (DartFileCoverageData item : coverageData) { String source = item.getSource(); if (source == null) { continue; } if (!mergedCoverageData.containsKey(source)) { mergedCoverageData.put(source, new TreeMap<Integer, Integer>()); } SortedMap<Integer, Integer> fileData = mergedCoverageData.get(source); List<Integer> hits = item.getHits(); if (hits == null) { continue; } for (int i = 0; i < hits.size(); i += 2) { Integer lineNumber = hits.get(i); Integer hitCount = hits.get(i + 1); if (!fileData.containsKey(lineNumber)) { fileData.put(lineNumber, 0); } fileData.put(lineNumber, fileData.get(lineNumber) + hitCount); } } } return mergedCoverageData; }
public boolean predict(SingleDecision decision) throws MaltChainedException { if (getGuide().getGuideMode() == ClassifierGuide.GuideMode.BATCH) { throw new GuideException("Can only predict during parsing. "); } else if (!(divideFeature.getFeatureValue() instanceof SingleFeatureValue)) { throw new GuideException("The divide feature does not have a single value. "); } // divideFeature.update(); if (divideModels != null && divideModels.containsKey( ((SingleFeatureValue) divideFeature.getFeatureValue()).getCode())) { return divideModels .get(((SingleFeatureValue) divideFeature.getFeatureValue()).getCode()) .predict(decision); } else if (masterModel != null && masterModel.getFrequency() > 0) { return masterModel.predict(decision); } else { getGuide() .getConfiguration() .getConfigLogger() .info( "Could not predict the next parser decision because there is " + "no divide or master model that covers the divide value '" + ((SingleFeatureValue) divideFeature.getFeatureValue()).getCode() + "', as default" + " class code '1' is used. "); decision.addDecision(1); // default prediction // classCodeTable.getEmptyKBestList().addKBestItem(1); } return true; }
/* If you set jmx.serial.form to "1.2.0" or "1.2.1", then we are bug-compatible with those versions. Specifically, field names are forced to lower-case before being written. This contradicts the spec, which, though it does not mention serialization explicitly, does say that the case of field names is preserved. But in 1.2.0 and 1.2.1, this requirement was not met. Instead, field names in the descriptor map were forced to lower case. Those versions expect this to have happened to a descriptor they deserialize and e.g. getFieldValue will not find a field whose name is spelt with a different case. */ private void writeObject(ObjectOutputStream out) throws IOException { ObjectOutputStream.PutField fields = out.putFields(); boolean compat = "1.0".equals(serialForm); if (compat) fields.put("currClass", currClass); /* Purge the field "targetObject" from the DescriptorSupport before * serializing since the referenced object is typically not * serializable. We do this here rather than purging the "descriptor" * variable below because that HashMap doesn't do case-insensitivity. * See CR 6332962. */ SortedMap<String, Object> startMap = descriptorMap; if (startMap.containsKey("targetObject")) { startMap = new TreeMap<String, Object>(descriptorMap); startMap.remove("targetObject"); } final HashMap<String, Object> descriptor; if (compat || "1.2.0".equals(serialForm) || "1.2.1".equals(serialForm)) { descriptor = new HashMap<String, Object>(); for (Map.Entry<String, Object> entry : startMap.entrySet()) descriptor.put(entry.getKey().toLowerCase(), entry.getValue()); } else descriptor = new HashMap<String, Object>(startMap); fields.put("descriptor", descriptor); out.writeFields(); }
private void addRequirementTo( SortedMap<String, Requirement> requirementsByPath, Class candidateClass) { String fullRequirementName = getFullRequirementPath(candidateClass); String[] packageNames = fullRequirementName.split(DOT_REGEX); String currentPath = ""; for (int level = 0; level < packageNames.length; level++) { currentPath = (currentPath.isEmpty()) ? packageNames[level] : Joiner.on(".").join(currentPath, packageNames[level]); String defaultRequirementType = getDefaultType(level); Requirement currentRequirement; if (!requirementsByPath.containsKey(currentPath)) { if (level < packageNames.length - 1) { currentRequirement = newParentRequirement(currentPath, packageNames[level], level, defaultRequirementType); requirementsByPath.put(currentPath, currentRequirement); } else { currentRequirement = newRequirement( candidateClass, currentPath, packageNames[level], level, defaultRequirementType); String fullPath = getFullRequirementPath(candidateClass); requirementsByPath.put(fullPath, currentRequirement); } } } }
public synchronized void putDefault(final String key, final String def) { if (!defaults.containsKey(key) || defaults.get(key) == null) { defaults.put(key, def); } else if (def != null && !defaults.get(key).equals(def)) { System.out.println("Defaults for " + key + " differ: " + def + " != " + defaults.get(key)); } }
public void addBestSearchEngineScoreOptionalColumn(MZTabColumn column, Integer id) { String position = column.getLogicPosition(); if (optionalColumnMapping.containsKey(position)) { throw new IllegalArgumentException( "There exists column " + optionalColumnMapping.get(position) + " in position " + position); } MZTabColumn newColumn = null; switch (section) { case Protein_Header: if (column.getName().equals(ProteinColumn.BEST_SEARCH_ENGINE_SCORE.getName())) { newColumn = MZTabColumn.createOptionalColumn(section, column, id, null); } break; case Peptide_Header: if (column.getName().equals(PeptideColumn.BEST_SEARCH_ENGINE_SCORE.getName())) { newColumn = MZTabColumn.createOptionalColumn(section, column, id, null); } break; case Small_Molecule_Header: if (column.getName().equals(SmallMoleculeColumn.BEST_SEARCH_ENGINE_SCORE.getName())) { newColumn = MZTabColumn.createOptionalColumn(section, column, id, null); } break; } if (newColumn != null) { optionalColumnMapping.put(newColumn.getLogicPosition(), newColumn); columnMapping.put(newColumn.getLogicPosition(), newColumn); } }
private AtomicModel getAtomicModel() throws MaltChainedException { if (getGuide().getGuideMode() == ClassifierGuide.GuideMode.BATCH) { throw new GuideException("Can only predict during parsing. "); } else if (!(divideFeature.getFeatureValue() instanceof SingleFeatureValue)) { throw new GuideException("The divide feature does not have a single value. "); } if (divideModels != null && divideModels.containsKey( ((SingleFeatureValue) divideFeature.getFeatureValue()).getCode())) { return divideModels.get(((SingleFeatureValue) divideFeature.getFeatureValue()).getCode()); } else if (masterModel != null && masterModel.getFrequency() > 0) { return masterModel; } else { getGuide() .getConfiguration() .getConfigLogger() .info( "Could not predict the next parser decision because there is " + "no divide or master model that covers the divide value '" + ((SingleFeatureValue) divideFeature.getFeatureValue()).getCode() + "', as default" + " class code '1' is used. "); } return null; }
protected static SortedMap<Integer, AgreementSummaryInstance> getAgreementSummaryList( List<Object[]> objects, boolean primary, boolean siteSearch) throws Exception { SortedMap<Integer, AgreementSummaryInstance> agreementMap = new TreeMap<Integer, AgreementSummaryInstance>(); AgreementSummaryInstance instance = null; for (Object[] row : objects) { if (row.length >= 1 && row[0] instanceof Agreement) { Agreement agreement = (Agreement) row[0]; if (agreementMap.containsKey(agreement.getId())) { instance = agreementMap.get(agreement.getId()); } else { instance = getAgreementSummaryInstance(agreement, primary, siteSearch); agreementMap.put(instance.getId(), instance); } } if (row.length == 2 && row[0] instanceof Agreement && row[1] != null && row[1] instanceof AgreementTerm) { AgreementTerm agreementTerm = (AgreementTerm) row[1]; applyAgreementTerm(instance, agreementTerm); } else if (row.length != 2 || !(row[0] instanceof Agreement) || !(row[1] == null || row[1] instanceof Agreement)) throw new Exception("Unexpected SQL result in getAgreementSummaryList"); } return agreementMap; // List<AgreementSummaryInstance> results = new ArrayList<AgreementSummaryInstance>(); // results.addAll(agreementMap.values()); // // return results; }
public void addInstance(SingleDecision decision) throws MaltChainedException { if (getGuide().getGuideMode() == ClassifierGuide.GuideMode.CLASSIFY) { throw new GuideException("Can only add instance during learning. "); } else if (!(divideFeature.getFeatureValue() instanceof SingleFeatureValue)) { throw new GuideException("The divide feature does not have a single value. "); } divideFeature.update(); if (divideModels != null) { if (!divideModels.containsKey( ((SingleFeatureValue) divideFeature.getFeatureValue()).getCode())) { divideModels.put( ((SingleFeatureValue) divideFeature.getFeatureValue()).getCode(), new AtomicModel( ((SingleFeatureValue) divideFeature.getFeatureValue()).getCode(), divideFeatureVector, this)); } divideModels .get(((SingleFeatureValue) divideFeature.getFeatureValue()).getCode()) .addInstance(decision); } else { throw new GuideException("The feature divide models cannot be found. "); } }
/** * @param bitmapCodec * @return */ private Map<Integer, CompositeDef> buildFieldsDefs(BitmapCodec bitmapCodec) { NodeList messageList = doc.getElementsByTagName(ELEMENT_MESSAGE); Map<Integer, CompositeDef> defs = new TreeMap<>(); for (int i = 0; i < messageList.getLength(); i++) { Element messageDef = (Element) messageList.item(i); Integer mti = getOptionalInteger(messageDef, ATTR_MTI); if (defs.containsKey(mti)) { throw new ConfigException(format("Duplicate message config for mti %d", mti)); } SortedMap<Integer, ComponentDef> messageFieldDefs = buildVarComponents(messageDef); if (messageFieldDefs.containsKey(1)) { throw new ConfigException("Message field with index 1 not allowed"); } defs.put( mti, new CompositeDef( messageFieldDefs, new VarCompositeCodec(bitmapCodec, defaultFailFast), true)); } return defs; }
public synchronized String get(final String key, final String def) { putDefault(key, def); if (override.containsKey(key)) return override.get(key); final String prop = properties.get(key); if (prop == null || prop.equals("")) return def; return prop; }
private DropdownMenu getDropDownOfQueries(String key, IWContext iwc) throws RemoteException, FinderException { SortedMap sortedMap = new TreeMap(new StringAlphabeticalComparator(iwc.getCurrentLocale())); DropdownMenu drp = new DropdownMenu(key); Iterator iterator = getQueryService(iwc).getQueries(iwc).iterator(); while (iterator.hasNext()) { EntityRepresentation userQuery = (EntityRepresentation) iterator.next(); String name = (String) userQuery.getColumnValue(QueryRepresentation.NAME_KEY); String id = userQuery.getPrimaryKey().toString(); if (sortedMap.containsKey(name)) { // usually the items have different names therefore we implement // a very simple solution name += " (1)"; } sortedMap.put(name, id); } Iterator sortedIterator = sortedMap.entrySet().iterator(); while (sortedIterator.hasNext()) { Map.Entry entry = (Map.Entry) sortedIterator.next(); String id = (String) entry.getValue(); String name = (String) entry.getKey(); drp.addMenuElement(id, name); } return drp; }
private static void determineColumnWidths(List<Integer> columnWidths, List<String> row) { SortedMap<Integer, Integer> cws = new TreeMap<Integer, Integer>(); int columnNo = 0; for (Integer width : columnWidths) { cws.put(columnNo, width); columnNo++; } columnNo = 0; for (String cell : row) { int width = get(cell).length(); int origWidth = 0; if (cws.containsKey(columnNo)) { origWidth = cws.get(columnNo); } if (width >= origWidth) { cws.put(columnNo, width); } columnNo++; } columnWidths.clear(); columnWidths.addAll(cws.values()); }
@Override public Construct get(Construct index, Target t) { if (!associative_mode) { try { return array.get(Static.getInt32(index, t)); } catch (IndexOutOfBoundsException e) { throw ConfigRuntimeException.BuildException( "The element at index \"" + index.val() + "\" does not exist", ExceptionType.IndexOverflowException, t, e); } } else { if (associative_array.containsKey(normalizeConstruct(index))) { Construct val = associative_array.get(normalizeConstruct(index)); if (val instanceof CEntry) { return ((CEntry) val).construct(); } return val; } else { // Create this so we can at least attach a stacktrace. @SuppressWarnings({"ThrowableInstanceNotThrown", "ThrowableInstanceNeverThrown"}) IndexOutOfBoundsException ioobe = new IndexOutOfBoundsException(); throw ConfigRuntimeException.BuildException( "The element at index \"" + index.val() + "\" does not exist", ExceptionType.IndexOverflowException, t, ioobe); } } }
@Override public synchronized void updateAccessData( String karafInstanceUrl, String karafInstanceUserName, String karafInstancePassword, Boolean remoteIsAccessible, Boolean allowUpdateMessages, String karafInstance) { if (karafInstance == null) throw new RuntimeException("karafInstance cannot be null"); if (karafInstanceUserName == null) throw new RuntimeException("username cannot be null"); if (karafInstancePassword == null) throw new RuntimeException("password cannot be null"); if (remoteIsAccessible == null) throw new RuntimeException("remoteIsAccessible cannot be null"); if (allowUpdateMessages == null) throw new RuntimeException("allowUpdateMessages cannot be null"); SortedMap<String, KarafManifestEntryJaxb> karafInstances = getKarafInstances(); if (!karafInstances.containsKey(karafInstance)) throw new RuntimeException("system does not know karafInstance=" + karafInstance); KarafManifestEntryJaxb ki = karafInstances.get(karafInstance); ki.setKarafInstancePassword(karafInstancePassword); ki.setKarafInstanceUserName(karafInstanceUserName); ki.setKarafInstanceUrl(karafInstanceUrl); ki.setRemoteIsAccessible(remoteIsAccessible); ki.setAllowUpdateMessages(allowUpdateMessages); persist(); }
/* * values[]: the alphabet (provided as Integers) bitLengths[]: the number of * bits of symbil's huffman code */ public CanonicalHuffmanIntegerCodec(int[] values, int[] bitLengths) { super(); // 1. Sort by (a) bit length and (b) by symbol value ----------- SortedMap codebook = new TreeMap<Integer, SortedSet<Integer>>(); for (int i = 0; i < values.length; i++) { if (codebook.containsKey(bitLengths[i])) ((TreeSet) codebook.get(bitLengths[i])).add(values[i]); else { TreeSet<Integer> entry = new TreeSet<Integer>(); entry.add(values[i]); codebook.put(bitLengths[i], entry); } } codeLentghSorted = new Integer[codebook.size()]; int keys = 0; // 2. Calculate and Assign Canonical Huffman Codes ------------- int codeLength = 0, codeValue = -1; // first Canonical is always 0 codes = new TreeMap<Integer, HuffmanBitCode>(); Set keySet = codebook.keySet(); for (Object key : keySet) { // Iterate over code lengths int iKey = Integer.parseInt(key.toString()); codeLentghSorted[keys++] = iKey; TreeSet<Integer> get = (TreeSet<Integer>) codebook.get(key); for (Integer entry : get) { // Iterate over symbols HuffmanBitCode code = new HuffmanBitCode(); code.bitLentgh = iKey; // given: bit length code.value = entry; // given: symbol codeValue++; // increment bit value by 1 int delta = iKey - codeLength; // new length? codeValue = codeValue << delta; // pad with 0's code.bitCode = codeValue; // calculated: huffman code codeLength += delta; // adjust current code len if (NumberOfSetBits(codeValue) > iKey) throw new IllegalArgumentException("Symbol out of range"); codes.put(entry, code); // Store HuffmanBitCode Map<Long, Integer> codeMap = codeCache.get(code.bitLentgh); if (codeMap == null) { codeMap = new HashMap<Long, Integer>(); codeCache.put(code.bitLentgh, codeMap); } codeMap.put(new Long(code.bitCode), code.value); } } // 3. Done. Just have to populate codeMaps --------------------- if (codeLentghSorted.length > 0) codeMaps = new Map[codeLentghSorted[codeLentghSorted.length - 1] + 1]; else codeMaps = new Map[1]; for (int len : codeLentghSorted) { // Iterate over code lengths codeMaps[len] = codeCache.get(len); } }
/** * Removes an attribute from this resource class. * * @param attr an attribute. * @throws EntityDoesNotExistException if the class does not declare the attribute. */ public void deleteAttribute(Attribute attr) throws EntityDoesNotExistException { if (!attributes.containsKey(attr.getName())) { throw new EntityDoesNotExistException( "class " + getName() + " does not declare attribute " + "named " + attr.getName()); } attributes.remove(attr.getName()); attr.setDeclaringClass(null); }
private String urciVybranyKlic() { if (allPatterns.size() == 0) { return null; } if (patterned.getPatternNumberCilovy() != null && allPatterns.containsKey(patterned.getPatternNumberCilovy())) { return patterned.getPatternNumberCilovy(); } if (patterned.getPatternNumberCilovy() == null && implicitnGeotaggingKey != null) { return implicitnGeotaggingKey; } if (patterned.getPatternNumberPredbezny() != null && allPatterns.containsKey(patterned.getPatternNumberPredbezny())) { return patterned.getPatternNumberPredbezny(); } return allPatterns.firstKey(); }
private void cleanUpImports() { Integer dummyVote = new Integer(Integer.MAX_VALUE); SortedMap newImports = new TreeMap(comparator); List classImports = new LinkedList(); Iterator iter = imports.keySet().iterator(); while (iter.hasNext()) { String importName = (String) iter.next(); Integer vote = (Integer) imports.get(importName); if (!importName.endsWith(".*")) { if (vote.intValue() < importClassLimit) continue; int delim = importName.lastIndexOf("."); if (delim != -1) { /* * Since the imports are sorted, newImports already contains * the package if it should be imported. */ if (newImports.containsKey(importName.substring(0, delim) + ".*")) continue; /* * This is a single Class import, that is not superseeded by * a package import. Mark it for importation, but don't put * it in newImports, yet. */ classImports.add(importName); } else if (pkg.length() != 0) { /* * This is a Class import from the unnamed package. It must * always be imported. */ newImports.put(importName, dummyVote); } } else { if (vote.intValue() < importPackageLimit) continue; newImports.put(importName, dummyVote); } } imports = newImports; cachedClassNames = new Hashtable(); /* * Now check if the class import conflict with any of the package * imports. */ iter = classImports.iterator(); while (iter.hasNext()) { /* * If there are more than one single class imports with the same * name, exactly the first (in sorted order) will be imported. */ String classFQName = (String) iter.next(); if (!conflictsImport(classFQName)) { imports.put(classFQName, dummyVote); String name = classFQName.substring(classFQName.lastIndexOf('.') + 1); cachedClassNames.put(classFQName, name); } } }
public double remove(String omxId) throws ParserConfigurationException { if (stockmap.containsKey(omxId)) { events.addEvent("Stock removed from portfolio", omxId, invest.getShortName(omxId)); updateLatestBuy(); updateLatestSell(); return stockmap.remove(omxId); } return 0; }