Package org.ametys.core.util
Class XMLUtils
- java.lang.Object
-
- org.apache.cocoon.xml.XMLUtils
-
- org.ametys.core.util.XMLUtils
-
- All Implemented Interfaces:
LogEnabled
,Component
,Serviceable
public class XMLUtils extends XMLUtils implements Component, Serviceable, LogEnabled
Component with XML utils methods
-
-
Field Summary
Fields Modifier and Type Field Description protected ServiceManager
_manager
Avalon service managerstatic String
ROLE
The avalon role-
Fields inherited from class org.apache.cocoon.xml.XMLUtils
EMPTY_ATTRIBUTES
-
-
Constructor Summary
Constructors Constructor Description XMLUtils()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
createElementIfNotNull(ContentHandler contentHandler, String localName, String stringValue)
Create a start and endElement with a empty Namespace and without Attributes If the string value isnull
, the element is not createdstatic void
createElementIfNotNull(ContentHandler contentHandler, String localName, String stringValue, Attributes attributes)
Create a start and endElement with a empty Namespace and without Attributes If the string value isnull
, the element is not createdstatic void
createI18nElementIfNotNull(ContentHandler contentHandler, String localName, I18nizable i18n)
Create a start and endElement with a empty Namespace and without Attributes with the givenI18nizable
If theI18nizable
isnull
, the element is not createdprotected org.slf4j.Logger
getLogger()
Returns theLogger
.void
service(ServiceManager manager)
void
setLogger(org.slf4j.Logger logger)
Called at creation time to provide aLogger
.String
toString(InputStream is)
Get a XML as a string and extract the text only-
Methods inherited from class org.apache.cocoon.xml.XMLUtils
createElement, createElement, createElement, createElement, createElementNS, createElementNS, createElementNS, createElementNS, createPropertiesForXML, data, defaultSerializeToXMLFormat, defaultSerializeToXMLFormat, endElement, endElement, getConsumer, getConsumer, serialize, serializeNode, serializeNode, serializeNodeToXML, startElement, startElement, startElement, startElement, stripDuplicateAttributes, valueOf, valueOf, valueOf, valueOf, valueOf
-
-
-
-
Field Detail
-
_manager
protected ServiceManager _manager
Avalon service manager
-
-
Constructor Detail
-
XMLUtils
public XMLUtils()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getLogger
protected org.slf4j.Logger getLogger()
Returns theLogger
.- Returns:
- the
Logger
.
-
setLogger
public void setLogger(org.slf4j.Logger logger)
Description copied from interface:LogEnabled
Called at creation time to provide aLogger
.- Specified by:
setLogger
in interfaceLogEnabled
- Parameters:
logger
- aLogger
for messages.
-
createI18nElementIfNotNull
public static void createI18nElementIfNotNull(ContentHandler contentHandler, String localName, I18nizable i18n) throws SAXException
Create a start and endElement with a empty Namespace and without Attributes with the givenI18nizable
If theI18nizable
isnull
, the element is not created- Parameters:
contentHandler
- theContentHandler
that will receive the SAX eventslocalName
- The local name (without prefix)i18n
- theI18nizable
to SAX- Throws:
SAXException
- if an error occurs during the SAX events generation
-
createElementIfNotNull
public static void createElementIfNotNull(ContentHandler contentHandler, String localName, String stringValue) throws SAXException
Create a start and endElement with a empty Namespace and without Attributes If the string value isnull
, the element is not created- Parameters:
contentHandler
- theContentHandler
that will receive the SAX eventslocalName
- The local name (without prefix)stringValue
- The content of the Element- Throws:
SAXException
- if an error occurs during the SAX events generation
-
createElementIfNotNull
public static void createElementIfNotNull(ContentHandler contentHandler, String localName, String stringValue, Attributes attributes) throws SAXException
Create a start and endElement with a empty Namespace and without Attributes If the string value isnull
, the element is not created- Parameters:
contentHandler
- theContentHandler
that will receive the SAX eventslocalName
- The local name (without prefix)stringValue
- The content of the Elementattributes
- The attributes attached to the element. If there are no attributes, it shall be an empty Attributes object.- Throws:
SAXException
- if an error occurs during the SAX events generation
-
toString
public String toString(InputStream is)
Get a XML as a string and extract the text only- Parameters:
is
- The inputstream of XML- Returns:
- The text or null if the XML is not well formed
-
-