Java XML QName Get getQNameWithBackslashedLocal( QName suspectQName)

Here you can find the source of getQNameWithBackslashedLocal( QName suspectQName)

Description

get Q Name With Backslashed Local

License

Apache License

Declaration

public static QName getQNameWithBackslashedLocal(
            QName suspectQName)
    

Method Source Code

//package com.java2s;
//License from project: Apache License 

import javax.xml.namespace.QName;

public class Main {
    public static QName getQNameWithBackslashedLocal(QName suspectQName)
    /*     */{/*from  w  w w.  j av a  2 s .  c o m*/
        /*  48 */String trustedString = null;
        /*     */
        /*  51 */trustedString = applyBackslashes(suspectQName
                .getLocalPart());
        /*  52 */return getQNameWithDifferentLocal(suspectQName,
                trustedString);
        /*     */}

    public static String applyBackslashes(String string)
    /*     */{
        /*  70 */return transformBackslashes(string, false);
        /*     */}

    public static QName getQNameWithDifferentLocal(QName qName,
            String localName)
    /*     */{
        /*  59 */QName trustedQName = null;
        /*     */
        /*  62 */trustedQName = new QName(qName.getNamespaceURI(),
                localName, qName.getPrefix());
        /*  63 */return trustedQName;
        /*     */}

    public static String transformBackslashes(String string, boolean delete)
    /*     */{
        /*  85 */byte[] suspectBytes = null;
        /*  86 */StringBuffer stringBuffer = null;
        /*     */
        /*  88 */suspectBytes = string.getBytes();
        /*  89 */stringBuffer = new StringBuffer(string);
        /*     */
        /*  91 */for (int b = suspectBytes.length - 1; b >= 0; b--) {
            /*  92 */if (suspectBytes[b] == 92) {
                /*  93 */if (delete)
                    /*  94 */stringBuffer.delete(b, b + 1);
                /*     */else {
                    /*  96 */stringBuffer.insert(b, "\\");
                    /*     */}
                /*     */}
            /*     */}
        /* 100 */return stringBuffer.toString();
        /*     */}
}

Related

  1. getQNameFromSerialzedForm(String qNameAsString)
  2. getQNameFromString(Element element, String qnameAsString)
  3. getQNameFromString(Object obj)
  4. getQNameHashCode(QName aQName)
  5. getQNameType(List objects, QName qName)
  6. getQNameWithDifferentLocal(QName qName, String localName)

  7. HOME | Copyright © www.java2s.com 2016