com.atlassian.confluence.search.v2
Class QuerySerializer

java.lang.Object
  extended by com.atlassian.confluence.search.v2.QuerySerializer

public class QuerySerializer
extends java.lang.Object

Note: Query serialization and deserialization does not work for all possible permutations of query parts at the moment. For instance, BooleanQuery will not work. You should not use the QuerySerializer in it's current guise.

Responsible for converting SearchQueries to and from their String form.


Constructor Summary
QuerySerializer(QueryFactory queryFactory)
          Construct a new query serializer
 
Method Summary
protected static java.lang.String escape(java.lang.String s)
          Escape any double-quote in a string with a backslash, and any backslash with a second backslash.
static java.lang.String queryToString(SearchQuery query)
          Convert a SearchQuery into a string form that can be transported over the wire, saved, and so on
 SearchQuery stringToQuery(java.lang.String s)
          Convert a string-form query back into object form.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QuerySerializer

public QuerySerializer(QueryFactory queryFactory)
Construct a new query serializer

Parameters:
queryFactory - the factory to convert SearchQuery string keys back into query objects
Method Detail

queryToString

public static java.lang.String queryToString(SearchQuery query)
Convert a SearchQuery into a string form that can be transported over the wire, saved, and so on

Parameters:
query - the query to convert
Returns:
a string form of that query

stringToQuery

public SearchQuery stringToQuery(java.lang.String s)
                          throws InvalidQueryException
Convert a string-form query back into object form. If the string is not a valid query an exception will be thrown. This will always be caused by one of two things: the string was generated incorrectly manually (i.e. not by the serializer), or some SearchQuery plugin that was used during query generation is no longer available.

All clients of the serializer must be able to recover from both of the above circumstances safely.

Parameters:
s - the string to convert
Returns:
the SearchQuery that corresponds to the string provided
Throws:
InvalidQueryException - if the string could not be converted successfully

escape

protected static java.lang.String escape(java.lang.String s)
Escape any double-quote in a string with a backslash, and any backslash with a second backslash.

Parameters:
s - the string to quote
Returns:
the escaped string


Copyright © 2003-2014 Atlassian. All Rights Reserved.