org.griphyn.common.util
Class Separator

java.lang.Object
  extended by org.griphyn.common.util.Separator

public class Separator
extends Object

This class solely defines the separators used in the textual in- and output between namespace, name and version(s). A textual representation of a definition looks like ns::name:version, and a textual representation of a uses like ns::name:min,max.

Version:
$Revision: 50 $
Author:
Jens-S. V??ckler, Yong Zhao
See Also:
Definition

Field Summary
private static int[][] actionmap
          Maps the action associated with a state and a character class.
private static short[][] actionmap2
          Maps the action associated with a state and char class.
static String DEFAULT
          Deprecated. The default namespace is null.
static String NAME
          This constant defines the separator between an identifier and its version.
static String NAMESPACE
          This constant defines the separator between a namespace and the identifier.
private static short[][] statemap
          Maps the state and character class to the follow-up state.
private static short[][] statemap2
          Maps the new state from current state and character class.
static String VERSION
          This constant defines the separator that denotes a version range.
 
Constructor Summary
Separator()
           
 
Method Summary
static String combine(String namespace, String name, String version)
          Combines the three components that constitute a fully-qualified definition identifier into a single string.
static String combine(String namespace, String name, String min, String max)
          Combines the four components that reference a fully-qualified definition identifier into a single string.
static String[] split(String fqdn)
          Splits a fully-qualified identifier into its components.
static String[] splitFQDI(String fqdi)
          Splits a fully-qualified definition identifier into separate namespace, name and version.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAMESPACE

public static final String NAMESPACE
This constant defines the separator between a namespace and the identifier.

See Also:
Constant Field Values

NAME

public static final String NAME
This constant defines the separator between an identifier and its version.

See Also:
Constant Field Values

VERSION

public static final String VERSION
This constant defines the separator that denotes a version range. Version ranges are only used with the "uses" clause, which maps from a derivation to a transformation.

See Also:
Constant Field Values

DEFAULT

public static final String DEFAULT
Deprecated. The default namespace is null.
Although not truly a separator, this is the name of the default namespace, which is used in the absence of a namespace.

See Also:
Constant Field Values

actionmap2

private static short[][] actionmap2
Maps the action associated with a state and char class. The following actions were determined:
0no operation
1save character
2empty save into ns
3empty save into id
4empty save into vs
5empty save into id, save


statemap2

private static short[][] statemap2
Maps the new state from current state and character class. The following character classes are distinguished:
0EOS
1colon (:)
2other (*)


actionmap

private static int[][] actionmap
Maps the action associated with a state and a character class. The actions are as follows:
0no operation
1save character
2empty save into ns
3empty save into name
4empty save into vs
5empty save into vs, 4args
6empty save into max
7empty save into max, 4args
8empty save into name, save


statemap

private static short[][] statemap
Maps the state and character class to the follow-up state. The final state 16 is a regular final state, and final state 17 is the error final state. All other states are intermediary states.

Four character classes are distinguished:

0end of string (EOS)
1colon (:)
2comma (,)
3any other

Constructor Detail

Separator

public Separator()
Method Detail

combine

public static String combine(String namespace,
                             String name,
                             String version)
Combines the three components that constitute a fully-qualified definition identifier into a single string.

Parameters:
namespace - is the namespace, may be empty or null.
name - is the name to use, must not be empty nor null.
version - is the version to attach, may be empty or null.
Returns:
the combination of namespace, name and version with separators.
Throws:
NullPointerException - will be thrown on an empty or null name, as no such identifier can be constructed.

combine

public static String combine(String namespace,
                             String name,
                             String min,
                             String max)
Combines the four components that reference a fully-qualified definition identifier into a single string.

Parameters:
namespace - is the namespace, may be empty or null.
name - is the name to use, must not be empty nor null.
min - is the lower version to attach, may be empty or null.
max - is the upper version to attach, may be empty or null.
Returns:
the combination of namespace, name and versions with appropriate separators.
Throws:
NullPointerException - will be thrown on an empty or null name, as no such identifier can be constructed.

splitFQDI

public static String[] splitFQDI(String fqdi)
                          throws IllegalArgumentException
Splits a fully-qualified definition identifier into separate namespace, name and version. Certain extensions permit a spec to distinguish between an empty namespace or version and a null (wildcard match) namespace and version.

There is a subtle distinction between a null value and an empty value for the namespace and version. A null value is usually taken as a wildcard match. An empty string however is an exact match of a definition without the namespace or version.

In order to enable the DAX generation function to distinguish these cases when specifying user input, the following convention is supported, where * stands in for wild-card matches, and (-) for a match of an empty element:

INPUT NS ID VS
id * id *
::id (-) id *
::id: (-) id (-)
id: * id (-)
id:vs * id vs
n::id n id *
n::id:n id (-)
n::i:vn i v
::i:v (-) i v

Parameters:
fqdi - is the fully-qualified definition identifier.
Returns:
an array with 3 entries representing namespace, name and version. Namespace and version may be empty or even null.
Throws:
IllegalArgumentException

split

public static String[] split(String fqdn)
                      throws IllegalArgumentException
Splits a fully-qualified identifier into its components. Please note that you must check the length of the result. If it contains three elements, it is a regular FQDN. If it contains four results, it is a tranformation reference range. Note though, if the version portion is not specified, a 3 argument string will always be returned, even if the context requires a 4 argument string.

Parameters:
fqdn - is the string to split into components.
Returns:
a vector with three or four Strings, if it was parsable.
  1. namespace, may be null
  2. name, never null
  3. version for 3arg, or minimum version for 4arg, may be null
  4. maximum version for 4arg, may be null
Throws:
IllegalArgumentException, - if the identifier cannot be parsed correctly.
IllegalArgumentException


Copyright © 2007 The University of Southern California. All Rights Reserved.