Package org.mustangproject
Class XMLTools
- java.lang.Object
-
- org.xml.sax.helpers.XMLFilterImpl
-
- org.dom4j.io.XMLWriter
-
- org.mustangproject.XMLTools
-
- All Implemented Interfaces:
org.xml.sax.ContentHandler,org.xml.sax.DTDHandler,org.xml.sax.EntityResolver,org.xml.sax.ErrorHandler,org.xml.sax.ext.LexicalHandler,org.xml.sax.XMLFilter,org.xml.sax.XMLReader
public class XMLTools extends org.dom4j.io.XMLWriter
-
-
Constructor Summary
Constructors Constructor Description XMLTools()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.StringencodeXML(java.lang.CharSequence s)relplaces some entities like < , > and & with their escaped pendant like <java.lang.StringescapeAttributeEntities(java.lang.String s)java.lang.StringescapeElementEntities(java.lang.String s)static byte[]getBytesFromStream(java.io.InputStream fileinput)static java.lang.StringgetNodeValue(org.w3c.dom.Node node)returns the value of an nodestatic java.lang.StringnDigitFormat(java.math.BigDecimal value, int scale)static java.lang.StringnDigitFormatDecimalRange(java.math.BigDecimal value, int maxDecimals, int minDecimals)formats a number so that at least minDecimals are displayed but at the maximum maxDecimals are there, i.e.static byte[]removeBOM(byte[] zugferdRaw)removes utf8 byte order marks from byte arrays, in case one is therestatic java.lang.StringtrimOrNull(org.w3c.dom.Node node)static java.math.BigDecimaltryBigDecimal(java.lang.String nodeValue)tries to convert a String to BigDecimal.static java.math.BigDecimaltryBigDecimal(org.w3c.dom.Node node)tries to convert a Node to a BigDecimal.static java.util.DatetryDate(java.lang.String toParse)returns a util.Date from a 102 String yyyymmddstatic java.util.DatetryDate(org.w3c.dom.Node node)returns a util.Date from a 102 String yyyymmdd in a node-
Methods inherited from class org.dom4j.io.XMLWriter
characters, close, comment, createWriter, defaultMaximumAllowedCharacter, endCDATA, endDocument, endDTD, endElement, endEntity, endPrefixMapping, flush, getLexicalHandler, getMaximumAllowedCharacter, getOutputFormat, getProperty, handleException, ignorableWhitespace, indent, installLexicalHandler, isElementSpacePreserved, isEscapeText, isExpandEmptyElements, isNamespaceDeclaration, notationDecl, parse, println, processingInstruction, resolveEntityRefs, setDocumentLocator, setEscapeText, setIndentLevel, setLexicalHandler, setMaximumAllowedCharacter, setOutputStream, setProperty, setResolveEntityRefs, setWriter, shouldEncodeChar, startCDATA, startDocument, startDTD, startElement, startEntity, startPrefixMapping, unparsedEntityDecl, write, write, write, write, write, write, write, write, write, write, write, write, write, writeAttribute, writeAttribute, writeAttribute, writeAttributes, writeAttributes, writeCDATA, writeClose, writeClose, writeComment, writeDeclaration, writeDocType, writeDocType, writeElement, writeElementContent, writeEmptyElementClose, writeEntity, writeEntityRef, writeEscapeAttributeEntities, writeNamespace, writeNamespace, writeNamespaces, writeNamespaces, writeNode, writeNodeText, writeOpen, writePrintln, writeProcessingInstruction, writeString
-
Methods inherited from class org.xml.sax.helpers.XMLFilterImpl
error, fatalError, getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getParent, parse, resolveEntity, setContentHandler, setDTDHandler, setEntityResolver, setErrorHandler, setFeature, setParent, skippedEntity, warning
-
-
-
-
Method Detail
-
escapeAttributeEntities
public java.lang.String escapeAttributeEntities(java.lang.String s)
- Overrides:
escapeAttributeEntitiesin classorg.dom4j.io.XMLWriter
-
escapeElementEntities
public java.lang.String escapeElementEntities(java.lang.String s)
- Overrides:
escapeElementEntitiesin classorg.dom4j.io.XMLWriter
-
nDigitFormat
public static java.lang.String nDigitFormat(java.math.BigDecimal value, int scale)
-
getNodeValue
public static java.lang.String getNodeValue(org.w3c.dom.Node node)
returns the value of an node- Parameters:
node- the Node to get the value from- Returns:
- A String or empty String, if no value was found
-
tryBigDecimal
public static java.math.BigDecimal tryBigDecimal(java.lang.String nodeValue)
tries to convert a String to BigDecimal.- Parameters:
nodeValue- The value as String- Returns:
- a BigDecimal with the value provides as String or a BigDecimal with value 0.00 if an error occurs
-
tryBigDecimal
public static java.math.BigDecimal tryBigDecimal(org.w3c.dom.Node node)
tries to convert a Node to a BigDecimal.- Parameters:
node- The value as String- Returns:
- a BigDecimal with the value provides as String or a BigDecimal with value 0.00 if an error occurs
-
nDigitFormatDecimalRange
public static java.lang.String nDigitFormatDecimalRange(java.math.BigDecimal value, int maxDecimals, int minDecimals)formats a number so that at least minDecimals are displayed but at the maximum maxDecimals are there, i.e. cuts potential 0s off the end until minDecimals- Parameters:
value- the value to be formattedmaxDecimals- number of maximal scaleminDecimals- number of minimal scale- Returns:
- value as String with decimals in the specified range
-
tryDate
public static java.util.Date tryDate(org.w3c.dom.Node node)
returns a util.Date from a 102 String yyyymmdd in a node- Parameters:
node- the node- Returns:
- a util.Date, or null, if not parseable
-
tryDate
public static java.util.Date tryDate(java.lang.String toParse)
returns a util.Date from a 102 String yyyymmdd- Parameters:
toParse- the string- Returns:
- a util.Date, or null, if not parseable
-
encodeXML
public static java.lang.String encodeXML(java.lang.CharSequence s)
relplaces some entities like < , > and & with their escaped pendant like <- Parameters:
s- the string- Returns:
- the "safe" string
-
removeBOM
public static byte[] removeBOM(byte[] zugferdRaw)
removes utf8 byte order marks from byte arrays, in case one is there- Parameters:
zugferdRaw- the CII XML- Returns:
- the byte array without bom
-
getBytesFromStream
public static byte[] getBytesFromStream(java.io.InputStream fileinput) throws java.io.IOException- Throws:
java.io.IOException
-
trimOrNull
public static java.lang.String trimOrNull(org.w3c.dom.Node node)
-
-