本文整理汇总了Java中org.xmlpull.v1.XmlSerializer类的典型用法代码示例。如果您正苦于以下问题:Java XmlSerializer类的具体用法?Java XmlSerializer怎么用?Java XmlSerializer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XmlSerializer类属于org.xmlpull.v1包,在下文中一共展示了XmlSerializer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startTag
import org.xmlpull.v1.XmlSerializer; //导入依赖的package包/类
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;
}
示例2: 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);
}
示例3: writeLongArrayXml
import org.xmlpull.v1.XmlSerializer; //导入依赖的package包/类
/**
* Flatten a long[] into an XmlSerializer. The list can later be read back
* with readThisLongArrayXml().
*
* @param val The long 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 writeLongArrayXml(long[] 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, "long-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", Long.toString(val[i]));
out.endTag(null, "item");
}
out.endTag(null, "long-array");
}
示例4: writeIntArrayXml
import org.xmlpull.v1.XmlSerializer; //导入依赖的package包/类
/**
* Flatten an int[] into an XmlSerializer. The list can later be read back
* with readThisIntArrayXml().
*
* @param val The int 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 writeIntArrayXml(int[] 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, "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: writeDoubleArrayXml
import org.xmlpull.v1.XmlSerializer; //导入依赖的package包/类
private static void writeDoubleArrayXml(double[] val, String name, XmlSerializer out)
throws XmlPullParserException, 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");
}
示例6: writeStringArrayXml
import org.xmlpull.v1.XmlSerializer; //导入依赖的package包/类
private static void writeStringArrayXml(String[] val, String name, XmlSerializer out)
throws XmlPullParserException, 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");
}
示例7: writeBooleanArrayXml
import org.xmlpull.v1.XmlSerializer; //导入依赖的package包/类
private static void writeBooleanArrayXml(boolean[] val, String name, XmlSerializer out)
throws XmlPullParserException, IOException {
if (val == null) {
out.startTag(null, "null");
out.endTag(null, "null");
return;
}
out.startTag(null, "boolean-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", Boolean.toString(val[i]));
out.endTag(null, "item");
}
out.endTag(null, "boolean-array");
}
示例8: onStartWriteXmlTag
import org.xmlpull.v1.XmlSerializer; //导入依赖的package包/类
@Override
public boolean onStartWriteXmlTag(XmlSerializer serializer, String key) throws Exception
{
super.onStartWriteXmlTag(serializer, key);
if (getBaseType().toString().equalsIgnoreCase(serializer.getName()))
{
serializer.attribute(FormulaList.XML_NS, XML_PROP_PLOT_STYLE,
twoDPlotStyle.toString().toLowerCase(Locale.ENGLISH));
functionView.getPlotParameters().writeToXml(serializer);
functionView.getAxisParameters().writeToXml(serializer);
functionView.getColorMapView().getColorMapParameters().writeToXml(serializer);
}
if (FormulaList.XML_TERM_TAG.equalsIgnoreCase(serializer.getName()) && key != null)
{
// contour-specific attributes
}
return false;
}
示例9: endTag
import org.xmlpull.v1.XmlSerializer; //导入依赖的package包/类
public XmlSerializer endTag(String namespace, String name)
throws IOException, IllegalArgumentException, IllegalStateException {
if (inTag) {
append(" />\n");
} else {
append("</");
if (namespace != null) {
append(namespace);
append(':');
}
append(name);
append(">\n");
}
inTag = false;
return this;
}
示例10: endTag
import org.xmlpull.v1.XmlSerializer; //导入依赖的package包/类
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;
}
示例11: writeByteArrayXml
import org.xmlpull.v1.XmlSerializer; //导入依赖的package包/类
/**
* Flatten a byte[] into an XmlSerializer. The list can later be read back
* with readThisByteArrayXml().
*
* @param val The byte 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
*/
public static final void writeByteArrayXml(byte[] 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, "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;
sb.append(h >= 10 ? ('a'+h-10) : ('0'+h));
h = b&0xff;
sb.append(h >= 10 ? ('a'+h-10) : ('0'+h));
}
out.text(sb.toString());
out.endTag(null, "byte-array");
}
示例12: writeSetXml
import org.xmlpull.v1.XmlSerializer; //导入依赖的package包/类
public static final void writeSetXml(Set 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, "set");
if (name != null) {
out.attribute(null, "name", name);
}
for (Object v : val) {
writeValueXml(v, null, out);
}
out.endTag(null, "set");
}
示例13: serializeToResValuesXml
import org.xmlpull.v1.XmlSerializer; //导入依赖的package包/类
@Override
public void serializeToResValuesXml(XmlSerializer serializer,
ResResource res) throws IOException, AndrolibException {
serializer.startTag(null, "plurals");
serializer.attribute(null, "name", res.getResSpec().getName());
for (int i = 0; i < mItems.length; i++) {
ResScalarValue item = mItems[i];
if (item == null) {
continue;
}
ResScalarValue rawValue = item;
serializer.startTag(null, "item");
serializer.attribute(null, "quantity", QUANTITY_MAP[i]);
serializer.text(ResXmlEncoders.enumerateNonPositionalSubstitutionsIfRequired(item.encodeAsResXmlValue()));
serializer.endTag(null, "item");
}
serializer.endTag(null, "plurals");
}
示例14: serializeToResValuesXml
import org.xmlpull.v1.XmlSerializer; //导入依赖的package包/类
@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");
}
示例15: serializeToResValuesXml
import org.xmlpull.v1.XmlSerializer; //导入依赖的package包/类
@Override
public void serializeToResValuesXml(XmlSerializer serializer,
ResResource res) throws IOException, AndrolibException {
String type = getType();
type = (type == null ? "" : type + "-") + "array";
serializer.startTag(null, type);
serializer.attribute(null, "name", res.getResSpec().getName());
// lets check if we need to add formatted="false" to this array
for (int i = 0; i < mItems.length; i++) {
if (mItems[i].hasMultipleNonPositionalSubstitutions()) {
serializer.attribute(null, "formatted", "false");
break;
}
}
// add <item>'s
for (int i = 0; i < mItems.length; i++) {
serializer.startTag(null, "item");
serializer.text(mItems[i].encodeAsResXmlNonEscapedItemValue());
serializer.endTag(null, "item");
}
serializer.endTag(null, type);
}