Skip to content
Permalink
Browse files
8264309: JFR: Improve .jfc parser
Reviewed-by: mgronlun
  • Loading branch information
egahlin committed Mar 29, 2021
1 parent 364cce1 commit 963f1fc6dea38c0e9f76dbab6fe846fb0f377cca
Showing with 9 additions and 14 deletions.
  1. +9 −14 src/jdk.jfr/share/classes/jdk/jfr/internal/jfc/JFCParserHandler.java
@@ -42,9 +42,9 @@
private static final String ATTRIBUTE_VERSION = "version";

final Map<String, String> settings = new LinkedHashMap<String, String>();
private String currentEventPath;
private final StringBuilder currentCharacters = new StringBuilder();
private String currentEventName;
private String currentSettingsName;
private StringBuilder currentCharacters;
String label;
String provider;
String description;
@@ -62,13 +62,13 @@ public void startElement(String uri, String localName, String qName, Attributes
provider = getOptional(attributes, ATTRIBUTE_PROVIDER, "");
break;
case ELEMENT_EVENT_TYPE:
currentEventPath = attributes.getValue(ATTRIBUTE_NAME);
currentEventName = attributes.getValue(ATTRIBUTE_NAME);
break;
case ELEMENT_SETTING:
currentSettingsName = attributes.getValue(ATTRIBUTE_NAME);
break;
}
currentCharacters = null;
currentCharacters.setLength(0);
}

private String getOptional(Attributes attributes, String name, String defaultValue) {
@@ -78,10 +78,9 @@ private String getOptional(Attributes attributes, String name, String defaultVal

@Override
public void characters(char[] ch, int start, int length) throws SAXException {
if (currentCharacters == null) {
currentCharacters = new StringBuilder(length);
if (currentSettingsName != null) {
currentCharacters.append(ch, start, length);
}
currentCharacters.append(ch, start, length);
}

@Override
@@ -90,17 +89,13 @@ public void endElement(String uri, String localName, String qName) {
case ELEMENT_CONFIGURATION:
break;
case ELEMENT_EVENT_TYPE:
currentEventPath = null;
currentEventName = null;
break;
case ELEMENT_SETTING:
String settingsValue = currentCharacters == null ? "" : currentCharacters.toString();
settings.put(currentEventPath + "#" + currentSettingsName, "" + settingsValue);
String settingsValue = currentCharacters.toString();
settings.put(currentEventName + "#" + currentSettingsName, settingsValue);
currentSettingsName = null;
break;
}
}

public Map<String, String> getSettings() {
return settings;
}
}

1 comment on commit 963f1fc

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on 963f1fc Mar 29, 2021

Please sign in to comment.