TPropertyQuery[] prpq = new TPropertyQuery[propInstances.size()];
byte[] tba = new byte[prpq.length * TPropertyQuery.sizeInBytes];
Iterator<TExportProperty> it = propInstances.iterator();
for (int i = 0; (it.hasNext()) && (i < prpq.length); i++)
{
prpq[i] = new TPropertyQuery((TExportProperty) it.next(), propInstances.size() - 1);
if ((lhr=getLocalHistoryRecord(prpq[i].prpName,"#0")) != null)
{
prpq[i].prpHistoryDepthLong = (short)lhr.getHspec().getDepthLong();
prpq[i].prpHistoryDepthShort = (short)lhr.getHspec().getDepthShort();
}
System.arraycopy(prpq[i].toByteArray(), 0, tba, i * TPropertyQuery.sizeInBytes,
TPropertyQuery.sizeInBytes);
}
return dout.putData(tba, "PRPQSr4");
}
else
{ // want the whole list ...
String[] slst = new String[propertyList.countUniqueProperties()];
propertyList.getPropertyNames().toArray(slst);
TPropertyQuery[] prpq = new TPropertyQuery[slst.length];
if (slst.length == 0) break;
byte[] tba = new byte[slst.length * TPropertyQuery.sizeInBytes];
TExportProperty prp;
for (int i=0; i<slst.length; i++)
{
prp = propertyList.getFirstProperty(slst[i]);
prpq[i] = new TPropertyQuery(prp,1);
System.arraycopy(prpq[i].toByteArray(), 0, tba, i * TPropertyQuery.sizeInBytes,
TPropertyQuery.sizeInBytes);
}
return dout.putData(tba, "PRPQSr4");
}
}
else if (dout.getTag().compareTo("XPQS") == 0 || (dout.getArrayLength() % XPropertyQuery.sizeInBytes) == 0)
{
if (din != null)
{ // looking for a specific property ...
LinkedList<TExportProperty> propInstances;
String propertyName = din.toString();
propertyName = propertyName.replace('\n', (char) 0).trim();
propInstances = propertyList.getEqualProperties(propertyName);
if ((propInstances == null) || (propInstances.size() == 0))
return TErrorList.not_exported;
// fill in the targeted property info
THistoryRecord lhr = null;
XPropertyQuery[] xpq = new XPropertyQuery[propInstances.size()];
byte[] tba = new byte[xpq.length * XPropertyQuery.sizeInBytes];
Iterator<TExportProperty> it = propInstances.iterator();
for (int i = 0; (it.hasNext()) && (i < xpq.length); i++)
{
xpq[i] = new XPropertyQuery((TExportProperty) it.next(), propInstances.size() - 1);
if ((lhr=getLocalHistoryRecord(xpq[i].prpName,"#0")) != null)
{
xpq[i].prpHistoryDepthLong = (short)lhr.getHspec().getDepthLong();
xpq[i].prpHistoryDepthShort = (short)lhr.getHspec().getDepthShort();
}
System.arraycopy(xpq[i].toByteArray(), 0, tba, i * XPropertyQuery.sizeInBytes,
XPropertyQuery.sizeInBytes);
}
return dout.putData(tba, "XPQS");
}
else
{ // want the whole list ...
String[] slst = new String[propertyList.countUniqueProperties()];
propertyList.getPropertyNames().toArray(slst);
XPropertyQuery[] xpq = new XPropertyQuery[slst.length];
if (slst.length == 0) break;
byte[] tba = new byte[slst.length * XPropertyQuery.sizeInBytes];
TExportProperty prp;
for (int i=0; i<slst.length; i++)
{
prp = propertyList.getFirstProperty(slst[i]);
xpq[i] = new XPropertyQuery(prp,1);
System.arraycopy(xpq[i].toByteArray(), 0, tba, i * XPropertyQuery.sizeInBytes,
XPropertyQuery.sizeInBytes);
}
return dout.putData(tba, "XPQS");
}
}
else if (dout.getTag().compareTo("PQS") == 0 || (dout.getArrayLength() % PropertyQuery.sizeInBytes) == 0)
{ // legacy request ...
if (din != null)
{ // looking for a specific property ...
LinkedList<TExportProperty> propInstances;
String propertyName = din.toString();
propertyName = propertyName.replace('\n', (char) 0).trim();
propInstances = propertyList.getEqualProperties(propertyName);
if ((propInstances == null) || (propInstances.size() == 0))
return TErrorList.not_exported;
// fill in the targeted property info
PropertyQuery[] pqs = new PropertyQuery[1];
TExportProperty prp = propertyList.getFirstProperty(propertyName);
byte[] tba = new byte[PropertyQuery.sizeInBytes];
pqs[0] = new PropertyQuery();
pqs[0].name = propertyName;
pqs[0].prpDesc = prp.getDescription().getText();
pqs[0].prpAccess = (byte)prp.getAccessMode();
pqs[0].prpFormat = (byte)(prp.getOutputFormat()%512);
pqs[0].prpSize = (short)prp.getOutputSize();
System.arraycopy(pqs[0].toByteArray(), 0, tba, 0, PropertyQuery.sizeInBytes);
return dout.putData(tba, "PQS");
}
else
{ // want the whole list ...
String[] slst = new String[propertyList.countUniqueProperties()];
propertyList.getPropertyNames().toArray(slst);
if (slst.length == 0) break;
PropertyQuery[] pqs = new PropertyQuery[slst.length];
byte[] tba = new byte[slst.length * PropertyQuery.sizeInBytes];
TExportProperty prp;
for (int i=0; i<slst.length; i++)
{
pqs[i] = new PropertyQuery();
pqs[i].name = slst[i];
prp = propertyList.getFirstProperty(slst[i]);
pqs[i].prpDesc = prp.getDescription().getText();
pqs[i].prpAccess = (byte)prp.getAccessMode();
pqs[i].prpFormat = (byte)(prp.getOutputFormat()%512);
pqs[i].prpSize = (short)prp.getOutputSize();
System.arraycopy(pqs[i].toByteArray(), 0, tba, i * PropertyQuery.sizeInBytes,
PropertyQuery.sizeInBytes);
}
return dout.putData(tba, "PQS");
}
}
}
}
/**/
return TErrorList.illegal_format;
}
};
TPropertyHandler metapropertiesStructHandler = new TPropertyHandler()
{
public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
{
if (dout != null)
{
int filter = getMetaPrpsCallFilter(din);
switch (dout.dFormat)
{ // TODO: tidy this copy-and-past job up !
case TFormat.CF_STRUCT:
LinkedList<TExportProperty> propInstances;
if (dout.getTag().compareTo("PRPQSr4") == 0 || (dout.getArrayLength() % TPropertyQuery.sizeInBytes) == 0)
{
if (din != null && filter != 0x7fffffff)
{ // looking for a specific property ...
String propertyName = din.toString();
propertyName = propertyName.replace('\n', (char) 0).trim();
propInstances = propertyList.getFilledMetaProperties(propertyName,filter);
if ((propInstances == null) || (propInstances.size() == 0))
return TErrorList.not_exported;
// fill in the targeted property info
TPropertyQuery[] prpq = new TPropertyQuery[propInstances.size()];
byte[] tba = new byte[prpq.length * TPropertyQuery.sizeInBytes];
Iterator<TExportProperty> it = propInstances.iterator();
for (int i = 0; (it.hasNext()) && (i < prpq.length); i++)
{
prpq[i] = new TPropertyQuery((TExportProperty) it.next(), propInstances.size() - 1);
System.arraycopy(prpq[i].toByteArray(), 0, tba, i * TPropertyQuery.sizeInBytes,
TPropertyQuery.sizeInBytes);
}
return dout.putData(tba, "PRPQSr4");
}
else
{ // want the whole list ...
String[] slst = new String[propertyList.countUniqueProperties()];
propertyList.getPropertyNames().toArray(slst);
if (slst.length == 0) break;
propInstances = new LinkedList<TExportProperty>();
LinkedList<TExportProperty> theseInstances;
for (int i=0; i<slst.length; i++)
{
theseInstances = propertyList.getFilledMetaProperties(slst[i],filter);
if (theseInstances.size() > 0) propInstances.addAll(theseInstances);
}
int size = propInstances.size();
TExportProperty prp;
TPropertyQuery[] prpq = new TPropertyQuery[size];
byte[] tba = new byte[size * TPropertyQuery.sizeInBytes];
for (int i=0; i<size; i++)
{
prp = propInstances.get(i);
prpq[i] = new TPropertyQuery(prp,1);
System.arraycopy(prpq[i].toByteArray(), 0, tba, i * TPropertyQuery.sizeInBytes,
TPropertyQuery.sizeInBytes);
}
return dout.putData(tba, "PRPQSr4");
}