List of usage examples for java.util SortedMap entrySet
Set<Map.Entry<K, V>> entrySet();
From source file:uk.q3c.krail.i18n.PropertiesBundleWriter.java
/** * @throws IOException/*from w w w . j a va 2 s . co m*/ */ @Override public void write(Locale locale, Optional<String> bundleName) throws IOException { Properties properties = new Properties(); EnumMap<E, String> entryMap = getBundle().getMap(); //copy to SortedMap so that output is sorted by key SortedMap<String, String> sortedMap = new TreeMap<>(); entryMap.forEach((k, v) -> { sortedMap.put(k.name(), v); }); for (Map.Entry<String, String> entry : sortedMap.entrySet()) { properties.put(entry.getKey(), entry.getValue()); } String bundleNameWithLocale = bundleNameWithLocale(locale, bundleName); File targetDir = getOptionWritePath(); if (!targetDir.exists()) { FileUtils.forceMkdir(targetDir); } FileOutputStream fos = new FileOutputStream(new File(targetDir, bundleNameWithLocale + ".properties")); properties.store(fos, "created by PropertiesBundleWriter"); }
From source file:org.eel.kitchen.jsonschema.syntax.DependenciesSyntaxChecker.java
@Override void checkValue(final Message.Builder msg, final List<Message> messages, final JsonNode schema) { /*/* www . j ava 2 s . c om*/ * At that point, we know this is an array. Build a map out of it and * call an internal validation method on each map entry -- see below. * * For convenience reasons, we also use a SortedMap so that messages * appear in property natural order: while there is no defined order in * a JSON Object, chances are very high that the schema will be written * with properties in order, so we might as well not confuse the user. */ final SortedMap<String, JsonNode> map = JacksonUtils.nodeToTreeMap(schema.get(keyword)); for (final Map.Entry<String, JsonNode> entry : map.entrySet()) analyzeDependency(entry, msg, messages); }
From source file:org.eel.kitchen.jsonschema.syntax.PropertiesSyntaxChecker.java
@Override void checkValue(final Message.Builder msg, final List<Message> messages, final JsonNode schema) { final SortedMap<String, JsonNode> map = JacksonUtils.nodeToTreeMap(schema.get(keyword)); NodeType type;//from w w w . ja v a2 s .co m JsonNode value; for (final Map.Entry<String, JsonNode> entry : map.entrySet()) { msg.addInfo("key", entry.getKey()); value = entry.getValue(); type = NodeType.getNodeType(entry.getValue()); if (!value.isObject()) { msg.setMessage("key value has incorrect type").addInfo("expected", NodeType.OBJECT).addInfo("found", type); messages.add(msg.build()); continue; } if (!value.has("required")) continue; type = NodeType.getNodeType(value.get("required")); if (type == NodeType.BOOLEAN) continue; msg.setMessage("\"required\" attribute has incorrect type").addInfo("expected", NodeType.BOOLEAN) .addInfo("found", type); messages.add(msg.build()); } }
From source file:org.eel.kitchen.jsonschema.syntax.PatternPropertiesSyntaxChecker.java
@Override void checkValue(final Message.Builder msg, final List<Message> messages, final JsonNode schema) { final SortedMap<String, JsonNode> properties = JacksonUtils.nodeToTreeMap(schema.get(keyword)); String key;/*from w w w . j a v a 2 s .c o m*/ JsonNode value; for (final Map.Entry<String, JsonNode> entry : properties.entrySet()) { key = entry.getKey(); value = entry.getValue(); msg.clearInfo().addInfo("key", key); if (!RhinoHelper.regexIsValid(entry.getKey())) { msg.setMessage("key is not a valid ECMA 262 regex"); messages.add(msg.build()); // No need to continue: even if we were to continue and check // the value, the latter would never be picked up anyway. continue; } if (value.isObject()) continue; msg.setMessage("illegal key value").addInfo("expected", NodeType.OBJECT).addInfo("found", NodeType.getNodeType(value)); messages.add(msg.build()); } }
From source file:com.jivesoftware.sdk.service.filter.JiveSignatureValidator.java
private String getSignatureValidation(JiveSignatureValidatable request) { SortedMap<String, String> sortedMap = request.getJiveSignatureMap(); StringBuilder sb = new StringBuilder(); for (Map.Entry<String, String> entry : sortedMap.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); if (key != null && value != null) { sb.append(key).append(':').append(value).append((char) 10); } // end if } // end for entry return sb.toString(); }
From source file:org.apache.accumulo.pig.AccumuloWholeRowStorage.java
@Override protected Tuple getTuple(Key key, Value value) throws IOException { SortedMap<Key, Value> rowKVs = WholeRowIterator.decodeRow(key, value); List<Tuple> columns = new ArrayList<Tuple>(rowKVs.size()); for (Entry<Key, Value> e : rowKVs.entrySet()) { columns.add(columnToTuple(e.getKey().getColumnFamily(), e.getKey().getColumnQualifier(), e.getKey().getColumnVisibility(), e.getKey().getTimestamp(), e.getValue())); }//from www . ja v a 2s . c o m // and wrap it in a tuple Tuple tuple = TupleFactory.getInstance().newTuple(2); tuple.set(0, new DataByteArray(key.getRow().getBytes())); tuple.set(1, new DefaultDataBag(columns)); return tuple; }
From source file:com.cloudera.flume.core.EventImpl.java
public String toString() { String mbody = StringEscapeUtils.escapeJava(new String(getBody())); StringBuilder attrs = new StringBuilder(); SortedMap<String, byte[]> sorted = new TreeMap<String, byte[]>(this.fields); for (Entry<String, byte[]> e : sorted.entrySet()) { attrs.append("{ " + e.getKey() + " : "); String o = Attributes.toString(this, e.getKey()); attrs.append(o + " } "); }// www. j a v a2 s . c om return getHost() + " [" + getPriority().toString() + " " + new Date(getTimestamp()) + "] " + attrs.toString() + mbody; }
From source file:de.micromata.genome.gwiki.controls.GWikiUserRightsPropsDescriptorValue.java
@Override public String render(GWikiPropsEditorArtefakt<?> editor, PropsEditContext pct) { GWikiAuthorization auth = pct.getWikiContext().getWikiWeb().getAuthorization(); if ((auth instanceof GWikiAuthorizationExt) == false) { return super.render(editor, pct); }/*from www .jav a 2s. c o m*/ GWikiAuthorizationExt authx = (GWikiAuthorizationExt) auth; SortedMap<String, GWikiRight> systemRights = authx.getSystemRights(pct.getWikiContext()); String pval = pct.getPropsValue(); SortedMap<String, GWikiRight> usr = authx.getUserRight(pct.getWikiContext(), systemRights, pval); for (Map.Entry<String, GWikiRight> me : usr.entrySet()) { if (systemRights.containsKey(me.getKey()) == false) { systemRights.put(me.getKey(), me.getValue()); } } Map<String, List<GWikiRight>> groups = new TreeMap<String, List<GWikiRight>>(); for (Map.Entry<String, GWikiRight> me : systemRights.entrySet()) { List<GWikiRight> gr = groups.get(me.getValue().getCategory()); if (gr == null) { gr = new ArrayList<GWikiRight>(); groups.put(me.getValue().getCategory(), gr); } gr.add(me.getValue()); } StringBuilder sb = new StringBuilder(); sb.append("<ul>\n"); for (Map.Entry<String, List<GWikiRight>> ge : groups.entrySet()) { sb.append("<li>").append(ge.getKey()).append("<br/><ul>"); for (GWikiRight r : ge.getValue()) { if (r.isPrivateRight() == true) { continue; } sb.append("<li><input type=\"checkbox\" name=\"right.").append(r.getName()).append("\""); if (usr.containsKey(r.getName()) == true) { sb.append(" checked=\"checked\""); } sb.append(">"); if (StringUtils.isNotBlank(r.getDescription()) == true) { sb.append("<a href=\"#\" title=\"") // .append(StringEscapeUtils.escapeXml(r.getDescription())).append("\">") .append(StringEscapeUtils.escapeXml(r.getName())).append("</a>"); } else { sb.append(StringEscapeUtils.escapeXml(r.getName())); } sb.append("</li>\n"); } sb.append("</ul></li>\n"); } // for (Map.Entry<String, GWikiRight> me : systemRights.entrySet()) { // // } sb.append("</ul>\n"); return sb.toString();// + super.render(editor, pct); }
From source file:com.atolcd.alfresco.audit.web.scripts.ExportGet.java
private void generateTree(String func, SortedMap<Date, Integer> res, List<Functionality> functionalities) { Set<Map.Entry<Date, Integer>> mapEntries = res.entrySet(); Iterator<Map.Entry<Date, Integer>> it = mapEntries.iterator(); List<Entry> entries = new ArrayList<Entry>(); while (it.hasNext()) { Map.Entry<Date, Integer> mapEntry = it.next(); entries.add(new Entry(mapEntry.getKey(), mapEntry.getValue())); }//from w ww .ja v a 2 s . c o m functionalities.add(new Functionality(func, entries)); }
From source file:com.jivesoftware.jivesdk.impl.auth.jiveauth.JiveSignatureValidatorImpl.java
@Nonnull private String createSignatureValidationRequest(@Nonnull InstanceRegistrationRequest request) throws NoSuchAlgorithmException { SortedMap<String, String> sortedMap = request.toSortedMap(); StringBuilder sb = new StringBuilder(); for (Map.Entry<String, String> entry : sortedMap.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); if (key != null && value != null) { sb.append(key).append(':').append(value).append((char) 10); }/*from w w w . j a v a 2 s .c om*/ } return sb.toString(); }