|
|
|
|
|
*/ |
|
/* |
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
|
* contributor license agreements. See the NOTICE file distributed with |
|
* this work for additional information regarding copyright ownership. |
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
|
* (the "License"); you may not use this file except in compliance with |
|
* the License. You may obtain a copy of the License at |
|
* |
|
* http://www.apache.org/licenses/LICENSE-2.0 |
|
* |
|
* Unless required by applicable law or agreed to in writing, software |
|
* distributed under the License is distributed on an "AS IS" BASIS, |
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
* See the License for the specific language governing permissions and |
|
* limitations under the License. |
|
*/ |
|
|
|
package com.sun.org.apache.xpath.internal.objects; |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public class XBoolean extends XObject |
|
{ |
|
static final long serialVersionUID = -2964933058866100881L; |
|
|
|
|
|
|
|
|
|
*/ |
|
public static final XBoolean S_TRUE = new XBooleanStatic(true); |
|
|
|
|
|
|
|
|
|
*/ |
|
public static final XBoolean S_FALSE = new XBooleanStatic(false); |
|
|
|
|
|
* @serial */ |
|
private final boolean m_val; |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public XBoolean(boolean b) |
|
{ |
|
|
|
super(); |
|
|
|
m_val = b; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public XBoolean(Boolean b) |
|
{ |
|
|
|
super(); |
|
|
|
m_val = b.booleanValue(); |
|
setObject(b); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public int getType() |
|
{ |
|
return CLASS_BOOLEAN; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public String getTypeString() |
|
{ |
|
return "#BOOLEAN"; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public double num() |
|
{ |
|
return m_val ? 1.0 : 0.0; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public boolean bool() |
|
{ |
|
return m_val; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public String str() |
|
{ |
|
return m_val ? "true" : "false"; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public Object object() |
|
{ |
|
if(null == m_obj) |
|
setObject(m_val); |
|
return m_obj; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public boolean equals(XObject obj2) |
|
{ |
|
|
|
// In order to handle the 'all' semantics of |
|
// nodeset comparisons, we always call the |
|
|
|
if (obj2.getType() == XObject.CLASS_NODESET) |
|
return obj2.equals(this); |
|
|
|
try |
|
{ |
|
return m_val == obj2.bool(); |
|
} |
|
catch(javax.xml.transform.TransformerException te) |
|
{ |
|
throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(te); |
|
} |
|
} |
|
|
|
} |