APK反编译源代码展示 - 南明离火平台提供

应用版本信息
应用名称:Web Browser Beta Pro-Fastest Browser
版本号:2.5.7
包名称:com.webbrowserbeta

MD5 校验值:195005882709ac21163d7a1b97aeec73

反编译源代码说明

NodeUtils.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。


package gnu.xquery.util;

import gnu.bytecode.ClassType;
import gnu.kawa.reflect.ClassMethods;
import gnu.kawa.xml.Document;
import gnu.kawa.xml.KDocument;
import gnu.kawa.xml.KElement;
import gnu.kawa.xml.KNode;
import gnu.kawa.xml.Nodes;
import gnu.kawa.xml.SortedNodes;
import gnu.kawa.xml.UntypedAtomic;
import gnu.lists.Consumer;
import gnu.lists.PositionConsumer;
import gnu.mapping.CallContext;
import gnu.mapping.Environment;
import gnu.mapping.Procedure;
import gnu.mapping.Symbol;
import gnu.mapping.Values;
import gnu.mapping.WrongType;
import gnu.text.Path;
import gnu.xml.NamespaceBinding;
import gnu.xml.NodeTree;
import gnu.xml.TextUtils;
import gnu.xml.XName;
import gnu.xquery.lang.XQuery;
import java.io.File;
import java.net.URI;
import java.net.URL;
import java.util.Stack;
import org.apache.xml.serialize.Method;

public class NodeUtils {
    static String collectionNamespace = "http://gnu.org/kawa/cached-collections";
    public static final Symbol collectionResolverSymbol = Symbol.make(XQuery.LOCAL_NAMESPACE, "collection-resolver", "qexo");

    public static boolean availableCached(Object obj, Object obj2) throws Throwable {
        Object resolve = resolve(obj, obj2, "doc-available");
        if (resolve == null) {
            return false;
        }
        try {
            Document.parseCached(resolve);
            return true;
        } catch (Throwable th) {
            return false;
        }
    }

    public static Object baseUri(Object obj) {
        if (obj == null || obj == Values.empty) {
            return obj;
        }
        if (!(obj instanceof KNode)) {
            throw new WrongType("base-uri", 1, obj, "node()?");
        }
        Path baseURI = ((KNode) obj).baseURI();
        return baseURI == null ? Values.empty : baseURI;
    }

    public static Object collection(Object obj, Object obj2) throws Throwable {
        String obj3;
        int indexOf;
        Object resolve = resolve(obj, obj2, "collection");
        Environment current = Environment.getCurrent();
        Symbol symbol = collectionResolverSymbol;
        Object obj4 = current.get(symbol, null, null);
        if (obj4 == null) {
            obj4 = current.get(Symbol.makeWithUnknownNamespace(symbol.getLocalName(), symbol.getPrefix()), null, null);
        }
        if (obj4 == null) {
            return getSavedCollection(resolve);
        }
        if (((obj4 instanceof String) || (obj4 instanceof UntypedAtomic)) && (indexOf = (obj3 = obj4.toString()).indexOf(58)) > 0) {
            String substring = obj3.substring(0, indexOf);
            String substring2 = obj3.substring(indexOf + 1);
            try {
                obj4 = ClassMethods.apply((ClassType) ClassType.make(Class.forName(substring)), substring2, (char) 0, XQuery.instance);
                if (obj4 == null) {
                    throw new RuntimeException("invalid collection-resolver: no method " + substring2 + " in " + substring);
                }
            } catch (ClassNotFoundException e) {
                throw new RuntimeException("invalid collection-resolver: class " + substring + " not found");
            } catch (Throwable th) {
                throw new RuntimeException("invalid collection-resolver: " + th);
            }
        }
        if (obj4 instanceof Procedure) {
            return ((Procedure) obj4).apply1(resolve);
        }
        throw new RuntimeException("invalid collection-resolver: " + obj4);
    }

    public static void data$X(Object obj, CallContext callContext) {
        Consumer consumer = callContext.consumer;
        if (!(obj instanceof Values)) {
            consumer.writeObject(KNode.atomicValue(obj));
            return;
        }
        Values values = (Values) obj;
        int startPos = values.startPos();
        while (true) {
            int nextPos = values.nextPos(startPos);
            startPos = nextPos;
            if (nextPos == 0) {
                return;
            } else {
                consumer.writeObject(KNode.atomicValue(values.getPosPrevious(startPos)));
            }
        }
    }

    public static Object docCached(Object obj, Object obj2) throws Throwable {
        Object resolve = resolve(obj, obj2, "doc");
        return resolve == null ? Values.empty : Document.parseCached(resolve);
    }

    public static Object documentUri(Object obj) {
        if (obj == null || obj == Values.empty) {
            return obj;
        }
        if (!(obj instanceof KNode)) {
            throw new WrongType("xs:document-uri", 1, obj, "node()?");
        }
        KNode kNode = (KNode) obj;
        Object documentUriOfPos = ((NodeTree) kNode.sequence).documentUriOfPos(kNode.ipos);
        return documentUriOfPos == null ? Values.empty : documentUriOfPos;
    }

    static Object getIDs(Object obj, Object obj2) {
        Stack stack;
        Object obj3 = obj;
        Object obj4 = obj2;
        if (obj3 instanceof KNode) {
            obj3 = KNode.atomicValue(obj3);
        }
        if (obj3 instanceof Values) {
            Object[] values = ((Values) obj3).getValues();
            int length = values.length;
            while (true) {
                length--;
                if (length < 0) {
                    break;
                }
                obj4 = getIDs(values[length], obj4);
            }
        } else {
            String coerceToString = StringUtils.coerceToString(obj3, "fn:id", 1, "");
            int length2 = coerceToString.length();
            int i = 0;
            while (i < length2) {
                int i2 = i;
                i++;
                char charAt = coerceToString.charAt(i2);
                if (!Character.isWhitespace(charAt)) {
                    int i3 = XName.isNameStart(charAt) ? i - 1 : length2;
                    while (i < length2) {
                        char charAt2 = coerceToString.charAt(i);
                        if (Character.isWhitespace(charAt2)) {
                            break;
                        }
                        i++;
                        if (i3 < length2 && !XName.isNamePart(charAt2)) {
                            i3 = length2;
                        }
                    }
                    if (i3 < length2) {
                        String substring = coerceToString.substring(i3, i);
                        if (obj4 == null) {
                            obj4 = substring;
                        } else {
                            if (obj4 instanceof Stack) {
                                stack = (Stack) obj4;
                            } else {
                                stack = new Stack();
                                stack.push(obj4);
                                obj4 = stack;
                            }
                            stack.push(substring);
                        }
                    }
                    i++;
                }
            }
        }
        return obj4;
    }

    public static String getLang(KNode kNode) {
        NodeTree nodeTree = (NodeTree) kNode.sequence;
        int ancestorAttribute = nodeTree.ancestorAttribute(kNode.ipos, NamespaceBinding.XML_NAMESPACE, "lang");
        if (ancestorAttribute == 0) {
            return null;
        }
        return KNode.getNodeValue(nodeTree, ancestorAttribute);
    }

    public static Object getSavedCollection(Object obj) {
        return getSavedCollection(obj, Environment.getCurrent());
    }

    public static Object getSavedCollection(Object obj, Environment environment) {
        Object obj2 = obj;
        if (obj2 == null) {
            obj2 = "#default";
        }
        Object obj3 = environment.get(Symbol.make(collectionNamespace, obj2.toString()), null, null);
        if (obj3 == null) {
            throw new RuntimeException("collection '" + obj2 + "' not found");
        }
        return obj3;
    }

    public static void id$X(Object obj, Object obj2, CallContext callContext) {
        KNode kNode = (KNode) obj2;
        NodeTree nodeTree = (NodeTree) kNode.sequence;
        Consumer consumer = callContext.consumer;
        Object iDs = getIDs(obj, null);
        if (iDs == null) {
            return;
        }
        nodeTree.makeIDtableIfNeeded();
        if ((consumer instanceof PositionConsumer) && ((iDs instanceof String) || (consumer instanceof SortedNodes))) {
            idScan(iDs, nodeTree, (PositionConsumer) consumer);
            return;
        }
        if (!(iDs instanceof String)) {
            SortedNodes sortedNodes = new SortedNodes();
            idScan(iDs, nodeTree, sortedNodes);
            Values.writeValues(sortedNodes, consumer);
        } else {
            int lookupID = nodeTree.lookupID((String) iDs);
            if (lookupID != -1) {
                consumer.writeObject(KNode.make(nodeTree, lookupID));
            }
        }
    }

    private static void idScan(Object obj, NodeTree nodeTree, PositionConsumer positionConsumer) {
        if (obj instanceof String) {
            int lookupID = nodeTree.lookupID((String) obj);
            if (lookupID != -1) {
                positionConsumer.writePosition(nodeTree, lookupID);
                return;
            }
            return;
        }
        if (obj instanceof Stack) {
            Stack stack = (Stack) obj;
            int size = stack.size();
            for (int i = 0; i < size; i++) {
                idScan(stack.elementAt(i), nodeTree, positionConsumer);
            }
        }
    }

    public static Object idref(Object obj, Object obj2) {
        KNode kNode = (KNode) obj2;
        return Values.empty;
    }

    public static void inScopePrefixes$X(Object obj, CallContext callContext) {
        Object nodeNameObject = ((KElement) obj).getNodeNameObject();
        if (nodeNameObject instanceof XName) {
            prefixesFromNodetype((XName) nodeNameObject, callContext.consumer);
        } else {
            callContext.consumer.writeObject(Method.XML);
        }
    }

