{ // No single-value id
if (idLoHi[0].length() == 0 || idLoHi[1].length() == 0)
{
// Something must be specified: single value or
// interval.
throw new XException(Constants.LOCATION_INTERN,
Constants.LAYER_PROTOCOL,
Constants.PACKAGE_PROTOCOL_RECORDS, "28");
}
typeIdIntervals.add(idLoHi);
} // then (id.length()==0)
else
{ // Single-value id found
if (idLoHi[0].length() > 0 || idLoHi[1].length() > 0)
{
// Any interval specification conflicts.
throw new XException(Constants.LOCATION_INTERN,
Constants.LAYER_PROTOCOL,
Constants.PACKAGE_PROTOCOL_RECORDS, "28");
}
typeIds.add(id);
} // else (id.length()==0)
} // if (recIdentMethod.equals("TypeIdentifier"))
recordTypeNames[pos] = XDomSupport.getTrimedNodeText(recTypeDecl);
// the record type name
if (!XDomSupport.isValidTagName(recordTypeNames[pos]))
{
// It must be a legal xml tag name.
throw new XException(Constants.LOCATION_INTERN,
Constants.LAYER_PROTOCOL,
Constants.PACKAGE_PROTOCOL_RECORDS, "30");
}
// Now look for record identification features, in particular the
// cardinality
// and existance indicator
if (recOrder.equals("Ordered") || recOrder.equals("Structured"))
{ // Records are listed in the record type order or in groups.
// The cardinality must be specified.
String occurrences = ((Element) recTypeDecl)
.getAttribute("Occurrences");
if (occurrences.length() == 0)
{
throw new XException(Constants.LOCATION_INTERN,
Constants.LAYER_PROTOCOL,
Constants.PACKAGE_PROTOCOL_RECORDS, "31");
}
if (!CardinalityStrings.isCardinalityValid(occurrences))
{
throw new XException(Constants.LOCATION_INTERN,
Constants.LAYER_PROTOCOL,
Constants.PACKAGE_PROTOCOL_RECORDS, "32");
}
// The first record in a record group must have cardinality 1.
if (recOrder.equals("Structured") && pos == 0)
{
try
{
int occurrNum = Integer.parseInt(occurrences);
if (occurrNum != 1)
{
throw new XException(Constants.LOCATION_INTERN,
Constants.LAYER_PROTOCOL,
Constants.PACKAGE_PROTOCOL_RECORDS, "33");
}
} // try
catch (NumberFormatException e)
{
throw new XException(Constants.LOCATION_INTERN,
Constants.LAYER_PROTOCOL,
Constants.PACKAGE_PROTOCOL_RECORDS, "33");
} // catch
} // if (recOrder.equals("Structured") && pos==0)
// If the record type is not given by an id but the cardinality
// is specified as an
// interval and there are also other record types, there must be
// an existance indicator
// refering the preceding record.
if (recordTypesCount > 1
&& !recIdentMethod.equals("TypeIdentifier")
&& CardinalityStrings.isCardinalityInterval(
occurrences, true))
{
String existIndField = ((Element) recTypeDecl)
.getAttribute("ExistIndicatorField");
// Indicator field specified by name
if (existIndField.length() == 0)
{
throw new XException(Constants.LOCATION_INTERN,
Constants.LAYER_PROTOCOL,
Constants.PACKAGE_PROTOCOL_RECORDS, "35");
}
String existIndValue = ((Element) recTypeDecl)
.getAttribute("ExistIndicatorValue");
if (existIndValue.length() == 0)
{
throw new XException(Constants.LOCATION_INTERN,
Constants.LAYER_PROTOCOL,
Constants.PACKAGE_PROTOCOL_RECORDS, "36");
}
precedingIndicator = new String[2];
precedingIndicator[0] = existIndField;
precedingIndicator[1] = existIndValue;
// If the record type may occurr more than once, it may be
// its
// predecessor itself.
if (CardinalityStrings
.getCardinalityHigh(occurrences, true) > 1)
{
existanceIndicators[pos] = new TreeMap();
existanceIndicators[pos].put(precedingIndicator[0],
precedingIndicator[1]);
} // if (getCardinalityHigh(occurrences,true)>1)
} // if (!recIdentMethod.equals("TypeIdentifier") &&
// isCardinalityInterval(occurrences,true))
} // if (recOrder.equals("Ordered") ||
// recOrder.equals("Structured"))
} // try
catch (ClassCastException e)
{
throw new XException(Constants.LOCATION_INTERN,
Constants.LAYER_PROTOCOL,
Constants.PACKAGE_PROTOCOL_RECORDS, "0", e);
} // catch
return precedingIndicator;
// Group starting record type found?