|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.semanticdesktop.aperture.rdf.util.XmlSafetyUtils
public class XmlSafetyUtils
A set of utility-methods for dealing with XML-safety.
The XML specification states that all characters in a valid XML document must be taken from a certain set. Defined at:
http://www.w3.org/TR/2006/REC-xml-20060816/#charsets The methods of this class help remove invalid characters from the output generated by Aperture components.
Constructor Summary | |
---|---|
XmlSafetyUtils()
|
Method Summary | |
---|---|
static char[] |
makeXmlSafe(char[] s)
Removes all non-valid XML character data chars from the specified char array. |
static char[] |
makeXmlSafe(char[] s,
int off,
int len)
Removes all non-valid XML character data chars from the specified char array and substitutes them with spaces. |
static Node |
makeXmlSafe(Model model,
Node node)
Returns an XML-safe version of the given node. |
static Statement |
makeXmlSafe(Model model,
Statement stmt)
Returns a statement with the same subject and predicate, but with an XML-safe object. |
static String |
makeXmlSafe(String s)
Strips all invalid XML Character data chars from the given string. |
static String |
makeXmlSafe(String in,
int off,
int len)
Strips all invalid XML Character data chars from the given string. |
static Model |
wrapXmlSafeModel(Model model)
Wraps the given model in a wrapper that ensures that all data passed into this model is free of any characters that are invalid in XML. |
static RDFContainer |
wrapXmlSafeRDFContainer(RDFContainer container)
Returns an RDFContainer backed by the same model as the given one, describing the same URI as the given one but ensuring that all the data passed into the model is XML-safe i.e. it doesn't conatain any characters that are invalid in XML. |
static RDFContainerFactory |
wrapXmlSafeRDFContainerFactory(RDFContainerFactory factory)
Returns a wrapper around the given factory that guarantees that all the rdf containers created by that factory will be XML-safe |
static Reader |
wrapXmlSafeReader(Reader reader)
Wraps the given reader in a filter that ensures that no XML-invalid characters are actually read. |
static Writer |
wrapXmlSafeWriter(Writer writer)
Wraps the given writer in a filter that ensures that no XML-invalid characters are actually written. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XmlSafetyUtils()
Method Detail |
---|
public static String makeXmlSafe(String s)
This method has been copy-pasted from: here and modified slightly. The original version removed the xml-invalid chars altogether this version substitutes them with spaces
s
- the input string
public static String makeXmlSafe(String in, int off, int len)
in
- the input stringoff
- the offset where the validity checking should beginlen
- the length of the substring to be checked
public static char[] makeXmlSafe(char[] s)
s
- the array to be checked
public static char[] makeXmlSafe(char[] s, int off, int len)
s
- the array to be checkedoff
- the offset where checking should beginlen
- of the sub-array to be checked
public static Node makeXmlSafe(Model model, Node node)
model
- the model used as the literal factory, in case the method needs to construct a new
XML-safe objectnode
- the node to be checked
public static Statement makeXmlSafe(Model model, Statement stmt)
model
- the model used as the literal factory, in case the method needs to construct a new
XML-safe objectstmt
- the statement to be checked
public static Writer wrapXmlSafeWriter(Writer writer)
writer
-
public static Reader wrapXmlSafeReader(Reader reader)
reader
-
public static Model wrapXmlSafeModel(Model model)
Note that the current implementation handles the add... methods and the methods that read from readers.
Id doesn't handle the update methods AbstractModel#update(Diff) and AbstractModel.update(org.ontoware.rdf2go.model.DiffReader)
and the methods that read from input
streams i.e. ModelIO.readFrom(java.io.InputStream)
,
ModelIO.readFrom(java.io.InputStream, Syntax)
,
ModelIO.readFrom(java.io.InputStream, Syntax, String)
. So it's still possible for XML-invalid
characters to sneak in via these channels. The user is advised to take care about this.
model
-
public static RDFContainer wrapXmlSafeRDFContainer(RDFContainer container)
container
- the container to wrap
public static RDFContainerFactory wrapXmlSafeRDFContainerFactory(RDFContainerFactory factory)
factory
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |