Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.hp.hpl.jena.reasoner.rulesys
Class Util

    java.lang.Object
      com.hp.hpl.jena.reasoner.rulesys.Util

    public class Util

extends java.lang.Object

A small random collection of utility functions used by the rule systems.

Version:
  $Revision: 1.30 $ on $Date: 2008/01/02 12:07:48 $
Author:
  Dave Reynolds

Constructor Summary
`Util()`

Method Summary
`static java.lang.Boolean` | `checkBinaryPredicate(Property predicate, Resource configuration)` Helper method - extracts the truth of a boolean configuration predicate.
`static int` | `compareInstants(Node n1, Node n2)` Compare two time Instant nodes.
`static int` | `compareNumbers(Node n1, Node n2)` Compare two numeric nodes.
`static boolean` | `convertBooleanPredicateArg(Property parameter, java.lang.Object value)` Convert the value of a boolean configuration parameter to a boolean value.
`static int` | `convertIntegerPredicateArg(Property parameter, java.lang.Object value)` Convert the value of an integer configuration parameter to an int value.
`static java.util.List` | `convertList(Node root, RuleContext context)` Convert an (assumed well formed) RDF list to a java list of Nodes
`static java.lang.Integer` | `getIntegerPredicate(Property predicate, Resource configuration)` Helper method - extracts the value of an integer configuration predicate.
`static int` | `getIntValue(Node n)` Return the integer value of a literal node
`static Node` | `getPropValue(Node root, Node prop, Finder context)` Helper - returns the (singleton) value for the given property on the given root node in the data graph.
`static Node` | `getPropValue(Node root, Node prop, Graph context)` Helper - returns the (singleton) value for the given property on the given root node in the data graph.
`static Node` | `getPropValue(Node root, Node prop, RuleContext context)` Helper - returns the (singleton) value for the given property on the given root node in the data graph.
`static boolean` | `isInstant(Node n)` Check whether a Node is an Instant (DateTime) value
`static boolean` | `isNumeric(Node n)` Check whether a Node is a numeric (integer) value
`static java.lang.String` | `loadResourceFile(java.lang.String filename)` Deprecated. Use loadRuleParserFromResourceFile
`static Rule.Parser` | `loadRuleParserFromResourceFile(java.lang.String filename)` Open a resource file and read it all into a single string.
`static java.lang.String` | `loadURLFile(java.lang.String urlStr)` Open a file defined by a URL and read all of it into a single string.
`static Node` | `makeDoubleNode(double value)` Construct a new double valued node
`static Node` | `makeIntNode(int value)` Construct a new integer valued node
`static Node` | `makeList(Node[] nodes, Graph graph)` Construct an RDF list from the given array of nodes and assert it in the graph returning the head of the list.
`static Node` | `makeLongNode(long value)` Construct a new long valued node
`static void` | `updateParameter(Resource config, Property parameter, java.lang.Object value)` Replace the value for a given parameter on the resource by a new value.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Util

    public Util()

Method Detail

### isNumeric

    public static boolean isNumeric(Node n)

  Check whether a Node is a numeric (integer) value

### getIntValue

    public static int getIntValue(Node n)

  Return the integer value of a literal node

### compareNumbers

    public static int compareNumbers(Node n1,
                                     Node n2)

  Compare two numeric nodes.

  Parameters:
    `n1` - the first numeric valued literal node
    `n2` - the second numeric valued literal node
  Returns:
    -1 if n1 is less than n2, 0 if n1 equals n2 and +1 if n1 greater than n2
  Throws:
    `java.lang.ClassCastException` - if either node is not numeric

### isInstant

    public static boolean isInstant(Node n)

  Check whether a Node is an Instant (DateTime) value

### compareInstants

    public static int compareInstants(Node n1,
                                      Node n2)

  Compare two time Instant nodes.

  Parameters:
    `n1` - the first time instant (XSDDateTime) valued literal node
    `n2` - the second time instant (XSDDateTime) valued literal node
  Returns:
    -1 if n1 is less than n2, 0 if n1 equals n2 and +1 if n1 greater than n2
  Throws:
    `java.lang.ClassCastException` - if either not is not numeric

