示例#1
0
 public void addSuggestion(Suggestion suggestion)
 {
     suggestions.Add(suggestion);
 }
示例#2
0
 public void startElement(String uri, String localName, String qName, Hashtable attributes)
 {
     int tag = xmlTags.getTag(qName);
     inKeyMatches = inKeyMatches || (tag == XMLTags.GM);
     inResponse = inResponse || (tag == XMLTags.RES); // inside response element
     inResult = inResponse && (inResult || (tag == XMLTags.R)); // inside results element
     inParm = inResponse && (inParm || (tag == XMLTags.PARM));//inside parametric
     inOneBoxResponse = inOneBoxResponse || (tag == XMLTags.OBRES);
     inOneBoxResult = inOneBoxResponse && (inOneBoxResult || (tag == XMLTags.MODULE_RESULT)); // inside oneBox results element
     inSpelling = inSpelling || (tag == XMLTags.Spelling);
     switch (tag)
     {
         case XMLTags.FIELD:
             if (inOneBoxResult)
             {
                 currOneBoxFieldName = attributes["name"] == null ? "" : attributes["name"].ToString();
             }
             break;
         case XMLTags.OBRES:
             String moduleName = attributes["module_name"] == null ? null : attributes["module_name"].ToString();
             currOneBoxResponse.setModuleName(moduleName);
             break;
         case XMLTags.RES:
             String startIndex = attributes["SN"] == null ? "1" : attributes["SN"].ToString();
             String endIndex = attributes["EN"] == null ? "1" : attributes["EN"].ToString();
             response.setStartIndex(startIndex != null ? long.Parse(startIndex) : 1);
             response.setEndIndex(endIndex != null ? long.Parse(endIndex) : 1);
             break;
         case XMLTags.R:
             String mimeType = attributes["MIME"] == null ? "" : attributes["MIME"].ToString();
             String indentation = attributes["L"] == null ? "1" : attributes["L"].ToString();
             currResult.Indentation = indentation == null ? 1 : Int32.Parse(indentation);
             currResult.Index = Convert.ToInt32(attributes["N"].ToString());
             currResult.MimeType = mimeType;
             break;
         case XMLTags.PARAM:
             String name = attributes["name"] == null ? "" : attributes["name"].ToString();
             String value = attributes["value"] == null ? "" : attributes["value"].ToString();
             response.putParam(name, value);
             break;
         case XMLTags.PMT:
             String parmName = attributes["NM"] == null ? "" : attributes["NM"].ToString();
             String parmDisplay = attributes["DN"] == null ? "" : attributes["DN"].ToString();
             String parmIsRange = attributes["IR"] == null ? "0" : attributes["IR"].ToString();
             String parmType = attributes["T"] == null ? "" : attributes["T"].ToString();
             currParamResponse = new ParametricNavigationResponse();
             currParamResponse.setName(parmName);
             currParamResponse.setDisplayName(parmDisplay);
             if (parmIsRange.Equals("1"))
             {
                 currParamResponse.setIsRange(true);
             } else
             {
                 currParamResponse.setIsRange(false);
             }
             currParamResponse.setType(parmType);
             response.addParametricResponse(currParamResponse);
             break;
         case XMLTags.PV:
             String V = attributes["V"] == null ? "" : attributes["V"].ToString();
             String L = attributes["L"] == null ? "" : attributes["L"].ToString();
             String H = attributes["H"] == null ? "" : attributes["H"].ToString();
             int C = attributes["C"] == null ? 0 : Int32.Parse(attributes["C"].ToString());
             currParamResponse.addResult(new ParametricResult(V,L,H,C));
             break;
         case XMLTags.C:
             if (inResult)
             {
                 String cid = attributes["CID"] == null ? "" : attributes["CID"].ToString();
                 String size = attributes["SZ"] == null ? "" : attributes["SZ"].ToString();
                 String encoding = attributes["ENC"] == null ? "" : attributes["ENC"].ToString();
                 if (null == encoding || "".Equals(encoding.Trim()))
                 {
                     encoding = "UTF-8";
                 }
                 currResult.CacheDocEncoding = encoding;
                 currResult.CacheDocId = cid;
                 currResult.CacheDocSize = size;
             }
             break;
         case XMLTags.FS:
             String fieldName = attributes["NAME"] == null ? "" : attributes["NAME"].ToString();
             String fieldValue = attributes["VALUE"] == null ? "" : attributes["VALUE"].ToString();
             currResult.Fields.Add(fieldName, fieldValue);
             break;
         case XMLTags.FI:
             response.setFiltered(true);
             break;
         case XMLTags.MT:
             String metaName = attributes["N"] == null ? "" : attributes["N"].ToString();
             String metaValue = attributes["V"] == null ? "" : attributes["V"].ToString();
             currResult.Metas.Add(metaName, metaValue);
             break;
         case XMLTags.Spelling:
             inSpelling = true;
             spelling = new Spelling();
             break;
         case XMLTags.Suggestion:
             if (inSpelling)
             {
                 currSuggestion = new Suggestion();
                 currSuggestion.setText(attributes["q"] == null ? "" : attributes["q"].ToString());
             }
             break;
         case XMLTags.Synonyms:
             inSynonyms = true;
             break;
         case XMLTags.GM:
             inKeyMatches = true;
             break;
         case XMLTags.OneSynonym:
             if (inSynonyms)
             {
                 response.addSynonymWithMarkup(attributes["q"] == null ? "" : attributes["q"].ToString());
             }
             break;
         case XMLTags.HN:
             currResult.MoreDetailsUrl = attributes["U"].ToString();
             break;
     }
     clearContent();
 }
示例#3
0
 public void addSuggestion(Suggestion suggestion)
 {
     suggestions.Add(suggestion);
 }