All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.htmlunit.corejs.javascript.xml.XMLObject Maven / Gradle / Ivy

/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package org.htmlunit.corejs.javascript.xml;

import org.htmlunit.corejs.javascript.Context;
import org.htmlunit.corejs.javascript.IdScriptableObject;
import org.htmlunit.corejs.javascript.NativeWith;
import org.htmlunit.corejs.javascript.Ref;
import org.htmlunit.corejs.javascript.Scriptable;

/** This Interface describes what all XML objects (XML, XMLList) should have in common. */
public abstract class XMLObject extends IdScriptableObject {

    private static final long serialVersionUID = 8455156490438576500L;

    public XMLObject() {}

    public XMLObject(Scriptable scope, Scriptable prototype) {
        super(scope, prototype);
    }

    /** Implementation of ECMAScript [[Has]]. */
    public abstract boolean has(Context cx, Object id);

    /** Implementation of ECMAScript [[Get]]. */
    public abstract Object get(Context cx, Object id);

    /** Implementation of ECMAScript [[Put]]. */
    public abstract void put(Context cx, Object id, Object value);

    /** Implementation of ECMAScript [[Delete]]. */
    public abstract boolean delete(Context cx, Object id);

    public abstract Object getFunctionProperty(Context cx, String name);

    public abstract Object getFunctionProperty(Context cx, int id);

    /**
     * Return an additional object to look for methods that runtime should consider during method
     * search. Return null if no such object available.
     */
    public abstract Scriptable getExtraMethodSource(Context cx);

    /** Generic reference to implement x.@y, x..y etc. */
    public abstract Ref memberRef(Context cx, Object elem, int memberTypeFlags);

    /** Generic reference to implement x::ns, x.@ns::y, x..@ns::y etc. */
    public abstract Ref memberRef(Context cx, Object namespace, Object elem, int memberTypeFlags);

    /** Wrap this object into NativeWith to implement the with statement. */
    public abstract NativeWith enterWith(Scriptable scope);

    /** Wrap this object into NativeWith to implement the .() query. */
    public abstract NativeWith enterDotQuery(Scriptable scope);

    /**
     * Custom + operator. Should return {@link Scriptable#NOT_FOUND} if this object
     * does not have custom addition operator for the given value, or the result of the addition
     * operation.
     *
     * 

The default implementation returns {@link Scriptable#NOT_FOUND} to indicate no custom * addition operation. * * @param cx the Context object associated with the current thread. * @param thisIsLeft if true, the object should calculate this + value if false, the object * should calculate value + this. * @param value the second argument for addition operation. */ public Object addValues(Context cx, boolean thisIsLeft, Object value) { return Scriptable.NOT_FOUND; } /** * Gets the value returned by calling the typeof operator on this object. * * @see org.htmlunit.corejs.javascript.ScriptableObject#getTypeOf() * @return "xml" or "undefined" if {@link #avoidObjectDetection()} returns true */ @Override public String getTypeOf() { return avoidObjectDetection() ? "undefined" : "xml"; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy