publicstatic String[] ArrayOutOfMultiDimArray(String _sMultiDimArray[][], int _index)
{
String[] sRetArray = null; if (_sMultiDimArray != null)
{
sRetArray = new String[_sMultiDimArray.length]; for (int i = 0; i < _sMultiDimArray.length; i++)
{
sRetArray[i] = _sMultiDimArray[i][_index];
}
} return sRetArray;
}
/**converts a list of Integer values included in an Integer vector to a list of int values
*/ publicstaticint[] IntegerTointList(java.util.List<Integer> _aIntegerVector)
{ int[] nintValues = null; if (_aIntegerVector.size() > 0) { int i = 0;
nintValues = newint[_aIntegerVector.size()]; for (Integer nIntegerValue : _aIntegerVector) {
nintValues[i++] = nIntegerValue.intValue();
}
} return nintValues;
}
/**converts a list of Boolean values included in a Boolean vector to a list of boolean values
*/ publicstaticboolean[] BooleanTobooleanList(java.util.List<Boolean> _aBooleanVector)
{ boolean[] bbooleanValues = null; if (_aBooleanVector.size() > 0) { int i = 0;
bbooleanValues = newboolean[_aBooleanVector.size()]; for (Boolean bBooleanValue : _aBooleanVector) {
bbooleanValues[i++] = bBooleanValue.booleanValue();
}
} return bbooleanValues;
}
publicstatic String getlongestArrayItem(String[] StringArray)
{
String sLongestItem = PropertyNames.EMPTY_STRING; int iCurLength; int iOldLength = 0; for (String str : StringArray)
{
iCurLength = str.length(); if (iCurLength > iOldLength)
{
iOldLength = iCurLength;
sLongestItem = str;
}
} return sLongestItem;
}
publicstatic String[] removeOutdatedFields(String[] baselist, String[] _complist)
{
String[] retarray = new String[]
{
}; if ((baselist != null) && (_complist != null))
{
ArrayList<String> retvector = new ArrayList<String>(); for (int i = 0; i < baselist.length; i++)
{ if (FieldInList(_complist, baselist[i]) > -1)
{
retvector.add(baselist[i]); // here you could call the method of a defined interface to notify the calling method
}
}
retarray = new String[retvector.size()];
retvector.toArray(retarray);
} return retarray;
}
publicstatic String[][] removeOutdatedFields(String[][] baselist, String[] _complist, int _compindex)
{
String[][] retarray = new String[][] {}; if ((baselist != null) && (_complist != null))
{ if (baselist.length > 0)
{
ArrayList<String[]> retvector = new ArrayList<String[]>(); for (int i = 0; i < baselist.length; i++)
{
String sValue = baselist[i][_compindex]; if (FieldInList(_complist, sValue) != -1)
{
retvector.add(baselist[i]); // here you could call the method of a defined interface to notify the calling method
}
}
retarray = new String[retvector.size()][2];
retvector.toArray(retarray);
}
} return retarray;
}
publicstatic PropertyValue[][] removeOutdatedFields(PropertyValue[][] baselist, String[] _complist)
{ if ((baselist != null) && (_complist != null))
{
ArrayList<PropertyValue[]> firstdimvector = new ArrayList<PropertyValue[]>(); for (int n = 0; n < baselist.length; n++)
{
ArrayList<PropertyValue> secdimvector = new ArrayList<PropertyValue>(); for (int m = 0; m < baselist[n].length; m++)
{ if (FieldInList(_complist, baselist[n][m].Name) > -1)
{
secdimvector.add(baselist[n][m]);
}
} if (!secdimvector.isEmpty())
{
PropertyValue[] internalArray = new PropertyValue[secdimvector.size()];
secdimvector.toArray(internalArray);
firstdimvector.add(internalArray);
}
}
PropertyValue[][] retarray = new PropertyValue[firstdimvector.size()][]; return firstdimvector.toArray(retarray);
} returnnew PropertyValue[][]
{
};
}
/** *searchesamultidimensionalarrayforduplicatefields.Accordingtothefollowingexample *SlaveFieldName1;SlaveFieldName2;SlaveFieldName3 *MasterFieldName1;MasterFieldName2;MasterFieldName3 *TheentriesSlaveFieldNameXandMasterFieldNameXaregroupedtogetherandthenthecreatedgroupsarecompared *Ifagroupisduplicatetheentryofthesecondgroupisreturned.
*/ publicstaticint getDuplicateFieldIndex(String[][] _scomplist)
{ int retvalue = -1; if (_scomplist.length > 0)
{ int fieldcount = _scomplist[0].length;
String[] sDescList = new String[fieldcount]; for (int m = 0; m < fieldcount; m++)
{ for (int n = 0; n < _scomplist.length; n++)
{ if (n == 0)
{
sDescList[m] = "";
}
sDescList[m] += _scomplist[n][m];
}
} return getDuplicateFieldIndex(sDescList);
} return retvalue;
}
/** *nottested!!!!!
*/ publicstaticint getDuplicateFieldIndex(String[] scomplist)
{ for (int n = 0; n < scomplist.length; n++)
{
String scurvalue = scomplist[n]; for (int m = n; m < scomplist.length; m++)
{ if (m != n)
{ if (scurvalue.equals(scomplist[m]))
{ return m;
}
}
}
} return -1;
}
publicstaticint getDuplicateFieldIndex(String[] _scomplist, String _fieldname)
{ int iduplicate = 0; for (int n = 0; n < _scomplist.length; n++)
{ if (_scomplist[n].equals(_fieldname))
{
iduplicate++; if (iduplicate == 2)
{ return n;
}
}
} return -1;
}
privatestaticboolean isEqual(PropertyValue firstPropValue, PropertyValue secPropValue)
{ if (!firstPropValue.Name.equals(secPropValue.Name))
{ returnfalse; //TODO replace 'equals' with AnyConverter.getType(firstpropValue).equals(secPropValue) to check content and Type
} if (!firstPropValue.Value.equals(secPropValue.Value))
{ returnfalse;
} return (firstPropValue.Handle == secPropValue.Handle);
}
publicstaticint[] getDuplicateFieldIndex(PropertyValue[][] ocomplist)
{ for (int n = 0; n < ocomplist.length; n++)
{
PropertyValue[] ocurValue = ocomplist[n]; for (int m = n; m < ocurValue.length; m++)
{
PropertyValue odetValue = ocurValue[m]; for (int s = 0; s < ocurValue.length; s++)
{ if (s != m)
{ if (isEqual(odetValue, ocurValue[s]))
{ returnnewint[]
{
n, s
};
}
}
}
}
} returnnewint[]
{
-1, -1
};
}
publicstatic String getSuffixNumber(String _sbasestring)
{ int suffixcharcount = 0; for (int i = _sbasestring.length() - 1; i >= 0; i--)
{ char b = _sbasestring.charAt(i); if ((b >= '0') && (b <= '9'))
{
suffixcharcount++;
} else
{ break;
}
} int istart = _sbasestring.length() - suffixcharcount; return _sbasestring.substring(istart, _sbasestring.length());
}
publicstatic String[] removefromList(String[] _sbaselist, String[] _sdellist) {
ArrayList<String> tempbaselist = new ArrayList<String>(); for (String _sbase : _sbaselist) { if (FieldInList(_sdellist, _sbase) == -1) {
tempbaselist.add(_sbase);
}
}
String[] sretlist = new String[tempbaselist.size()];
tempbaselist.toArray(sretlist); return sretlist;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.