org.newsml.toolkit.conformance
Class Util

java.lang.Object
  |
  +--org.newsml.toolkit.conformance.Util

public final class Util
extends Object

Convenient static utility methods for NewsML conformance tests.

Many of the methods in this class depend on the Gnu Regexp Java library.

Version:
2.0
Author:
Reuters PLC

Field Summary
static String DATE_REGEXP
          Regular expression to validate an ISO 8601 date.
static String URL_REGEXP
          Regular expression to validate RFC 1738 URL syntax.
static String URN_REGEXP
          Regular expression to validate RFC 2141 URN syntax.
 
Constructor Summary
Util()
           
 
Method Summary
static boolean isDuidRef(String ref)
          Test whether a string matches Duid reference syntax.
static boolean isHttpUrl(String url)
          Test whether a string matches HTTP URL syntax.
static boolean isISODate(String s)
          Test whether a string is an ISO 8601 date (NewsML subset).
static boolean isISOLang(String s)
          Test whether a string matches IETF RFC 1766 language syntax.
static boolean isNewsMLUrn(String urn)
          Test whether a string matches NewsML URN syntax.
static boolean isUrl(String url)
          Test whether a string matches general URL syntax.
static boolean isUrn(String urn)
          Test whether a string matches general URN syntax.
static boolean matches(String regexp, String data)
          Match a string against a regular expression.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATE_REGEXP

public static final String DATE_REGEXP
Regular expression to validate an ISO 8601 date.

This matches only the NewsML subset of the Basic Format.


URL_REGEXP

public static final String URL_REGEXP
Regular expression to validate RFC 1738 URL syntax.

URN_REGEXP

public static final String URN_REGEXP
Regular expression to validate RFC 2141 URN syntax.
Constructor Detail

Util

public Util()
Method Detail

matches

public static boolean matches(String regexp,
                              String data)
Match a string against a regular expression.
Parameters:
regexp - The regular expression, in Perl5 syntax.
data - The string to match.
Returns:
true if the string matches, false otherwise.

isISODate

public static boolean isISODate(String s)
Test whether a string is an ISO 8601 date (NewsML subset).

isISOLang

public static boolean isISOLang(String s)
Test whether a string matches IETF RFC 1766 language syntax. See NewsML 1.04, section 5.4.2 -- it must be ll-CC or ll-CCC.

isDuidRef

public static boolean isDuidRef(String ref)
Test whether a string matches Duid reference syntax.

isNewsMLUrn

public static boolean isNewsMLUrn(String urn)
Test whether a string matches NewsML URN syntax.

isHttpUrl

public static boolean isHttpUrl(String url)
Test whether a string matches HTTP URL syntax.

isUrl

public static boolean isUrl(String url)
Test whether a string matches general URL syntax.

isUrn

public static boolean isUrn(String urn)
Test whether a string matches general URN syntax.