Exemplo n.º 1
0
        public static String parseCookie(String value)
        {
            String strRes = "";
            Tokenizer stringtokenizer = new Tokenizer(value, ";");
            while (stringtokenizer.hasMoreTokens())
            {
                String tok = stringtokenizer.nextToken();
                tok = tok.trim();
                if (tok.length() == 0)
                {
                    continue;
                }

                //expires=Thu, 01 Jan 1970 00:00:00 GMT, auth_token=
                int nExp = tok.indexOf("expires=");
                if (nExp >= 0)
                {
                    int nEnd = tok.indexOf(',', nExp);
                    if (nEnd >= 0)
                    {
                        int nEnd1 = tok.indexOf(',', nEnd + 1);
                        if (nEnd1 >= 0)
                            nEnd = nEnd1;
                        else
                            nEnd = tok.length() - 1;
                    }

                    tok = tok.substring(0, nExp) + tok.substring(nEnd + 1);
                    tok = tok.trim();
                }

                int nEq = tok.indexOf('=');
                if (nEq < 0)
                    continue;

                strRes += tok + ";";
            }

            return strRes;
        }
Exemplo n.º 2
0
    static void loadAttrs(DBAdapter db, Hashtable< int, Hashtable<String,int> > mapAttrs, String strDBAttr,
        Hashtable<String, int> mapSrcNames)
    {
        mapAttrs.clear();
        String strSql = "SELECT source_id,";
        strSql += strDBAttr + ",name from sources";
    	
	    IDBResult res = db.executeSQL(strSql);
	    for ( ; !res.isEnd(); res.next() )
	    { 
	        int nSrcID = res.getIntByIdx(0);
	        String strAttribs = res.getStringByIdx(1);
	        if ( strAttribs.length() == 0 )
	            continue;
	
	        Tokenizer oTokenizer = new Tokenizer( strAttribs, "," );
	
	        Hashtable<String,int> mapAttr = new Hashtable<String,int>();
	        String strAttr = "";
			while (oTokenizer.hasMoreTokens()) 
	        {
				String tok = oTokenizer.nextToken();
				if (tok.length() == 0)
					continue;
	            
	            if ( strAttr.length() > 0 )
	            {
	                mapAttr.put(strAttr, int.Parse(tok) );
	                strAttr = "";
	            }else
	                strAttr = tok;
	        }
	
			mapAttrs.put( nSrcID, mapAttr );
			if ( mapSrcNames != null )
				mapSrcNames.put(res.getStringByIdx(2).toUpperCase(), nSrcID);
	    }
    }
Exemplo n.º 3
0
        void parseAssociations(String strAssociations)
        {
            if (strAssociations.length() == 0 )
                return;

            Tokenizer oTokenizer = new Tokenizer( strAssociations, "," );

            String strSrcName = "";
            while (oTokenizer.hasMoreTokens()) 
            {
    	        String tok = oTokenizer.nextToken();
    	        if (tok.length() == 0)
    		        continue;
            
                if ( strSrcName.length() > 0 )
                {
            	    m_arAssociations.addElement( new CAssociation(strSrcName, tok) );
                    strSrcName = "";
                }else
                    strSrcName = tok;
            }
        }
Exemplo n.º 4
0
	    public void fromFile(String strFilePath)
		{
	        String strData = CRhoFile.readStringFromFile(strFilePath);
	        
	        Tokenizer oTokenizer = new Tokenizer( strData, ";" );
	        int nPos = 0;
			while (oTokenizer.hasMoreTokens()) 
	        {
				String tok = oTokenizer.nextToken().trim();
				
				switch(nPos)
				{
				case 0:
					m_strRhoVer = tok;
					break;
				case 1:
					m_strAppVer = tok;
					break;
				case 2:
					m_bEncrypted = tok.compareTo("encrypted") == 0;
					break;
				case 3:
					m_bSqlite = tok.compareTo("sqlite") == 0;
					break;				
				}
				nPos++;
	        }
		}
Exemplo n.º 5
0
    void loadFromString(String szSettings, Hashtable<String,String> mapValues)
    {
		Tokenizer stringtokenizer = new Tokenizer(szSettings, "\n");
		while (stringtokenizer.hasMoreTokens()) {
			String tok = stringtokenizer.nextToken();
			tok = tok.trim();
			if (tok.length() == 0) {
				continue;
			}
			
			if ( tok.length() > 0 && tok.charAt(0) == '#' )
				continue;
			
			int i = tok.indexOf('=');
			String name;
			String value;
			if (i > 0) {
				name = tok.substring(0, i);
				value = tok.substring(i + 1);
			} else {
				name = tok;
				value = "";
			}
			name = name.trim();
			value = value.trim();
			
			if (value.startsWith("\'") && value.endsWith("\'")) {
				value = value.substring(1,value.length()-1);
			}
				
			setPropertyByName(name,value,mapValues);
		}
	}