當前位置: 首頁>>代碼示例>>Java>>正文


Java XmlSerializer.startTag方法代碼示例

本文整理匯總了Java中org.xmlpull.v1.XmlSerializer.startTag方法的典型用法代碼示例。如果您正苦於以下問題:Java XmlSerializer.startTag方法的具體用法?Java XmlSerializer.startTag怎麽用?Java XmlSerializer.startTag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.xmlpull.v1.XmlSerializer的用法示例。


在下文中一共展示了XmlSerializer.startTag方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: 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");
}
 
開發者ID:Pixplicity,項目名稱:HtmlCompat,代碼行數:20,代碼來源:XmlUtils.java

示例3: filterExport

import org.xmlpull.v1.XmlSerializer; //導入方法依賴的package包/類
private void filterExport(XmlSerializer serializer) throws IOException {
    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");
        }
    cursor.close();
}
 
開發者ID:miankai,項目名稱:MKAPP,代碼行數:24,代碼來源:ActivitySettings.java

示例4: 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);
}
 
開發者ID:Doist,項目名稱:JobSchedulerCompat,代碼行數:29,代碼來源:JobStore.java

示例5: writeToXml

import org.xmlpull.v1.XmlSerializer; //導入方法依賴的package包/類
/**
 * XML interface: procedure returns string that contains XML representation of this formula
 */
public void writeToXml(XmlSerializer serializer, String key) throws Exception
{
    if (onStartWriteXmlTag(serializer, key))
    {
        return;
    }
    for (TermField t : terms)
    {
        serializer.startTag(FormulaList.XML_NS, FormulaList.XML_TERM_TAG);
        serializer.attribute(FormulaList.XML_NS, FormulaList.XML_PROP_KEY, t.getTermKey());
        if (onStartWriteXmlTag(serializer, t.getTermKey()))
        {
            continue;
        }
        if (t.isWritable)
        {
            t.writeToXml(serializer);
        }
        serializer.endTag(FormulaList.XML_NS, FormulaList.XML_TERM_TAG);
    }
}
 
開發者ID:mkulesh,項目名稱:microMathematics,代碼行數:25,代碼來源:FormulaBase.java

示例6: 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.
 *
 * @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");
}
 
開發者ID:Pixplicity,項目名稱:HtmlCompat,代碼行數:35,代碼來源:XmlUtils.java

示例7: 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");
}
 
開發者ID:Pixplicity,項目名稱:HtmlCompat,代碼行數:35,代碼來源:XmlUtils.java

示例8: 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

示例9: 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");
    }
}
 
開發者ID:imkiva,項目名稱:AndroidApktool,代碼行數:13,代碼來源:ResEnumAttr.java

示例10: serializeToResValuesXml

import org.xmlpull.v1.XmlSerializer; //導入方法依賴的package包/類
@Override
public void serializeToResValuesXml(XmlSerializer serializer,
                                    ResResource res) throws IOException, AndrolibException {
    serializer.startTag(null, "item");
    serializer
            .attribute(null, "type", res.getResSpec().getType().getName());
    serializer.attribute(null, "name", res.getResSpec().getName());
    serializer.endTag(null, "item");
}
 
開發者ID:imkiva,項目名稱:AndroidApktool,代碼行數:10,代碼來源:ResIdValue.java

示例11: 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");
}
 
開發者ID:ukanth,項目名稱:XPrivacy,代碼行數:40,代碼來源:XmlUtils.java

示例12: 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

示例13: serializeToResValuesXml

import org.xmlpull.v1.XmlSerializer; //導入方法依賴的package包/類
@Override
public void serializeToResValuesXml(XmlSerializer serializer,
                                    ResResource res) throws IOException, AndrolibException {
    String type = res.getResSpec().getType().getName();
    boolean item = !"reference".equals(mType) && !type.equals(mType);

    String body = encodeAsResXmlValue();

    // check for resource reference
    if (!type.equalsIgnoreCase("color")) {
        if (body.contains("@")) {
            if (!res.getFilePath().contains("string")) {
                item = true;
            }
        }
    }

    // check for using attrib as node or item
    String tagName = item ? "item" : type;

    serializer.startTag(null, tagName);
    if (item) {
        serializer.attribute(null, "type", type);
    }
    serializer.attribute(null, "name", res.getResSpec().getName());

    serializeExtraXmlAttrs(serializer, res);

    if (!body.isEmpty()) {
        serializer.ignorableWhitespace(body);
    }

    serializer.endTag(null, tagName);
}
 
開發者ID:imkiva,項目名稱:AndroidApktool,代碼行數:35,代碼來源:ResScalarValue.java

示例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);
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:70,代碼來源:SettingsExporter.java

示例15: getAllSMS

import org.xmlpull.v1.XmlSerializer; //導入方法依賴的package包/類
/**
 * 獲取手機短信並保存到xml中
 * <p>需添加權限 {@code <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>}</p>
 * <p>需添加權限 {@code <uses-permission android:name="android.permission.READ_SMS"/>}</p>
 */
public static void getAllSMS() {
    // 1.獲取短信
    // 1.1獲取內容解析者
    ContentResolver resolver = Utils.getContext().getContentResolver();
    // 1.2獲取內容提供者地址   sms,sms表的地址:null  不寫
    // 1.3獲取查詢路徑
    Uri uri = Uri.parse("content://sms");
    // 1.4.查詢操作
    // projection : 查詢的字段
    // selection : 查詢的條件
    // selectionArgs : 查詢條件的參數
    // sortOrder : 排序
    Cursor cursor = resolver.query(uri, new String[]{"address", "date", "type", "body"}, null, null, null);
    // 設置最大進度
    int count = cursor.getCount();//獲取短信的個數
    // 2.備份短信
    // 2.1獲取xml序列器
    XmlSerializer xmlSerializer = Xml.newSerializer();
    try {
        // 2.2設置xml文件保存的路徑
        // os : 保存的位置
        // encoding : 編碼格式
        xmlSerializer.setOutput(new FileOutputStream(new File("/mnt/sdcard/backupsms.xml")), "utf-8");
        // 2.3設置頭信息
        // standalone : 是否獨立保存
        xmlSerializer.startDocument("utf-8", true);
        // 2.4設置根標簽
        xmlSerializer.startTag(null, "smss");
        // 1.5.解析cursor
        while (cursor.moveToNext()) {
            SystemClock.sleep(1000);
            // 2.5設置短信的標簽
            xmlSerializer.startTag(null, "sms");
            // 2.6設置文本內容的標簽
            xmlSerializer.startTag(null, "address");
            String address = cursor.getString(0);
            // 2.7設置文本內容
            xmlSerializer.text(address);
            xmlSerializer.endTag(null, "address");
            xmlSerializer.startTag(null, "date");
            String date = cursor.getString(1);
            xmlSerializer.text(date);
            xmlSerializer.endTag(null, "date");
            xmlSerializer.startTag(null, "type");
            String type = cursor.getString(2);
            xmlSerializer.text(type);
            xmlSerializer.endTag(null, "type");
            xmlSerializer.startTag(null, "body");
            String body = cursor.getString(3);
            xmlSerializer.text(body);
            xmlSerializer.endTag(null, "body");
            xmlSerializer.endTag(null, "sms");
            System.out.println("address:" + address + "   date:" + date + "  type:" + type + "  body:" + body);
        }
        xmlSerializer.endTag(null, "smss");
        xmlSerializer.endDocument();
        // 2.8將數據刷新到文件中
        xmlSerializer.flush();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:68,代碼來源:PhoneUtils.java


注:本文中的org.xmlpull.v1.XmlSerializer.startTag方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。