| Constructor and Description |
|---|
XMLParser() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addTags(StringBuffer source,
String tag)
|
static void |
addTagsAndAttributes(StringBuffer source,
String tag,
String attributes)
|
static void |
appendObjectWithTags(StringBuffer xml,
Object s,
String tag)
|
static void |
appendObjectWithTagsAndAttributes(StringBuffer xml,
Object s,
String tag,
String attributes)
|
static void |
appendObjectWithTagsAndAttributes(StringBuffer xml,
Object s,
String tag,
String attributes,
boolean writeClassInfo)
|
static void |
appendSequencesWithTags(StringBuffer xml,
String tag,
Sequence... seqs)
|
static StringBuffer |
extractForTag(StringBuffer source,
String tag)
Extracts the contents of
source between tag start and end tags. |
static StringBuffer |
extractForTag(StringBuffer source,
String tag,
Map<String,String> attributes,
Map<String,String> filterAttributes)
Extracts the contents of
source between tag start and end tags. |
static Object |
extractObjectAndAttributesForTags(StringBuffer xml,
String tag,
Map<String,String> attributes,
Map<String,String> filterAttributes)
Returns the parsed value between the tags.
|
static <T> T |
extractObjectAndAttributesForTags(StringBuffer xml,
String tag,
Map<String,String> attributes,
Map<String,String> filterAttributes,
Class<T> k)
Returns the parsed value between the tags.
|
static <T,S> T |
extractObjectAndAttributesForTags(StringBuffer xml,
String tag,
Map<String,String> attributes,
Map<String,String> filterAttributes,
Class<T> k,
Class<S> outerClass,
S outerInstance)
Returns the parsed value between the tags as an inner instance of the object
outerInstance. |
static Object |
extractObjectForTags(StringBuffer xml,
String tag)
Returns the parsed value between the tags.
|
static <T> T |
extractObjectForTags(StringBuffer xml,
String tag,
Class<T> k)
Returns the parsed value between the tags.
|
static Sequence[] |
extractSequencesWithTags(StringBuffer xml,
String tag)
Extracts a set of sequences from their XML representation.
|
static boolean |
hasTag(StringBuffer source,
String tag,
Map<String,String> attributes,
Map<String,String> filterAttributes)
This method allows to check whether an XML contains a tagged entry.
|
static String |
parseAttributes(Map<String,String> map)
This method parses a map of attribute, i.e.
|
static String |
parseString(String original)
|
public static void addTags(StringBuffer source, String tag)
source - the source StringBuffer that should be encoded in XMLtag - the tags by which the StringBuffer should be framedaddTagsAndAttributes(StringBuffer, String, String)public static void addTagsAndAttributes(StringBuffer source, String tag, String attributes)
source - the source StringBuffer that should be encoded in XMLtag - the tags by which the StringBuffer should be framedattributes - null or some attributes, i.e. value="100" confidence="0"parseAttributes(Map)public static void appendObjectWithTags(StringBuffer xml, Object s, String tag)
xml - the source StringBuffer that should be encoded in XMLs - the object that should be framed by the tags and appended to the source,
s might be null, Storable, String, primitive type,
wrapper class of a primitive type, or any array thereoftag - the tags by which the value should be framedparseAttributes(Map),
appendObjectWithTagsAndAttributes(StringBuffer, Object, String, String, boolean)public static void appendObjectWithTagsAndAttributes(StringBuffer xml, Object s, String tag, String attributes)
xml - the source StringBuffer that should be encoded in XMLs - the object that should be framed by the tags and appended to the source,
s might be null, Storable, String, primitive type,
wrapper class of a primitive type, or any array thereoftag - the tags by which the value should be framedattributes - null or some attributes, e.g., value="100" confidence="0"parseAttributes(Map),
appendObjectWithTagsAndAttributes(StringBuffer, Object, String, String, boolean)public static void appendObjectWithTagsAndAttributes(StringBuffer xml, Object s, String tag, String attributes, boolean writeClassInfo)
xml - the source StringBuffer that should be encoded in XMLs - the object that should be framed by the tags and appended to the source,
s might be null, Storable, String, primitive type,
wrapper class of a primitive type, or any array thereoftag - the tags by which the value should be framedattributes - null or some attributes, e.g., value="100" confidence="0"writeClassInfo - a boolean to enable to write class information (e.g. Class.getSimpleName()) of the Object s into the XML.parseAttributes(Map),
extractObjectAndAttributesForTags(StringBuffer, String, Map, Map, Class)public static String parseAttributes(Map<String,String> map)
map - the Map of attribute names and valuesString representation of the attributesparseAttributes(String)public static StringBuffer extractForTag(StringBuffer source, String tag) throws NonParsableException
source between tag start and end tags.source - the XML-code containing start and end tagtag - the tag (without angle brackets)StringBufferNonParsableException - if start or end tag could not be foundpublic static StringBuffer extractForTag(StringBuffer source, String tag, Map<String,String> attributes, Map<String,String> filterAttributes) throws NonParsableException
source between tag start and end tags.
If attributes is not null, the attributes of the start tag are added to this Map.
If filterAttributes is not null, the start tag is accepted only if its attributes and associated values contain those defined in filterAttributed.source - the XML-code containing start and end tagtag - the tag (without angle brackets)attributes - a Map for attributes and values, or null if no attributes should be parsed.filterAttributes - a Map of attributes and associated values, which must be present in the attributes of the start tag, or null for no filteringStringBuffer, if the XML does not contain such a tagged entry, the method returns nullNonParsableException - if the XML is malformedpublic static boolean hasTag(StringBuffer source, String tag, Map<String,String> attributes, Map<String,String> filterAttributes) throws NonParsableException
source - the XML-code containing start and end tagtag - the tag (without angle brackets)attributes - a Map for attributes and values, or null if no attributes should be parsed.filterAttributes - a Map of attributes and associated values, which must be present in the attributes of the start tag, or null for no filteringtrue if the XML contains such a tag, otherwise falseNonParsableException - if the XML is malformedpublic static Object extractObjectForTags(StringBuffer xml, String tag) throws NonParsableException
xml - the source StringBuffer that should be decoded from XMLtag - the tags between which the value shall be takenNonParsableException - if the value could not be parsedextractObjectAndAttributesForTags(StringBuffer, String, Map, Map, Class)public static <T> T extractObjectForTags(StringBuffer xml, String tag, Class<T> k) throws NonParsableException
T - the type of the parsed objectxml - the source StringBuffer that should be decoded from XMLtag - the tags between which the value shall be takenk - the class used to parse the value between the tag, if null the class will be inferred from the XMLNonParsableException - if the value could not be parsedextractObjectAndAttributesForTags(StringBuffer, String, Map, Map, Class)public static Object extractObjectAndAttributesForTags(StringBuffer xml, String tag, Map<String,String> attributes, Map<String,String> filterAttributes) throws NonParsableException
xml - the source StringBuffer that should be decoded from XMLtag - the tags between which the value shall be takenattributes - a Map which can be used to obtain the attribute of the tagfilterAttributes - a Map which defines a filter for the tagsNonParsableException - if the value could not be parsedextractObjectAndAttributesForTags(StringBuffer, String, Map, Map, Class)public static <T> T extractObjectAndAttributesForTags(StringBuffer xml, String tag, Map<String,String> attributes, Map<String,String> filterAttributes, Class<T> k) throws NonParsableException
T - the type of the parsed objectxml - the source StringBuffer that should be decoded from XMLtag - the tags between which the value shall be takenattributes - a Map which can be used to obtain the attribute of the tagfilterAttributes - a Map which defines a filter for the tagsk - the class used to parse the value between the tag, if null the class will be inferred from the XMLNonParsableException - if the value could not be parsedappendObjectWithTagsAndAttributes(StringBuffer, Object, String, String, boolean)public static <T,S> T extractObjectAndAttributesForTags(StringBuffer xml, String tag, Map<String,String> attributes, Map<String,String> filterAttributes, Class<T> k, Class<S> outerClass, S outerInstance) throws NonParsableException
outerInstance.T - the type of the parsed objectS - the type of the outer objectxml - the source StringBuffer that should be decoded from XMLtag - the tags between which the value shall be takenattributes - a Map which can be used to obtain the attribute of the tagfilterAttributes - a Map which defines a filter for the tagsk - the class used to parse the value between the tag, if null the class will be inferred from the XMLouterClass - the class of the outer instance of the parsed objectouterInstance - the outer instance of the parsed objectNonParsableException - if the value could not be parsedappendObjectWithTagsAndAttributes(StringBuffer, Object, String, String, boolean)public static void appendSequencesWithTags(StringBuffer xml, String tag, Sequence... seqs)
Sequences to XML, although Sequence does not implement Storable.
Use for general data storage is discouraged and should be limited to those cases, where a Sequence needs
to the stored within another object implementing Storable.xml - the XML buffertag - the tagseqs - the sequencespublic static Sequence[] extractSequencesWithTags(StringBuffer xml, String tag) throws NonParsableException, WrongAlphabetException
Sequence needs
to the stored within another object implementing Storable.xml - the XML buffertag - the tagNonParsableException - if the XML could not be parsedWrongAlphabetException - if the alphabet does not fit the sequence information