    public static boolean lang(Object obj, Object obj2) {
        String stringValue = (obj == null || obj == Values.empty) ? "" : TextUtils.stringValue(obj);
        String lang = getLang((KNode) obj2);
        if (lang == null) {
            return false;
        }
        int length = lang.length();
        int length2 = stringValue.length();
        if (length > length2 && lang.charAt(length2) == '-') {
            lang = lang.substring(0, length2);
        }
        return lang.equalsIgnoreCase(stringValue);
    }

    public static String localName(Object obj) {
        if (obj == Values.empty || obj == null) {
            return "";
        }
        if (!(obj instanceof KNode)) {
            throw new WrongType("local-name", 1, obj, "node()?");
        }
        Object nodeNameObject = ((KNode) obj).getNodeNameObject();
        return (nodeNameObject == null || nodeNameObject == Values.empty) ? "" : nodeNameObject instanceof Symbol ? ((Symbol) nodeNameObject).getName() : nodeNameObject.toString();
    }

    public static String name(Object obj) {
        if (obj == Values.empty || obj == null) {
            return "";
        }
        Object nodeNameObject = ((KNode) obj).getNodeNameObject();
        return (nodeNameObject == null || nodeNameObject == Values.empty) ? "" : nodeNameObject.toString();
    }

    public static Object namespaceURI(Object obj) {
        if (obj != Values.empty && obj != null) {
            if (!(obj instanceof KNode)) {
                throw new WrongType("namespace-uri", 1, obj, "node()?");
            }
            Object nodeNameObject = ((KNode) obj).getNodeNameObject();
            if (nodeNameObject instanceof Symbol) {
                return QNameUtils.namespaceURIFromQName(nodeNameObject);
            }
        }
        return "";
    }

    public static Object nilled(Object obj) {
        if (obj == null || obj == Values.empty) {
            return obj;
        }
        if (obj instanceof KNode) {
            return !(obj instanceof KElement) ? Values.empty : Boolean.FALSE;
        }
        throw new WrongType("nilled", 1, obj, "node()?");
    }

    public static Object nodeName(Object obj) {
        if (obj == Values.empty || obj == null) {
            return obj;
        }
        if (!(obj instanceof KNode)) {
            throw new WrongType("node-name", 1, obj, "node()?");
        }
        Symbol nodeSymbol = ((KNode) obj).getNodeSymbol();
        return nodeSymbol == null ? Values.empty : nodeSymbol;
    }

    public static void prefixesFromNodetype(XName xName, Consumer consumer) {
        NamespaceBinding namespaceNodes = xName.getNamespaceNodes();
        NamespaceBinding namespaceBinding = namespaceNodes;
        while (true) {
            NamespaceBinding namespaceBinding2 = namespaceBinding;
            if (namespaceBinding2 == null) {
                return;
            }
            if (namespaceBinding2.getUri() != null) {
                String prefix = namespaceBinding2.getPrefix();
                NamespaceBinding namespaceBinding3 = namespaceNodes;
                while (true) {
                    NamespaceBinding namespaceBinding4 = namespaceBinding3;
                    if (namespaceBinding4 == namespaceBinding2) {
                        consumer.writeObject(prefix == null ? "" : prefix);
                    } else if (namespaceBinding4.getPrefix() == prefix) {
                        break;
                    } else {
                        namespaceBinding3 = namespaceBinding4.getNext();
                    }
                }
            }
            namespaceBinding = namespaceBinding2.getNext();
        }
    }

    static Object resolve(Object obj, Object obj2, String str) throws Throwable {
        Object obj3 = obj;
        if (!(obj3 instanceof File) && !(obj3 instanceof Path) && !(obj3 instanceof URI) && !(obj3 instanceof URL)) {
            obj3 = StringUtils.coerceToString(obj3, str, 1, null);
        }
        if (obj3 == Values.empty || obj3 == null) {
            return null;
        }
        return Path.currentPath().resolve(Path.valueOf(obj3));
    }

    public static Object root(Object obj) {
        if (obj == null || obj == Values.empty) {
            return obj;
        }
        if (!(obj instanceof KNode)) {
            throw new WrongType("root", 1, obj, "node()?");
        }
        KNode kNode = (KNode) obj;
        return Nodes.root((NodeTree) kNode.sequence, kNode.getPos());
    }

    public static KDocument rootDocument(Object obj) {
        if (!(obj instanceof KNode)) {
            throw new WrongType("root-document", 1, obj, "node()?");
        }
        KNode kNode = (KNode) obj;
        KNode root = Nodes.root((NodeTree) kNode.sequence, kNode.getPos());
        if (root instanceof KDocument) {
            return (KDocument) root;
        }
        throw new WrongType("root-document", 1, obj, "document()");
    }

    public static void setSavedCollection(Object obj, Object obj2) {
        setSavedCollection(obj, obj2, Environment.getCurrent());
    }

    public static void setSavedCollection(Object obj, Object obj2, Environment environment) {
        Object obj3 = obj;
        if (obj3 == null) {
            obj3 = "#default";
        }
        environment.put(Symbol.make(collectionNamespace, obj3.toString()), null, obj2);
    }
}