fi.iki.hsivonen.xml
Class AttributeUtil

java.lang.Object
  extended by fi.iki.hsivonen.xml.AttributeUtil

public class AttributeUtil
extends Object

Static utilities for working with (X)HTML5 attribute values.

Version:
$Id: AttributeUtil.java,v 1.4 2006/11/29 18:13:33 hsivonen Exp $
Author:
hsivonen

Field Summary
private static String[] EMPTY_STRING_ARRAY
          An empty string array instance.
private static Pattern INTEGER_PATTERN
          The pattern for extracting an integer by skipping white space and ignoring trailing garbage.
 
Constructor Summary
private AttributeUtil()
          Private constructor to prevent instantiation.
 
Method Summary
static int parseInteger(String attrVal)
          Returns the integer represented by attrVal or Integer.MIN_VALUE on error.
static int parseNonNegativeInteger(String attrVal)
          Returns the non-negative integer represented by attrVal or -1 on error.
static int parsePositiveInteger(String attrVal)
          Returns the positive integer represented by attrVal or -1 on error.
static String[] split(String value)
          Splits the argument on white space.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_STRING_ARRAY

private static final String[] EMPTY_STRING_ARRAY
An empty string array instance.


INTEGER_PATTERN

private static Pattern INTEGER_PATTERN
The pattern for extracting an integer by skipping white space and ignoring trailing garbage.

Constructor Detail

AttributeUtil

private AttributeUtil()
Private constructor to prevent instantiation.

Method Detail

parseInteger

public static int parseInteger(String attrVal)
Returns the integer represented by attrVal or Integer.MIN_VALUE on error.

Parameters:
attrVal - a string representing an integer attribute value (can be null)
Returns:
the integer represented by attrVal or Integer.MIN_VALUE on error

parseNonNegativeInteger

public static int parseNonNegativeInteger(String attrVal)
Returns the non-negative integer represented by attrVal or -1 on error.

Parameters:
attrVal - a string representing a non-negative integer attribute value (can be null)
Returns:
the integer represented by attrVal or -1 on error

parsePositiveInteger

public static int parsePositiveInteger(String attrVal)
Returns the positive integer represented by attrVal or -1 on error.

Parameters:
attrVal - a string representing a positive integer attribute value (can be null)
Returns:
the integer represented by attrVal or -1 on error

split

public static String[] split(String value)
Splits the argument on white space.

Parameters:
value - the attribute value
Returns:
a string array with zero or more strings none of which is the empty string and none of which contains white space characters.