public void setAttributeDetail(Object v, int r, int c) {
String input = null;
if (c != 3)
input = (String) v;
while (r >= getLength()) {
MapElement nme = new MapElement();
nme.setBackendPrincipal(true);
rm.addMapElement(nme);
Reporter.info("add a MapElement"); //NOI18N
}
MapElement me = rm.getMapElement(r);
if ((c != 3 &&(null == input || 0 == input.trim().length())) || (c == 3 && ((Vector)v).size() == 0)) {
// test for need to delete
if (r >= getLength())
return;
boolean rowHasValue = false;
String value = null;
if (c != 0) {
value = me.getAttributeValue(MapElement.BACKEND_PRINCIPAL, 0, "user-name"); //NOI18N
if (null != value && value.trim().length() > 0)
rowHasValue = true;
}
if (c != 1) {
value = me.getAttributeValue(MapElement.BACKEND_PRINCIPAL, 0, "password"); //NOI18N
if (null != value && value.trim().length() > 0)
rowHasValue = true;
}
if (c != 2) {
value = me.getAttributeValue(MapElement.BACKEND_PRINCIPAL, 0, "credential"); //NOI18N
if (null != value && value.trim().length() > 0)
rowHasValue = true;
}
if (c != 3) {
if (0 != me.sizePrincipal())
rowHasValue = true;
}
// int otherDex = c - 1;
// if (otherDex < 0)
// otherDex = -otherDex;
// String otherVal = ra.getAttributeValue(ResourceAdapter.PROPERTY, r, //NOI18N
// intToAttribute(otherDex));
// String otherVal = ra.getAttributeValue(ResourceAdapter.PROPERTY, r, //NOI18N
// intToAttribute(otherDex));
if (!rowHasValue) {
Reporter.info("remove a MapElement"); //NOI18N
rm.removeMapElement(me);
return;
}
// ra.removePropertyElement(r);
// return;
// }
// input = " ";
}
while (r >= getLength()) {
Reporter.info("add a MapElement"); //NOI18N
me = new MapElement();
me.setBackendPrincipal(true);
rm.addMapElement(me);
}
if (0 == c)
me.setAttributeValue(MapElement.BACKEND_PRINCIPAL, 0, "user-name", (String) v); //NOI18N
if (1 == c)
me.setAttributeValue(MapElement.BACKEND_PRINCIPAL, 0, "password", (String) v); //NOI18N
if (2 == c)
me.setAttributeValue(MapElement.BACKEND_PRINCIPAL, 0, "credential",(String) v); //NOI18N
if (3 == c) {
/*
java.util.StringTokenizer toker =
new java.util.StringTokenizer((String)v,","); // NOI18N
Principal[] ps = new Principal[toker.countTokens()];
int i = 0;
while (toker.hasMoreTokens()) {
String tok = toker.nextToken();
Principal p = new Principal();
p.setAttributeValue("user-name",tok); //NOI18N
ps[i] = p;
i++;
}
me.setPrincipal(ps);
*/
Vector vec = (Vector)v;
Reporter.info(new Integer(vec.size()));
Principal[] principals = new Principal[vec.size()];
for (int i = 0; i < vec.size(); i++) {
Principal prin = new Principal();
String[] principal = (String[])vec.elementAt(i);
// Reporter.info("(" + principal[0] + ") (" + principal[1] + ")"); //NOI18N
prin.setAttributeValue("user-name", principal[0]); //NOI18N
prin.setDescription(principal[1]);
principals[i] = prin;
}
me.setPrincipal(principals);
// Reporter.info(new Integer(me.sizePrincipal()));
}
//ra.addPropertyElement(true);
//System.out.println("SETAttributeDetail on " + ra.hashCode()); //NOI18N
//ra.setPropertyElement(r,true);