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


Java XmlSerializer.setFeature方法代码示例

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


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

示例1: 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);
    }
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:41,代码来源:VUserManagerService.java

示例2: 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);
    }
}
 
开发者ID:Axe-Ishmael,项目名称:Blockly,代码行数:41,代码来源:BlocklyXmlHelper.java

示例3: 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:7763sea,项目名称:VirtualHook,代码行数:34,代码来源:VUserManagerService.java

示例4: writeToStream

import org.xmlpull.v1.XmlSerializer; //导入方法依赖的package包/类
/**
 * XML interface: procedure writes this list into the given stream
 */
public boolean writeToStream(OutputStream stream, String name)
{
    try
    {
        final StringWriter writer = new StringWriter();
        final XmlSerializer serializer = Xml.newSerializer();
        serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
        serializer.setOutput(writer);
        serializer.startDocument("UTF-8", true);
        serializer.setPrefix(FormulaList.XML_PROP_MMT, FormulaList.XML_HTTP);
        serializer.startTag(FormulaList.XML_NS, FormulaList.XML_MAIN_TAG);
        serializer.startTag(FormulaList.XML_NS, XML_LIST_TAG);
        documentSettings.writeToXml(serializer);
        final ArrayList<FormulaBase> fList = formulaListView.getFormulas(FormulaBase.class);
        for (FormulaBase f : fList)
        {
            final String term = f.getBaseType().toString().toLowerCase(Locale.ENGLISH);
            serializer.startTag(FormulaList.XML_NS, term);
            f.writeToXml(serializer, String.valueOf(f.getId()));
            serializer.endTag(FormulaList.XML_NS, term);
        }
        serializer.endTag(FormulaList.XML_NS, XML_LIST_TAG);
        serializer.endTag(FormulaList.XML_NS, FormulaList.XML_MAIN_TAG);
        serializer.endDocument();
        stream.write(writer.toString().getBytes());
        return true;
    }
    catch (Exception e)
    {
        final String error = String.format(activity.getResources().getString(R.string.error_file_write), name);
        Toast.makeText(activity, error, Toast.LENGTH_LONG).show();
    }
    return false;
}
 
开发者ID:mkulesh,项目名称:microMathematics,代码行数:38,代码来源:FormulaList.java

示例5: initAndStartDocument

import org.xmlpull.v1.XmlSerializer; //导入方法依赖的package包/类
private static XmlSerializer initAndStartDocument(Writer output)
        throws IllegalArgumentException, IllegalStateException, IOException {
    XmlSerializer serializer = Xml.newSerializer();
    serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
    serializer.setOutput(output);
    serializer.startDocument(StringUtils.CHARSET_UTF8.name(), Boolean.TRUE);
    return serializer;
}
 
开发者ID:archos-sa,项目名称:aos-MediaLib,代码行数:9,代码来源:NfoWriter.java

示例6: 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();
}
 
开发者ID:miankai,项目名称:MKAPP,代码行数:56,代码来源:ActivitySettings.java

示例7: writeListXml

import org.xmlpull.v1.XmlSerializer; //导入方法依赖的package包/类
/**
 * Flatten a List into an output stream as XML.  The list can later be
 * read back with readListXml().
 *
 * @param val The list to be flattened.
 * @param out Where to write the XML data.
 *
 * @see #writeListXml(List, String, XmlSerializer)
 * @see #writeMapXml
 * @see #writeValueXml
 * @see #readListXml
 */
public static final void writeListXml(List val, OutputStream out)
        throws XmlPullParserException, java.io.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);
    writeListXml(val, null, serializer);
    serializer.endDocument();
}
 
开发者ID:Pixplicity,项目名称:HtmlCompat,代码行数:23,代码来源:XmlUtils.java

示例8: writeMapXml

import org.xmlpull.v1.XmlSerializer; //导入方法依赖的package包/类
/**
 * Flatten a Map into an output stream as XML.  The map can later be
 * read back with readMapXml().
 *
 * @param val The map to be flattened.
 * @param out Where to write the XML data.
 *
 * @see #writeMapXml(Map, String, XmlSerializer)
 * @see #writeListXml
 * @see #writeValueXml
 * @see #readMapXml
 */
public static final void writeMapXml(Map val, OutputStream out)
        throws XmlPullParserException, java.io.IOException {
    XmlSerializer serializer = new FastXmlSerializer();
    serializer.setOutput(out, StandardCharsets.UTF_8.name());
    serializer.startDocument(null, true);
    serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
    writeMapXml(val, null, serializer);
    serializer.endDocument();
}
 
开发者ID:ukanth,项目名称:XPrivacy,代码行数:22,代码来源:XmlUtils.java

示例9: writeListXml

import org.xmlpull.v1.XmlSerializer; //导入方法依赖的package包/类
/**
 * Flatten a List into an output stream as XML.  The list can later be
 * read back with readListXml().
 *
 * @param val The list to be flattened.
 * @param out Where to write the XML data.
 *
 * @see #writeListXml(List, String, XmlSerializer)
 * @see #writeMapXml
 * @see #writeValueXml
 * @see #readListXml
 */
public static final void writeListXml(List val, OutputStream out)
throws XmlPullParserException, java.io.IOException
{
    XmlSerializer serializer = Xml.newSerializer();
    serializer.setOutput(out, StandardCharsets.UTF_8.name());
    serializer.startDocument(null, true);
    serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
    writeListXml(val, null, serializer);
    serializer.endDocument();
}
 
开发者ID:ukanth,项目名称:XPrivacy,代码行数:23,代码来源:XmlUtils.java


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