Logo Search packages:      
Sourcecode: gdata-sharp version File versions  Download package

basenametable.cs

/* 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.
*/
#region Using directives

#define USE_TRACING

using System;
using System.Xml;
using System.IO; 

#endregion

//////////////////////////////////////////////////////////////////////
// <summary>basenametable, holds common names for atom&rss parsing</summary> 
//////////////////////////////////////////////////////////////////////
namespace Google.GData.Client
{

    //////////////////////////////////////////////////////////////////////
    /// <summary>BaseNameTable. An initialized nametable for faster XML processing
    /// parses:  
    ///     *  opensearch:totalResults - the total number of search results available (not necessarily all present in the feed).
    ///     *  opensearch:startIndex - the 1-based index of the first result.
    ///     *  opensearch:itemsPerPage - the maximum number of items that appear on one page. This allows clients to generate direct links to any set of subsequent pages.
    ///     *  gData:processed
    ///  </summary>
    //////////////////////////////////////////////////////////////////////
00040     public class BaseNameTable
    {
        /// <summary>the nametable itself, based on XML core</summary> 
00043         private NameTable atomNameTable; 

        /// <summary>opensearch:totalResults</summary> 
00046         private object totalResults;
        /// <summary>opensearch:startIndex</summary> 
00048         private object startIndex;
        /// <summary>opensearch:itemsPerPage</summary> 
00050         private object itemsPerPage;
         /// <summary>xml base</summary> 
00052         private object baseUri;
        /// <summary>xml language</summary> 
00054         private object language;

        // batch extensions
        private object batchId; 
        private object batchStatus;
        private object batchOperation;
        private object batchInterrupt;
        private object batchContentType;
        private object batchStatusCode; 
        private object batchReason;
        private object batchErrors;
        private object batchError;
        private object batchSuccessCount;
        private object batchFailureCount;
        private object batchParsedCount;
        private object batchField;
        private object batchUnprocessed; 

        private object type;
        private object value;
        private object name;
        private object eTagAttribute;


        /// <summary>
        ///  namespace of the opensearch v1.0 elements
        /// </summary>
00081         public const string NSOpenSearchRss = "http://a9.com/-/spec/opensearchrss/1.0/";
        /// <summary>
        ///  namespace of the opensearch v1.1 elements
        /// </summary>
00085         public const string NSOpenSearch11 = "http://a9.com/-/spec/opensearch/1.1/"; 
        /// <summary>static namespace string declaration</summary> 
00087         public const string NSAtom = "http://www.w3.org/2005/Atom";
        /// <summary>namespace for app publishing control, draft version</summary> 
00089         public const string NSAppPublishing = "http://purl.org/atom/app#"; 
       /// <summary>namespace for app publishing control, final version</summary> 
00091         public const string NSAppPublishingFinal = "http://www.w3.org/2007/app"; 
        /// <summary>xml namespace</summary> 
00093         public const string NSXml = "http://www.w3.org/XML/1998/namespace";
        /// <summary>GD namespace</summary> 
00095         public const string gNamespace = "http://schemas.google.com/g/2005";
        /// <summary>GData batch extension namespace</summary> 
00097         public const string gBatchNamespace = "http://schemas.google.com/gdata/batch"; 
        /// <summary>GD namespace prefix</summary> 
00099         public const string gNamespacePrefix = gNamespace+ "#";
        /// <summary>the post definiton in the link collection</summary> 
00101         public const string ServicePost = gNamespacePrefix + "post";
        /// <summary>the feed definition in the link collection</summary> 
00103         public const string ServiceFeed = gNamespacePrefix + "feed";
        /// <summary>the batch URI definition in the link collection</summary>
00105         public const string ServiceBatch = gNamespacePrefix + "batch";
        /// <summary>GData Kind Scheme</summary> 
00107         public const string gKind = gNamespacePrefix + "kind";
        /// <summary>label scheme</summary>
00109         public const string gLabels = gNamespace + "/labels";
        /// <summary>the edit definition in the link collection</summary> 
00111         public const string ServiceEdit = "edit";
        /// <summary>the next chunk URI in the link collection</summary> 
00113         public const string ServiceNext = "next";
        /// <summary>the previous chunk URI in the link collection</summary> 
00115         public const string ServicePrev = "previous";
        /// <summary>the self URI in the link collection</summary> 
00117         public const string ServiceSelf = "self";
        /// <summary>the alternate URI in the link collection</summary> 
00119         public const string ServiceAlternate = "alternate";
        /// <summary>the alternate URI in the link collection</summary> 
00121         public const string ServiceMedia = "edit-media";

        /// <summary>prefix for atom if writing</summary> 
00124         public const string AtomPrefix = "atom"; 

        /// <summary>prefix for gNamespace if writing</summary> 
00127         public const string gDataPrefix = "gd"; 

        /// <summary>prefix for gdata:batch if writing</summary> 
00130         public const string gBatchPrefix = "batch"; 



        // app publishing control strings
        /// <summary>prefix for appPublishing if writing</summary> 
00136         public const string gAppPublishingPrefix = "app"; 

        /// <summary>xmlelement for app:control</summary> 
00139         public const string XmlElementPubControl = "control"; 

        /// <summary>xmlelement for app:draft</summary> 
00142         public const string XmlElementPubDraft = "draft";
        /// <summary>xmlelement for app:draft</summary> 
00144         public const string XmlElementPubEdited = "edited";

        /// <summary>
        /// static string for parsing the etag attribute
        /// </summary>
        /// <returns></returns>
00150         public const string XmlEtagAttribute = "etag";



        // batch strings:

        
        /// <summary>xmlelement for batch:id</summary> 
00158         public const string XmlElementBatchId = "id"; 
        /// <summary>xmlelement for batch:operation</summary> 
00160         public const string XmlElementBatchOperation = "operation"; 
        /// <summary>xmlelement for batch:status</summary> 
00162         public const string XmlElementBatchStatus = "status"; 
        /// <summary>xmlelement for batch:interrupted</summary> 
00164         public const string XmlElementBatchInterrupt = "interrupted"; 
        /// <summary>xmlattribute for batch:status@contentType</summary> 
00166         public const string XmlAttributeBatchContentType = "content-type"; 
        /// <summary>xmlattribute for batch:status@code</summary> 
00168         public const string XmlAttributeBatchStatusCode = "code"; 
        /// <summary>xmlattribute for batch:status@reason</summary> 
00170         public const string XmlAttributeBatchReason = "reason";
        /// <summary>xmlelement for batch:status:errors</summary> 
00172         public const string XmlElementBatchErrors = "errors"; 
        /// <summary>xmlelement for batch:status:errors:error</summary> 
00174         public const string XmlElementBatchError = "error"; 
       /// <summary>xmlattribute for batch:interrupted@success</summary> 
00176         public const string XmlAttributeBatchSuccess = "success";
        /// <summary>XmlAttribute for batch:interrupted@parsed</summary> 
00178         public const string XmlAttributeBatchParsed = "parsed"; 
        /// <summary>XmlAttribute for batch:interrupted@field</summary> 
00180         public const string XmlAttributeBatchField = "field"; 
        /// <summary>XmlAttribute for batch:interrupted@unprocessed</summary> 
00182         public const string XmlAttributeBatchUnprocessed = "unprocessed"; 
        /// <summary>XmlConstant for value in enums</summary> 
00184         public const string XmlValue = "value"; 
        /// <summary>XmlConstant for name in enums</summary> 
00186         public const string XmlName = "name"; 
        /// <summary>XmlAttribute for type in enums</summary> 
00188         public const string XmlAttributeType = "type"; 

        //////////////////////////////////////////////////////////////////////
        /// <summary>initializes the name table for use with atom parsing. This is the
        /// only place where strings are defined for parsing</summary> 
        //////////////////////////////////////////////////////////////////////
00194         public virtual void InitAtomParserNameTable()
        {
            // create the nametable object
            Tracing.TraceCall("Initializing basenametable support"); 
            this.atomNameTable = new NameTable(); 
            // <summary>add the keywords for the Feed
            this.totalResults = this.atomNameTable.Add("totalResults");
            this.startIndex   = this.atomNameTable.Add("startIndex");
            this.itemsPerPage = this.atomNameTable.Add("itemsPerPage");
            this.baseUri      = this.atomNameTable.Add("base");  
            this.language     = this.atomNameTable.Add("lang");  

            // batch keywords
            this.batchId            = this.atomNameTable.Add(BaseNameTable.XmlElementBatchId);
            this.batchOperation     = this.atomNameTable.Add(BaseNameTable.XmlElementBatchOperation); 
            this.batchStatus        = this.atomNameTable.Add(BaseNameTable.XmlElementBatchStatus);
            this.batchInterrupt     = this.atomNameTable.Add(BaseNameTable.XmlElementBatchInterrupt);
            this.batchContentType   = this.atomNameTable.Add(BaseNameTable.XmlAttributeBatchContentType); 
            this.batchStatusCode    = this.atomNameTable.Add(BaseNameTable.XmlAttributeBatchStatusCode); 
            this.batchReason        = this.atomNameTable.Add(BaseNameTable.XmlAttributeBatchReason); 
            this.batchErrors        = this.atomNameTable.Add(BaseNameTable.XmlElementBatchErrors); 
            this.batchError         = this.atomNameTable.Add(BaseNameTable.XmlElementBatchError); 
            this.batchSuccessCount  = this.atomNameTable.Add(BaseNameTable.XmlAttributeBatchSuccess); 
            this.batchFailureCount  = this.batchError; 
            this.batchParsedCount   = this.atomNameTable.Add(BaseNameTable.XmlAttributeBatchParsed); 
            this.batchField         = this.atomNameTable.Add(BaseNameTable.XmlAttributeBatchField); 
            this.batchUnprocessed   = this.atomNameTable.Add(BaseNameTable.XmlAttributeBatchUnprocessed); 

            this.type              = this.atomNameTable.Add(BaseNameTable.XmlAttributeType); 
            this.value             = this.atomNameTable.Add(BaseNameTable.XmlValue); 
            this.name              = this.atomNameTable.Add(BaseNameTable.XmlName); 
            this.eTagAttribute = this.atomNameTable.Add(BaseNameTable.XmlEtagAttribute);
        }
        /////////////////////////////////////////////////////////////////////////////

        #region Read only accessors 8/10/2005

        //////////////////////////////////////////////////////////////////////
        /// <summary>Read only accessor for atomNameTable</summary> 
        //////////////////////////////////////////////////////////////////////
        internal NameTable Nametable
00235         {
            get {return this.atomNameTable;}
        }
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>Read only accessor for BatchId</summary> 
        //////////////////////////////////////////////////////////////////////
        public object BatchId
00244         {
            get {return this.batchId;}
        }
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>Read only accessor for BatchOperation</summary> 
        //////////////////////////////////////////////////////////////////////
        public object BatchOperation
00253         {
            get {return this.batchOperation;}
        }
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>Read only accessor for BatchStatus</summary> 
        //////////////////////////////////////////////////////////////////////
        public object BatchStatus
00262         {
            get {return this.batchStatus;}
        }
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>Read only accessor for BatchInterrupt</summary> 
        //////////////////////////////////////////////////////////////////////
        public object BatchInterrupt
00271         {
            get {return this.batchInterrupt;}
        }
        /////////////////////////////////////////////////////////////////////////////


        //////////////////////////////////////////////////////////////////////
        /// <summary>Read only accessor for BatchContentType</summary> 
        //////////////////////////////////////////////////////////////////////
        public object BatchContentType
00281         {
            get {return this.batchContentType;}
        }
        /////////////////////////////////////////////////////////////////////////////


        //////////////////////////////////////////////////////////////////////
        /// <summary>Read only accessor for BatchStatusCode</summary> 
        //////////////////////////////////////////////////////////////////////
        public object BatchStatusCode
00291         {
            get {return this.batchStatusCode;}
        }
        /////////////////////////////////////////////////////////////////////////////


        //////////////////////////////////////////////////////////////////////
        /// <summary>Read only accessor for BatchErrors</summary> 
        //////////////////////////////////////////////////////////////////////
        public object BatchErrors
00301         {
            get {return this.batchErrors;}
        }
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>Read only accessor for BatchError</summary> 
        //////////////////////////////////////////////////////////////////////
        public object BatchError
00310         {
            get {return this.batchError;}
        }
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>Read only accessor for BatchReason</summary> 
        //////////////////////////////////////////////////////////////////////
        public object BatchReason
00319         {
            get {return this.batchReason;}
        }
        /////////////////////////////////////////////////////////////////////////////


        //////////////////////////////////////////////////////////////////////
        /// <summary>Read only accessor for BatchReason</summary> 
        //////////////////////////////////////////////////////////////////////
        public object BatchField
00329         {
            get {return this.batchField;}
        }
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>Read only accessor for BatchUnprocessed</summary> 
        //////////////////////////////////////////////////////////////////////
        public object BatchUnprocessed
00338         {
            get {return this.batchUnprocessed;}
        }
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>Read only accessor for BatchSuccessCount</summary> 
        //////////////////////////////////////////////////////////////////////
        public object BatchSuccessCount
00347         {
            get {return this.batchSuccessCount;}
        }
        /////////////////////////////////////////////////////////////////////////////


        //////////////////////////////////////////////////////////////////////
        /// <summary>Read only accessor for BatchFailureCount</summary> 
        //////////////////////////////////////////////////////////////////////
        public object BatchFailureCount
00357         {
            get {return this.batchFailureCount;}
        }
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>Read only accessor for BatchParsedCount</summary> 
        //////////////////////////////////////////////////////////////////////
        public object BatchParsedCount
00366         {
            get {return this.batchParsedCount;}
        }
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>Read only accessor for totalResults</summary> 
        //////////////////////////////////////////////////////////////////////
        public object TotalResults
00375         {
            get {return this.totalResults;}
        }
        /////////////////////////////////////////////////////////////////////////////


        //////////////////////////////////////////////////////////////////////
        /// <summary>Read only accessor for startIndex</summary> 
        //////////////////////////////////////////////////////////////////////
        public object StartIndex
00385         {
            get {return this.startIndex;}
        }
        /////////////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////
        /// <summary>Read only accessor for itemsPerPage</summary> 
        //////////////////////////////////////////////////////////////////////
        public object ItemsPerPage
00393         {
            get {return this.itemsPerPage;}
        }
        /////////////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////
        /// <summary>Read only accessor for parameter</summary> 
        //////////////////////////////////////////////////////////////////////
        static public string Parameter
00401         {
            get {return "parameter";}
        }
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>Read only accessor for baseUri</summary> 
        //////////////////////////////////////////////////////////////////////
        public object Base
00410         {
            get {return this.baseUri;}
        }
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>Read only accessor for language</summary> 
        //////////////////////////////////////////////////////////////////////
        public object Language
00419         {
            get {return this.language;}
        }
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>Read only accessor for value</summary> 
        //////////////////////////////////////////////////////////////////////
        public object Value
00428         {
            get {return this.value;}
        }
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>Read only accessor for value</summary> 
        //////////////////////////////////////////////////////////////////////
        public object Type
00437         {
            get {return this.type;}
        }
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>Read only accessor for name</summary> 
        //////////////////////////////////////////////////////////////////////
        public object Name
00446         {
            get {return this.name;}
        }
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>Read only accessor for etag</summary> 
        //////////////////////////////////////////////////////////////////////
        public object ETag
00455         {
            get {return this.eTagAttribute;}
        }
        /////////////////////////////////////////////////////////////////////////////
        #endregion end of Read only accessors



        /// <summary>
        /// returns the correct opensearchnamespace to use based
        /// on the version information passed in. All protocols with 
        /// version > 1 use opensearch1.1 where version 1 uses
        /// opensearch 1.0
        /// </summary>
        /// <param name="v">The versioninformation</param>
        /// <returns></returns>
00471         public static string OpenSearchNamespace(IVersionAware v)
        {
            int major = VersionDefaults.Major;
            if (v != null)
                major = v.ProtocolMajor;

            if (major == 1)
                return BaseNameTable.NSOpenSearchRss;

            return BaseNameTable.NSOpenSearch11;
        }



        /// <summary>
        /// returns the correct app:publishing namespace to use based
        /// on the version information passed in. All protocols with 
        /// version > 1 use the final version of the namespace, where 
        /// version 1 uses the draft version. 
        /// </summary>
        /// <param name="v">The versioninformation</param>
        /// <returns></returns>
00493         public static string AppPublishingNamespace(IVersionAware v)
        {
            int major = VersionDefaults.Major; 

            if (v != null)
                major = v.ProtocolMajor;
                
            if (major == 1)
                return BaseNameTable.NSAppPublishing;

            return BaseNameTable.NSAppPublishingFinal;
        }


    }
    /////////////////////////////////////////////////////////////////////////////

}
/////////////////////////////////////////////////////////////////////////////

 

Generated by  Doxygen 1.6.0   Back to index