本文整理汇总了Java中org.xmlpull.v1.XmlSerializer.endTag方法的典型用法代码示例。如果您正苦于以下问题:Java XmlSerializer.endTag方法的具体用法?Java XmlSerializer.endTag怎么用?Java XmlSerializer.endTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.xmlpull.v1.XmlSerializer
的用法示例。
在下文中一共展示了XmlSerializer.endTag方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeConstraintsToXml
import org.xmlpull.v1.XmlSerializer; //导入方法依赖的package包/类
/**
* Write out a tag with data identifying this job's constraints. If the constraint isn't here it doesn't apply.
*/
private void writeConstraintsToXml(XmlSerializer out, JobStatus jobStatus) throws IOException {
out.startTag(null, XML_TAG_PARAMS_CONSTRAINTS);
if (jobStatus.needsAnyConnectivity()) {
out.attribute(null, "connectivity", Boolean.toString(true));
}
if (jobStatus.needsMeteredConnectivity()) {
out.attribute(null, "metered", Boolean.toString(true));
}
if (jobStatus.needsUnmeteredConnectivity()) {
out.attribute(null, "unmetered", Boolean.toString(true));
}
if (jobStatus.needsNonRoamingConnectivity()) {
out.attribute(null, "not-roaming", Boolean.toString(true));
}
if (jobStatus.hasIdleConstraint()) {
out.attribute(null, "idle", Boolean.toString(true));
}
if (jobStatus.hasChargingConstraint()) {
out.attribute(null, "charging", Boolean.toString(true));
}
if (jobStatus.hasBatteryNotLowConstraint()) {
out.attribute(null, "battery-not-low", Boolean.toString(true));
}
out.endTag(null, XML_TAG_PARAMS_CONSTRAINTS);
}
示例2: writeMapXml
import org.xmlpull.v1.XmlSerializer; //导入方法依赖的package包/类
private static void writeMapXml(Map val, String name, XmlSerializer out)
throws XmlPullParserException, IOException {
if (val == null) {
out.startTag(null, "null");
out.endTag(null, "null");
return;
}
out.startTag(null, "map");
if (name != null) {
out.attribute(null, "name", name);
}
writeMapXml(val, out);
out.endTag(null, "map");
}
示例3: writeSetXml
import org.xmlpull.v1.XmlSerializer; //导入方法依赖的package包/类
private static void writeSetXml(Set val, String name, XmlSerializer out)
throws XmlPullParserException, IOException {
if (val == null) {
out.startTag(null, "null");
out.endTag(null, "null");
return;
}
out.startTag(null, "set");
if (name != null) {
out.attribute(null, "name", name);
}
for (Object v : val) {
writeValueXml(v, null, out);
}
out.endTag(null, "set");
}
示例4: writeIntArrayXml
import org.xmlpull.v1.XmlSerializer; //导入方法依赖的package包/类
private static void writeIntArrayXml(int[] val, String name, XmlSerializer out)
throws XmlPullParserException, IOException {
if (val == null) {
out.startTag(null, "null");
out.endTag(null, "null");
return;
}
out.startTag(null, "int-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", Integer.toString(val[i]));
out.endTag(null, "item");
}
out.endTag(null, "int-array");
}
示例5: generatePublicXml
import org.xmlpull.v1.XmlSerializer; //导入方法依赖的package包/类
private void generatePublicXml(ResPackage pkg, Directory out,
XmlSerializer serial) throws AndrolibException {
try {
OutputStream outStream = out.getFileOutput("values/public.xml");
serial.setOutput(outStream, null);
serial.startDocument(null, null);
serial.startTag(null, "resources");
for (ResResSpec spec : pkg.listResSpecs()) {
serial.startTag(null, "public");
serial.attribute(null, "type", spec.getType().getName());
serial.attribute(null, "name", spec.getName());
serial.attribute(null, "id", String.format("0x%08x", spec.getId().id));
serial.endTag(null, "public");
}
serial.endTag(null, "resources");
serial.endDocument();
serial.flush();
outStream.close();
} catch (IOException | DirectoryException ex) {
throw new AndrolibException("Could not generate public.xml file", ex);
}
}
示例6: writeUserLocked
import org.xmlpull.v1.XmlSerializer; //导入方法依赖的package包/类
private void writeUserLocked(VUserInfo userInfo) {
FileOutputStream fos = null;
AtomicFile userFile = new AtomicFile(new File(mUsersDir, userInfo.id + ".xml"));
try {
fos = userFile.startWrite();
final BufferedOutputStream bos = new BufferedOutputStream(fos);
// XmlSerializer serializer = XmlUtils.serializerInstance();
final XmlSerializer serializer = new FastXmlSerializer();
serializer.setOutput(bos, "utf-8");
serializer.startDocument(null, true);
serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
serializer.startTag(null, TAG_USER);
serializer.attribute(null, ATTR_ID, Integer.toString(userInfo.id));
serializer.attribute(null, ATTR_SERIAL_NO, Integer.toString(userInfo.serialNumber));
serializer.attribute(null, ATTR_FLAGS, Integer.toString(userInfo.flags));
serializer.attribute(null, ATTR_CREATION_TIME, Long.toString(userInfo.creationTime));
serializer.attribute(null, ATTR_LAST_LOGGED_IN_TIME,
Long.toString(userInfo.lastLoggedInTime));
if (userInfo.iconPath != null) {
serializer.attribute(null, ATTR_ICON_PATH, userInfo.iconPath);
}
if (userInfo.partial) {
serializer.attribute(null, ATTR_PARTIAL, "true");
}
serializer.startTag(null, TAG_NAME);
serializer.text(userInfo.name);
serializer.endTag(null, TAG_NAME);
serializer.endTag(null, TAG_USER);
serializer.endDocument();
userFile.finishWrite(fos);
} catch (Exception ioe) {
VLog.e(LOG_TAG, "Error writing user info " + userInfo.id + "\n" + ioe);
userFile.failWrite(fos);
}
}
示例7: writeToXmlImpl
import org.xmlpull.v1.XmlSerializer; //导入方法依赖的package包/类
/**
* Serializes all Blocks in the given list and writes them to the either the output stream or
* writer, whichever is not null.
*
* @param toSerialize A list of Blocks to serialize.
* @param os An OutputStream to write the blocks to.
* @param writer A writer to write the blocks to, if {@code os} is null.
* @param options The options to configure the block serialization. If omitted,
* {@link IOOptions#WRITE_ALL_DATA} will be used by default.
*
* @throws BlocklySerializerException
*/
public static void writeToXmlImpl(final @NonNull List<Block> toSerialize,
@Nullable OutputStream os, @Nullable Writer writer,
@Nullable IOOptions options)
throws BlocklySerializerException {
final IOOptions finalOptions = options == null ? IOOptions.WRITE_ALL_DATA : options;
XmlContentWriter contentWriter = new XmlContentWriter() {
@Override
public void write(XmlSerializer serializer) throws IOException {
serializer.setPrefix("", XML_NAMESPACE);
serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
serializer.startTag(XML_NAMESPACE, "xml");
for (int i = 0; i < toSerialize.size(); i++) {
toSerialize.get(i).serialize(serializer, true, finalOptions);
}
serializer.endTag(XML_NAMESPACE, "xml");
}
};
try {
if (os != null) {
writeXml(os, contentWriter);
} else {
writeXml(writer, contentWriter);
}
} catch (IOException e) {
throw new BlocklySerializerException(e);
}
}
示例8: writeXmlInner
import org.xmlpull.v1.XmlSerializer; //导入方法依赖的package包/类
public static void writeXmlInner(XmlSerializer serializer, EpisodeTags tag) throws
IllegalArgumentException,
IllegalStateException,
IOException {
serializer.startTag("", "episodedetails");
{
textTag(serializer, "title", tag.getTitle());
textTag(serializer, "showtitle", tag.getShowTags().getTitle());
textTag(serializer, "rating", tag.getRating());
textTag(serializer, "season", tag.getSeason());
textTag(serializer, "episode", tag.getEpisode());
textTag(serializer, "plot", tag.getPlot());
textTag(serializer, "mpaa", tag.getContentRating());
textTag(serializer, "imdbid", tag.getImdbId());
textTag(serializer, "tvdbid", tag.getOnlineId());
textTag(serializer, "lastplayed", tag.getLastPlayed(TimeUnit.SECONDS));
textTag(serializer, "bookmark", tag.getBookmark());
textTag(serializer, "resume", tag.getResume());
textTag(serializer, "aired", formatShowDate(tag.getAired()));
textTag(serializer, "runtime", tag.getRuntime(TimeUnit.MINUTES));
for (String director : tag.getDirectors())
textTag(serializer, "director", director);
for (Entry<String, String> entry : tag.getActors().entrySet()) {
serializer.startTag("", "actor");
{
textTag(serializer, "name", entry.getKey());
textTag(serializer, "role", entry.getValue());
}
serializer.endTag("", "actor");
}
}
serializer.endTag("", "episodedetails");
}
示例9: writeExecutionCriteriaToXml
import org.xmlpull.v1.XmlSerializer; //导入方法依赖的package包/类
private void writeExecutionCriteriaToXml(XmlSerializer out, JobStatus jobStatus) throws IOException {
final JobInfo job = jobStatus.getJob();
if (jobStatus.getJob().isPeriodic()) {
out.startTag(null, XML_TAG_PERIODIC);
out.attribute(null, "period", Long.toString(job.getIntervalMillis()));
out.attribute(null, "flex", Long.toString(job.getFlexMillis()));
} else {
out.startTag(null, XML_TAG_ONEOFF);
}
if (jobStatus.hasDeadlineConstraint()) {
// Wall clock deadline.
final long deadlineWallclock = System.currentTimeMillis() +
(jobStatus.getLatestRunTimeElapsed() - SystemClock.elapsedRealtime());
out.attribute(null, "deadline", Long.toString(deadlineWallclock));
}
if (jobStatus.hasTimingDelayConstraint()) {
// Wall clock delay.
final long delayWallclock = System.currentTimeMillis() +
(jobStatus.getEarliestRunTimeElapsed() - SystemClock.elapsedRealtime());
out.attribute(null, "delay", Long.toString(delayWallclock));
}
// Only write out back-off policy if it differs from the default.
// This also helps the case where the job is idle -> these aren't allowed to specify back-off.
if (jobStatus.getJob().getInitialBackoffMillis() != JobInfo.DEFAULT_INITIAL_BACKOFF_MILLIS
|| jobStatus.getJob().getBackoffPolicy() != JobInfo.DEFAULT_BACKOFF_POLICY) {
out.attribute(null, "backoff-policy", Integer.toString(job.getBackoffPolicy()));
out.attribute(null, "initial-backoff", Long.toString(job.getInitialBackoffMillis()));
}
if (job.isPeriodic()) {
out.endTag(null, XML_TAG_PERIODIC);
} else {
out.endTag(null, XML_TAG_ONEOFF);
}
}
示例10: serializeBody
import org.xmlpull.v1.XmlSerializer; //导入方法依赖的package包/类
@Override
protected void serializeBody(XmlSerializer serializer, ResResource res)
throws AndrolibException, IOException {
for (Duo<ResReferenceValue, ResIntValue> duo : mItems) {
int intVal = duo.m2.getValue();
serializer.startTag(null, "enum");
serializer.attribute(null, "name", duo.m1.getReferent().getName());
serializer.attribute(null, "value", String.valueOf(intVal));
serializer.endTag(null, "enum");
}
}
示例11: textTag
import org.xmlpull.v1.XmlSerializer; //导入方法依赖的package包/类
private static void textTag(XmlSerializer serializer, String tag, String text)
throws IllegalArgumentException, IllegalStateException, IOException {
if (text != null && !text.isEmpty()) {
serializer.startTag("", tag);
serializer.text(text);
serializer.endTag("", tag);
}
}
示例12: writeByteArrayXml
import org.xmlpull.v1.XmlSerializer; //导入方法依赖的package包/类
private static void writeByteArrayXml(byte[] val, String name, XmlSerializer out)
throws XmlPullParserException, IOException {
if (val == null) {
out.startTag(null, "null");
out.endTag(null, "null");
return;
}
out.startTag(null, "byte-array");
if (name != null) {
out.attribute(null, "name", name);
}
final int N = val.length;
out.attribute(null, "num", Integer.toString(N));
StringBuilder sb = new StringBuilder(val.length * 2);
for (int i = 0; i < N; i++) {
int b = val[i];
int h = (b >> 4) & 0x0f;
sb.append((char) (h >= 10 ? ('a' + h - 10) : ('0' + h)));
h = b & 0x0f;
sb.append((char) (h >= 10 ? ('a' + h - 10) : ('0' + h)));
}
out.text(sb.toString());
out.endTag(null, "byte-array");
}
示例13: writeUserListLocked
import org.xmlpull.v1.XmlSerializer; //导入方法依赖的package包/类
private void writeUserListLocked() {
FileOutputStream fos = null;
AtomicFile userListFile = new AtomicFile(mUserListFile);
try {
fos = userListFile.startWrite();
final BufferedOutputStream bos = new BufferedOutputStream(fos);
// XmlSerializer serializer = XmlUtils.serializerInstance();
final XmlSerializer serializer = new FastXmlSerializer();
serializer.setOutput(bos, "utf-8");
serializer.startDocument(null, true);
serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
serializer.startTag(null, TAG_USERS);
serializer.attribute(null, ATTR_NEXT_SERIAL_NO, Integer.toString(mNextSerialNumber));
serializer.attribute(null, ATTR_USER_VERSION, Integer.toString(mUserVersion));
for (int i = 0; i < mUsers.size(); i++) {
VUserInfo user = mUsers.valueAt(i);
serializer.startTag(null, TAG_USER);
serializer.attribute(null, ATTR_ID, Integer.toString(user.id));
serializer.endTag(null, TAG_USER);
}
serializer.endTag(null, TAG_USERS);
serializer.endDocument();
userListFile.finishWrite(fos);
} catch (Exception e) {
userListFile.failWrite(fos);
VLog.e(LOG_TAG, "Error writing user list");
}
}
示例14: writeIdentity
import org.xmlpull.v1.XmlSerializer; //导入方法依赖的package包/类
private static void writeIdentity(XmlSerializer serializer, String accountUuid, String identity,
Map<String, Object> prefs) throws IOException {
serializer.startTag(null, IDENTITY_ELEMENT);
String prefix = accountUuid + ".";
String suffix = "." + identity;
// Write name belonging to the identity
String name = (String) prefs.get(prefix + Account.IDENTITY_NAME_KEY + suffix);
serializer.startTag(null, NAME_ELEMENT);
serializer.text(name);
serializer.endTag(null, NAME_ELEMENT);
// Write email address belonging to the identity
String email = (String) prefs.get(prefix + Account.IDENTITY_EMAIL_KEY + suffix);
serializer.startTag(null, EMAIL_ELEMENT);
serializer.text(email);
serializer.endTag(null, EMAIL_ELEMENT);
// Write identity description
String description = (String) prefs.get(prefix + Account.IDENTITY_DESCRIPTION_KEY + suffix);
if (description != null) {
serializer.startTag(null, DESCRIPTION_ELEMENT);
serializer.text(description);
serializer.endTag(null, DESCRIPTION_ELEMENT);
}
// Write identity settings
serializer.startTag(null, SETTINGS_ELEMENT);
for (Map.Entry<String, Object> entry : prefs.entrySet()) {
String key = entry.getKey();
String valueString = entry.getValue().toString();
String[] comps = key.split("\\.");
if (comps.length < 3) {
// Skip non-identity config entries
continue;
}
String keyUuid = comps[0];
String identityKey = comps[1];
String identityIndex = comps[2];
if (!keyUuid.equals(accountUuid) || !identityIndex.equals(identity)) {
// Skip entries that belong to another identity
continue;
}
TreeMap<Integer, SettingsDescription> versionedSetting = IdentitySettings.SETTINGS.get(identityKey);
if (versionedSetting != null) {
Integer highestVersion = versionedSetting.lastKey();
SettingsDescription setting = versionedSetting.get(highestVersion);
if (setting != null) {
// Only write settings that have an entry in IdentitySettings.SETTINGS
try {
writeKeyAndPrettyValueFromSetting(serializer, identityKey, setting, valueString);
} catch (InvalidSettingValueException e) {
Timber.w("Identity setting \"%s\" has invalid value \"%s\" in preference storage. " +
"This shouldn't happen!", identityKey, valueString);
}
}
}
}
serializer.endTag(null, SETTINGS_ELEMENT);
serializer.endTag(null, IDENTITY_ELEMENT);
}
示例15: xmlExport
import org.xmlpull.v1.XmlSerializer; //导入方法依赖的package包/类
private void xmlExport(OutputStream out) throws IOException {
XmlSerializer serializer = Xml.newSerializer();
serializer.setOutput(out, "UTF-8");
serializer.startDocument(null, true);
serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
serializer.startTag(null, "netguard");
serializer.startTag(null, "application");
xmlExport(PreferenceManager.getDefaultSharedPreferences(this), serializer);
serializer.endTag(null, "application");
serializer.startTag(null, "wifi");
xmlExport(getSharedPreferences("wifi", Context.MODE_PRIVATE), serializer);
serializer.endTag(null, "wifi");
serializer.startTag(null, "mobile");
xmlExport(getSharedPreferences("other", Context.MODE_PRIVATE), serializer);
serializer.endTag(null, "mobile");
serializer.startTag(null, "screen_wifi");
xmlExport(getSharedPreferences("screen_wifi", Context.MODE_PRIVATE), serializer);
serializer.endTag(null, "screen_wifi");
serializer.startTag(null, "screen_other");
xmlExport(getSharedPreferences("screen_other", Context.MODE_PRIVATE), serializer);
serializer.endTag(null, "screen_other");
serializer.startTag(null, "roaming");
xmlExport(getSharedPreferences("roaming", Context.MODE_PRIVATE), serializer);
serializer.endTag(null, "roaming");
serializer.startTag(null, "lockdown");
xmlExport(getSharedPreferences("lockdown", Context.MODE_PRIVATE), serializer);
serializer.endTag(null, "lockdown");
serializer.startTag(null, "apply");
xmlExport(getSharedPreferences("apply", Context.MODE_PRIVATE), serializer);
serializer.endTag(null, "apply");
serializer.startTag(null, "notify");
xmlExport(getSharedPreferences("notify", Context.MODE_PRIVATE), serializer);
serializer.endTag(null, "notify");
serializer.startTag(null, "filter");
filterExport(serializer);
serializer.endTag(null, "filter");
serializer.startTag(null, "forward");
forwardExport(serializer);
serializer.endTag(null, "forward");
serializer.endTag(null, "netguard");
serializer.endDocument();
serializer.flush();
}