de.saar.chorus.domgraph.codec
Class CodecTools

Object
  extended by CodecTools

public class CodecTools
extends Object

Methods that are useful in the implementation of codecs.

Author:
Alexander Koller

Constructor Summary
CodecTools()
           
 
Method Summary
static String atomify(String label)
          Computes a string that is a valid Oz or Prolog atom from the argument.
static void graphLabelsConsistencyAssertion(DomGraph graph, NodeLabels labels)
          Asserts that all labelled nodes in the dominance graph actually have labels.
static String varify(String label)
          Computes a string that is a valid Prolog variable from the argument.
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CodecTools

public CodecTools()
Method Detail

atomify

public static String atomify(String label)
Computes a string that is a valid Oz or Prolog atom from the argument. If the argument starts with a lowercase letter and all later symbols are letters, digit, or underscore, the argument itself is returned; otherwise, the argument is surrounded by quotes '...'.

Parameters:
label - a string
Returns:
the string possibly surrounded with quotes

varify

public static String varify(String label)
Computes a string that is a valid Prolog variable from the argument. If the argument starts with an uppercase letter or an underscore, it is returned directly; otherwise, it is prefixed with an underscore.

Note that the returned string will still not be a valid Prolog variable name if it contains symbols that are not valid in Prolog variable names.

Parameters:
label - a straing
Returns:
the string, possibly prefixed with an underscore

graphLabelsConsistencyAssertion

public static void graphLabelsConsistencyAssertion(DomGraph graph,
                                                   NodeLabels labels)
Asserts that all labelled nodes in the dominance graph actually have labels. If this is not the case and assertions are enabled, then an assertion exception is thrown. This is useful in debugging codecs.

Parameters:
graph - a dominance graph
labels - a matching labels object