List of usage examples for java.util Hashtable get
@SuppressWarnings("unchecked") public synchronized V get(Object key)
From source file:org.jberet.support.io.XmlFactoryObjectFactory.java
/** * Gets an instance of {@code com.fasterxml.jackson.dataformat.xml.XmlFactory} based on the resource configuration in the * application server. The parameter {@code environment} contains XmlFactory configuration properties, and accepts * the following properties:// w w w.j ava 2 s . c om * <ul> * <li>inputDecorator: fully-qualified name of a class that extends {@code com.fasterxml.jackson.core.io.InputDecorator} * <li>outputDecorator: fully-qualified name of a class that extends {@code com.fasterxml.jackson.core.io.OutputDecorator} * <li>xmlTextElementName: * <li>defaultUseWrapper: * </ul> * * @param obj the JNDI name of {@code com.fasterxml.jackson.dataformat.xml.XmlFactory} resource * @param name always null * @param nameCtx always null * @param environment a {@code Hashtable} of configuration properties * @return an instance of {@code com.fasterxml.jackson.dataformat.xml.XmlFactory} * @throws Exception any exception occurred */ @Override public Object getObjectInstance(final Object obj, final Name name, final Context nameCtx, final Hashtable<?, ?> environment) throws Exception { XmlFactory xmlFactory = xmlFactoryCached; if (xmlFactory == null) { synchronized (this) { xmlFactory = xmlFactoryCached; if (xmlFactory == null) { xmlFactoryCached = xmlFactory = new XmlFactory(); } JacksonXmlModule xmlModule = null; NoMappingJsonFactoryObjectFactory.configureInputDecoratorAndOutputDecorator(xmlFactory, environment); final Object xmlTextElementName = environment.get("xmlTextElementName"); if (xmlTextElementName != null) { xmlModule = new JacksonXmlModule(); xmlModule.setXMLTextElementName((String) xmlTextElementName); } final Object defaultUseWrapper = environment.get("defaultUseWrapper"); if (defaultUseWrapper != null) { if (defaultUseWrapper.equals("false")) { if (xmlModule == null) { xmlModule = new JacksonXmlModule(); } xmlModule.setDefaultUseWrapper(false); } else if (defaultUseWrapper.equals("true")) { //default value is already true, so nothing to do } else { throw SupportMessages.MESSAGES.invalidReaderWriterProperty(null, (String) defaultUseWrapper, "defaultUseWrapper"); } } final XmlMapper xmlMapper = xmlModule == null ? new XmlMapper(xmlFactory) : new XmlMapper(xmlFactory, xmlModule); xmlFactory.setCodec(xmlMapper); } } return xmlFactory; }
From source file:GifEncoder.java
public void encode(BufferedImage bufferedimage, DataOutputStream dataoutputstream, Hashtable hashtable) throws Exception { try {//from w w w . jav a 2 s . c om a = bufferedimage.getWidth(); g = bufferedimage.getHeight(); e = bufferedimage.getRGB(0, 0, a, g, null, 0, a); int i4 = 0; b = hashtable.get("encoding").toString(); if (b.equals("websafe")) { int ai[] = new int[256]; i = new int[256]; h = 8; int k1 = 0; int j; int j1 = j = 0; for (; j <= 255; j += 51) { for (int l = 0; l <= 255; l += 51) { for (int i1 = 0; i1 <= 255;) { i[j1] = (j << 16) + (l << 8) + i1; ai[k1++] = j1; i1 += 51; j1++; } } } if (f > 0) { int j4 = c[0]; int l1 = ((c[0] >> 16 & 0xff) + 25) / 51; int k2 = ((c[0] >> 8 & 0xff) + 25) / 51; int j3 = ((c[0] & 0xff) + 25) / 51; i4 = l1 * 36 + k2 * 6 + j3; for (j = 1; j < f; j++) { int i2 = ((c[j] >> 16 & 0xff) + 25) / 51; int l2 = ((c[j] >> 8 & 0xff) + 25) / 51; int k3 = ((c[j] & 0xff) + 25) / 51; ai[i2 * 36 + l2 * 6 + k3] = i4; } } j = 0; try { do { int i5 = e[j]; int j2 = ((i5 >> 16 & 0xff) + 25) / 51; int i3 = ((i5 >> 8 & 0xff) + 25) / 51; int l3 = ((i5 & 0xff) + 25) / 51; e[j++] = ai[j2 * 36 + i3 * 6 + l3]; } while (true); } catch (Exception exception1) { } } /*else if(b.equals("optimized")) { try { int k4 = Integer.parseInt(hashtable.get("colors").toString()); for(h = 1; k4 - 1 >> h > 0; h++) { } i = new int[1 << h]; CSelectiveQuant cselectivequant = new CSelectiveQuant(); for(int j5 = 0; j5 < e.length; j5++) { cselectivequant.addPixel(e[j5]); } boolean flag = f > 0; int k5 = flag ? 1 : 0; int ai1[] = cselectivequant.createPalette(k4 - k5); for(int l5 = 0; l5 < i.length; l5++) { try { i[l5] = ai1[l5 - k5]; } catch(ArrayIndexOutOfBoundsException arrayindexoutofboundsexception) { i[l5] = 0; } } if(flag) { i4 = 0; for(int i6 = 0; i6 < f; i6++) { cselectivequant.setIndex(c[i6], -1); } } for(int j6 = 0; j6 < e.length; j6++) { e[j6] = cselectivequant.getIndex(e[j6]) + k5; } } catch(NumberFormatException numberformatexception) { CmsLogger.logInfo("Parameter: 'colors' is malformated..."); return; } } */ dataoutputstream.write("GIF89a".getBytes()); dataoutputstream.writeByte(a); dataoutputstream.writeByte(a >> 8); dataoutputstream.writeByte(g); dataoutputstream.writeByte(g >> 8); dataoutputstream.writeByte(0xf0 | h - 1); dataoutputstream.writeByte(0); dataoutputstream.writeByte(0); int k = 0; try { do { int l4 = i[k++]; dataoutputstream.writeByte(l4 >> 16 & 0xff); dataoutputstream.writeByte(l4 >> 8 & 0xff); dataoutputstream.writeByte(l4 & 0xff); } while (true); } catch (Exception exception) { } if (f > 0) { dataoutputstream.writeByte(33); dataoutputstream.writeByte(249); dataoutputstream.writeByte(4); dataoutputstream.writeByte(1); dataoutputstream.writeByte(0); dataoutputstream.writeByte(0); dataoutputstream.writeByte(i4); dataoutputstream.writeByte(0); } dataoutputstream.writeByte(44); dataoutputstream.writeByte(0); dataoutputstream.writeByte(0); dataoutputstream.writeByte(0); dataoutputstream.writeByte(0); dataoutputstream.writeByte(a); dataoutputstream.writeByte(a >> 8); dataoutputstream.writeByte(g); dataoutputstream.writeByte(g >> 8); dataoutputstream.writeByte(0); dataoutputstream.writeByte(h); a(e, h, dataoutputstream); dataoutputstream.writeByte(59); dataoutputstream.flush(); return; } catch (Exception e) { } }
From source file:net.nosleep.superanalyzer.analysis.views.EncodingKindView.java
private void refreshDataset() { PiePlot3D plot = (PiePlot3D) _chart.getPlot(); _dataset.clear();/* w w w . j av a2 s .c o m*/ // plot.clearSectionPaints(true); Hashtable kindHash = null; if (_comboBox == null) { kindHash = _analysis.getEncodingKinds(Analysis.KIND_TRACK, null); } else { ComboItem item = (ComboItem) _comboBox.getSelectedItem(); kindHash = _analysis.getEncodingKinds(item.getKind(), item.getValue()); } Color[] colors = Theme.getColorSet(); Enumeration e = kindHash.keys(); int i = 0; while (e.hasMoreElements()) { String kindName = (String) e.nextElement(); Integer count = (Integer) kindHash.get(kindName); // if (count.intValue() > 0) { _dataset.setValue(kindName, new Double(count)); plot.setSectionPaint(kindName, colors[5 - (i % colors.length)]); // mod it in case we don't have enough colors i++; if (i > colors.length) i = 0; // } } // plot.notifyListeners(new PlotChangeEvent(plot)); // _chartPanel.invalidate(); }
From source file:eionet.gdem.qa.XQueryService.java
/** * Request from XML/RPC client Stores the source files and starts a job in the workqueue. * * @param files - Structure with XMLschemas as a keys and values are list of XML Files * @return Hashtable result: Structure with JOB ids as a keys and source files as values *//*from w w w . j a va 2 s .co m*/ public Vector analyzeXMLFiles(Hashtable files) throws GDEMException { Vector result = new Vector(); if (files == null) { return result; } Enumeration _schemas = files.keys(); while (_schemas.hasMoreElements()) { String _schema = _schemas.nextElement().toString(); Vector _files = (Vector) files.get(_schema); if (Utils.isNullVector(_files)) { continue; } for (int i = 0; i < _files.size(); i++) { String _file = (String) _files.get(i); analyzeXMLFiles(_schema, _file, result); } } return result; }
From source file:EditorPaneExample20.java
public static JMenu buildMenu(String name, MenuSpec[] menuSpecs, Hashtable actions) { int count = menuSpecs.length; JMenu menu = new JMenu(name); for (int i = 0; i < count; i++) { MenuSpec spec = menuSpecs[i];/*from www .java 2 s . c o m*/ if (spec.isSubMenu()) { // Recurse to handle a sub menu JMenu subMenu = buildMenu(spec.getName(), spec.getSubMenus(), actions); if (subMenu != null) { menu.add(subMenu); } } else if (spec.isAction()) { // It's an Action - add it directly to the menu menu.add(spec.getAction()); } else { // It's an action name - add it if possible String actionName = spec.getActionName(); Action targetAction = (Action) actions.get(actionName); // Create the menu item JMenuItem menuItem = menu.add(spec.getName()); if (targetAction != null) { // The editor kit knows the action menuItem.addActionListener(targetAction); } else { // Action not known - disable the menu item menuItem.setEnabled(false); } } } // Return null if nothing was added to the menu. if (menu.getMenuComponentCount() == 0) { menu = null; } return menu; }
From source file:com.globalsight.everest.webapp.pagehandler.administration.vendors.VendorHelper.java
/** * Given a list of locale pairs, remove them from the list of all locale * pairs. Then create a hashtable where the key is the source locale, and * the value is all possible target locales. * // w ww.ja v a 2s . c o m */ public static Hashtable getRemainingLocales(List currentLocales) throws EnvoyServletException { Hashtable remaining = new Hashtable(); Vector sourceLocales = UserHandlerHelper.getAllSourceLocales(); for (int i = 0; i < sourceLocales.size(); i++) { GlobalSightLocale curLocale = (GlobalSightLocale) sourceLocales.elementAt(i); Vector validTargets = UserHandlerHelper.getTargetLocales(curLocale); remaining.put(curLocale, validTargets); } // Now that we have a hashtable of all valid source locales and // their target locales, removes the ones that already exist for // this vendor. for (int i = 0; i < currentLocales.size(); i++) { LocalePair pair = (LocalePair) currentLocales.get(i); GlobalSightLocale target = pair.getTarget(); Vector targets = (Vector) remaining.get(pair.getSource()); if (targets != null && targets.contains(target)) { targets.remove(target); if (targets.size() == 0) { // no valid targets left so remove the entry in the hash remaining.remove(pair.getSource()); } } } return remaining; }
From source file:io.github.msdk.features.ransacaligner.RansacAlignerMethod.java
/** {@inheritDoc} */ @Override/*w ww . j a v a 2 s. c o m*/ public FeatureTable execute() throws MSDKException { // Calculate number of feature to process. Each feature will be // processed twice: first for score calculation and then for actual // alignment. for (FeatureTable featureTable : featureTables) { totalFeatures += featureTable.getRows().size() * 2; } // Iterate through all feature tables Boolean firstFeatureTable = true; for (FeatureTable featureTable : featureTables) { // Add columns from the original feature table to the result table for (FeatureTableColumn<?> column : featureTable.getColumns()) { if (firstFeatureTable) result.addColumn(column); else if (column.getSample() != null) result.addColumn(column); } firstFeatureTable = false; // Create a sorted array of matching scores between two rows List<RowVsRowScore> scoreSet = new ArrayList<RowVsRowScore>(); // Calculate scores for all possible alignments of this row for (FeatureTableRow row : featureTable.getRows()) { final Double mz = row.getMz(); if (mz == null) continue; // Calculate the m/z range limit for the current row Range<Double> mzRange = mzTolerance.getToleranceRange(mz); // Continue if no chromatography info is available ChromatographyInfo chromatographyInfo = row.getChromatographyInfo(); if (chromatographyInfo == null) continue; // Calculate the RT range limit for the current row Range<Double> rtRange = rtTolerance.getToleranceRange(chromatographyInfo.getRetentionTime()); processedFeatures++; if (canceled) return null; } // Create a table of mappings for best scores Hashtable<FeatureTableRow, FeatureTableRow> alignmentMapping = this.getAlignmentMap(featureTable); // Align all rows using the mapping for (FeatureTableRow sourceRow : featureTable.getRows()) { FeatureTableRow targetRow = alignmentMapping.get(sourceRow); // If we have no mapping for this row, add a new one if (targetRow == null) { targetRow = MSDKObjectBuilder.getFeatureTableRow(result, newRowID); result.addRow(targetRow); FeatureTableColumn<Integer> column = result.getColumn(ColumnName.ID, null); targetRow.setData(column, newRowID); newRowID++; } // Add all features from the original row to the aligned row for (Sample sample : sourceRow.getFeatureTable().getSamples()) { FeatureTableUtil.copyFeatureValues(sourceRow, targetRow, sample); } // Combine common values from the original row with the aligned // row FeatureTableUtil.copyCommonValues(sourceRow, targetRow, true); processedFeatures++; } // Re-calculate average row averages FeatureTableUtil.recalculateAverages(result); if (canceled) return null; } // Return the new feature table return result; }
From source file:net.nosleep.superanalyzer.analysis.views.GrowthView.java
private void refreshDataset() { TimeSeries series1 = new TimeSeries(Misc.getString("SONGS_IN_LIBRARY")); Hashtable addedHash = null; if (_comboBox == null) { addedHash = _analysis.getDatesAdded(Analysis.KIND_TRACK, null); } else {//from www .ja va 2 s . c o m ComboItem item = (ComboItem) _comboBox.getSelectedItem(); addedHash = _analysis.getDatesAdded(item.getKind(), item.getValue()); } Vector items = new Vector(); Enumeration e = addedHash.keys(); while (e.hasMoreElements()) { Day day = (Day) e.nextElement(); Integer count = (Integer) addedHash.get(day); if (count.intValue() > 0) { items.addElement(new GrowthItem(day, count)); } } Collections.sort(items, new GrowthComparator()); double value = 0.0; for (int i = 0; i < items.size(); i++) { GrowthItem item = (GrowthItem) items.elementAt(i); value += item.Count; series1.add(item.Day, value); } _dataset.removeAllSeries(); _dataset.addSeries(series1); }
From source file:edu.ku.brc.af.ui.forms.persist.ViewSet.java
/** * This verifies that a view refers to a valid ViewDef. It also sets the ViewDef object into the AltView. * @param views the hash of views/*from w w w. j av a 2s . c o m*/ * @param viewDefs the hash of viewdefs */ protected void verifyViewsAndViewDefs(final Hashtable<AltViewIFace, String> altViewsViewDefName) { // Need to get the Viewdefs and put them into the AltView for (ViewIFace view : views.values()) { for (AltViewIFace av : view.getAltViews()) { String viewDefName = altViewsViewDefName.get(av); if (av.getViewDef() == null) { if (StringUtils.isNotEmpty(viewDefName)) { ViewDefIFace referredToViewDef = viewDefs.get(viewDefName); if (referredToViewDef != null) { av.setViewDef(referredToViewDef); } else { String msg = "ViewSet[" + name + "] View[" + view + "] AltView [" + av.getName() + "] refers to a non-existent ViewDef with name[" + av.getViewDefName() + "]"; log.error(msg); FormDevHelper.appendFormDevError(msg); } } else { String msg = "ViewSet[" + name + "] Couldn't find the ViewDef Name for the AltView!"; log.error(msg); FormDevHelper.appendFormDevError(msg); } } } } }