// is "None" the empty string will be appended.
openMark = "";
if (!markType.equals(NewsPreParserConfig.MARK_TYPE_NONE)) {
throw new InvalidConfigFileFormatException("\"" +
componentName +
"\" element needs a value in the \"" +
NewsPreParserConfig.OPEN_MARK +
"\" attribute.");
}
}
/*
* Retrieve and build the close mark.
*/
// If matched type, just use the open mark.
if (markType.equals(NewsPreParserConfig.MARK_TYPE_MATCHED)) {
closeMark = openMark;
}
else if (markType.equals(NewsPreParserConfig.MARK_TYPE_UNMATCHED)) {
// Retrieve the close mark.
closeMark = xmlParseUtils.getAttributeValueFromNode(
componentNode, NewsPreParserConfig.CLOSE_MARK);
// If empty, use the default close mark.
if (closeMark == null || closeMark.equals("")) {
closeMark = defaultCloseMark;
}
}
/*
* Add the pending if turned on.
*/
// Find out what the pending setting is.
pendingSetting = xmlParseUtils.getAttributeValueFromNode(
componentNode, NewsPreParserConfig.PENDING);
// Add it if turned on.
if (pendingSetting.equals(NewsPreParserConfig.PENDING_ON)) {
openMark = openMarkPrePend + openMark + openMarkPostPend;
closeMark = closeMarkPrePend + closeMark + closeMarkPostPend;
}
/*
* Retrieve and build the content pattern
* (its the stuff between the marks).
*/
content = xmlParseUtils.getAttributeValueFromNode(
componentNode, NewsPreParserConfig.CONTENT);
if (content == null) {
content = "";
// If type is Matched or Unmatched, but content is empty,
// use default. If OpenOnly is mark types, will only use
// the content from the element, if any supplied.
}
if ( (markType.equals(NewsPreParserConfig.MARK_TYPE_MATCHED) ||
markType.equals(NewsPreParserConfig.MARK_TYPE_UNMATCHED)) &&
content.equals("")) {
content = defaultContent;
}
// Get mark pattern if any, for previous instances of this element.
patternList = (List) patternListMap.get(componentName);
// If not previously entered (it's null) initialize it.
if (patternList == null) {
// If null, we need to initialize it to empty string.
patternList = new LinkedList();
// Add that list pattern to the map.
patternListMap.put(componentName, patternList);
}
if (markType.equals(NewsPreParserConfig.MARK_TYPE_OPEN)) {
// The mark type says there should be no pending.
newMarkPattern = openMark + content;
}
else if (markType.equals(NewsPreParserConfig.MARK_TYPE_NONE)) {
newMarkPattern = content;
}
else {
newMarkPattern = openMark + content + closeMark;
}
// Change the < entity to <.
newMarkPattern = strings.substitute(LT_ENTITY, "<", newMarkPattern);
// Convert any escaped Unicode strings to literal value
// (i.e. \u0041 to A).
try {
newMarkPattern =
strings.convertStringWithEscapedCode(newMarkPattern);
}
catch (NumberFormatException e) {
throw new InvalidConfigFileFormatException(
"Invalid value in \"" +
componentName + "\" element: " + e.getMessage());
}
// Add the new pattern to the list.