当前位置: 首页>>代码示例>>Java>>正文


Java XmlSerializer.attribute方法代码示例

本文整理汇总了Java中org.xmlpull.v1.XmlSerializer.attribute方法的典型用法代码示例。如果您正苦于以下问题:Java XmlSerializer.attribute方法的具体用法?Java XmlSerializer.attribute怎么用?Java XmlSerializer.attribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.xmlpull.v1.XmlSerializer的用法示例。


在下文中一共展示了XmlSerializer.attribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeMapXml

import org.xmlpull.v1.XmlSerializer; //导入方法依赖的package包/类
/**
 * 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.
 * @param callback Method to call when an Object type is not recognized.
 *
 * @see #writeMapXml(Map, OutputStream)
 * @see #writeListXml
 * @see #writeValueXml
 * @see #readMapXml
 *
 * @hide
 */
public static final void writeMapXml(Map val, String name, XmlSerializer out,
        WriteMapCallback callback) throws XmlPullParserException, java.io.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, callback);

    out.endTag(null, "map");
}
 
开发者ID:ukanth,项目名称:XPrivacy,代码行数:36,代码来源:XmlUtils.java

示例2: 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;
}
 
开发者ID:mkulesh,项目名称:microMathematics,代码行数:19,代码来源:PlotContour.java

示例3: writeBooleanArrayXml

import org.xmlpull.v1.XmlSerializer; //导入方法依赖的package包/类
/**
 * Flatten a boolean[] into an XmlSerializer.  The list can later be read back
 * with readThisBooleanArrayXml().
 *
 * @param val The boolean 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 writeBooleanArrayXml(boolean[] 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, "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");
}
 
开发者ID:ukanth,项目名称:XPrivacy,代码行数:39,代码来源:XmlUtils.java

示例4: 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");
}
 
开发者ID:ukanth,项目名称:XPrivacy,代码行数:39,代码来源:XmlUtils.java

示例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");
}
 
开发者ID:Doist,项目名称:JobSchedulerCompat,代码行数:25,代码来源:XmlUtils.java

示例6: 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()))
    {
        functionView.getPlotParameters().writeToXml(serializer);
        functionView.getAxisParameters().writeToXml(serializer);
        serializer.attribute(FormulaList.XML_NS, XML_PROP_FUNCTIONS_NUMBER, String.valueOf(functions.size()));
    }
    if (FormulaList.XML_TERM_TAG.equalsIgnoreCase(serializer.getName()) && key != null)
    {
        for (Function2D f : functions)
        {
            if (key.equals(f.y.getTermKey()))
            {
                f.getLineParameters().writeToXml(serializer);
            }
        }
    }
    return false;
}
 
开发者ID:mkulesh,项目名称:microMathematics,代码行数:23,代码来源:PlotFunction.java

示例7: 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);
    }
}
 
开发者ID:imkiva,项目名称:AndroidApktool,代码行数:25,代码来源:AndrolibResources.java

示例8: writeStringArrayXml

import org.xmlpull.v1.XmlSerializer; //导入方法依赖的package包/类
/**
 * 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");
}
 
开发者ID:ukanth,项目名称:XPrivacy,代码行数:39,代码来源:XmlUtils.java

示例9: writeDoubleArrayXml

import org.xmlpull.v1.XmlSerializer; //导入方法依赖的package包/类
/**
 * 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");
}
 
开发者ID:ukanth,项目名称:XPrivacy,代码行数:39,代码来源:XmlUtils.java

示例10: 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);
    }
}
 
开发者ID:Doist,项目名称:JobSchedulerCompat,代码行数:37,代码来源:JobStore.java

示例11: writeCompatToXml

import org.xmlpull.v1.XmlSerializer; //导入方法依赖的package包/类
/**
 * Write out fields that wouldn't be needed in the framework's APIs,
 * because JobSchedulerService is always running and never killed.
 */
private void writeCompatToXml(JobStatus jobStatus, JobInfo job, XmlSerializer out)
        throws IOException, XmlPullParserException {
    out.startTag(null, XML_TAG_COMPAT);
    Bundle compat = new Bundle();

    JobInfo.TriggerContentUri[] triggerUris = job.getTriggerContentUris();
    if (triggerUris != null) {
        compat.putParcelableArrayList("trigger-content-uris", new ArrayList<>(Arrays.asList(triggerUris)));
        compat.putLong("trigger-content-update-delay", job.getTriggerContentUpdateDelay());
        compat.putLong("trigger-content-max-delay", job.getMaxExecutionDelayMillis());
    }

    if (jobStatus.changedUris != null) {
        compat.putParcelableArrayList(
                "changed-uris",
                new ArrayList<>(jobStatus.changedUris));
        compat.putStringArrayList(
                "changed-authorities",
                new ArrayList<>(jobStatus.changedAuthorities));
    }

    compat.putBundle("transient-extras", job.getTransientExtras());

    out.attribute(null, "data", Base64.encodeToString(parcelableToByteArray(compat), Base64.DEFAULT));
    out.endTag(null, XML_TAG_COMPAT);
}
 
开发者ID:Doist,项目名称:JobSchedulerCompat,代码行数:31,代码来源:JobStore.java

示例12: 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");
    }
}
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:34,代码来源:VUserManagerService.java

示例13: onStartWriteXmlTag

import org.xmlpull.v1.XmlSerializer; //导入方法依赖的package包/类
/**
 * XML interface: callback on start of an xml tag reading
 */
public boolean onStartWriteXmlTag(XmlSerializer serializer, String key) throws Exception
{
    if (inRightOfPrevious && getBaseType().toString().equalsIgnoreCase(serializer.getName()))
    {
        serializer.attribute(FormulaList.XML_NS, FormulaList.XML_PROP_INRIGHTOFPREVIOUS,
                String.valueOf(inRightOfPrevious));
    }
    return false;
}
 
开发者ID:mkulesh,项目名称:microMathematics,代码行数:13,代码来源:FormulaBase.java

示例14: serialize

import org.xmlpull.v1.XmlSerializer; //导入方法依赖的package包/类
@Override
public void serialize(XmlSerializer serializer) throws IOException {
    serializer.startTag("", "mutation");
    serializer.attribute("", "attr", mAttrib);
    serializer.text(mText);
    serializer.endTag("", "mutation");
}
 
开发者ID:Axe-Ishmael,项目名称:Blockly,代码行数:8,代码来源:MutatorTest.java

示例15: writeToXml

import org.xmlpull.v1.XmlSerializer; //导入方法依赖的package包/类
public void writeToXml(XmlSerializer serializer) throws Exception
{
    serializer.attribute(FormulaList.XML_NS, XML_PROP_ZLABELSNUMBER, String.valueOf(zLabelsNumber));
    serializer.attribute(FormulaList.XML_NS, XML_PROP_COLORMAP, colorMap.toString().toLowerCase(Locale.ENGLISH));
}
 
开发者ID:mkulesh,项目名称:microMathematics,代码行数:6,代码来源:ColorMapProperties.java


注:本文中的org.xmlpull.v1.XmlSerializer.attribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。