List of usage examples for java.util LinkedHashMap size
int size();
From source file:com.taobao.datax.plugins.writer.oraclejdbcwriter.OracleJdbcWriter.java
public String buildInsertString() { StringBuilder sb = new StringBuilder(); sb.append("INSERT INTO ").append(this.schema + "." + this.table).append(" "); if (!StringUtils.isEmpty(this.colorder)) { sb.append("(").append(this.colorder).append(")"); }/*from w w w .ja v a 2 s .c o m*/ sb.append(" VALUES("); try { ResultSet rs = this.connection.createStatement() .executeQuery("SELECT COLUMN_NAME,DATA_TYPE FROM USER_TAB_COLUMNS WHERE TABLE_NAME='" + this.table.toUpperCase() + "'"); LinkedHashMap<String, String> map = new LinkedHashMap<String, String>(); while (rs.next()) { String colName = rs.getString(1); String colType = rs.getString(2); map.put(colName, colType); } logger.debug("Column map:size=" + map.size() + ";cols=" + map.toString()); if (StringUtils.isEmpty(this.colorder)) { Iterator<Entry<String, String>> it = map.entrySet().iterator(); while (it.hasNext()) { Entry<String, String> entry = it.next(); String colType = entry.getValue(); if (colType.toUpperCase().equals("DATE")) { sb.append("to_date(?,'" + this.dtfmt + "'),"); } else { sb.append("?,"); } } sb.deleteCharAt(sb.length() - 1);// remove last comma sb.append(")"); } else { String[] arr = colorder.split(","); for (String colName : arr) { if (!map.containsKey(colName)) { throw new DataExchangeException("col " + colName + " not in database"); } String colType = map.get(colName); if (colType.toUpperCase().equals("DATE")) { sb.append("to_date(?,'" + this.dtfmt + "'),"); } else { sb.append("?,"); } } sb.deleteCharAt(sb.length() - 1);// remove last comma sb.append(")"); } } catch (SQLException e) { e.printStackTrace(); throw new DataExchangeException(e.getMessage()); } return sb.toString(); }
From source file:com.andremion.louvre.home.GalleryAdapter.java
void selectAll() { if (mData == null) { return;/* w w w . ja va2 s . c o m*/ } LinkedHashMap<Long, Uri> selectionToAdd = new LinkedHashMap<>(); int count = mData.getCount(); for (int position = 0; position < count; position++) { if (!isSelected(position)) { long id = getItemId(position); Uri data = getData(position); selectionToAdd.put(id, data); } } if (mSelection.size() + selectionToAdd.size() > mMaxSelection) { if (mCallbacks != null) { mCallbacks.onWillExceedMaxSelection(); } } else { mSelection.putAll(selectionToAdd); notifySelectionChanged(); } }
From source file:com.opengamma.analytics.financial.interestrate.MultipleYieldCurveFinderDataBundle.java
/** * Create a MultipleYieldCurveFinderDataBundle where the number of nodes and the list of curve names correspond to all the curves (known curves and curves still to be calibrated). * This constructor is used to compute the extended Jacobian matrix when curves are calibrated in several blocks. * @param derivatives The list of instruments used in the calibration. * @param marketValues The market value of the instruments. * @param knownCurves The curves already calibrated. * @param unknownCurveNodePoints The node points of the new curves to calibrate. * @param unknownCurveInterpolators The interpolators of the new curves to calibrate. * @param useFiniteDifferenceByDefault Flag for using the finite difference computation of the Jacobian. * @param fxMatrix The FX Matrix with the required exchange rates. * @return The data bundle./*from w w w . ja v a 2s . com*/ */ public static MultipleYieldCurveFinderDataBundle withAllCurves(final List<InstrumentDerivative> derivatives, final double[] marketValues, final YieldCurveBundle knownCurves, final LinkedHashMap<String, double[]> unknownCurveNodePoints, final LinkedHashMap<String, Interpolator1D> unknownCurveInterpolators, final boolean useFiniteDifferenceByDefault, final FXMatrix fxMatrix) { // Argument checker: start ArgumentChecker.notNull(derivatives, "derivatives"); ArgumentChecker.noNulls(derivatives, "derivatives"); ArgumentChecker.notNull(marketValues, "market values null"); ArgumentChecker.notNull(unknownCurveNodePoints, "unknown curve node points"); ArgumentChecker.notNull(unknownCurveInterpolators, "unknown curve interpolators"); ArgumentChecker.notEmpty(unknownCurveNodePoints, "unknown curve node points"); ArgumentChecker.notEmpty(unknownCurveInterpolators, "unknown curve interpolators"); ArgumentChecker.isTrue(derivatives.size() == marketValues.length, "marketValues wrong length; must be one par rate per derivative (have {} values for {} derivatives", marketValues.length, derivatives.size()); ArgumentChecker.notNull(fxMatrix, "FX matrix"); if (knownCurves != null) { for (final String name : knownCurves.getAllNames()) { if (unknownCurveInterpolators.containsKey(name)) { throw new IllegalArgumentException("Curve name in known set matches one to be solved for"); } } } if (unknownCurveNodePoints.size() != unknownCurveInterpolators.size()) { throw new IllegalArgumentException("Number of unknown curves not the same as curve interpolators"); } // Argument checker: end int nbNodes = 0; if (knownCurves != null) { for (final String name : knownCurves.getAllNames()) { nbNodes += knownCurves.getCurve(name).getNumberOfParameters(); } } for (final double[] nodes : unknownCurveNodePoints.values()) { // Nodes from new curves nbNodes += nodes.length; } final List<String> names = new ArrayList<>(); if (knownCurves != null) { names.addAll(knownCurves.getAllNames()); // Names from existing curves } final Iterator<Entry<String, double[]>> nodePointsIterator = unknownCurveNodePoints.entrySet().iterator(); final Iterator<Entry<String, Interpolator1D>> unknownCurvesIterator = unknownCurveInterpolators.entrySet() .iterator(); while (nodePointsIterator.hasNext()) { // Names from new curves final Entry<String, double[]> entry1 = nodePointsIterator.next(); final Entry<String, Interpolator1D> entry2 = unknownCurvesIterator.next(); final String name1 = entry1.getKey(); if (!name1.equals(entry2.getKey())) { throw new IllegalArgumentException("Names must be the same"); } ArgumentChecker.notNull(entry1.getValue(), "curve node points for " + name1); ArgumentChecker.notNull(entry2.getValue(), "interpolator for " + name1); names.add(name1); } return new MultipleYieldCurveFinderDataBundle(derivatives, marketValues, knownCurves, unknownCurveNodePoints, unknownCurveInterpolators, useFiniteDifferenceByDefault, fxMatrix, nbNodes, names); }
From source file:com.zimbra.cs.db.SQLite.java
@Override public void registerDatabaseInterest(DbConnection conn, String dbname) throws SQLException, ServiceException { LinkedHashMap<String, String> attachedDBs = getAttachedDatabases(conn); if (attachedDBs != null && attachedDBs.containsKey(dbname)) return;/* www. jav a 2s .c o m*/ // if we're using more databases than we're allowed to, detach the least recently used if (attachedDBs != null && attachedDBs.size() >= MAX_ATTACHED_DATABASES) { for (Iterator<String> it = attachedDBs.keySet().iterator(); attachedDBs.size() >= MAX_ATTACHED_DATABASES && it.hasNext();) { String name = it.next(); if (!name.equals("zimbra") && detachDatabase(conn, name)) it.remove(); } } attachDatabase(conn, dbname); }
From source file:com.ultramegasoft.flavordex2.fragment.ViewInfoFragment.java
/** * Populates the table of extra fields.//from w w w. j a v a 2s . c o m * * @param data A LinkedHashMap containing the extra values */ protected void populateExtras(@NonNull LinkedHashMap<String, ExtraFieldHolder> data) { final Activity activity = getActivity(); if (activity == null) { return; } final TableLayout table = activity.findViewById(R.id.entry_info); if (!mExtraRows.isEmpty()) { for (View tableRow : mExtraRows) { table.removeView(tableRow); } mExtraRows.clear(); } if (data.size() > 0) { final LayoutInflater inflater = LayoutInflater.from(activity); for (ExtraFieldHolder extra : data.values()) { if (extra.preset) { continue; } final View root = inflater.inflate(R.layout.view_info_extra, table, false); ((TextView) root.findViewById(R.id.label)).setText(getString(R.string.label_field, extra.name)); ((TextView) root.findViewById(R.id.value)).setText(extra.value); table.addView(root); mExtraRows.add(root); } } }
From source file:eu.hydrologis.jgrass.charting.datamodels.MultiXYTimeChartCreator.java
/** * Make a composite with the plot of the supplied chartdata. There are several HINT* variables * that can be set to tweak and configure the plot. * /*from w w w . j ava2 s .c om*/ * @param parentComposite * @param chartData */ public void makePlot(Composite parentComposite, NumericChartData chartData) { final int tabNums = chartData.getTabItemNumbers(); if (tabNums == 0) { return; } Shell dummyShell = null; // try { // dummyShell = PlatformUI.getWorkbench().getDisplay().getActiveShell(); // } catch (Exception e) { dummyShell = new Shell(Display.getCurrent(), SWT.None); // } /* * wrapping panel needed in the case of hide checks */ TabFolder tabFolder = null; if (tabNums > 1) { tabFolder = new TabFolder(parentComposite, SWT.BORDER); tabFolder.setLayout(new GridLayout()); tabFolder.setLayoutData( new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL)); } for (int i = 0; i < tabNums; i++) { NumericChartDataItem chartItem = chartData.getChartDataItem(i); int chartNums = chartItem.chartSeriesData.size(); /* * are there data to create the lower chart panel */ List<LinkedHashMap<String, Integer>> series = new ArrayList<LinkedHashMap<String, Integer>>(); List<XYPlot> plots = new ArrayList<XYPlot>(); List<JFreeChart> charts = new ArrayList<JFreeChart>(); for (int j = 0; j < chartNums; j++) { final LinkedHashMap<String, Integer> chartSeries = new LinkedHashMap<String, Integer>(); XYPlot chartPlot = null; JGrassChart chart = null; double[][][] cLD = chartItem.chartSeriesData.get(j); if (M_HINT_CREATE_CHART[i][j]) { final String[] cT = chartItem.seriesNames.get(j); final String title = chartItem.chartTitles.get(j); final String xT = chartItem.chartXLabels.get(j); final String yT = chartItem.chartYLabels.get(j); if (M_HINT_CHART_TYPE[i][j] == XYLINECHART) { chart = new JGrassXYLineChart(cT, cLD); } else if (M_HINT_CHART_TYPE[i][j] == XYBARCHART) { chart = new JGrassXYBarChart(cT, cLD, HINT_barwidth); } else if (M_HINT_CHART_TYPE[i][j] == TIMEYLINECHART) { chart = new JGrassXYTimeLineChart(cT, cLD, Minute.class); ((JGrassXYTimeLineChart) chart).setTimeAxisFormat(TIMEFORMAT); } else if (M_HINT_CHART_TYPE[i][j] == TIMEYBARCHART) { chart = new JGrassXYTimeBarChart(cT, cLD, Minute.class, HINT_barwidth); ((JGrassXYTimeBarChart) chart).setTimeAxisFormat(TIMEFORMAT); } else if (M_HINT_CHART_TYPE[i][j] == XYPOINTCHART) { chart = new JGrassXYLineChart(cT, cLD); ((JGrassXYLineChart) chart).toggleLineShapesDisplay(false, true); } else if (M_HINT_CHART_TYPE[i][j] == TIMEXYPOINTCHART) { chart = new JGrassXYTimeLineChart(cT, cLD, Minute.class); ((JGrassXYTimeLineChart) chart).setTimeAxisFormat(TIMEFORMAT); ((JGrassXYTimeLineChart) chart).toggleLineShapesDisplay(false, true); } else { chart = new JGrassXYLineChart(cT, cLD); } final Composite p1Composite = new Composite(dummyShell, SWT.None); p1Composite.setLayout(new FillLayout()); p1Composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); chart.makeChartPanel(p1Composite, title, xT, yT, null, true, true, true, true); chartPlot = (XYPlot) chart.getPlot(); XYItemRenderer renderer = chartPlot.getRenderer(); chartPlot.setDomainGridlinesVisible(HINT_doDomainGridVisible); chartPlot.setRangeGridlinesVisible(HINT_doRangeGridVisible); if (HINT_doDisplayToolTips) { renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); } if (!M_HINT_CHARTORIENTATION_UP[i][j]) { chartPlot.getRangeAxis().setInverted(true); } if (M_HINT_CHARTSERIESCOLOR != null) { final XYItemRenderer rend = renderer; for (int k = 0; k < cLD.length; k++) { rend.setSeriesPaint(k, M_HINT_CHARTSERIESCOLOR[i][j][k]); } } chart.toggleFilledShapeDisplay(HINT_doDisplayBaseShapes, HINT_doFillBaseShapes, true); for (int k = 0; k < cT.length; k++) { chartSeries.put(cT[k], k); } series.add(chartSeries); chartPlot.setNoDataMessage("No data available"); chartPlot.setNoDataMessagePaint(Color.red); plots.add(chartPlot); charts.add(chart.getChart(title, xT, yT, null, true, HINT_doDisplayToolTips, true)); chartsList.add(chart); /* * add annotations? */ if (chartItem.annotationsOnChart.size() > 0) { LinkedHashMap<String, double[]> annotations = chartItem.annotationsOnChart.get(j); if (annotations.size() > 0) { Set<String> keys = annotations.keySet(); for (String key : keys) { double[] c = annotations.get(key); XYPointerAnnotation ann = new XYPointerAnnotation(key, c[0], c[1], HINT_AnnotationArrowAngle); ann.setTextAnchor(HINT_AnnotationTextAncor); ann.setPaint(HINT_AnnotationTextColor); ann.setArrowPaint(HINT_AnnotationArrowColor); // ann.setArrowLength(15); renderer.addAnnotation(ann); // Marker currentEnd = new ValueMarker(c[0]); // currentEnd.setPaint(Color.red); // currentEnd.setLabel(""); // currentEnd.setLabelAnchor(RectangleAnchor.TOP_RIGHT); // currentEnd.setLabelTextAnchor(TextAnchor.TOP_LEFT); // chartPlot.addDomainMarker(currentEnd); // Drawable cd = new LineDrawer(Color.red, new BasicStroke(1.0f)); // XYAnnotation bestBid = new XYDrawableAnnotation(c[0], c[1]/2.0, // 0, c[1], // cd); // chartPlot.addAnnotation(bestBid); // pointer.setFont(new Font("SansSerif", Font.PLAIN, 9)); } } } } } JFreeChart theChart = null; if (plots.size() > 1) { ValueAxis domainAxis = null; if (M_HINT_CHART_TYPE[i][0] == ChartCreator.TIMEYBARCHART || M_HINT_CHART_TYPE[i][0] == ChartCreator.TIMEYLINECHART) { domainAxis = (plots.get(0)).getDomainAxis(); } else { domainAxis = new NumberAxis(chartItem.chartXLabels.get(0)); } final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(domainAxis); plot.setGap(10.0); // add the subplots... for (int k = 0; k < plots.size(); k++) { XYPlot tmpPlot = plots.get(k); if (HINT_labelInsets != null) { tmpPlot.getRangeAxis().setLabelInsets(HINT_labelInsets); } plot.add(tmpPlot, k + 1); } plot.setOrientation(PlotOrientation.VERTICAL); theChart = new JFreeChart(chartItem.bigTitle, JFreeChart.DEFAULT_TITLE_FONT, plot, true); } else if (plots.size() == 1) { theChart = new JFreeChart(chartItem.chartTitles.get(0), JFreeChart.DEFAULT_TITLE_FONT, plots.get(0), true); } else { return; } /* * create the chart composite */ Composite tmp; if (tabNums > 1 && tabFolder != null) { tmp = new Composite(tabFolder, SWT.None); } else { tmp = new Composite(parentComposite, SWT.None); } tmp.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL)); tmp.setLayout(new GridLayout()); final ChartComposite frame = new ChartComposite(tmp, SWT.None, theChart, 680, 420, 300, 200, 700, 500, false, true, // properties true, // save true, // print true, // zoom true // tooltips ); // public static final boolean DEFAULT_BUFFER_USED = false; // public static final int DEFAULT_WIDTH = 680; // public static final int DEFAULT_HEIGHT = 420; // public static final int DEFAULT_MINIMUM_DRAW_WIDTH = 300; // public static final int DEFAULT_MINIMUM_DRAW_HEIGHT = 200; // public static final int DEFAULT_MAXIMUM_DRAW_WIDTH = 800; // public static final int DEFAULT_MAXIMUM_DRAW_HEIGHT = 600; // public static final int DEFAULT_ZOOM_TRIGGER_DISTANCE = 10; frame.setLayoutData( new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL)); frame.setLayout(new FillLayout()); frame.setDisplayToolTips(HINT_doDisplayToolTips); frame.setHorizontalAxisTrace(HINT_doHorizontalAxisTrace); frame.setVerticalAxisTrace(HINT_doVerticalAxisTrace); frame.setDomainZoomable(HINT_doDomainZoomable); frame.setRangeZoomable(HINT_doRangeZoomable); if (tabNums > 1 && tabFolder != null) { final TabItem item = new TabItem(tabFolder, SWT.NONE); item.setText(chartData.getChartDataItem(i).chartStringExtra); item.setControl(tmp); } /* * create the hide toggling part */ for (int j = 0; j < plots.size(); j++) { if (M_HINT_CREATE_TOGGLEHIDESERIES[i][j]) { final LinkedHashMap<Button, Integer> allButtons = new LinkedHashMap<Button, Integer>(); Group checksComposite = new Group(tmp, SWT.None); checksComposite.setText(""); RowLayout rowLayout = new RowLayout(); rowLayout.wrap = true; rowLayout.type = SWT.HORIZONTAL; checksComposite.setLayout(rowLayout); checksComposite .setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL)); final XYItemRenderer renderer = plots.get(j).getRenderer(); Set<String> lTitles = series.get(j).keySet(); for (final String title : lTitles) { final Button b = new Button(checksComposite, SWT.CHECK); b.setText(title); b.setSelection(true); final int index = series.get(j).get(title); b.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { boolean visible = renderer.getItemVisible(index, 0); renderer.setSeriesVisible(index, new Boolean(!visible)); } }); allButtons.put(b, index); } /* * toggle all and none */ if (HINT_doToggleTuttiButton) { Composite allchecksComposite = new Composite(tmp, SWT.None); RowLayout allrowLayout = new RowLayout(); allrowLayout.wrap = true; allrowLayout.type = SWT.HORIZONTAL; allchecksComposite.setLayout(allrowLayout); allchecksComposite .setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL)); final Button tuttiButton = new Button(allchecksComposite, SWT.BORDER | SWT.PUSH); tuttiButton.setText("Tutti"); tuttiButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Set<Button> set = allButtons.keySet(); for (Button button : set) { button.setSelection(true); int i = allButtons.get(button); if (renderer != null) { renderer.setSeriesVisible(i, new Boolean(true)); } } } }); final Button noneButton = new Button(allchecksComposite, SWT.BORDER | SWT.PUSH); noneButton.setText("Nessuno"); noneButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Set<Button> set = allButtons.keySet(); for (Button button : set) { button.setSelection(false); int i = allButtons.get(button); if (renderer != null) { renderer.setSeriesVisible(i, new Boolean(false)); } } } }); } } } } }
From source file:com.google.gwt.emultest.java.util.LinkedHashMapTest.java
public void testAddEqualKeys() { final LinkedHashMap<Number, Object> expected = new LinkedHashMap<Number, Object>(); assertEquals(expected.size(), 0); iterateThrough(expected);/*from w w w . j a v a 2 s. com*/ expected.put(new Long(45), new Object()); assertEquals(expected.size(), 1); iterateThrough(expected); expected.put(new Integer(45), new Object()); assertNotSame(new Integer(45), new Long(45)); assertEquals(expected.size(), 2); iterateThrough(expected); }
From source file:ubic.gemma.visualization.ExperimentalDesignVisualizationServiceImpl.java
@Override public Map<Long, LinkedHashMap<BioAssayValueObject, LinkedHashMap<ExperimentalFactor, Double>>> sortLayoutSamplesByFactor( final Map<Long, LinkedHashMap<BioAssayValueObject, LinkedHashMap<ExperimentalFactor, Double>>> layouts) { Map<Long, LinkedHashMap<BioAssayValueObject, LinkedHashMap<ExperimentalFactor, Double>>> sortedLayouts = new HashMap<Long, LinkedHashMap<BioAssayValueObject, LinkedHashMap<ExperimentalFactor, Double>>>(); StopWatch timer = new StopWatch(); timer.start();// www. ja v a2 s . c o m for (Long bioAssaySet : layouts.keySet()) { final LinkedHashMap<BioAssayValueObject, LinkedHashMap<ExperimentalFactor, Double>> layout = layouts .get(bioAssaySet); if (layout == null || layout.size() == 0) { log.warn("Null or empty layout for ee: " + bioAssaySet); // does this happen? continue; } LinkedHashMap<BioAssayValueObject, LinkedHashMap<ExperimentalFactor, Double>> sortedLayout = new LinkedHashMap<BioAssayValueObject, LinkedHashMap<ExperimentalFactor, Double>>(); Collection<ExperimentalFactor> filteredFactors = extractFactors(layout, false); if (filteredFactors.isEmpty()) { if (sortedLayouts.containsKey(bioAssaySet)) { log.warn("sortedLayouts already contained ee with ID = " + bioAssaySet + ". Value was map with # keys = " + sortedLayouts.get(bioAssaySet).keySet().size()); } sortedLayouts.put(bioAssaySet, sortedLayout); continue; // batch was the only factor. } List<BioMaterialValueObject> bmList = new ArrayList<BioMaterialValueObject>(); Map<BioMaterialValueObject, BioAssayValueObject> BMtoBA = new HashMap<BioMaterialValueObject, BioAssayValueObject>(); for (BioAssayValueObject ba : layout.keySet()) { BioMaterialValueObject bm = ba.getSample(); BMtoBA.put(bm, ba); bmList.add(bm); } // sort factors within layout by number of values LinkedList<ExperimentalFactor> sortedFactors = (LinkedList<ExperimentalFactor>) ExpressionDataMatrixColumnSort .orderFactorsByExperimentalDesignVO(bmList, filteredFactors); // this isn't necessary, because we can have factors get dropped if we are looking at a subset. // assert sortedFactors.size() == filteredFactors.size(); List<BioMaterialValueObject> sortedBMList = ExpressionDataMatrixColumnSort .orderBiomaterialsBySortedFactorsVO(bmList, sortedFactors); assert sortedBMList.size() == bmList.size(); // sort layout entries according to sorted ba list // List<BioAssayValueObject> sortedBAList = new ArrayList<BioAssayValueObject>(); for (BioMaterialValueObject bm : sortedBMList) { BioAssayValueObject ba = BMtoBA.get(bm); assert ba != null; // sortedBAList.add( bavo ); // sort factor-value pairs for each biomaterial LinkedHashMap<ExperimentalFactor, Double> facs = layout.get(ba); LinkedHashMap<ExperimentalFactor, Double> sortedFacs = new LinkedHashMap<ExperimentalFactor, Double>(); for (ExperimentalFactor fac : sortedFactors) { sortedFacs.put(fac, facs.get(fac)); } // assert facs.size() == sortedFacs.size() : "Expected " + facs.size() + " factors, got " // + sortedFacs.size(); sortedLayout.put(ba, sortedFacs); } sortedLayouts.put(bioAssaySet, sortedLayout); } if (timer.getTime() > 1000) { log.info("Sorting layout samples by factor: " + timer.getTime() + "ms"); } return sortedLayouts; }
From source file:com.grarak.kerneladiutor.activities.tools.DownloadsActivity.java
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_downloads); initToolBar();/* ww w . j av a 2 s. c om*/ SupportedDownloads.KernelContent content = new SupportedDownloads.KernelContent( getIntent().getStringExtra(JSON_INTENT)); getSupportActionBar().setTitle(Utils.htmlFrom(content.getName()).toString()); final ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager); LinkedHashMap<String, Fragment> items = new LinkedHashMap<>(); List<SupportedDownloads.KernelContent.Feature> features = content.getFeatures(); List<SupportedDownloads.KernelContent.Download> downloads = content.getDownloads(); if (content.getShortDescription() != null && content.getLongDescription() != null) { items.put(getString(R.string.about), AboutFragment.newInstance(content)); } if (features.size() > 0) { items.put(getString(R.string.features), FeaturesFragment.newInstance(features)); } if (downloads.size() > 0) { items.put(getString(R.string.downloads), DownloadKernelFragment.newInstance(downloads)); } viewPager.setOffscreenPageLimit(items.size()); PagerAdapter pagerAdapter = new PagerAdapter(getSupportFragmentManager(), items); viewPager.setAdapter(pagerAdapter); TabLayout tabLayout = (TabLayout) findViewById(R.id.tablayout); tabLayout.setupWithViewPager(viewPager); viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout)); }
From source file:com.google.gwt.emultest.java.util.LinkedHashMapTest.java
public void testLinkedHashMapMap() { LinkedHashMap<Integer, Integer> srcMap = new LinkedHashMap<Integer, Integer>(); assertNotNull(srcMap);/*from w w w. j av a 2s . com*/ checkEmptyLinkedHashMapAssumptions(srcMap); srcMap.put(INTEGER_1, INTEGER_11); srcMap.put(INTEGER_2, INTEGER_22); srcMap.put(INTEGER_3, INTEGER_33); LinkedHashMap<Integer, Integer> hashMap = cloneLinkedHashMap(srcMap); assertFalse(hashMap.isEmpty()); assertTrue(hashMap.size() == SIZE_THREE); Collection<Integer> valColl = hashMap.values(); assertTrue(valColl.contains(INTEGER_11)); assertTrue(valColl.contains(INTEGER_22)); assertTrue(valColl.contains(INTEGER_33)); Collection<Integer> keyColl = hashMap.keySet(); assertTrue(keyColl.contains(INTEGER_1)); assertTrue(keyColl.contains(INTEGER_2)); assertTrue(keyColl.contains(INTEGER_3)); }