diff options
author | Mark Wielaard <mark@gcc.gnu.org> | 2006-01-17 18:09:40 +0000 |
---|---|---|
committer | Mark Wielaard <mark@gcc.gnu.org> | 2006-01-17 18:09:40 +0000 |
commit | 2127637945ea6b763966398130e0770fa993c860 (patch) | |
tree | c976ca91e3ef0bda3b34b37c0195145638d8d08e /libjava/classpath/gnu/xml/xpath/Expr.java | |
parent | bcb36c3e02e3bd2843aad1b9888513dfb5d6e337 (diff) | |
download | gcc-2127637945ea6b763966398130e0770fa993c860.zip gcc-2127637945ea6b763966398130e0770fa993c860.tar.gz gcc-2127637945ea6b763966398130e0770fa993c860.tar.bz2 |
Imported GNU Classpath 0.20
Imported GNU Classpath 0.20
* Makefile.am (AM_CPPFLAGS): Add classpath/include.
* java/nio/charset/spi/CharsetProvider.java: New override file.
* java/security/Security.java: Likewise.
* sources.am: Regenerated.
* Makefile.in: Likewise.
From-SVN: r109831
Diffstat (limited to 'libjava/classpath/gnu/xml/xpath/Expr.java')
-rw-r--r-- | libjava/classpath/gnu/xml/xpath/Expr.java | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/libjava/classpath/gnu/xml/xpath/Expr.java b/libjava/classpath/gnu/xml/xpath/Expr.java index b4b55dc..76fd49ee 100644 --- a/libjava/classpath/gnu/xml/xpath/Expr.java +++ b/libjava/classpath/gnu/xml/xpath/Expr.java @@ -1,5 +1,5 @@ /* Expr.java -- - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004,2006 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -233,9 +233,11 @@ public abstract class Expr */ public static String _local_name(Node context, Collection nodeSet) { - Node node = (nodeSet == null || nodeSet.size() == 0) ? context : - firstNode(nodeSet); - return node.getLocalName(); + if (nodeSet == null || nodeSet.isEmpty()) + return ""; + Node node = firstNode(nodeSet); + String ret = node.getLocalName(); + return (ret == null) ? "" : ret; } /** @@ -248,9 +250,11 @@ public abstract class Expr */ public static String _namespace_uri(Node context, Collection nodeSet) { - Node node = (nodeSet == null || nodeSet.size() == 0) ? context : - firstNode(nodeSet); - return node.getNamespaceURI(); + if (nodeSet == null || nodeSet.isEmpty()) + return ""; + Node node = firstNode(nodeSet); + String ret = node.getNamespaceURI(); + return (ret == null) ? "" : ret; } /** @@ -271,17 +275,18 @@ public abstract class Expr */ public static String _name(Node context, Collection nodeSet) { - Node node = (nodeSet == null || nodeSet.size() == 0) ? context : - firstNode(nodeSet); + if (nodeSet == null || nodeSet.isEmpty()) + return ""; + Node node = firstNode(nodeSet); + String ret = null; switch (node.getNodeType()) { case Node.ATTRIBUTE_NODE: case Node.ELEMENT_NODE: case Node.PROCESSING_INSTRUCTION_NODE: - return node.getNodeName(); - default: - return ""; + ret = node.getNodeName(); } + return (ret == null) ? "" : ret; } /** @@ -371,7 +376,10 @@ public abstract class Expr } if (object instanceof Double) { - return ((Double) object).doubleValue() != 0.0; + Double value = (Double) object; + if (value.isNaN()) + return false; + return value.doubleValue() != 0.0; } if (object instanceof String) { @@ -473,4 +481,15 @@ public abstract class Expr } } + static int intValue(Object val) + { + if (val instanceof Double) + { + Double d = (Double) val; + return d.isNaN() ? 0 : d.intValue(); + } + else + return (int) Math.ceil(_number(null, val)); + } + } |