org.foray.common
Class XMLCharacter

java.lang.Object
  extended by org.foray.common.XMLCharacter

public final class XMLCharacter
extends Object

This class provides assistance in handling certain XML-specific tasks. Appendix B of the XML 1.0 Standard defines several character classes. The methods in this class are used to map a given character to these classes.


Method Summary
static String expandEntityReference(char c)
          Takes an entity reference character and converts it to its expanded value.
static CharSequence expandEntityReferences(CharSequence rawText)
          For a sequence of raw text characters, expands entity references.
static boolean isBaseChar(char c)
          Indicates whether a given char is a "base" character as defined in the XML specification.
static boolean isCombiningChar(char c)
          Indicates whether a given char is a "combining" character as defined in the XML specification.
static boolean isDigit(char c)
          Indicates whether a given char is a "digit" character as defined in the XML specification.
static boolean isEntityReference(char c)
          Indicates whether the input is one of the five predefined XML entity references.
static boolean isExtender(char c)
          Indicates whether a given char is an "extender" character as defined in the XML specification.
static boolean isIdeographic(char c)
          Indicates whether a given char is an "ideographic" character as defined in the XML specification.
static boolean isLetter(char c)
          Indicates whether a given char is a "letter" character as defined in the XML specification.
static boolean isNCName(String input)
          Indicates whether the argument is a valid NAME as defined by XML.
static boolean isXMLWhitespace(char c)
          Tests a character for inclusion in XML whitespace.
static boolean isXMLWhitespace(char[] chars)
          Tests whether a given sequence of chars is all XML whitespace.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isBaseChar

public static boolean isBaseChar(char c)
Indicates whether a given char is a "base" character as defined in the XML specification.

Parameters:
c - The char to be tested.
Returns:
True iff c is a "base" character.

isIdeographic

public static boolean isIdeographic(char c)
Indicates whether a given char is an "ideographic" character as defined in the XML specification.

Parameters:
c - The char to be tested.
Returns:
True iff c is an "ideographic" character.

isCombiningChar

public static boolean isCombiningChar(char c)
Indicates whether a given char is a "combining" character as defined in the XML specification.

Parameters:
c - The char to be tested.
Returns:
True iff c is a "combining" character.

isDigit

public static boolean isDigit(char c)
Indicates whether a given char is a "digit" character as defined in the XML specification.

Parameters:
c - The char to be tested.
Returns:
True iff c is a "digit" character.

isExtender

public static boolean isExtender(char c)
Indicates whether a given char is an "extender" character as defined in the XML specification.

Parameters:
c - The char to be tested.
Returns:
True iff c is an "extender" character.

isLetter

public static boolean isLetter(char c)
Indicates whether a given char is a "letter" character as defined in the XML specification.

Parameters:
c - The char to be tested.
Returns:
True iff c is a "letter" character.

isXMLWhitespace

public static boolean isXMLWhitespace(char c)
Tests a character for inclusion in XML whitespace. The definition of XML whitespace is obtained from the XML 1.0 Recommendation, Section 2.3.

Parameters:
c - The character to be tested.
Returns:
True iff the character is XML whitespace.

isXMLWhitespace

public static boolean isXMLWhitespace(char[] chars)
Tests whether a given sequence of chars is all XML whitespace. The definition of XML whitespace is obtained from the XML 1.0 Recommendation, Section 2.3.

Parameters:
chars - The sequence of character to be tested.
Returns:
True iff every character in chars is XML whitespace.

isNCName

public static boolean isNCName(String input)
Indicates whether the argument is a valid NAME as defined by XML.

Parameters:
input - The String to check.
Returns:
True iff input is a valid XML NAME.
See Also:
The NCName definition for XML

isEntityReference

public static boolean isEntityReference(char c)
Indicates whether the input is one of the five predefined XML entity references.

Parameters:
c - The char to be tested.
Returns:
True iff c is a predefined XML entity reference.

expandEntityReference

public static String expandEntityReference(char c)
Takes an entity reference character and converts it to its expanded value. For example, "&" is converted to "&".

Parameters:
c - The char which should be converted to a predefined XML entity reference.
Returns:
A string containing the predefined XML entity reference for c.

expandEntityReferences

public static CharSequence expandEntityReferences(CharSequence rawText)
For a sequence of raw text characters, expands entity references.

Parameters:
rawText - The raw text which should be expanded.
Returns:
The text containing the expanded entities.


Copyright © 2017. All rights reserved.