本文整理汇总了Java中org.mozilla.javascript.xml.XMLObject类的典型用法代码示例。如果您正苦于以下问题:Java XMLObject类的具体用法?Java XMLObject怎么用?Java XMLObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XMLObject类属于org.mozilla.javascript.xml包,在下文中一共展示了XMLObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ecmaToString
import org.mozilla.javascript.xml.XMLObject; //导入依赖的package包/类
private String ecmaToString() {
// See ECMA357 10.1.1
if (isAttribute() || isText()) {
return ecmaValue();
}
if (this.hasSimpleContent()) {
StringBuilder rv = new StringBuilder();
for (int i=0; i < this.node.getChildCount(); i++) {
XmlNode child = this.node.getChild(i);
if (!child.isProcessingInstructionType() &&
!child.isCommentType())
{
// TODO: Probably inefficient; taking clean non-optimized
// solution for now
XML x = new XML(getLib(), getParentScope(),
(XMLObject)getPrototype(), child);
rv.append(x.toString());
}
}
return rv.toString();
}
return toXMLString();
}
示例2: getObjectElem
import org.mozilla.javascript.xml.XMLObject; //导入依赖的package包/类
public static Object getObjectElem(Scriptable obj, Object elem,
Context cx)
{
if (obj instanceof XMLObject) {
XMLObject xmlObject = (XMLObject)obj;
return xmlObject.ecmaGet(cx, elem);
}
Object result;
String s = toStringIdOrIndex(cx, elem);
if (s == null) {
int index = lastIndexResult(cx);
result = ScriptableObject.getProperty(obj, index);
} else {
result = ScriptableObject.getProperty(obj, s);
}
if (result == Scriptable.NOT_FOUND) {
result = Undefined.instance;
}
return result;
}
示例3: getObjectProp
import org.mozilla.javascript.xml.XMLObject; //导入依赖的package包/类
public static Object getObjectProp(Scriptable obj, String property,
Context cx)
{
if (obj instanceof XMLObject) {
// TODO: Change XMLObject to just use Scriptable interface
// to avoid paying cost of instanceof check on *every property
// lookup* !
XMLObject xmlObject = (XMLObject)obj;
return xmlObject.ecmaGet(cx, property);
}
Object result = ScriptableObject.getProperty(obj, property);
if (result == Scriptable.NOT_FOUND) {
if (cx.hasFeature(Context.FEATURE_STRICT_MODE)) {
Context.reportWarning(ScriptRuntime.getMessage1(
"msg.ref.undefined.prop", property));
}
result = Undefined.instance;
}
return result;
}
示例4: getObjectPropNoWarn
import org.mozilla.javascript.xml.XMLObject; //导入依赖的package包/类
public static Object getObjectPropNoWarn(Object obj, String property,
Context cx)
{
Scriptable sobj = toObjectOrNull(cx, obj);
if (sobj == null) {
throw undefReadError(obj, property);
}
if (obj instanceof XMLObject) {
// TODO: fix as mentioned in note in method above
getObjectProp(sobj, property, cx);
}
Object result = ScriptableObject.getProperty(sobj, property);
if (result == Scriptable.NOT_FOUND) {
return Undefined.instance;
}
return result;
}
示例5: setObjectElem
import org.mozilla.javascript.xml.XMLObject; //导入依赖的package包/类
public static Object setObjectElem(Scriptable obj, Object elem,
Object value, Context cx)
{
if (obj instanceof XMLObject) {
XMLObject xmlObject = (XMLObject)obj;
xmlObject.ecmaPut(cx, elem, value);
return value;
}
String s = toStringIdOrIndex(cx, elem);
if (s == null) {
int index = lastIndexResult(cx);
ScriptableObject.putProperty(obj, index, value);
} else {
ScriptableObject.putProperty(obj, s, value);
}
return value;
}
示例6: deleteObjectElem
import org.mozilla.javascript.xml.XMLObject; //导入依赖的package包/类
public static boolean deleteObjectElem(Scriptable target, Object elem,
Context cx)
{
boolean result;
if (target instanceof XMLObject) {
XMLObject xmlObject = (XMLObject)target;
result = xmlObject.ecmaDelete(cx, elem);
} else {
String s = toStringIdOrIndex(cx, elem);
if (s == null) {
int index = lastIndexResult(cx);
target.delete(index);
return !target.has(index, target);
} else {
target.delete(s);
return !target.has(s, target);
}
}
return result;
}
示例7: hasObjectElem
import org.mozilla.javascript.xml.XMLObject; //导入依赖的package包/类
public static boolean hasObjectElem(Scriptable target, Object elem,
Context cx)
{
boolean result;
if (target instanceof XMLObject) {
XMLObject xmlObject = (XMLObject)target;
result = xmlObject.ecmaHas(cx, elem);
} else {
String s = toStringIdOrIndex(cx, elem);
if (s == null) {
int index = lastIndexResult(cx);
result = ScriptableObject.hasProperty(target, index);
} else {
result = ScriptableObject.hasProperty(target, s);
}
}
return result;
}
示例8: strictSetName
import org.mozilla.javascript.xml.XMLObject; //导入依赖的package包/类
public static Object strictSetName(Scriptable bound, Object value,
Context cx, Scriptable scope, String id) {
if (bound != null) {
// TODO: The LeftHandSide also may not be a reference to a
// data property with the attribute value {[[Writable]]:false},
// to an accessor property with the attribute value
// {[[Put]]:undefined}, nor to a non-existent property of an
// object whose [[Extensible]] internal property has the value
// false. In these cases a TypeError exception is thrown (11.13.1).
if (bound instanceof XMLObject) {
XMLObject xmlObject = (XMLObject) bound;
xmlObject.ecmaPut(cx, id, value);
} else {
ScriptableObject.putProperty(bound, id, value);
}
return value;
} else {
// See ES5 8.7.2
String msg = "Assignment to undefined \"" + id + "\" in strict mode";
throw constructError("ReferenceError", msg);
}
}
示例9: ecmaToString
import org.mozilla.javascript.xml.XMLObject; //导入依赖的package包/类
private String ecmaToString() {
// See ECMA357 10.1.1
if (isAttribute() || isText()) {
return ecmaValue();
}
if (this.hasSimpleContent()) {
StringBuffer rv = new StringBuffer();
for (int i=0; i < this.node.getChildCount(); i++) {
XmlNode child = this.node.getChild(i);
if (!child.isProcessingInstructionType() &&
!child.isCommentType())
{
// TODO: Probably inefficient; taking clean non-optimized
// solution for now
XML x = new XML(getLib(), getParentScope(),
(XMLObject)getPrototype(), child);
rv.append(x.toString());
}
}
return rv.toString();
}
return toXMLString();
}
示例10: getObjectElem
import org.mozilla.javascript.xml.XMLObject; //导入依赖的package包/类
public static Object getObjectElem(Scriptable obj, Object elem,
Context cx)
{
Object result;
if (obj instanceof XMLObject) {
result = ((XMLObject)obj).get(cx, elem);
} else {
String s = toStringIdOrIndex(cx, elem);
if (s == null) {
int index = lastIndexResult(cx);
result = ScriptableObject.getProperty(obj, index);
} else {
result = ScriptableObject.getProperty(obj, s);
}
}
if (result == Scriptable.NOT_FOUND) {
result = Undefined.instance;
}
return result;
}
示例11: setObjectElem
import org.mozilla.javascript.xml.XMLObject; //导入依赖的package包/类
public static Object setObjectElem(Scriptable obj, Object elem,
Object value, Context cx)
{
if (obj instanceof XMLObject) {
((XMLObject)obj).put(cx, elem, value);
} else {
String s = toStringIdOrIndex(cx, elem);
if (s == null) {
int index = lastIndexResult(cx);
ScriptableObject.putProperty(obj, index, value);
} else {
ScriptableObject.putProperty(obj, s, value);
}
}
return value;
}
示例12: getObjectElem
import org.mozilla.javascript.xml.XMLObject; //导入依赖的package包/类
public static Object getObjectElem(Scriptable obj, Object elem,
Context cx)
{
Object result;
if (obj instanceof XMLObject) {
result = ((XMLObject)obj).get(cx, elem);
} else if (isSymbol(elem)) {
result = ScriptableObject.getProperty(obj, (Symbol)elem);
} else {
String s = toStringIdOrIndex(cx, elem);
if (s == null) {
int index = lastIndexResult(cx);
result = ScriptableObject.getProperty(obj, index);
} else {
result = ScriptableObject.getProperty(obj, s);
}
}
if (result == Scriptable.NOT_FOUND) {
result = Undefined.instance;
}
return result;
}
示例13: setObjectElem
import org.mozilla.javascript.xml.XMLObject; //导入依赖的package包/类
public static Object setObjectElem(Scriptable obj, Object elem,
Object value, Context cx)
{
if (obj instanceof XMLObject) {
((XMLObject)obj).put(cx, elem, value);
} else if (isSymbol(elem)) {
ScriptableObject.putProperty(obj, (Symbol)elem, value);
} else {
String s = toStringIdOrIndex(cx, elem);
if (s == null) {
int index = lastIndexResult(cx);
ScriptableObject.putProperty(obj, index, value);
} else {
ScriptableObject.putProperty(obj, s, value);
}
}
return value;
}
示例14: fromScript
import org.mozilla.javascript.xml.XMLObject; //导入依赖的package包/类
public OMElement fromScript(Object o) {
if (!(o instanceof XMLObject)) {
return super.fromScript(o);
}
// TODO: E4X Bug? Shouldn't need this copy, but without it the outer element gets lost. See Mozilla bugzilla 361722
Scriptable jsXML = (Scriptable) ScriptableObject.callMethod((Scriptable) o, "copy", new Object[0]);
Wrapper wrapper = (Wrapper) ScriptableObject.callMethod((XMLObject)jsXML, "getXmlObject", new Object[0]);
XmlObject xmlObject = (XmlObject)wrapper.unwrap();
try {
StAXOMBuilder builder = new StAXOMBuilder(xmlObject.newInputStream());
OMElement omElement = builder.getDocumentElement();
return omElement;
} catch (XMLStreamException e) {
throw new RuntimeException(e);
}
}
示例15: getObjectIndex
import org.mozilla.javascript.xml.XMLObject; //导入依赖的package包/类
public static Object getObjectIndex(Scriptable obj, int index,
Context cx)
{
if (obj instanceof XMLObject) {
XMLObject xmlObject = (XMLObject)obj;
return xmlObject.ecmaGet(cx, Integer.valueOf(index));
}
Object result = ScriptableObject.getProperty(obj, index);
if (result == Scriptable.NOT_FOUND) {
result = Undefined.instance;
}
return result;
}