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_managerAvalon service managerstatic StringROLEThe 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 voidcreateElementIfNotNull(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 voidcreateElementIfNotNull(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 voidcreateI18nElementIfNotNull(ContentHandler contentHandler, String localName, I18nizable i18n)Create a start and endElement with a empty Namespace and without Attributes with the givenI18nizableIf theI18nizableisnull, the element is not createdprotected org.slf4j.LoggergetLogger()Returns theLogger.voidservice(ServiceManager manager)voidsetLogger(org.slf4j.Logger logger)Called at creation time to provide aLogger.StringtoString(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:
servicein 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:LogEnabledCalled at creation time to provide aLogger.- Specified by:
setLoggerin interfaceLogEnabled- Parameters:
logger- aLoggerfor 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 givenI18nizableIf theI18nizableisnull, the element is not created- Parameters:
contentHandler- theContentHandlerthat will receive the SAX eventslocalName- The local name (without prefix)i18n- theI18nizableto 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- theContentHandlerthat 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- theContentHandlerthat 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
-
-