Package org.docx4j.model.sdt
Class QueryString
java.lang.Object
org.docx4j.model.sdt.QueryString
public class QueryString
extends java.lang.Object
There is no standard for how more than one value should
be stored in w:/sdtPr/w:tag
This class stores them like a URL query string
If all apps were to do that, two different applications
which stored data to w:tag could possibly co-exist.
To that end, it is recommended you use a namespace
(ie somenamespace: ) as part of each of your keys.
Note that Word 2007 limits the length of an w:sdtPr/w:tag
to 64 characters, so you may wish to keep to that
length.
-
Constructor Summary
Constructors Constructor Description QueryString() -
Method Summary
Modifier and Type Method Description static java.lang.Stringcreate(java.util.Map<java.lang.String,java.lang.String> map)Encode the map as a query string, suitable for storing in w:/sdtPr/w:tag Note that if you intend to use unmarshalString on this, you'll first need to encode the '&' as '&'static java.util.HashMap<java.lang.String,java.lang.String>parseQueryString(java.lang.String s)static java.util.HashMap<java.lang.String,java.lang.String>parseQueryString(java.lang.String s, boolean lax)Parses a query string passed from the client to the server and builds aHashTableobject with key-value pairs.
-
Constructor Details
-
QueryString
public QueryString()
-
-
Method Details
-
create
public static java.lang.String create(java.util.Map<java.lang.String,java.lang.String> map)Encode the map as a query string, suitable for storing in w:/sdtPr/w:tag Note that if you intend to use unmarshalString on this, you'll first need to encode the '&' as '&'- Parameters:
map-- Returns:
-
parseQueryString
public static java.util.HashMap<java.lang.String,java.lang.String> parseQueryString(java.lang.String s) -
parseQueryString
public static java.util.HashMap<java.lang.String,java.lang.String> parseQueryString(java.lang.String s, boolean lax)Parses a query string passed from the client to the server and builds aHashTableobject with key-value pairs. The query string should be in the form of a string packaged by the GET or POST method, that is, it should have key-value pairs in the form key=value, with each pair separated from the next by a & character.A key can appear more than once in the query string with different values. However, the key appears only once in the hashtable, with its value being an array of strings containing the multiple values sent by the query string.
When the keys (only - *not* values) are moved into the hashtable, any + characters are converted to spaces, and characters sent in hexadecimal notation (like %xx) are converted to ASCII characters. This method adapted from Java sources
- Parameters:
s- a string containing the query to be parsed- Returns:
- a
HashTableobject built from the parsed key-value pairs - Throws:
java.lang.IllegalArgumentException- if the query string is invalid
-