boolean bHasNow = false;
boolean bHasLowerNow = false;
boolean bHasUpperNow = false;
boolean bHasDeterminate = false;
boolean bLastWasUpperNow = false;
TpInterval firstInterval = null;
List<String> lIMetaTerms = new ArrayList<String>();
List<String> lSMetaTerms = new ArrayList<String>();
ArrayList<Fieldable> lFields = new ArrayList<Fieldable>();
int nIntervals = intervals.size();
int nLastInterval = (nIntervals - 1);
for (int i=0;i<nIntervals;i++) {
boolean bLastInterval = (i == nLastInterval);
TpInterval interval = intervals.get(i);
String sCurInd = Val.chkStr(interval.getIndeterminate());
if (sCurInd.equals("unknown")) {
bHasUnknown = true;
} else {
nInterval++;
String sLowerField = this.getLowerFieldName(nInterval);
String sUpperField = this.getUpperFieldName(nInterval);
long nCurLower = interval.getLower().longValue();
long nCurUpper = interval.getUpper().longValue();
lFields.add(this.makeBoundaryField(sLowerField,nCurLower));
lFields.add(this.makeBoundaryField(sUpperField,nCurUpper));
if (firstInterval == null) {
firstInterval = interval;
}
if (sCurInd.equals("now")) {
bHasNow = true;
lIMetaTerms.add(this.getMetaValue("now",nInterval));
} else if (sCurInd.equals("now.lower")) {
bHasLowerNow = true;
lIMetaTerms.add(this.getMetaValue("now.l",nInterval));
if (nCurUpper > nUpper) {
nUpper = nCurUpper;
}
} else if (sCurInd.equals("now.upper")) {
bHasUpperNow = true;
if (bLastInterval) bLastWasUpperNow = true;
lIMetaTerms.add(this.getMetaValue("now.u",nInterval));
if (nCurLower < nLower) {
nLower = nCurLower;
}
} else {
bHasDeterminate = true;
lIMetaTerms.add(this.getMetaValue("determinate",nInterval));
if (nCurLower < nLower) {
nLower = nCurLower;
}
if (nCurUpper > nUpper) {
nUpper = nCurUpper;
}
}
}
}
int nMultiplicity = lFields.size() / 2;
boolean bIsUnknown = bHasUnknown && (nMultiplicity == 0);
boolean bIsDeterminate = bHasDeterminate && !bHasUnknown &&
!bHasNow && !bHasLowerNow && !bHasUpperNow;
boolean bIs1Determinate = bIsDeterminate && (nMultiplicity == 1);
boolean bIsIndeterminate = bHasNow || bHasLowerNow || bHasUpperNow;
boolean bIs1Indeterminate = bIsIndeterminate && (nMultiplicity == 1);
boolean bWasEmpty = !bWasInvalid && (nIntervals == 0);
if (bIsDeterminate) lSMetaTerms.add("isDeterminate");
if (bIs1Determinate) lSMetaTerms.add("is1Determinate");
if (bIsIndeterminate) lSMetaTerms.add("isIndeterminate");
if (bIs1Indeterminate) lSMetaTerms.add("is1Indeterminate");
if (bIsUnknown) lSMetaTerms.add("isUnknown");
if (bHasDeterminate) lSMetaTerms.add("hasDeterminate");
if (bHasUnknown) lSMetaTerms.add("hasUnknown");
if (bHasNow) lSMetaTerms.add("hasNow");
if (bHasLowerNow) lSMetaTerms.add("hasLowerNow");
if (bHasUpperNow) lSMetaTerms.add("hasUpperNow");
if (bWasInvalid) lSMetaTerms.add("wasInvalid");
if (bWasEmpty) lSMetaTerms.add("wasEmpty");
// make the summary interval (for the document minLower->maxUpper)
nInterval = 0;
String sLowerField = this.getLowerFieldName(nInterval);
String sUpperField = this.getUpperFieldName(nInterval);
if (bIsDeterminate) {
String sMeta = "determinate";
lFields.add(0,this.makeBoundaryField(sUpperField,nUpper));
lFields.add(0,this.makeBoundaryField(sLowerField,nLower));
lIMetaTerms.add(0,this.getMetaValue(sMeta,nInterval));
} else if (nMultiplicity == 1) {
TpInterval interval = firstInterval;
String sCurInd = Val.chkStr(interval.getIndeterminate());
String sMeta = null;
if (sCurInd.equals("now")) {
sMeta = "now";
} else if (sCurInd.equals("now.lower")) {
sMeta = "now.l";