List of usage examples for java.util Map size
int size();
From source file:com.lightbox.android.network.HttpHelper.java
private static URI addQueryParametersToUri(URI uri, Map<String, Object> urlParameters) { if (urlParameters != null && urlParameters.size() > 0) { Uri androidUri = Uri.parse(uri.toString()); Uri.Builder uriBuilder = androidUri.buildUpon(); for (Map.Entry<String, Object> param : urlParameters.entrySet()) { uriBuilder.appendQueryParameter(param.getKey(), param.getValue().toString()); }//from ww w.j av a 2 s . c om uri = URI.create(uriBuilder.build().toString()); } return uri; }
From source file:com.aitangba.volley.BasicNetwork.java
/** * Converts Headers[] to Map<String, String>. */// w ww . j ava2 s.c o m protected static Map<String, String> convertHeaders(Map<String, String> headers) { Map<String, String> result = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER); if (headers != null && headers.size() > 0) { for (String key : headers.keySet()) { result.put(key, headers.get(key)); } } return result; }
From source file:URISupport.java
public static String createQueryString(Map options) throws URISyntaxException { try {//from w w w. j a v a2s . c o m if (options.size() > 0) { StringBuffer rc = new StringBuffer(); boolean first = true; for (Iterator iter = options.keySet().iterator(); iter.hasNext();) { if (first) { first = false; } else { rc.append("&"); } String key = (String) iter.next(); String value = (String) options.get(key); rc.append(URLEncoder.encode(key, "UTF-8")); rc.append("="); rc.append(URLEncoder.encode(value, "UTF-8")); } return rc.toString(); } else { return ""; } } catch (UnsupportedEncodingException e) { throw (URISyntaxException) new URISyntaxException(e.toString(), "Invalid encoding").initCause(e); } }
From source file:com.adobe.acs.commons.util.TypeUtil.java
/** * Transforms a Map of <String, ?> into a ValueMap. * * @param map//from w w w . j a va 2s. c o m * @return a ValueMap of the parameter map */ public static ValueMap toValueMap(final Map<String, ?> map) { final Map<String, Object> objectMap = new LinkedHashMap<String, Object>(map.size()); for (final Map.Entry<String, ?> entry : map.entrySet()) { objectMap.put(entry.getKey(), entry.getValue()); } return new ValueMapDecorator(objectMap); }
From source file:com.mgmtp.perfload.core.common.util.PropertiesUtils.java
public static Map<String, String> getSubMap(final PropertiesMap properties, final String keyPrefix) { final String prefix = keyPrefix.endsWith(".") ? keyPrefix : keyPrefix + "."; Map<String, String> map = Maps.filterKeys(properties, new Predicate<String>() { @Override/*from w ww . j a v a 2 s . c o m*/ public boolean apply(final String input) { return input.startsWith(prefix); } }); Map<String, String> result = newHashMapWithExpectedSize(map.size()); for (Entry<String, String> entry : map.entrySet()) { result.put(substringAfter(entry.getKey(), prefix), entry.getValue()); } return result; }
From source file:com.netsteadfast.greenstep.bsc.util.BscMobileCardUtils.java
public static List<VisionVO> getVisionCard(String frequency, String startDate, String endDate) throws ServiceException, Exception { List<VisionVO> visionScores = new ArrayList<VisionVO>(); Map<String, String> visions = visionService.findForMap(false); if (null == visions || visions.size() < 1) { return visionScores; }//from w w w .j av a2s .c om Context context = new ContextBase(); context.put("startDate", startDate); context.put("endDate", endDate); context.put("startYearDate", startDate.substring(0, 4)); context.put("endYearDate", endDate.substring(0, 4)); context.put("frequency", frequency); context.put("dataFor", BscConstants.MEASURE_DATA_FOR_ALL); context.put("orgId", BscConstants.MEASURE_DATA_ORGANIZATION_FULL); context.put("empId", BscConstants.MEASURE_DATA_EMPLOYEE_FULL); for (Map.Entry<String, String> entry : visions.entrySet()) { String visionOid = entry.getKey(); context.put("visionOid", visionOid); SimpleChain chain = new SimpleChain(); ChainResultObj resultObj = chain.getResultFromResource("performanceScoreChain", context); BscStructTreeObj treeObj = (BscStructTreeObj) resultObj.getValue(); for (int i = 0; treeObj.getVisions() != null && i < treeObj.getVisions().size(); i++) { VisionVO vision = treeObj.getVisions().get(i); vision.setContent(" ".getBytes()); DefaultResult<VisionVO> vResult = visionService.findObjectByOid(vision); if (vResult.getValue() != null) { // chain ?vision content ?, ?, ?content? vision.setContent( new String(vResult.getValue().getContent(), Constants.BASE_ENCODING).getBytes()); } for (PerspectiveVO perspective : vision.getPerspectives()) { for (ObjectiveVO objective : perspective.getObjectives()) { for (KpiVO kpi : objective.getKpis()) { // ??? kpi.getAggregationMethod().setDescription(" "); kpi.getAggregationMethod().setExpression1(" "); kpi.getAggregationMethod().setExpression2(" "); kpi.getFormula().setExpression(" "); } } } visionScores.add(vision); } } return visionScores; }
From source file:de.tudarmstadt.ukp.clarin.webanno.brat.curation.AgreementUtils.java
public static AgreementResult[][] getPairwiseCohenKappaAgreement(DiffResult aDiff, String aType, String aFeature, Map<String, List<JCas>> aCasMap) { AgreementResult[][] result = new AgreementResult[aCasMap.size()][aCasMap.size()]; List<Entry<String, List<JCas>>> entryList = new ArrayList<>(aCasMap.entrySet()); for (int m = 0; m < entryList.size(); m++) { for (int n = 0; n < entryList.size(); n++) { // Diagonal if (m == n) { result[m][n] = new AgreementResult(aType, aFeature); result[m][n].setAgreement(1.0d); }//from w ww . ja va2 s . c o m // Triangle matrix mirrored if (n < m) { Map<String, List<JCas>> pairwiseCasMap = new LinkedHashMap<>(); pairwiseCasMap.put(entryList.get(m).getKey(), entryList.get(m).getValue()); pairwiseCasMap.put(entryList.get(n).getKey(), entryList.get(n).getValue()); result[m][n] = getCohenKappaAgreement(aDiff, aType, aFeature, pairwiseCasMap); result[n][m] = result[m][n]; } } } return result; }
From source file:edu.valelab.GaussianFit.CoordinateMapper.java
/*** Rigid body transform (rotation and translation only) /*from w w w . j a v a 2s. co m*/ /** * Creates an AffineTransform object that uses only rotation and translation * * @pointPairs is a Map of points measured in the two coordinates systems (srcPt->destPt) */ public static AffineTransform generateRigidBodyTransform(Map<Point2D.Double, Point2D.Double> pointPairs) { int number = pointPairs.size(); RealMatrix X = new Array2DRowRealMatrix(2 * number, 4); RealMatrix U = new Array2DRowRealMatrix(2 * number, 1); int i = 0; for (Map.Entry<Point2D.Double, Point2D.Double> pair : pointPairs.entrySet()) { double[] thisRow = { pair.getKey().x, pair.getKey().y, 1.0, 0.0 }; X.setRow(i, thisRow); double[] otherRow = { pair.getKey().y, -pair.getKey().x, 0.0, 1.0 }; X.setRow(i + number, otherRow); U.setEntry(i, 0, pair.getValue().x); U.setEntry(i + number, 0, pair.getValue().y); i++; } DecompositionSolver solver = (new QRDecompositionImpl(X)).getSolver(); double[][] m = solver.solve(U).getData(); return new AffineTransform(m[0][0], m[1][0], -m[1][0], m[0][0], m[2][0], m[3][0]); }
From source file:com.datumbox.common.dataobjects.MatrixDataset.java
public static RealVector parseRecord(Record r, Map<Object, Integer> featureIdsReference) { if (featureIdsReference.isEmpty()) { throw new RuntimeException("The featureIdsReference map should not be empty."); }/*from w w w. j a va2s .c o m*/ int d = featureIdsReference.size(); RealVector v = new ArrayRealVector(d); boolean addConstantColumn = featureIdsReference.containsKey(Dataset.constantColumnName); if (addConstantColumn) { v.setEntry(0, 1.0); //add the constant column } for (Map.Entry<Object, Object> entry : r.getX().entrySet()) { Object feature = entry.getKey(); Double value = Dataset.toDouble(entry.getValue()); if (value != null) { Integer featureId = featureIdsReference.get(feature); if (featureId != null) {//if the feature exists in our database v.setEntry(featureId, value); } } else { //else the X matrix maintains the 0.0 default value } } return v; }
From source file:net.erdfelt.android.sdkfido.git.internal.GitInfo.java
private static void infoRefs(Repository db) { Map<String, Ref> refs = db.getAllRefs(); System.out.printf("%nAll Refs (%d)%n", refs.size()); Ref head = refs.get(Constants.HEAD); if (head == null) { System.out.println(" HEAD ref is dead and/or non-existent?"); return;/*from ww w . j a va 2 s .co m*/ } Map<String, Ref> printRefs = new TreeMap<String, Ref>(); String current = head.getLeaf().getName(); if (current.equals(Constants.HEAD)) { printRefs.put("(no branch)", head); } for (Ref ref : RefComparator.sort(refs.values())) { String name = ref.getName(); if (name.startsWith(Constants.R_HEADS) || name.startsWith(Constants.R_REMOTES)) { printRefs.put(name, ref); } } int maxLength = 0; for (String name : printRefs.keySet()) { maxLength = Math.max(maxLength, name.length()); } System.out.printf("Refs (Heads/Remotes) (%d)%n", printRefs.size()); for (Entry<String, Ref> e : printRefs.entrySet()) { Ref ref = e.getValue(); ObjectId objectId = ref.getObjectId(); System.out.printf("%c %-" + maxLength + "s %s%n", (current.equals(ref.getName()) ? '*' : ' '), e.getKey(), objectId.abbreviate(ABBREV_LEN).name()); } }