org.xmlpull.v1.XmlSerializer Java Examples
The following examples show how to use
org.xmlpull.v1.XmlSerializer.
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: UserRestrictionsUtils.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
public static void writeRestrictions(@NonNull XmlSerializer serializer, @Nullable Bundle restrictions, @NonNull String tag) throws IOException { if (restrictions == null) { return; } serializer.startTag(null, tag); for (String key : restrictions.keySet()) { if (NON_PERSIST_USER_RESTRICTIONS.contains(key)) { continue; // Don't persist. } if (USER_RESTRICTIONS.contains(key)) { if (restrictions.getBoolean(key)) { serializer.attribute(null, key, "true"); } continue; } Log.w(TAG, "Unknown user restriction detected: " + key); } serializer.endTag(null, tag); }
Example #2
Source File: RankingHelper.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
public void writeXml(XmlSerializer out, boolean forBackup) throws IOException { out.startTag(null, TAG_RANKING); out.attribute(null, ATT_VERSION, Integer.toString(XML_VERSION)); synchronized (mRecords) { final int N = mRecords.size(); for (int i = 0; i < N; i++) { final Record r = mRecords.valueAt(i); //TODO: http://b/22388012 if (forBackup && UserHandle.getUserId(r.uid) != UserHandle.USER_SYSTEM) { continue; } final boolean hasNonDefaultSettings = r.importance != DEFAULT_IMPORTANCE || r.priority != DEFAULT_PRIORITY || r.visibility != DEFAULT_VISIBILITY || r.showBadge != DEFAULT_SHOW_BADGE || r.lockedAppFields != DEFAULT_LOCKED_APP_FIELDS || r.channels.size() > 0 || r.groups.size() > 0; if (hasNonDefaultSettings) { out.startTag(null, TAG_PACKAGE); out.attribute(null, ATT_NAME, r.pkg); if (r.importance != DEFAULT_IMPORTANCE) { out.attribute(null, ATT_IMPORTANCE, Integer.toString(r.importance)); } if (r.priority != DEFAULT_PRIORITY) { out.attribute(null, ATT_PRIORITY, Integer.toString(r.priority)); } if (r.visibility != DEFAULT_VISIBILITY) { out.attribute(null, ATT_VISIBILITY, Integer.toString(r.visibility)); } out.attribute(null, ATT_SHOW_BADGE, Boolean.toString(r.showBadge)); out.attribute(null, ATT_APP_USER_LOCKED_FIELDS, Integer.toString(r.lockedAppFields)); if (!forBackup) { out.attribute(null, ATT_UID, Integer.toString(r.uid)); } for (NotificationChannelGroup group : r.groups.values()) { group.writeXml(out); } for (NotificationChannel channel : r.channels.values()) { if (forBackup) { if (!channel.isDeleted()) { channel.writeXmlForBackup(out, mContext); } } else { channel.writeXml(out); } } out.endTag(null, TAG_PACKAGE); } } } out.endTag(null, TAG_RANKING); }
Example #3
Source File: XulDebugMonitor.java From starcor.xul with GNU Lesser General Public License v3.0 | 6 votes |
public synchronized boolean dumpGlobalSelector(final XulHttpServer.XulHttpServerRequest request, final XulHttpServer.XulHttpServerResponse response) { XmlSerializer xmlWriter = obtainXmlSerializer(response.getBodyStream()); if (xmlWriter == null) { return false; } try { xmlWriter.startDocument("utf-8", Boolean.TRUE); XmlContentDumper contentDumper = initContentDumper(request.queries, xmlWriter); contentDumper.setNoSelectors(false); contentDumper.dumpSelectors(XulManager.getSelectors()); xmlWriter.endDocument(); xmlWriter.flush(); return true; } catch (IOException e) { XulLog.e(TAG, e); } return false; }
Example #4
Source File: ActivitySettings.java From NetGuard with GNU General Public License v3.0 | 6 votes |
private void filterExport(XmlSerializer serializer) throws IOException { try (Cursor cursor = DatabaseHelper.getInstance(this).getAccess()) { int colUid = cursor.getColumnIndex("uid"); int colVersion = cursor.getColumnIndex("version"); int colProtocol = cursor.getColumnIndex("protocol"); int colDAddr = cursor.getColumnIndex("daddr"); int colDPort = cursor.getColumnIndex("dport"); int colTime = cursor.getColumnIndex("time"); int colBlock = cursor.getColumnIndex("block"); while (cursor.moveToNext()) for (String pkg : getPackages(cursor.getInt(colUid))) { serializer.startTag(null, "rule"); serializer.attribute(null, "pkg", pkg); serializer.attribute(null, "version", Integer.toString(cursor.getInt(colVersion))); serializer.attribute(null, "protocol", Integer.toString(cursor.getInt(colProtocol))); serializer.attribute(null, "daddr", cursor.getString(colDAddr)); serializer.attribute(null, "dport", Integer.toString(cursor.getInt(colDPort))); serializer.attribute(null, "time", Long.toString(cursor.getLong(colTime))); serializer.attribute(null, "block", Integer.toString(cursor.getInt(colBlock))); serializer.endTag(null, "rule"); } } }
Example #5
Source File: FastXmlSerializer.java From J2ME-Loader with Apache License 2.0 | 6 votes |
@Override public XmlSerializer startTag(String namespace, String name) throws IOException, IllegalArgumentException, IllegalStateException { if (mInTag) { append(">\n"); } if (mIndent) { appendIndent(mNesting); } mNesting++; append('<'); if (namespace != null) { append(namespace); append(':'); } append(name); mInTag = true; mLineStart = false; return this; }
Example #6
Source File: XmlUtils.java From android-job with Apache License 2.0 | 6 votes |
/** * Flatten a double[] into an XmlSerializer. The list can later be read back * with readThisDoubleArrayXml(). * * @param val The double array to be flattened. * @param name Name attribute to include with this array's tag, or null for * none. * @param out XmlSerializer to write the array into. * * @see #writeMapXml * @see #writeValueXml * @see #readThisIntArrayXml */ public static final void writeDoubleArrayXml(double[] val, String name, XmlSerializer out) throws XmlPullParserException, java.io.IOException { if (val == null) { out.startTag(null, "null"); out.endTag(null, "null"); return; } out.startTag(null, "double-array"); if (name != null) { out.attribute(null, "name", name); } final int n = val.length; out.attribute(null, "num", Integer.toString(n)); for (int i=0; i<n; i++) { out.startTag(null, "item"); out.attribute(null, "value", Double.toString(val[i])); out.endTag(null, "item"); } out.endTag(null, "double-array"); }
Example #7
Source File: GenericXmlTest.java From google-http-java-client with Apache License 2.0 | 6 votes |
private void processAnyTypeGeneric(final String anyTypeXmlNestedArray) throws XmlPullParserException, IOException { AnyTypeGeneric xml = new AnyTypeGeneric(); XmlPullParser parser = Xml.createParser(); parser.setInput(new StringReader(anyTypeXmlNestedArray)); XmlNamespaceDictionary namespaceDictionary = new XmlNamespaceDictionary(); Xml.parseElement(parser, xml, namespaceDictionary, null); assertNotNull(xml); assertEquals(4, xml.values().size()); // serialize XmlSerializer serializer = Xml.createSerializer(); ByteArrayOutputStream out = new ByteArrayOutputStream(); serializer.setOutput(out, "UTF-8"); namespaceDictionary.serialize(serializer, "any", xml); assertEquals(anyTypeXmlNestedArray, out.toString()); }
Example #8
Source File: XmlUtils.java From PreferenceFragment with Apache License 2.0 | 6 votes |
/** * Flatten a Map into an XmlSerializer. The map can later be read back * with readThisMapXml(). * * @param val The map to be flattened. * @param name Name attribute to include with this list's tag, or null for * none. * @param out XmlSerializer to write the map into. * * @see #writeMapXml(Map, OutputStream) * @see #writeListXml * @see #writeValueXml * @see #readMapXml */ public static final void writeMapXml(Map val, String name, XmlSerializer out) throws XmlPullParserException, java.io.IOException { if (val == null) { out.startTag(null, "null"); out.endTag(null, "null"); return; } Set s = val.entrySet(); Iterator i = s.iterator(); out.startTag(null, "map"); if (name != null) { out.attribute(null, "name", name); } while (i.hasNext()) { Map.Entry e = (Map.Entry)i.next(); writeValueXml(e.getValue(), (String)e.getKey(), out); } out.endTag(null, "map"); }
Example #9
Source File: ResourcesParser.java From Stringlate with MIT License | 6 votes |
private static void parsePlurals(XmlSerializer serializer, ResPlurals plurals) throws IOException { serializer.startTag(ns, ResType.PLURALS.toString()); serializer.attribute(ns, ID, ResType.resolveID(plurals.getId())); for (ResPlurals.Item item : plurals.expand()) { serializer.startTag(ns, ResType.ITEM.toString()); serializer.attribute(ns, QUANTITY, item.getQuantity()); if (item.wasModified() != DEFAULT_MODIFIED) serializer.attribute(ns, MODIFIED, Boolean.toString(item.wasModified())); serializer.text(ResTag.sanitizeContent(item.getContent())); serializer.endTag(ns, ResType.ITEM.toString()); } serializer.endTag(ns, ResType.PLURALS.toString()); }
Example #10
Source File: FastXmlSerializer.java From TowerCollector with Mozilla Public License 2.0 | 6 votes |
public XmlSerializer endTag(String namespace, String name) throws IOException, IllegalArgumentException, IllegalStateException { mNesting--; if (mInTag) { append(" />\n"); } else { if (mIndent && mLineStart) { appendIndent(mNesting); } append("</"); if (namespace != null) { append(namespace); append(':'); } append(name); append(">\n"); } mLineStart = true; mInTag = false; return this; }
Example #11
Source File: GenericXmlListTest.java From google-http-java-client with Apache License 2.0 | 6 votes |
/** The purpose of this test is to map an XML with an Array of {@link String} objects. */ @Test public void testParseArrayTypeString() throws Exception { ArrayTypeStringGeneric xml = new ArrayTypeStringGeneric(); XmlPullParser parser = Xml.createParser(); parser.setInput(new StringReader(MULTIPLE_STRING_ELEMENT)); XmlNamespaceDictionary namespaceDictionary = new XmlNamespaceDictionary(); Xml.parseElement(parser, xml, namespaceDictionary, null); // check type assertEquals(2, xml.rep.length); assertEquals("rep1", xml.rep[0]); assertEquals("rep2", xml.rep[1]); // serialize XmlSerializer serializer = Xml.createSerializer(); ByteArrayOutputStream out = new ByteArrayOutputStream(); serializer.setOutput(out, "UTF-8"); namespaceDictionary.serialize(serializer, "any", xml); assertEquals(MULTIPLE_STRING_ELEMENT, out.toString()); }
Example #12
Source File: ResBagValue.java From ratel with Apache License 2.0 | 6 votes |
@Override public void serializeToResValuesXml(XmlSerializer serializer, ResResource res) throws IOException, AndrolibException { String type = res.getResSpec().getType().getName(); if ("style".equals(type)) { new ResStyleValue(mParent, new Duo[0], null) .serializeToResValuesXml(serializer, res); return; } if ("array".equals(type)) { new ResArrayValue(mParent, new Duo[0]).serializeToResValuesXml( serializer, res); return; } if ("plurals".equals(type)) { new ResPluralsValue(mParent, new Duo[0]).serializeToResValuesXml( serializer, res); return; } serializer.startTag(null, "item"); serializer.attribute(null, "type", type); serializer.attribute(null, "name", res.getResSpec().getName()); serializer.endTag(null, "item"); }
Example #13
Source File: ForceCloseLogSerializer.java From commcare-android with Apache License 2.0 | 6 votes |
@Override public void writeToDeviceReport(XmlSerializer serializer) throws IOException { this.serializer = serializer; serializer.startTag(DeviceReportWriter.XMLNS, "force_close_subreport"); try { if (singleEntry != null) { serializeLog(singleEntry.getID(), singleEntry); } else { for (ForceCloseLogEntry entry : logStorage) { serializeLog(entry.getID(), entry); } } } finally { serializer.endTag(DeviceReportWriter.XMLNS, "force_close_subreport"); } }
Example #14
Source File: XulDebugMonitor.java From starcor.xul with GNU Lesser General Public License v3.0 | 6 votes |
public boolean getItemContent(final int itemId, final XulHttpServer.XulHttpServerRequest request, final XulHttpServer.XulHttpServerResponse response) { return execUiOpAndWait(itemId, new UiOpRunnable() { @Override boolean beginExec() { return !(_xulPage == null && _xulView == null); } @Override protected void exec(PageInfo pageInfo, XulPage xulPage, XulView xulView) throws Exception { if (xulView == null) { xulView = xulPage.getLayout(); } XmlPullParserFactory xmlPullParserFactory = XmlPullParserFactory.newInstance(); XmlSerializer writer = xmlPullParserFactory.newSerializer(); writer.setOutput(response.getBodyStream(), "utf-8"); writer.startDocument("utf-8", Boolean.TRUE); dumpItem(xulView, writer, request.queries); writer.endDocument(); writer.flush(); } }); }
Example #15
Source File: XmlUtils.java From ticdesign with Apache License 2.0 | 6 votes |
/** * Flatten a String[] into an XmlSerializer. The list can later be read back * with readThisStringArrayXml(). * * @param val The String array to be flattened. * @param name Name attribute to include with this array's tag, or null for * none. * @param out XmlSerializer to write the array into. * * @see #writeMapXml * @see #writeValueXml * @see #readThisIntArrayXml */ public static final void writeStringArrayXml(String[] val, String name, XmlSerializer out) throws XmlPullParserException, java.io.IOException { if (val == null) { out.startTag(null, "null"); out.endTag(null, "null"); return; } out.startTag(null, "string-array"); if (name != null) { out.attribute(null, "name", name); } final int N = val.length; out.attribute(null, "num", Integer.toString(N)); for (int i=0; i<N; i++) { out.startTag(null, "item"); out.attribute(null, "value", val[i]); out.endTag(null, "item"); } out.endTag(null, "string-array"); }
Example #16
Source File: XmlUtils.java From HeadsUp with GNU General Public License v2.0 | 6 votes |
/** * Flatten a List into an XmlSerializer. The list can later be read back * with readThisListXml(). * * @param val The list to be flattened. * @param name Name attribute to include with this list's tag, or null for * none. * @param out XmlSerializer to write the list into. * @see #writeListXml(List, OutputStream) * @see #writeMapXml * @see #writeValueXml * @see #readListXml */ public static void writeListXml(List val, String name, XmlSerializer out) throws XmlPullParserException, java.io.IOException { if (val == null) { out.startTag(null, "null"); out.endTag(null, "null"); return; } out.startTag(null, "list"); if (name != null) { out.attribute(null, "name", name); } int N = val.size(); int i = 0; while (i < N) { writeValueXml(val.get(i), null, out); i++; } out.endTag(null, "list"); }
Example #17
Source File: XmlUtils.java From JobSchedulerCompat with Apache License 2.0 | 6 votes |
/** * Flatten a double[] into an XmlSerializer. The list can later be read back * with readThisDoubleArrayXml(). * * @param val The double array to be flattened. * @param name Name attribute to include with this array's tag, or null for * none. * @param out XmlSerializer to write the array into. * * @see #writeMapXml * @see #writeValueXml * @see #readThisIntArrayXml */ public static final void writeDoubleArrayXml(double[] val, String name, XmlSerializer out) throws XmlPullParserException, java.io.IOException { if (val == null) { out.startTag(null, "null"); out.endTag(null, "null"); return; } out.startTag(null, "double-array"); if (name != null) { out.attribute(null, "name", name); } final int N = val.length; out.attribute(null, "num", Integer.toString(N)); for (int i=0; i<N; i++) { out.startTag(null, "item"); out.attribute(null, "value", Double.toString(val[i])); out.endTag(null, "item"); } out.endTag(null, "double-array"); }
Example #18
Source File: FastXmlSerializer.java From HeadsUp with GNU General Public License v2.0 | 6 votes |
public XmlSerializer startTag(String namespace, String name) throws IOException, IllegalArgumentException, IllegalStateException { if (mInTag) { append(">\n"); } if (mIndent) { appendIndent(mNesting); } mNesting++; append('<'); if (namespace != null) { append(namespace); append(':'); } append(name); mInTag = true; mLineStart = false; return this; }
Example #19
Source File: XmlListTest.java From google-http-java-client with Apache License 2.0 | 6 votes |
/** The purpose of this test is to map an XML with an Array of {@link Enum} objects. */ @Test public void testParseArrayTypeWithEnum() throws Exception { ArrayTypeEnum xml = new ArrayTypeEnum(); XmlPullParser parser = Xml.createParser(); parser.setInput(new StringReader(MULTIPLE_ENUM_ELEMENT)); XmlNamespaceDictionary namespaceDictionary = new XmlNamespaceDictionary(); Xml.parseElement(parser, xml, namespaceDictionary, null); // check type assertEquals(2, xml.rep.length); assertEquals(XmlEnumTest.AnyEnum.ENUM_1, xml.rep[0]); assertEquals(XmlEnumTest.AnyEnum.ENUM_2, xml.rep[1]); // serialize XmlSerializer serializer = Xml.createSerializer(); ByteArrayOutputStream out = new ByteArrayOutputStream(); serializer.setOutput(out, "UTF-8"); namespaceDictionary.serialize(serializer, "any", xml); assertEquals(MULTIPLE_ENUM_ELEMENT, out.toString()); }
Example #20
Source File: XmlUtils.java From Android-PreferencesManager with Apache License 2.0 | 6 votes |
/** * Flatten a List into an XmlSerializer. The list can later be read back * with readThisListXml(). * * @param val The list to be flattened. * @param name Name attribute to include with this list's tag, or null for * none. * @param out XmlSerializer to write the list into. * @see #writeListXml(List, OutputStream) * @see #writeMapXml * @see #writeValueXml * @see #readListXml */ public static final void writeListXml(List val, String name, XmlSerializer out) throws XmlPullParserException, java.io.IOException { if (val == null) { out.startTag(null, "null"); out.endTag(null, "null"); return; } out.startTag(null, "list"); if (name != null) { out.attribute(null, "name", name); } int N = val.size(); int i = 0; while (i < N) { writeValueXml(val.get(i), null, out); i++; } out.endTag(null, "list"); }
Example #21
Source File: KeySetManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
void writePublicKeysLPr(XmlSerializer serializer) throws IOException { serializer.startTag(null, "keys"); for (int pKeyIndex = 0; pKeyIndex < mPublicKeys.size(); pKeyIndex++) { long id = mPublicKeys.keyAt(pKeyIndex); PublicKeyHandle pkh = mPublicKeys.valueAt(pKeyIndex); String encodedKey = encodePublicKey(pkh.getKey()); serializer.startTag(null, "public-key"); serializer.attribute(null, "identifier", Long.toString(id)); serializer.attribute(null, "value", encodedKey); serializer.endTag(null, "public-key"); } serializer.endTag(null, "keys"); }
Example #22
Source File: SaveLoad.java From ssj with GNU General Public License v3.0 | 5 votes |
/** * @param serializer XmlSerializer * @param object Object * @throws IOException */ private static void addOptions(XmlSerializer serializer, Object object) throws IOException { serializer.startTag(null, OPTIONS); Option[] options = PipelineBuilder.getOptionList(object); if (options != null) { for (Option option : options) { if (option.isAssignableByString() && option.get() != null) { serializer.startTag(null, OPTION); serializer.attribute(null, NAME, option.getName()); if (option.getType().isArray()) { Object value = option.get(); List ar = new ArrayList(); int length = Array.getLength(value); for (int i = 0; i < length; i++) { ar.add(Array.get(value, i)); } Object[] objects = ar.toArray(); serializer.attribute(null, VALUE, Arrays.toString(objects)); } else { serializer.attribute(null, VALUE, String.valueOf(option.get())); } serializer.endTag(null, OPTION); } } } serializer.endTag(null, OPTIONS); }
Example #23
Source File: FastXmlSerializer.java From Android-PreferencesManager with Apache License 2.0 | 5 votes |
public XmlSerializer attribute(String namespace, String name, String value) throws IOException, IllegalArgumentException, IllegalStateException { append(' '); if (namespace != null) { append(namespace); append(':'); } append(name); append("=\""); escapeAndAppendString(value); append('"'); return this; }
Example #24
Source File: SystemUpdatePolicy.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * @hide */ public void saveToXml(XmlSerializer out) throws IOException { out.attribute(null, KEY_POLICY_TYPE, Integer.toString(mPolicyType)); out.attribute(null, KEY_INSTALL_WINDOW_START, Integer.toString(mMaintenanceWindowStart)); out.attribute(null, KEY_INSTALL_WINDOW_END, Integer.toString(mMaintenanceWindowEnd)); for (int i = 0; i < mFreezePeriods.size(); i++) { FreezePeriod interval = mFreezePeriods.get(i); out.startTag(null, KEY_FREEZE_TAG); out.attribute(null, KEY_FREEZE_START, interval.getStart().toString()); out.attribute(null, KEY_FREEZE_END, interval.getEnd().toString()); out.endTag(null, KEY_FREEZE_TAG); } }
Example #25
Source File: StorageManagerService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@GuardedBy("mLock") private void writeSettingsLocked() { FileOutputStream fos = null; try { fos = mSettingsFile.startWrite(); XmlSerializer out = new FastXmlSerializer(); out.setOutput(fos, StandardCharsets.UTF_8.name()); out.startDocument(null, true); out.startTag(null, TAG_VOLUMES); writeIntAttribute(out, ATTR_VERSION, VERSION_FIX_PRIMARY); writeStringAttribute(out, ATTR_PRIMARY_STORAGE_UUID, mPrimaryStorageUuid); final int size = mRecords.size(); for (int i = 0; i < size; i++) { final VolumeRecord rec = mRecords.valueAt(i); writeVolumeRecord(out, rec); } out.endTag(null, TAG_VOLUMES); out.endDocument(); mSettingsFile.finishWrite(fos); } catch (IOException e) { if (fos != null) { mSettingsFile.failWrite(fos); } } }
Example #26
Source File: XmlUtils.java From ticdesign with Apache License 2.0 | 5 votes |
@Deprecated public static void writeBitmapAttribute(XmlSerializer out, String name, Bitmap value) throws IOException { if (value != null) { final ByteArrayOutputStream os = new ByteArrayOutputStream(); value.compress(CompressFormat.PNG, 90, os); writeByteArrayAttribute(out, name, os.toByteArray()); } }
Example #27
Source File: JsonToXml.java From XmlToJson with Apache License 2.0 | 5 votes |
private String nodeToXML(Node node) { XmlSerializer serializer = Xml.newSerializer(); StringWriter writer = new StringWriter(); try { serializer.setOutput(writer); serializer.startDocument("UTF-8", true); nodeToXml(serializer, node); serializer.endDocument(); return writer.toString(); } catch (IOException e) { throw new RuntimeException(e); // TODO: do my own } }
Example #28
Source File: XulDebugMonitor.java From starcor.xul with GNU Lesser General Public License v3.0 | 5 votes |
private XmlSerializer obtainXmlSerializer(OutputStream stream) { XmlSerializer xmlWriter = null; try { XmlPullParserFactory xmlPullParserFactory = XmlPullParserFactory.newInstance(); xmlWriter = xmlPullParserFactory.newSerializer(); xmlWriter.setOutput(stream, "utf-8"); } catch (Exception e) { XulLog.e(TAG, e); } return xmlWriter; }
Example #29
Source File: XulDebugMonitor.java From starcor.xul with GNU Lesser General Public License v3.0 | 5 votes |
private XmlContentDumper initContentDumper(Map<String, String> queries, XmlSerializer writer) { XmlContentDumper contentDumper = new XmlContentDumper(writer); if (queries != null) { String noProp = queries.get("skip-prop"); String withPosition = queries.get("with-position"); String withBindingData = queries.get("with-binding-data"); String withSelector = queries.get("with-selector"); if ("true".equals(noProp)) { contentDumper.setNoProp(true); } if ("true".equals(withPosition)) { contentDumper.setNoPosition(false); } else { contentDumper.setNoPosition(true); } if ("true".equals(withBindingData)) { contentDumper.setNoBindingData(false); } else { contentDumper.setNoBindingData(true); } if ("true".equalsIgnoreCase(withSelector)) { contentDumper.setNoSelectors(false); } else { contentDumper.setNoSelectors(true); } } else { contentDumper.setNoPosition(true); contentDumper.setNoBindingData(true); } return contentDumper; }
Example #30
Source File: XmlNamespaceDictionaryTest.java From google-http-java-client with Apache License 2.0 | 5 votes |
public void testSerializeByName_emptyMap() throws Exception { ImmutableMap<String, String> map = ImmutableMap.of(); StringWriter writer = new StringWriter(); XmlSerializer serializer = Xml.createSerializer(); serializer.setOutput(writer); XmlNamespaceDictionary namespaceDictionary = new XmlNamespaceDictionary(); namespaceDictionary.set("", Atom.ATOM_NAMESPACE); namespaceDictionary.serialize(serializer, "entry", map); assertEquals(EXPECTED_EMPTY_MAP, writer.toString()); }