From 2127637945ea6b763966398130e0770fa993c860 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 17 Jan 2006 18:09:40 +0000 Subject: 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 --- libjava/classpath/gnu/xml/xpath/Expr.java | 45 ++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 13 deletions(-) (limited to 'libjava/classpath/gnu/xml/xpath/Expr.java') 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)); + } + } -- cgit v1.1