[google-gdata commit] r317 - trunk/clients/cs/src/core

1 view
Skip to first unread message

codesite...@google.com

unread,
Nov 12, 2007, 2:18:33 PM11/12/07
to google-he...@googlegroups.com
Author: fmantek
Date: Mon Nov 12 11:17:59 2007
New Revision: 317

Modified:
trunk/clients/cs/src/core/documentquery.cs

Log:
Fixed title-exact query construction

Modified: trunk/clients/cs/src/core/documentquery.cs
==============================================================================
--- trunk/clients/cs/src/core/documentquery.cs (original)
+++ trunk/clients/cs/src/core/documentquery.cs Mon Nov 12 11:17:59 2007
@@ -1,163 +1,161 @@
-/* Copyright (c) 2006 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using System.Diagnostics;
-using System.Globalization;
-using System.Text;
-using System.Xml;
-
-namespace Google.GData.Client
-{
- /// <summary>
- /// A subclass of FeedQuery, to create a document based query URI.
- /// Provides public properties that describe the different
- /// aspects of the URI, as well as a composite URI.
- /// </summary>
- public class DocumentQuery : FeedQuery
- {
- private string title;
- private bool exact;
-
- /// <summary>
- /// Constructor - Sets the base URI
- /// </summary>
- /// <param name="baseUri"></param>
- public DocumentQuery(string baseUri) : base(baseUri)
- {
- Title = null;
- Exact = false;
- }
-
- /// <summary>
- /// The exact or unexact title to query for.
- /// </summary>
- public string Title
- {
- get
- {
- return title;
- }
-
- set
- {
- title = value;
- }
- }
-
- /// <summary>
- /// If true, then only the exact title string will be looked for.
- /// </summary>
- public bool Exact
- {
- get
- {
- return exact;
- }
-
- set
- {
- exact = value;
- }
- }
-
-#if WindowsCE || PocketPC
-#else
-
- /// <summary>
- /// Parses an incoming URI string and sets the instance variables
- /// of this object.
- /// </summary>
- /// <param name="targetUri">Takes an incoming Uri string and
parses all the properties of it</param>
- /// <returns>Throws a query exception when it finds something
wrong with the input, otherwise returns a baseuri.</returns>
- protected override Uri ParseUri(Uri targetUri)
- {
- base.ParseUri(targetUri);
- if (targetUri != null)
- {
- char[] delimiters = { '?', '&' };
-
- TokenCollection tokens = new
TokenCollection(targetUri.Query, delimiters);
- foreach (String token in tokens)
- {
- if (token.Length > 0)
- {
- char[] otherDelimiters = { '=' };
- String[] parameters =
token.Split(otherDelimiters, 2);
- switch (parameters[0])
- {
- case "title":
- Title = parameters[1];
- Exact = false;
- break;
- case "title-exact":
- Title = parameters[1];
- Exact = true;
- break;
- }
- }
- }
- }
- return this.Uri;
- }
-#endif
- /// <summary>
- /// Resets object state to default, as if newly created.
- /// </summary>
- protected override void Reset()
- {
- base.Reset();
- Title = null;
- Exact = false;
- }
-
- /// <summary>
- /// Creates the partial URI query string based on all set properties.
- /// </summary>
- /// <returns> string => the query part of the URI </returns>
- protected override string CalculateQuery()
- {
- string path = base.CalculateQuery();
- StringBuilder newPath = new StringBuilder(path, 2048);
-
- char paramInsertion;
-
- if (path.IndexOf('?') == -1)
- {
- paramInsertion = '?';
- }
- else
- {
- paramInsertion = '&';
- }
-
- if (Title != null)
- {
- newPath.Append(paramInsertion);
-
- if (Exact)
+/* Copyright (c) 2006 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Diagnostics;
+using System.Globalization;
+using System.Text;
+using System.Xml;
+
+namespace Google.GData.Client
+{
+ /// <summary>
+ /// A subclass of FeedQuery, to create a document based query URI.
+ /// Provides public properties that describe the different
+ /// aspects of the URI, as well as a composite URI.
+ /// </summary>
+ public class DocumentQuery : FeedQuery
+ {
+ private string title;
+ private bool exact;
+
+ /// <summary>
+ /// Constructor - Sets the base URI
+ /// </summary>
+ /// <param name="baseUri"></param>
+ public DocumentQuery(string baseUri) : base(baseUri)
+ {
+ Title = null;
+ Exact = false;
+ }
+
+ /// <summary>
+ /// The exact or unexact title to query for.
+ /// </summary>
+ public string Title
+ {
+ get
+ {
+ return title;
+ }
+
+ set
+ {
+ title = value;
+ }
+ }
+
+ /// <summary>
+ /// If true, then only the exact title string will be looked for.
+ /// </summary>
+ public bool Exact
+ {
+ get
+ {
+ return exact;
+ }
+
+ set
+ {
+ exact = value;
+ }
+ }
+
+#if WindowsCE || PocketPC

+#else

+
+ /// <summary>
+ /// Parses an incoming URI string and sets the instance variables
+ /// of this object.
+ /// </summary>
+ /// <param name="targetUri">Takes an incoming Uri string and
parses all the properties of it</param>
+ /// <returns>Throws a query exception when it finds something
wrong with the input, otherwise returns a baseuri.</returns>
+ protected override Uri ParseUri(Uri targetUri)
+ {
+ base.ParseUri(targetUri);
+ if (targetUri != null)
+ {
+ char[] delimiters = { '?', '&' };
+
+ TokenCollection tokens = new
TokenCollection(targetUri.Query, delimiters);
+ foreach (String token in tokens)
{
-
newPath.AppendFormat(CultureInfo.InvariantCulture, "title-exact={0}", Utilities.UriEncodeReserved(Title));
- }
- else
+ if (token.Length > 0)
+ {
+ char[] otherDelimiters = { '=' };
+ String[] parameters =
token.Split(otherDelimiters, 2);
+ switch (parameters[0])
+ {
+ case "title":
+ Title = parameters[1];
+ Exact = false;
+ break;
+ case "title-exact":
+ Title = parameters[1];
+ Exact = true;
+ break;
+ }
+ }
+ }
+ }
+ return this.Uri;
+ }
+#endif
+ /// <summary>
+ /// Resets object state to default, as if newly created.
+ /// </summary>
+ protected override void Reset()
+ {
+ base.Reset();
+ Title = null;
+ Exact = false;
+ }
+
+ /// <summary>
+ /// Creates the partial URI query string based on all set properties.
+ /// </summary>
+ /// <returns> string => the query part of the URI </returns>
+ protected override string CalculateQuery()
+ {
+ string path = base.CalculateQuery();
+ StringBuilder newPath = new StringBuilder(path, 2048);
+
+ char paramInsertion;
+
+ if (path.IndexOf('?') == -1)
+ {
+ paramInsertion = '?';
+ }
+ else
+ {
+ paramInsertion = '&';
+ }
+
+ if (Title != null)
+ {
+ newPath.Append(paramInsertion);
+
newPath.AppendFormat(CultureInfo.InvariantCulture, "title={0}", Utilities.UriEncodeReserved(Title));
+
+ if (Exact)
{
-
newPath.AppendFormat(CultureInfo.InvariantCulture, "title={0}", Utilities.UriEncodeReserved(Title));
- }
- }
-
- return newPath.ToString();
- }
- }
-}
+ newPath.Append(paramInsertion);
+ newPath.AppendFormat(CultureInfo.InvariantCulture, "title-exact=true");
+ }
+ }
+
+ return newPath.ToString();
+ }
+ }
+}

Reply all
Reply to author
Forward
0 new messages