Java Code Examples for java.util.SortedMap#entrySet()
The following examples show how to use
java.util.SortedMap#entrySet() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Primality.java From symja_android_library with GNU General Public License v3.0 | 6 votes |
public static BigInteger charmichaelLambda(BigInteger value) { if (value.equals(BigInteger.ZERO)) { return BigInteger.ZERO; } if (value.compareTo(BigInteger.ZERO) < 0) { value = value.negate(); } if (value.equals(BigInteger.ONE)) { return BigInteger.ONE; } SortedMap<BigInteger, Integer> map = new TreeMap<BigInteger, Integer>(); factorInteger(value, map); BigInteger l = BigInteger.ONE; for (Map.Entry<BigInteger, Integer> entry : map.entrySet()) { BigInteger base = entry.getKey(); int exponent = entry.getValue(); if (exponent >= 3 && base.equals(TWO)) { l = lcm(l, base.pow(exponent - 2)); } else { l = lcm(l, (base.pow(exponent - 1)).multiply(base.subtract(BigInteger.ONE))); } } return l; }
Example 2
Source File: MissingTranslations.java From airsonic-advanced with GNU General Public License v3.0 | 6 votes |
private static void diff(String locale1, String locale2) throws IOException { Properties en = new Properties(); en.load(MissingTranslations.class.getResourceAsStream("/org/airsonic/player/i18n/ResourceBundle_" + locale1 + ".properties")); SortedMap<Object,Object> enSorted = new TreeMap<Object, Object>(en); Properties mk = new Properties(); mk.load(MissingTranslations.class.getResourceAsStream("/org/airsonic/player/i18n/ResourceBundle_" + locale2 + ".properties")); System.out.println("\nMessages present in locale " + locale1 + " and missing in locale " + locale2 + ":"); int count = 0; for (Map.Entry<Object, Object> entry : enSorted.entrySet()) { if (!mk.containsKey(entry.getKey())) { System.out.println(entry.getKey() + " = " + entry.getValue()); count++; } } System.out.println("\nTotal: " + count); }
Example 3
Source File: SignatureUtil.java From jeewx with Apache License 2.0 | 6 votes |
/** * 创建md5摘要,规则是:按参数名称a-z排序,遇到空值的参数不参加签名。 */ private static String createSign(Map<String, String> paramMap, String key) { StringBuffer sb = new StringBuffer(); SortedMap<String,String> sort=new TreeMap<String,String>(paramMap); Set<Entry<String, String>> es = sort.entrySet(); Iterator<Entry<String, String>> it = es.iterator(); while (it.hasNext()) { @SuppressWarnings("rawtypes") Map.Entry entry = (Map.Entry) it.next(); String k = (String) entry.getKey(); String v = (String) entry.getValue(); if (null != v && !"".equals(v)&& !"null".equals(v) && !"sign".equals(k) && !"key".equals(k)) { sb.append(k + "=" + v + "&"); } } sb.append("key=" + key); LOG.info("HMAC source:{}", new Object[] { sb.toString() } ); String sign = MD5Util.MD5Encode(sb.toString(), "UTF-8").toUpperCase(); LOG.info("HMAC:{}", new Object[] { sign } ); return sign; }
Example 4
Source File: ChartDataProvider.java From slr-toolkit with Eclipse Public License 1.0 | 6 votes |
public SortedMap<String, Integer> calculateNumberOfCitesPerYearForClass(Term inputTerm, SortedMap<String,Boolean> visibleMap) { SortedMap<String, Integer> citesPerYear = new TreeMap<>(); boolean isTermFoundInPaperTaxonomy = false; for(Resource r : resources) { for (Document d : getDocumentList(r)) { isTermFoundInPaperTaxonomy = SearchUtils.findTermInDocument(d, inputTerm) != null; if (isTermFoundInPaperTaxonomy) { String year = d.getYear(); int count = citesPerYear.containsKey(year) ? citesPerYear.get(year) : 0; citesPerYear.put(year, count + d.getCites()); } } } for(Map.Entry<String, Boolean> entry : visibleMap.entrySet()) if(!entry.getValue()) citesPerYear.remove(entry.getKey()); return citesPerYear; }
Example 5
Source File: JTop.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Get the thread list with CPU consumption and the ThreadInfo * for each thread sorted by the CPU time. */ private List<Map.Entry<Long, ThreadInfo>> getThreadList() { // Get all threads and their ThreadInfo objects // with no stack trace long[] tids = tmbean.getAllThreadIds(); ThreadInfo[] tinfos = tmbean.getThreadInfo(tids); // build a map with key = CPU time and value = ThreadInfo SortedMap<Long, ThreadInfo> map = new TreeMap<Long, ThreadInfo>(); for (int i = 0; i < tids.length; i++) { long cpuTime = tmbean.getThreadCpuTime(tids[i]); // filter out threads that have been terminated if (cpuTime != -1 && tinfos[i] != null) { map.put(new Long(cpuTime), tinfos[i]); } } // build the thread list and sort it with CPU time // in decreasing order Set<Map.Entry<Long, ThreadInfo>> set = map.entrySet(); List<Map.Entry<Long, ThreadInfo>> list = new ArrayList<Map.Entry<Long, ThreadInfo>>(set); Collections.reverse(list); return list; }
Example 6
Source File: IngestRateIterator.java From datawave with Apache License 2.0 | 6 votes |
@Override protected void processRow(SortedMap<Key,Value> row) { LinkedList<Double> rates = new LinkedList<>(); Text timestamp = row.firstKey().getRow(); IngestEntryKey iek = new IngestEntryKey(); for (Entry<Key,Value> e : row.entrySet()) { try { iek.parse(e.getKey()); } catch (InvalidKeyException e1) { continue; } // value will be in Events/s double rate = ((double) iek.getCount()) / (((double) iek.getDuration()) / 1000.0); rates.add(rate); } // get the avg double avgRate = 0; for (Double d : rates) { avgRate += d / rates.size(); } row.clear(); row.put(new Key(timestamp, new Text(Double.toString(avgRate)), et), ev); }
Example 7
Source File: LocaleExtensions.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
private static String toID(SortedMap<Character, Extension> map) { StringBuilder buf = new StringBuilder(); Extension privuse = null; for (Entry<Character, Extension> entry : map.entrySet()) { char singleton = entry.getKey(); Extension extension = entry.getValue(); if (LanguageTag.isPrivateusePrefixChar(singleton)) { privuse = extension; } else { if (buf.length() > 0) { buf.append(LanguageTag.SEP); } buf.append(extension); } } if (privuse != null) { if (buf.length() > 0) { buf.append(LanguageTag.SEP); } buf.append(privuse); } return buf.toString(); }
Example 8
Source File: AbstractVersionedTargetGraphBuilder.java From buck with Apache License 2.0 | 5 votes |
/** @return a flavor to which summarizes the given version selections. */ static Flavor getVersionedFlavor(SortedMap<BuildTarget, Version> versions) { Preconditions.checkArgument(!versions.isEmpty()); Hasher hasher = Hashing.md5().newHasher(); for (Map.Entry<BuildTarget, Version> ent : versions.entrySet()) { hasher.putString(ent.getKey().toString(), Charsets.UTF_8); hasher.putString(ent.getValue().getName(), Charsets.UTF_8); } return InternalFlavor.of("v" + hasher.hash().toString().substring(0, 7)); }
Example 9
Source File: BlobStoreCompactor.java From ambry with Apache License 2.0 | 5 votes |
/** * Adds all the index segments that refer to log segments in {@code logSegmentNames} to the application index and * removes all the index segments that refer to the log segments that will be cleaned up from the application index. * The change is atomic with the use of {@link PersistentIndex#changeIndexSegments(List, Set)}. * @param logSegmentNames the names of the log segments whose index segments need to be committed. * @throws StoreException if there were any problems committing the changed index segments. */ private void updateSrcIndex(List<String> logSegmentNames) throws StoreException { Set<Offset> indexSegmentsToRemove = new HashSet<>(); for (String logSegmentName : compactionLog.getCompactionDetails().getLogSegmentsUnderCompaction()) { indexSegmentsToRemove.addAll(getIndexSegmentDetails(logSegmentName).keySet()); } List<File> indexSegmentFilesToAdd = new ArrayList<>(); Map<String, SortedMap<Offset, File>> newLogSegmentsToIndexSegmentDetails = getLogSegmentsToIndexSegmentsMap(logSegmentNames); for (Map.Entry<String, SortedMap<Offset, File>> entry : newLogSegmentsToIndexSegmentDetails.entrySet()) { LogSegment logSegment = srcLog.getSegment(entry.getKey()); SortedMap<Offset, File> indexSegmentDetails = entry.getValue(); long endOffset = logSegment.getStartOffset(); for (Map.Entry<Offset, File> indexSegmentEntry : indexSegmentDetails.entrySet()) { File indexSegmentFile = indexSegmentEntry.getValue(); IndexSegment indexSegment = new IndexSegment(indexSegmentFile, true, storeKeyFactory, config, tgtMetrics, null, time); endOffset = indexSegment.getEndOffset().getOffset(); indexSegmentFilesToAdd.add(indexSegmentFile); } logSegment.setEndOffset(endOffset); } logger.debug("Adding {} to the application index and removing {} from the application index in {}", indexSegmentFilesToAdd, indexSegmentsToRemove, storeId); srcIndex.changeIndexSegments(indexSegmentFilesToAdd, indexSegmentsToRemove); }
Example 10
Source File: MaildirMessageMapper.java From james-project with Apache License 2.0 | 5 votes |
private List<MailboxMessage> findMessagesInMailboxBetweenUIDs(Mailbox mailbox, FilenameFilter filter, MessageUid from, MessageUid to, int max) throws MailboxException { MaildirFolder folder = maildirStore.createMaildirFolder(mailbox); int cur = 0; SortedMap<MessageUid, MaildirMessageName> uidMap = null; try { if (filter != null) { uidMap = folder.getUidMap(mailboxSession, filter, from, to); } else { uidMap = folder.getUidMap(from, to); } ArrayList<MailboxMessage> messages = new ArrayList<>(); for (Entry<MessageUid, MaildirMessageName> entry : uidMap.entrySet()) { messages.add(new MaildirMailboxMessage(mailbox, entry.getKey(), entry.getValue())); if (max != -1) { cur++; if (cur >= max) { break; } } } return messages; } catch (IOException e) { throw new MailboxException("Failure while search for Messages in Mailbox " + mailbox, e); } }
Example 11
Source File: AuthUtil.java From roncoo-pay with Apache License 2.0 | 5 votes |
/** * post请求 * * @param paramMap 请求参数 * @param requestUrl 请求地址 * @return */ private static Map<String, Object> request(SortedMap<String, String> paramMap, String requestUrl) { logger.info("鉴权请求地址:[{}],请求参数:[{}]", requestUrl, paramMap); HttpClient httpClient = new HttpClient(); HttpConnectionManagerParams managerParams = httpClient.getHttpConnectionManager().getParams(); // 设置连接超时时间(单位毫秒) managerParams.setConnectionTimeout(9000); // 设置读数据超时时间(单位毫秒) managerParams.setSoTimeout(12000); PostMethod postMethod = new PostMethod(requestUrl); postMethod.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "utf-8"); NameValuePair[] pairs = new NameValuePair[paramMap.size()]; int i = 0; for (Map.Entry<String, String> entry : paramMap.entrySet()) { pairs[i++] = new NameValuePair(entry.getKey(), entry.getValue()); } postMethod.setRequestBody(pairs); try { Integer code = httpClient.executeMethod(postMethod); if (code.compareTo(200) == 0) { String result = postMethod.getResponseBodyAsString(); logger.info("鉴权请求成功,同步返回数据:{}", result); return JSON.parseObject(result); } else { logger.error("鉴权请求失败,返回状态码:[{}]", code); } } catch (IOException e) { logger.info("鉴权请求异常:{}", e); return null; } return null; }
Example 12
Source File: SiddhiStreamMetadataUtils.java From Eagle with Apache License 2.0 | 5 votes |
/** * @see org.wso2.siddhi.query.api.definition.Attribute.Type * make sure StreamMetadataManager.init is invoked before this method * @param streamName * @return */ public static String convertToStreamDef(String streamName){ SortedMap<String, AlertStreamSchemaEntity> map = getAttrMap(streamName); StringBuilder sb = new StringBuilder(); sb.append(EAGLE_ALERT_CONTEXT_FIELD + " object,"); for(Map.Entry<String, AlertStreamSchemaEntity> entry : map.entrySet()){ String attrName = entry.getKey(); sb.append(attrName); sb.append(" "); String attrType = entry.getValue().getAttrType(); if(attrType.equalsIgnoreCase(AttributeType.STRING.name())){ sb.append("string"); }else if(attrType.equalsIgnoreCase(AttributeType.INTEGER.name())){ sb.append("int"); }else if(attrType.equalsIgnoreCase(AttributeType.LONG.name())){ sb.append("long"); }else if(attrType.equalsIgnoreCase(AttributeType.BOOL.name())){ sb.append("bool"); }else if(attrType.equalsIgnoreCase(AttributeType.FLOAT.name())){ sb.append("float"); }else if(attrType.equalsIgnoreCase(AttributeType.DOUBLE.name())){ sb.append("double"); }else{ LOG.warn("AttrType is not recognized, ignore : " + attrType); } sb.append(","); } if(sb.length() > 0){ sb.deleteCharAt(sb.length()-1); } String siddhiStreamDefFormat = "define stream " + streamName + "(" + "%s" + ");"; return String.format(siddhiStreamDefFormat, sb.toString()); }
Example 13
Source File: InitIssuesAnswerer.java From batfish with Apache License 2.0 | 5 votes |
@VisibleForTesting static SortedMap<ParseStatus, Set<String>> aggregateParseStatuses( SortedMap<String, ParseStatus> fileStatuses) { SortedMap<ParseStatus, Set<String>> aggregatedStatuses = new TreeMap<>(); for (Entry<String, ParseStatus> entry : fileStatuses.entrySet()) { Set<String> files = aggregatedStatuses.computeIfAbsent(entry.getValue(), s -> new HashSet<>()); files.add(entry.getKey()); } return aggregatedStatuses; }
Example 14
Source File: SimpleTheme.java From WorldPainter with GNU General Public License v3.0 | 5 votes |
@Override public final void setMaxHeight(int maxHeight, HeightTransform transform) { if (maxHeight != this.maxHeight) { this.maxHeight = maxHeight; waterHeight = clamp(transform.transformHeight(waterHeight), maxHeight - 1); Terrain[] oldTerrainRangesTable = terrainRangesTable; terrainRangesTable = new Terrain[maxHeight]; if (terrainRanges != null) { SortedMap<Integer, Terrain> oldTerrainRanges = this.terrainRanges; terrainRanges = new TreeMap<>(); for (Map.Entry<Integer, Terrain> oldEntry: oldTerrainRanges.entrySet()) { terrainRanges.put(oldEntry.getKey() < 0 ? oldEntry.getKey() : clamp(transform.transformHeight(oldEntry.getKey()), maxHeight - 1), oldEntry.getValue()); } for (int i = 0; i < maxHeight; i++) { terrainRangesTable[i] = terrainRanges.get(terrainRanges.headMap(i).lastKey()); } } else { // No terrain ranges map set; this is probably because it is // an old map. All we can do is extend the last entry System.arraycopy(oldTerrainRangesTable, 0, terrainRangesTable, 0, Math.min(oldTerrainRangesTable.length, terrainRangesTable.length)); if (terrainRangesTable.length > oldTerrainRangesTable.length) { for (int i = oldTerrainRangesTable.length; i < terrainRangesTable.length; i++) { terrainRangesTable[i] = oldTerrainRangesTable[oldTerrainRangesTable.length - 1]; } } } initCaches(); } }
Example 15
Source File: JavaASTAnnotatedTokenizer.java From tassal with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void preVisit(final ASTNode node) { final int fromPosition = node.getStartPosition(); final int endPosition = fromPosition + node.getLength(); final int nodeType = node.getNodeType(); final int parentType; if (node.getParent() != null) { parentType = node.getParent().getNodeType(); } else { parentType = -1; } final SortedMap<Integer, FullToken> nodeTokens = baseTokens.subMap( fromPosition, endPosition); for (final Entry<Integer, FullToken> token : nodeTokens.entrySet()) { if (token.getValue().token.startsWith("WS_") && baseTokenizer instanceof JavaWhitespaceTokenizer) { annotatedTokens.put( token.getKey(), new AstAnnotatedToken(new FullToken(token .getValue().token, token.getValue().tokenType), null, null)); } else { annotatedTokens.put( token.getKey(), new AstAnnotatedToken(new FullToken(token .getValue().token, token.getValue().tokenType), nodeIdToString(nodeType), nodeIdToString(parentType))); } } super.preVisit(node); }
Example 16
Source File: CodePrinter.java From api-mining with GNU General Public License v3.0 | 4 votes |
/** * Return a StringBuffer with colored tokens as specified from the * coloredTokens. There should be one-to-one correspondence with the actual * tokens. */ public StringBuffer getHTMLwithColors( final List<ColoredToken> coloredTokens, final File codeFile) throws IOException, InstantiationException, IllegalAccessException { final String code = FileUtils.readFileToString(codeFile); lineNumber = 1; final StringBuffer buf = new StringBuffer(); final SortedMap<Integer, FullToken> toks = tokenizer .fullTokenListWithPos(code.toCharArray()); int i = 0; int prevPos = 0; buf.append("<html>\n<head>\n<link href='http://fonts.googleapis.com/css?family=Source+Code+Pro:300,400,500,600,700,800,900' rel='stylesheet' type='text/css'>\n"); buf.append(CSS_STYLE); buf.append("</head>\n<body style='background-color:rgb(" + documentBackgroundColor.getRed() + "," + documentBackgroundColor.getGreen() + "," + documentBackgroundColor.getBlue() + ")'>"); appendLineDiv(buf, false); for (final Entry<Integer, FullToken> entry : toks.entrySet()) { if (i == 0 || entry.getKey() == Integer.MAX_VALUE) { i++; continue; } addSlack(code.substring(prevPos, entry.getKey()), buf); final ColoredToken tok = coloredTokens.get(i); buf.append("<span style='background-color:rgba(" + tok.bgColor.getRed() + "," + tok.bgColor.getGreen() + "," + tok.bgColor.getBlue() + "," + (ignoreTokBG ? "0" : "1") + "); color:rgb(" + tok.fontColor.getRed() + "," + tok.fontColor.getGreen() + "," + tok.fontColor.getBlue() + "); " + tok.extraStyle + "'>" + StringEscapeUtils.escapeHtml(entry.getValue().token) + "</span>"); i++; prevPos = entry.getKey() + entry.getValue().token.length(); } buf.append("</div></body></html>"); return buf; }
Example 17
Source File: DescriptorSupport.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
/** * Serializes a {@link DescriptorSupport} to an {@link ObjectOutputStream}. */ /* 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(); }
Example 18
Source File: Command.java From speechutils with Apache License 2.0 | 4 votes |
public String toTsv(SortedMap<Integer, String> header) { StringBuilder sb = new StringBuilder(); boolean isFirst = true; for (SortedMap.Entry<Integer, String> entry : header.entrySet()) { if (isFirst) { isFirst = false; } else { sb.append('\t'); } switch (entry.getValue()) { case UtteranceRewriter.HEADER_LABEL: sb.append(escape(mLabel)); break; case UtteranceRewriter.HEADER_COMMENT: sb.append(escape(mComment)); break; case UtteranceRewriter.HEADER_LOCALE: sb.append(escape(mLocale)); break; case UtteranceRewriter.HEADER_SERVICE: sb.append(escape(mService)); break; case UtteranceRewriter.HEADER_APP: sb.append(escape(mApp)); break; case UtteranceRewriter.HEADER_UTTERANCE: sb.append(escape(mUtt)); break; case UtteranceRewriter.HEADER_REPLACEMENT: sb.append(escape(mReplacement)); break; case UtteranceRewriter.HEADER_COMMAND: sb.append(escape(mCommand)); break; case UtteranceRewriter.HEADER_ARG1: if (mArgs.length > 0) { sb.append(escape(mArgs[0])); } break; case UtteranceRewriter.HEADER_ARG2: if (mArgs.length > 1) { sb.append(escape(mArgs[1])); } break; default: break; } } return sb.toString(); }
Example 19
Source File: CassandraBinaryRecordReader.java From titan1withtp3.1 with Apache License 2.0 | 4 votes |
private KV completeNextKV() throws IOException { KV completedKV = null; boolean hasNext; do { hasNext = reader.nextKeyValue(); if (!hasNext) { completedKV = incompleteKV; incompleteKV = null; } else { StaticArrayBuffer key = StaticArrayBuffer.of(reader.getCurrentKey()); // DAVID CASSANDRA // SortedMap<ByteBuffer, Cell> valueSortedMap = reader.getCurrentValue(); SortedMap<ByteBuffer, ColumnFamilyRecordReader.Column> valueSortedMap = reader.getCurrentValue(); List<Entry> entries = new ArrayList<>(valueSortedMap.size()); // DAVID CASSANDRA for (Map.Entry<ByteBuffer, ColumnFamilyRecordReader.Column> ent : valueSortedMap.entrySet()) { ByteBuffer col = ent.getKey(); ByteBuffer val = ent.getValue().value; entries.add(StaticArrayEntry.of(StaticArrayBuffer.of(col), StaticArrayBuffer.of(val))); } if (null == incompleteKV) { // Initialization; this should happen just once in an instance's lifetime incompleteKV = new KV(key); } else if (!incompleteKV.key.equals(key)) { // The underlying Cassandra reader has just changed to a key we haven't seen yet // This implies that there will be no more entries for the prior key completedKV = incompleteKV; incompleteKV = new KV(key); } incompleteKV.addEntries(entries); } /* Loop ends when either * A) the cassandra reader ran out of data * or * B) the cassandra reader switched keys, thereby completing a KV */ } while (hasNext && null == completedKV); return completedKV; }
Example 20
Source File: DescriptorSupport.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * Serializes a {@link DescriptorSupport} to an {@link ObjectOutputStream}. */ /* 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(); }