### getPropValue

    public static Node getPropValue(Node root,
                                    Node prop,
                                    Finder context)

  Helper - returns the (singleton) value for the given property on the given root node in the data graph.

### getPropValue

    public static Node getPropValue(Node root,
                                    Node prop,
                                    Graph context)

  Helper - returns the (singleton) value for the given property on the given root node in the data graph.

### getPropValue

    public static Node getPropValue(Node root,
                                    Node prop,
                                    RuleContext context)

  Helper - returns the (singleton) value for the given property on the given root node in the data graph.

### convertList

    public static java.util.List convertList(Node root,
                                             RuleContext context)

  Convert an (assumed well formed) RDF list to a java list of Nodes

  Parameters:
    `root` - the root node of the list
    `context` - the graph containing the list assertions

### makeIntNode

    public static Node makeIntNode(int value)

  Construct a new integer valued node

### makeLongNode

    public static Node makeLongNode(long value)

  Construct a new long valued node

### makeDoubleNode

    public static Node makeDoubleNode(double value)

  Construct a new double valued node

### makeList

    public static Node makeList(Node[] nodes,
                                Graph graph)

  Construct an RDF list from the given array of nodes and assert it in the graph returning the head of the list.

### loadResourceFile

    public static java.lang.String loadResourceFile(java.lang.String filename)

  Deprecated. Use loadRuleParserFromResourceFile

  Open a resource file and read it all into a single string. Treats lines starting with # as comment lines, as per stringFromReader.

### loadRuleParserFromResourceFile

    public static Rule.Parser loadRuleParserFromResourceFile(java.lang.String filename)

  Open a resource file and read it all into a single string. Treats lines starting with # as comment lines, as per stringFromReader

### loadURLFile

    public static java.lang.String loadURLFile(java.lang.String urlStr)
                                        throws java.io.IOException

  Open a file defined by a URL and read all of it into a single string. If the URL fails it will try a plain file name as well.

  Throws:
    `java.io.IOException`

### checkBinaryPredicate

    public static java.lang.Boolean checkBinaryPredicate(Property predicate,
                                                         Resource configuration)

  Helper method - extracts the truth of a boolean configuration predicate.

  Parameters:
    `predicate` - the predicate to be tested
    `configuration` - the configuration node
  Returns:
    null if there is no setting otherwise a Boolean giving the setting value

### getIntegerPredicate

    public static java.lang.Integer getIntegerPredicate(Property predicate,
                                                        Resource configuration)

  Helper method - extracts the value of an integer configuration predicate.

  Parameters:
    `predicate` - the predicate to be tested
    `configuration` - the configuration node
  Returns:
    null if there is no such configuration parameter otherwise the value as an integer

### convertBooleanPredicateArg

    public static boolean convertBooleanPredicateArg(Property parameter,
                                                     java.lang.Object value)

  Convert the value of a boolean configuration parameter to a boolean value. Allows the value to be specified using a String or Boolean.

  Parameters:
    `parameter` - the configuration property being set (to help with error messages)
    `value` - the parameter value
  Returns:
    the converted value
  Throws:
    `IllegalParameterException` - if the value can't be converted

### convertIntegerPredicateArg

    public static int convertIntegerPredicateArg(Property parameter,
                                                 java.lang.Object value)

  Convert the value of an integer configuration parameter to an int value. Allows the value to be specified using a String or Number.

  Parameters:
    `parameter` - the configuration property being set (to help with error messages)
    `value` - the parameter value
  Returns:
    the converted value
  Throws:
    `IllegalParameterException` - if the value can't be converted

### updateParameter

    public static void updateParameter(Resource config,
                                       Property parameter,
                                       java.lang.Object value)

  Replace the value for a given parameter on the resource by a new value.

  Parameters:
    `config` - the resource whose values are to be updated
    `parameter` - a predicate defining the parameter to be set
    `value` - the new value

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP