fop 1.0

org.apache.fop.util
Class XMLUtil

java.lang.Object
  extended by org.apache.fop.util.XMLUtil
All Implemented Interfaces:
XMLConstants

public class XMLUtil
extends java.lang.Object
implements XMLConstants

A collection of utility method for XML handling.


Field Summary
 
Fields inherited from interface org.apache.fop.util.XMLConstants
CDATA, XLINK_HREF, XLINK_NAMESPACE, XLINK_PREFIX, XML_NAMESPACE, XML_PREFIX, XML_SPACE, XMLNS_NAMESPACE_URI, XMLNS_PREFIX
 
Constructor Summary
XMLUtil()
           
 
Method Summary
static void addAttribute(org.xml.sax.helpers.AttributesImpl atts, org.apache.xmlgraphics.util.QName attribute, java.lang.String value)
          Adds an attribute to a given AttributesImpl instance.
static void addAttribute(org.xml.sax.helpers.AttributesImpl atts, java.lang.String localName, java.lang.String value)
          Adds an attribute to a given AttributesImpl instance.
static java.util.Locale convertRFC3066ToLocale(java.lang.String lang)
          Converts an RFC 3066 compliant language identifier to a Locale instance.
static boolean getAttributeAsBoolean(org.xml.sax.Attributes attributes, java.lang.String name, boolean defaultValue)
          Returns an attribute value as a boolean value.
static int getAttributeAsInt(org.xml.sax.Attributes attributes, java.lang.String name)
          Returns an attribute value as a int value.
static int getAttributeAsInt(org.xml.sax.Attributes attributes, java.lang.String name, int defaultValue)
          Returns an attribute value as a int value.
static int[] getAttributeAsIntArray(org.xml.sax.Attributes attributes, java.lang.String name)
          Returns an attribute value as a integer array.
static java.lang.Integer getAttributeAsInteger(org.xml.sax.Attributes attributes, java.lang.String name)
          Returns an attribute value as a Integer value.
static java.awt.Rectangle getAttributeAsRectangle(org.xml.sax.Attributes attributes, java.lang.String name)
          Returns an attribute value as a Rectangle value.
static java.awt.geom.Rectangle2D getAttributeAsRectangle2D(org.xml.sax.Attributes attributes, java.lang.String name)
          Returns an attribute value as a Rectangle2D value.
static java.lang.String toRFC3066(java.util.Locale language)
          Converts a Locale instance to an RFC 3066 compliant language identifier.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLUtil

public XMLUtil()
Method Detail

getAttributeAsBoolean

public static boolean getAttributeAsBoolean(org.xml.sax.Attributes attributes,
                                            java.lang.String name,
                                            boolean defaultValue)
Returns an attribute value as a boolean value.

Parameters:
attributes - the Attributes object
name - the name of the attribute
defaultValue - the default value if the attribute is not specified
Returns:
the attribute value as a boolean

getAttributeAsInt

public static int getAttributeAsInt(org.xml.sax.Attributes attributes,
                                    java.lang.String name,
                                    int defaultValue)
Returns an attribute value as a int value.

Parameters:
attributes - the Attributes object
name - the name of the attribute
defaultValue - the default value if the attribute is not specified
Returns:
the attribute value as an int

getAttributeAsInt

public static int getAttributeAsInt(org.xml.sax.Attributes attributes,
                                    java.lang.String name)
                             throws org.xml.sax.SAXException
Returns an attribute value as a int value.

Parameters:
attributes - the Attributes object
name - the name of the attribute
Returns:
the attribute value as an int
Throws:
org.xml.sax.SAXException - if the attribute is missing

getAttributeAsInteger

public static java.lang.Integer getAttributeAsInteger(org.xml.sax.Attributes attributes,
                                                      java.lang.String name)
Returns an attribute value as a Integer value.

Parameters:
attributes - the Attributes object
name - the name of the attribute
Returns:
the attribute value as an Integer or null if the attribute is missing

getAttributeAsRectangle2D

public static java.awt.geom.Rectangle2D getAttributeAsRectangle2D(org.xml.sax.Attributes attributes,
                                                                  java.lang.String name)
Returns an attribute value as a Rectangle2D value. The string value is expected as 4 double-precision numbers separated by whitespace.

Parameters:
attributes - the Attributes object
name - the name of the attribute
Returns:
the attribute value as an Rectangle2D

getAttributeAsRectangle

public static java.awt.Rectangle getAttributeAsRectangle(org.xml.sax.Attributes attributes,
                                                         java.lang.String name)
Returns an attribute value as a Rectangle value. The string value is expected as 4 integer numbers separated by whitespace.

Parameters:
attributes - the Attributes object
name - the name of the attribute
Returns:
the attribute value as an Rectangle

getAttributeAsIntArray

public static int[] getAttributeAsIntArray(org.xml.sax.Attributes attributes,
                                           java.lang.String name)
Returns an attribute value as a integer array. The string value is expected as 4 integer numbers separated by whitespace.

Parameters:
attributes - the Attributes object
name - the name of the attribute
Returns:
the attribute value as an int array

addAttribute

public static void addAttribute(org.xml.sax.helpers.AttributesImpl atts,
                                org.apache.xmlgraphics.util.QName attribute,
                                java.lang.String value)
Adds an attribute to a given AttributesImpl instance.

Parameters:
atts - the attributes collection
attribute - the attribute to add
value - the attribute's CDATA value

addAttribute

public static void addAttribute(org.xml.sax.helpers.AttributesImpl atts,
                                java.lang.String localName,
                                java.lang.String value)
Adds an attribute to a given AttributesImpl instance. The attribute will be added in the default namespace.

Parameters:
atts - the attributes collection
localName - the local name of the attribute
value - the attribute's CDATA value

toRFC3066

public static java.lang.String toRFC3066(java.util.Locale language)
Converts a Locale instance to an RFC 3066 compliant language identifier.

Parameters:
language - the language
Returns:
the formatted language identifier

convertRFC3066ToLocale

public static java.util.Locale convertRFC3066ToLocale(java.lang.String lang)
Converts an RFC 3066 compliant language identifier to a Locale instance.

Parameters:
lang - the language string
Returns:
the converted locale instance

fop 1.0

Copyright 1999-2010 The Apache Software Foundation. All Rights Reserved.