本文整理汇总了C#中Vector.elementAt方法的典型用法代码示例。如果您正苦于以下问题:C# Vector.elementAt方法的具体用法?C# Vector.elementAt怎么用?C# Vector.elementAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector
的用法示例。
在下文中一共展示了Vector.elementAt方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: processServerCmd_Ver3_Schema
void processServerCmd_Ver3_Schema(String strCmd, String strObject, JSONStructIterator attrIter)
{
if ( strCmd.compareTo("insert") == 0 )
{
Vector<Object> vecValues = new Vector<Object>();
Vector<String> vecAttrs = new Vector<String>();
String strCols = "", strQuest = "", strSet = "";
for( ; !attrIter.isEnd() && getSync().isContinueSync(); attrIter.next() )
{
CAttrValue oAttrValue = new CAttrValue(attrIter.getCurKey(),attrIter.getCurString());
if ( !processBlob(strCmd,strObject,oAttrValue) )
continue;
if ( strCols.length() > 0 )
strCols += ",";
if ( strQuest.length() > 0)
strQuest += ",";
if ( strSet.length() > 0)
strSet += ",";
strCols += oAttrValue.m_strAttrib;
strQuest += "?";
strSet += oAttrValue.m_strAttrib + "=?";
vecAttrs.addElement(oAttrValue.m_strAttrib);
vecValues.addElement(oAttrValue.m_strValue);
}
vecValues.addElement(strObject);
if ( strCols.length() > 0 )
strCols += ",";
if ( strQuest.length() > 0)
strQuest += ",";
strCols += "object";
strQuest += "?";
String strSqlInsert = "INSERT INTO ";
strSqlInsert += getName() + " (";
strSqlInsert += strCols + ") VALUES(" + strQuest + ")";
if ( !getSync().isContinueSync() )
return;
IDBResult resInsert = getDB().executeSQLReportNonUniqueEx(strSqlInsert, vecValues );
if ( resInsert.isNonUnique() )
{
String strSqlUpdate = "UPDATE ";
strSqlUpdate += getName() + " SET " + strSet + " WHERE object=?";
getDB().executeSQLEx(strSqlUpdate, vecValues);
if ( getSyncType().compareTo("none") != 0 )
{
// oo conflicts
for( int i = 0; i < (int)vecAttrs.size(); i++ )
{
getDB().executeSQL("UPDATE changed_values SET sent=4 where object=? and attrib=? and source_id=? and sent>1",
strObject, vecAttrs.elementAt(i), getID() );
}
//
}
}
if ( getSyncType().compareTo("none") != 0 )
getNotify().onObjectChanged(getID(),strObject, SyncNotify.enUpdate);
m_nInserted++;
}else if (strCmd.compareTo("delete") == 0)
{
Vector<String> vecAttrs = new Vector<String>();
String strSet = "";
for( ; !attrIter.isEnd() && getSync().isContinueSync(); attrIter.next() )
{
CAttrValue oAttrValue = new CAttrValue(attrIter.getCurKey(),attrIter.getCurString());
if ( strSet.length() > 0 )
strSet += ",";
vecAttrs.addElement(oAttrValue.m_strAttrib);
strSet += oAttrValue.m_strAttrib + "=NULL";
}
String strSqlUpdate = "UPDATE ";
strSqlUpdate += getName() + " SET " + strSet + " WHERE object=?";
if ( strSet.length() == 0 || !getSync().isContinueSync() )
return;
getDB().executeSQL(strSqlUpdate, strObject);
//Remove item if all nulls
String strSelect = "SELECT * FROM " + getName() + " WHERE object=?";
IDBResult res = getDB().executeSQL( strSelect, strObject );
if ( !res.isEnd() )
{
boolean bAllNulls = true;
for( int i = 0; i < res.getColCount(); i ++)
{
if ( !res.isNullByIdx(i) && res.getColName(i).compareTo("object")!=0 )
{
bAllNulls = false;
break;
}
//.........这里部分代码省略.........
示例2: processMultipartItems
void processMultipartItems( Vector<MultipartItem> arItems )
{
for( int i = 0; i < (int)arItems.size(); i++ )
{
MultipartItem oItem = (MultipartItem)arItems.elementAt(i);
if ( oItem.m_strName.length() == 0 )
oItem.m_strName = "blob";
if ( oItem.m_strFileName.length() == 0 )
{
if ( oItem.m_strFilePath.length() > 0 )
{
oItem.m_strFileName = CFilePath.getBaseName(oItem.m_strFilePath);
}
//else
// oItem.m_strFileName = "doesnotmatter.txt";
}
oItem.m_strDataPrefix = i > 0 ? "\r\n" : "";
oItem.m_strDataPrefix +=
"------------A6174410D6AD474183FDE48F5662FCC5\r\n"+
"Content-Disposition: form-data; name=\"";
oItem.m_strDataPrefix += oItem.m_strName + "\"";
if (oItem.m_strFileName.length()>0)
oItem.m_strDataPrefix += "; filename=\"" + oItem.m_strFileName + "\"";
oItem.m_strDataPrefix += "\r\n";
if ( oItem.m_strContentType != null && oItem.m_strContentType.length() > 0 )
oItem.m_strDataPrefix += "Content-Type: " + oItem.m_strContentType + "\r\n";
long nContentSize = 0;
if ( oItem.m_strFilePath.length() > 0 )
{
CRhoFile file = null;
try{
file = RhoClassFactory.createFile();
file.open(oItem.m_strFilePath, CRhoFile.EOpenModes.OpenReadOnly);
nContentSize = file.size();
if ( !file.isOpened() ){
LOG.ERROR("File not found: " + oItem.m_strFilePath);
throw new Exception("File not found:" + oItem.m_strFilePath);
}
}finally{
if ( file != null )
try{ file.close(); }catch(IOException e)
{
LOG.ERROR("file closing failed.", e);
}
}
}
else
nContentSize = oItem.m_strBody.length();
if ( oItem.m_strContentType != null && oItem.m_strContentType.length() > 0 )
oItem.m_strDataPrefix += "Content-Length: " + nContentSize + "\r\n";
oItem.m_strDataPrefix += "\r\n";
}
}
示例3: onSyncSourceEnd
public void onSyncSourceEnd( int nSrc, Vector<SyncSource> sources )
{
SyncSource src = sources.elementAt(nSrc);
/*
if ( getSync().getState() == SyncEngine.esStop && src.m_nErrCode != RhoAppAdapter.ERR_NONE )
{
SyncNotification pSN = getSyncNotifyBySrc(src);
if ( pSN != null )
fireSyncNotification(src, true, src.m_nErrCode, "");
else
fireAllSyncNotifications(true, src.m_nErrCode, src.m_strError, "" );
}
else*/
fireSyncNotification( src, true, src.m_nErrCode, "");
cleanCreateObjectErrors();
}
示例4: updateAllAttribChanges
public void updateAllAttribChanges()
{
//Check for attrib = object
IDBResult res = executeSQL("SELECT object, source_id, update_type " +
"FROM changed_values where attrib = 'object' and sent=0" );
if ( res.isEnd() )
return;
startTransaction();
Vector<String> arObj = new Vector<String>(), arUpdateType = new Vector<String>();
Vector<int> arSrcID = new Vector<int>();
for( ; !res.isEnd(); res.next() )
{
arObj.addElement(res.getStringByIdx(0));
arSrcID.addElement(res.getIntByIdx(1));
arUpdateType.addElement(res.getStringByIdx(2));
}
for( int i = 0; i < (int)arObj.size(); i++ )
{
IDBResult resSrc = executeSQL("SELECT name, schema FROM sources where source_id=?", arSrcID.elementAt(i) );
boolean bSchemaSource = false;
String strTableName = "object_values";
if ( !resSrc.isEnd() )
{
bSchemaSource = resSrc.getStringByIdx(1).length() > 0;
if ( bSchemaSource )
strTableName = resSrc.getStringByIdx(0);
}
if (bSchemaSource)
{
IDBResult res2 = executeSQL( "SELECT * FROM " + strTableName + " where object=?", arObj.elementAt(i) );
for( int j = 0; j < res2.getColCount(); j ++)
{
String strAttrib = res2.getColName(j);
String value = res2.getStringByIdx(j);
String attribType = getAttrMgr().isBlobAttr(arSrcID.elementAt(i), strAttrib) ? "blob.file" : "";
executeSQLReportNonUnique("INSERT INTO changed_values (source_id,object,attrib,value,update_type,attrib_type,sent) VALUES(?,?,?,?,?,?,?)",
arSrcID.elementAt(i), arObj.elementAt(i), strAttrib, value, arUpdateType.elementAt(i), attribType, 0 );
}
}else
{
IDBResult res2 = executeSQL( "SELECT attrib, value FROM " + strTableName + " where object=? and source_id=?",
arObj.elementAt(i), arSrcID.elementAt(i) );
for( ; !res2.isEnd(); res2.next() )
{
String strAttrib = res2.getStringByIdx(0);
String value = res2.getStringByIdx(1);
String attribType = getAttrMgr().isBlobAttr(arSrcID.elementAt(i), strAttrib) ? "blob.file" : "";
executeSQLReportNonUnique("INSERT INTO changed_values (source_id,object,attrib,value,update_type,attrib_type,sent) VALUES(?,?,?,?,?,?,?)",
arSrcID.elementAt(i), arObj.elementAt(i), strAttrib, value, arUpdateType.elementAt(i), attribType, 0 );
}
}
}
executeSQL("DELETE FROM changed_values WHERE attrib='object'");
endTransaction();
}
示例5: copyChangedValues
void copyChangedValues(DBAdapter db)
{
updateAllAttribChanges();
copyTable("changed_values", m_dbStorage, db.m_dbStorage );
{
Vector<int> arOldSrcs = new Vector<int>();
{
IDBResult resSrc = db.executeSQL( "SELECT DISTINCT(source_id) FROM changed_values" );
for ( ; !resSrc.isEnd(); resSrc.next() )
arOldSrcs.addElement( resSrc.getIntByIdx(0) );
}
for( int i = 0; i < arOldSrcs.size(); i++)
{
int nOldSrcID = arOldSrcs.elementAt(i);
IDBResult res = executeSQL("SELECT name from sources WHERE source_id=?", nOldSrcID);
if ( !res.isEnd() )
{
String strSrcName = res.getStringByIdx(0);
IDBResult res2 = db.executeSQL("SELECT source_id from sources WHERE name=?", strSrcName );
if ( !res2.isEnd() )
{
if ( nOldSrcID != res2.getIntByIdx(0) )
{
db.executeSQL("UPDATE changed_values SET source_id=? WHERE source_id=?", res2.getIntByIdx(0), nOldSrcID);
}
continue;
}
}
//source not exist in new partition, remove this changes
db.executeSQL("DELETE FROM changed_values WHERE source_id=?", nOldSrcID);
}
}
}
示例6: destroyTableName
private boolean destroyTableName(String tableName, Vector<String> arIncludeTables, Vector<String> arExcludeTables )
{
int i;
for (i = 0; i < (int)arExcludeTables.size(); i++ )
{
if ( arExcludeTables.elementAt(i).equalsIgnoreCase(tableName) )
return false;
}
for (i = 0; i < (int)arIncludeTables.size(); i++ )
{
if ( arIncludeTables.elementAt(i).equalsIgnoreCase(tableName) )
return true;
}
return arIncludeTables.size()==0;
}
示例7: executeSQLEx
public IDBResult executeSQLEx(String strStatement, Vector<Object> vecValues){
Object[] values = new Object[vecValues.size()];
for (int i = 0; i < vecValues.size(); i++ )
values[i] = vecValues.elementAt(i);
return executeSQL(strStatement,values);
}
示例8: executeSQLReportNonUniqueEx
public IDBResult executeSQLReportNonUniqueEx(String strStatement, Vector<Object> vecValues){
//LOG.TRACE("executeSQLReportNonUnique: " + strStatement);
Object[] values = new Object[vecValues.size()];
for (int i = 0; i < vecValues.size(); i++ )
values[i] = vecValues.elementAt(i);
IDBResult res = null;
Lock();
try{
res = m_dbStorage.executeSQL(strStatement,values, true, false);
}finally
{
Unlock();
}
return res;
}
示例9: findSrcIndex
static int findSrcIndex( Vector<SyncSource> sources, String strSrcName)
{
for ( int i = 0; i < (int)sources.size(); i++)
{
if (strSrcName.compareTo( ((SyncSource)sources.elementAt(i)).getName()) == 0 )
return i;
}
return -1;
}
示例10: doSearch
public void doSearch(Vector<String> arSources, String strParams, String strAction, boolean bSearchSyncChanges, int nProgressStep)
{
try
{
prepareSync(esSearch, null);
if ( !isContinueSync() )
{
if ( getState() != esExit )
setState(esNone);
return;
}
TimeInterval startTime = TimeInterval.getCurrentTime();
if ( bSearchSyncChanges )
{
for ( int i = 0; i < (int)arSources.size(); i++ )
{
SyncSource pSrc = findSourceByName((String)arSources.elementAt(i));
if ( pSrc != null )
pSrc.syncClientChanges();
}
}
while( isContinueSync() )
{
int nSearchCount = 0;
String strUrl = getProtocol().getServerQueryUrl(strAction);
String strQuery = getProtocol().getServerQueryBody("", getClientID(), getSyncPageSize());
if ( strParams.length() > 0 )
strQuery += strParams;
String strTestResp = "";
for ( int i = 0; i < (int)arSources.size(); i++ )
{
SyncSource pSrc = findSourceByName((String)arSources.elementAt(i));
if ( pSrc != null )
{
strQuery += "&sources[][name]=" + pSrc.getName();
if ( !pSrc.isTokenFromDB() && pSrc.getToken() > 1 )
strQuery += "&sources[][token]=" + pSrc.getToken();
strTestResp = getSourceOptions().getProperty(pSrc.getID(), "rho_server_response");
}
}
LOG.INFO("Call search on server. Url: " + (strUrl+strQuery) );
NetResponse resp = getNet().pullData(strUrl+strQuery, this);
if ( !resp.isOK() )
{
stopSync();
m_nErrCode = RhoAppAdapter.getErrorFromResponse(resp);
m_strError = resp.getCharData();
continue;
}
String szData = null;
if ( strTestResp != null && strTestResp.length() > 0 )
szData = strTestResp;
else
szData = resp.getCharData();
JSONArrayIterator oJsonArr = new JSONArrayIterator(szData);
for( ; !oJsonArr.isEnd() && isContinueSync(); oJsonArr.next() )
{
JSONArrayIterator oSrcArr = oJsonArr.getCurArrayIter();//new JSONArrayIterator(oJsonArr.getCurItem());
if (oSrcArr.isEnd())
break;
int nVersion = 0;
if ( !oSrcArr.isEnd() && oSrcArr.getCurItem().hasName("version") )
{
nVersion = oSrcArr.getCurItem().getInt("version");
oSrcArr.next();
}
if ( nVersion != getProtocol().getVersion() )
{
LOG.ERROR( "Sync server send search data with incompatible version. Client version: " + getProtocol().getVersion() +
"; Server response version: " + nVersion );
stopSync();
m_nErrCode = RhoAppAdapter.ERR_SYNCVERSION;
continue;
}
if ( !oSrcArr.isEnd() && oSrcArr.getCurItem().hasName("token"))
{
oSrcArr.next();
}
if ( !oSrcArr.getCurItem().hasName("source") )
{
LOG.ERROR( "Sync server send search data without source name." );
stopSync();
m_nErrCode = RhoAppAdapter.ERR_UNEXPECTEDSERVERRESPONSE;
//.........这里部分代码省略.........