本文整理了Java中org.jdom.Element.addContent()
方法的一些代码示例,展示了Element.addContent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.addContent()
方法的具体详情如下:
包路径:org.jdom.Element
类名称:Element
方法名:addContent
[英]Inserts the content in a collection into the content list at the given index. In event of an exception the original content will be unchanged and the objects in the supplied collection will be unaltered.
[中]将集合中的内容插入到给定索引处的内容列表中。发生异常时,原始内容将保持不变,所提供集合中的对象将保持不变。
代码示例来源:origin: JetBrains/ideavim
public void saveData(@NotNull Element element) {
if (isKeyRepeat != null) {
final Element editor = new Element("editor");
element.addContent(editor);
final Element keyRepeat = new Element("key-repeat");
keyRepeat.setAttribute("enabled", Boolean.toString(isKeyRepeat));
editor.addContent(keyRepeat);
}
}
代码示例来源:origin: JetBrains/ideavim
private void saveData(@NotNull Element element, String key) {
final HistoryBlock block = histories.get(key);
if (block == null) {
return;
}
final Element root = new Element("history-" + key);
for (HistoryEntry entry : block.getEntries()) {
final Element entryElement = new Element("entry");
StringHelper.setSafeXmlText(entryElement, entry.getEntry());
root.addContent(entryElement);
}
element.addContent(root);
}
代码示例来源:origin: JetBrains/ideavim
public void saveData(@NotNull Element element) {
final Element conflictsElement = new Element(SHORTCUT_CONFLICTS_ELEMENT);
for (Map.Entry<KeyStroke, ShortcutOwner> entry : shortcutConflicts.entrySet()) {
final ShortcutOwner owner = entry.getValue();
if (owner != ShortcutOwner.UNDEFINED) {
final Element conflictElement = new Element(SHORTCUT_CONFLICT_ELEMENT);
conflictElement.setAttribute(OWNER_ATTRIBUTE, owner.getName());
final Element textElement = new Element(TEXT_ELEMENT);
StringHelper.setSafeXmlText(textElement, entry.getKey().toString());
conflictElement.addContent(textElement);
conflictsElement.addContent(conflictElement);
}
}
element.addContent(conflictsElement);
}
代码示例来源:origin: JetBrains/ideavim
public void saveData(@NotNull Element element) {
logger.debug("saveData");
Element search = new Element("search");
if (lastSearch != null) {
search.addContent(createElementWithText("last-search", lastSearch));
}
if (lastOffset != null) {
search.addContent(createElementWithText("last-offset", lastOffset));
}
if (lastPattern != null) {
search.addContent(createElementWithText("last-pattern", lastPattern));
}
if (lastReplace != null) {
search.addContent(createElementWithText("last-replace", lastReplace));
}
if (lastSubstitute != null) {
search.addContent(createElementWithText("last-substitute", lastSubstitute));
}
Element text = new Element("last-dir");
text.addContent(Integer.toString(lastDir));
search.addContent(text);
text = new Element("show-last");
text.addContent(Boolean.toString(showSearchHighlight));
if (logger.isDebugEnabled()) logger.debug("text=" + text);
search.addContent(text);
element.addContent(search);
}
代码示例来源:origin: JetBrains/ideavim
public void saveData(@NotNull final Element element) {
logger.debug("saveData");
final Element registersElement = new Element("registers");
for (Character key : registers.keySet()) {
final Register register = registers.get(key);
final Element registerElement = new Element("register");
registerElement.setAttribute("name", String.valueOf(key));
registerElement.setAttribute("type", Integer.toString(register.getType().getValue()));
final String text = register.getText();
if (text != null) {
final Element textElement = new Element("text");
StringHelper.setSafeXmlText(textElement, text);
registerElement.addContent(textElement);
}
else {
final Element keys = new Element("keys");
final List<KeyStroke> list = register.getKeys();
for (KeyStroke stroke : list) {
final Element k = new Element("key");
k.setAttribute("char", Integer.toString(stroke.getKeyChar()));
k.setAttribute("code", Integer.toString(stroke.getKeyCode()));
k.setAttribute("mods", Integer.toString(stroke.getModifiers()));
keys.addContent(k);
}
registerElement.addContent(keys);
}
registersElement.addContent(registerElement);
}
element.addContent(registersElement);
}
代码示例来源:origin: voldemort/voldemort
private Element mapZone(Zone zone) {
Element zoneElement = new Element(ZONE_ELMT);
zoneElement.addContent(new Element(ZONE_ID_ELMT).setText(Integer.toString(zone.getId())));
String proximityListTest = StringUtils.join(zone.getProximityList().toArray(), ", ");
zoneElement.addContent(new Element(ZONE_PROXIMITY_LIST_ELMT).setText(proximityListTest));
return zoneElement;
}
代码示例来源:origin: hsz/idea-gitignore
/**
* Creates {@link Element} with a list of the {@link UserTemplate} items.
*
* @param userTemplates templates
* @return {@link Element} instance with user templates
*/
public static Element createTemplatesElement(@NotNull List<UserTemplate> userTemplates) {
Element templates = new Element(KEY.USER_TEMPLATES.toString());
for (UserTemplate userTemplate : userTemplates) {
Element templateElement = new Element(KEY.USER_TEMPLATES_TEMPLATE.toString());
templateElement.setAttribute(KEY.USER_TEMPLATES_NAME.toString(), userTemplate.getName());
templateElement.addContent(userTemplate.getContent());
templates.addContent(templateElement);
}
return templates;
}
代码示例来源:origin: voldemort/voldemort
private Element mapServer(Node node, boolean displayZones) {
Element server = new Element(SERVER_ELMT);
server.addContent(new Element(SERVER_ID_ELMT).setText(Integer.toString(node.getId())));
server.addContent(new Element(HOST_ELMT).setText(node.getHost()));
server.addContent(new Element(HTTP_PORT_ELMT).setText(Integer.toString(node.getHttpPort())));
server.addContent(new Element(SOCKET_PORT_ELMT).setText(Integer.toString(node.getSocketPort())));
server.addContent(new Element(ADMIN_PORT_ELMT).setText(Integer.toString(node.getAdminPort())));
if(node.getRestPort() > 0) {
server.addContent(new Element(REST_PORT_ELMT).setText(Integer.toString(node.getRestPort())));
}
String serverPartitionsText = StringUtils.join(node.getPartitionIds().toArray(), ", ");
server.addContent(new Element(SERVER_PARTITIONS_ELMT).setText(serverPartitionsText));
if(displayZones)
server.addContent(new Element(ZONE_ID_ELMT).setText(Integer.toString(node.getZoneId())));
return server;
}
}
代码示例来源:origin: voldemort/voldemort
public static void addSerializer(Element parent, SerializerDefinition def) {
parent.addContent(new Element(STORE_SERIALIZATION_TYPE_ELMT).setText(def.getName()));
if(def.hasSchemaInfo()) {
for(Map.Entry<Integer, String> entry: def.getAllSchemaInfoVersions().entrySet()) {
Element schemaElmt = new Element(STORE_SERIALIZATION_META_ELMT);
if(def.hasVersion())
schemaElmt.setAttribute(STORE_VERSION_ATTR, Integer.toString(entry.getKey()));
else
schemaElmt.setAttribute(STORE_VERSION_ATTR, "none");
schemaElmt.setText(entry.getValue());
parent.addContent(schemaElmt);
}
}
if(def.hasCompression()) {
Compression compression = def.getCompression();
Element compressionElmt = new Element(STORE_COMPRESSION_ELMT);
Element type = new Element(STORE_COMPRESSION_TYPE_ELMT);
type.setText(compression.getType());
compressionElmt.addContent(type);
String optionsText = compression.getOptions();
if(optionsText != null) {
Element options = new Element(STORE_COMPRESSION_OPTIONS_ELMT);
options.setText(optionsText);
compressionElmt.addContent(options);
}
parent.addContent(compressionElmt);
}
}
代码示例来源:origin: voldemort/voldemort
public String writeStoreList(List<StoreDefinition> stores) {
Element root = new Element(STORES_ELMT);
for(StoreDefinition def: stores) {
if(def.isView())
root.addContent(viewToElement(def));
else
root.addContent(storeToElement(def));
}
XMLOutputter serializer = new XMLOutputter(Format.getPrettyFormat());
return serializer.outputString(root);
}
代码示例来源:origin: JetBrains/ideavim
@Override
public Element getState() {
LOG.debug("Saving state");
final Element element = new Element("ideavim");
// Save whether the plugin is enabled or not
final Element state = new Element("state");
state.setAttribute("version", Integer.toString(STATE_VERSION));
state.setAttribute("enabled", Boolean.toString(enabled));
element.addContent(state);
mark.saveData(element);
register.saveData(element);
search.saveData(element);
history.saveData(element);
key.saveData(element);
editor.saveData(element);
return element;
}
代码示例来源:origin: voldemort/voldemort
public String writeCluster(Cluster cluster) {
Document doc = new Document(new Element(CLUSTER_ELMT));
doc.getRootElement().addContent(new Element(CLUSTER_NAME_ELMT).setText(cluster.getName()));
boolean displayZones = cluster.getZones().size() > 1;
if(displayZones) {
for(Zone n: cluster.getZones())
doc.getRootElement().addContent(mapZone(n));
}
for(Node n: cluster.getNodes())
doc.getRootElement().addContent(mapServer(n, displayZones));
XMLOutputter serializer = new XMLOutputter(Format.getPrettyFormat());
return serializer.outputString(doc.getRootElement());
}
代码示例来源:origin: JetBrains/ideavim
public void saveData(@NotNull Element element) {
Element marksElem = new Element("globalmarks");
for (Mark mark : globalMarks.values()) {
if (!mark.isClear()) {
Element markElem = new Element("mark");
markElem.setAttribute("key", Character.toString(mark.getKey()));
markElem.setAttribute("line", Integer.toString(mark.getLogicalLine()));
markElem.setAttribute("column", Integer.toString(mark.getCol()));
markElem.setAttribute("filename", StringUtil.notNullize(mark.getFilename()));
markElem.setAttribute("protocol", StringUtil.notNullize(mark.getProtocol(), "file"));
marksElem.addContent(markElem);
if (logger.isDebugEnabled()) {
logger.debug("saved mark = " + mark);
element.addContent(marksElem);
markElem.setAttribute("line", Integer.toString(mark.getLogicalLine()));
markElem.setAttribute("column", Integer.toString(mark.getCol()));
fileMarkElem.addContent(markElem);
fileMarksElem.addContent(fileMarkElem);
element.addContent(fileMarksElem);
jumpElem.setAttribute("column", Integer.toString(jump.getCol()));
jumpElem.setAttribute("filename", StringUtil.notNullize(jump.getFilename()));
jumpsElem.addContent(jumpElem);
if (logger.isDebugEnabled()) {
logger.debug("saved jump = " + jump);
代码示例来源:origin: voldemort/voldemort
/**
* Given a storedefinition, constructs the xml string to be sent out in
* response to a "schemata" fetch request
*
* @param storeDefinition
* @return serialized store definition
*/
public static String constructSerializerInfoXml(StoreDefinition storeDefinition) {
Element store = new Element(StoreDefinitionsMapper.STORE_ELMT);
store.addContent(new Element(StoreDefinitionsMapper.STORE_NAME_ELMT).setText(storeDefinition.getName()));
Element keySerializer = new Element(StoreDefinitionsMapper.STORE_KEY_SERIALIZER_ELMT);
StoreDefinitionsMapper.addSerializer(keySerializer, storeDefinition.getKeySerializer());
store.addContent(keySerializer);
Element valueSerializer = new Element(StoreDefinitionsMapper.STORE_VALUE_SERIALIZER_ELMT);
StoreDefinitionsMapper.addSerializer(valueSerializer, storeDefinition.getValueSerializer());
store.addContent(valueSerializer);
XMLOutputter serializer = new XMLOutputter(Format.getPrettyFormat());
return serializer.outputString(store);
}
代码示例来源:origin: voldemort/voldemort
private Element storeToElement(StoreDefinition storeDefinition) {
Element store = new Element(STORE_ELMT);
store.addContent(new Element(STORE_NAME_ELMT).setText(storeDefinition.getName()));
store.addContent(new Element(STORE_PERSISTENCE_ELMT).setText(storeDefinition.getType()));
if(storeDefinition.getDescription() != null)
store.addContent(new Element(STORE_DESCRIPTION_ELMT).setText(storeDefinition.getDescription()));
if(storeDefinition.getOwners() != null && storeDefinition.getOwners().size() > 0) {
String ownersText = StringUtils.join(storeDefinition.getOwners().toArray(), ", ");
store.addContent(new Element(STORE_OWNERS_ELMT).setText(ownersText));
store.addContent(new Element(STORE_ROUTING_STRATEGY).setText(storeDefinition.getRoutingStrategyType()));
store.addContent(new Element(STORE_ROUTING_TIER_ELMT).setText(storeDefinition.getRoutingPolicy()
.toDisplay()));
store.addContent(new Element(STORE_REPLICATION_FACTOR_ELMT).setText(Integer.toString(storeDefinition.getReplicationFactor())));
HashMap<Integer, Integer> zoneReplicationFactor = storeDefinition.getZoneReplicationFactor();
zoneReplicationFactorNode.addContent(new Element(STORE_REPLICATION_FACTOR_ELMT).setText(Integer.toString(zoneReplicationFactor.get(zone)))
.setAttribute(STORE_ZONE_ID_ELMT,
Integer.toString(zone)));
store.addContent(zoneReplicationFactorNode);
store.addContent(new Element(STORE_PREFERRED_READS_ELMT).setText(Integer.toString(storeDefinition.getPreferredReads())));
store.addContent(new Element(STORE_REQUIRED_READS_ELMT).setText(Integer.toString(storeDefinition.getRequiredReads())));
if(storeDefinition.hasPreferredWrites())
store.addContent(new Element(STORE_PREFERRED_WRITES_ELMT).setText(Integer.toString(storeDefinition.getPreferredWrites())));
store.addContent(new Element(STORE_REQUIRED_WRITES_ELMT).setText(Integer.toString(storeDefinition.getRequiredWrites())));
if(storeDefinition.hasZoneCountReads())
store.addContent(new Element(STORE_ZONE_COUNT_READS).setText(Integer.toString(storeDefinition.getZoneCountReads())));
if(storeDefinition.hasZoneCountWrites())
代码示例来源:origin: JetBrains/ideavim
public void saveData(@NotNull Element element) {
logger.debug("saveData");
Element hist = new Element("history");
saveData(hist, SEARCH);
saveData(hist, COMMAND);
saveData(hist, EXPRESSION);
saveData(hist, INPUT);
element.addContent(hist);
}
代码示例来源:origin: hsz/idea-gitignore
@Override
public Element getState() {
final Element element = new Element(KEY.ROOT.toString());
element.setAttribute(KEY.MISSING_GITIGNORE.toString(), Boolean.toString(missingGitignore));
element.setAttribute(KEY.IGNORED_FILE_STATUS.toString(), Boolean.toString(ignoredFileStatus));
element.setAttribute(KEY.OUTER_IGNORE_RULES.toString(), Boolean.toString(outerIgnoreRules));
element.setAttribute(KEY.OUTER_IGNORE_WRAPPER_HEIGHT.toString(), Integer.toString(outerIgnoreWrapperHeight));
element.setAttribute(KEY.VERSION.toString(), version);
element.setAttribute(KEY.NOTIFY_IGNORED_EDITING.toString(), Boolean.toString(notifyIgnoredEditing));
Element languagesElement = new Element(KEY.LANGUAGES.toString());
for (Map.Entry<IgnoreLanguage, TreeMap<IgnoreLanguagesSettings.KEY, Object>> entry :
languagesSettings.entrySet()) {
continue;
Element languageElement = new Element(KEY.LANGUAGES_LANGUAGE.toString());
languageElement.setAttribute(KEY.LANGUAGES_ID.toString(), entry.getKey().getID());
for (Map.Entry<IgnoreLanguagesSettings.KEY, Object> data : entry.getValue().entrySet()) {
languageElement.setAttribute(data.getKey().name(), data.getValue().toString());
languagesElement.addContent(languageElement);
element.addContent(languagesElement);
element.addContent(createTemplatesElement(userTemplates));
代码示例来源:origin: voldemort/voldemort
private Element viewToElement(StoreDefinition storeDefinition) {
Element store = new Element(VIEW_ELMT);
store.addContent(new Element(STORE_NAME_ELMT).setText(storeDefinition.getName()));
store.addContent(new Element(VIEW_TARGET_ELMT).setText(storeDefinition.getViewTargetStoreName()));
if(storeDefinition.getDescription() != null)
store.addContent(new Element(STORE_DESCRIPTION_ELMT).setText(storeDefinition.getDescription()));
if(storeDefinition.getOwners() != null && storeDefinition.getOwners().size() > 0) {
String ownersText = StringUtils.join(storeDefinition.getOwners().toArray(), ", ");
store.addContent(new Element(STORE_OWNERS_ELMT).setText(ownersText));
store.addContent(new Element(VIEW_TRANS_ELMT).setText(storeDefinition.getValueTransformation()));
store.addContent(new Element(STORE_ROUTING_TIER_ELMT).setText(storeDefinition.getRoutingPolicy()
.toDisplay()));
if(storeDefinition.hasPreferredReads())
store.addContent(new Element(STORE_PREFERRED_READS_ELMT).setText(Integer.toString(storeDefinition.getPreferredReads())));
store.addContent(new Element(STORE_REQUIRED_READS_ELMT).setText(Integer.toString(storeDefinition.getRequiredReads())));
if(storeDefinition.hasPreferredWrites())
store.addContent(new Element(STORE_PREFERRED_WRITES_ELMT).setText(Integer.toString(storeDefinition.getPreferredWrites())));
store.addContent(new Element(STORE_REQUIRED_WRITES_ELMT).setText(Integer.toString(storeDefinition.getRequiredWrites())));
store.addContent(new Element(STORE_ZONE_COUNT_READS).setText(Integer.toString(storeDefinition.getZoneCountReads())));
if(storeDefinition.hasZoneCountWrites())
store.addContent(new Element(STORE_ZONE_COUNT_WRITES).setText(Integer.toString(storeDefinition.getZoneCountWrites())));
store.addContent(valueSerializer);
addSerializer(transformsSerializer, storeDefinition.getTransformsSerializer());
store.addContent(transformsSerializer);
if(storeDefinition.getSerializerFactory() != null) {
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
protected void doTestProducedConfigurations(@Nullable PsiElement context) {
assertNotNull(context);
ConfigurationContext configurationContext = new ConfigurationContext(context);
List<ConfigurationFromContext> configurationAndSettings = configurationContext.getConfigurationsFromContext();
Element configurationsElement = new Element("configurations");
if (configurationAndSettings != null) {
for (ConfigurationFromContext setting : configurationAndSettings) {
try {
RunConfiguration configuration = setting.getConfiguration();
Element configurationElement = new Element("configurations");
configurationElement.setAttribute("name", configuration.getName());
configurationElement.setAttribute("class", configuration.getClass().getSimpleName());
configuration.writeExternal(configurationElement);
configurationsElement.addContent(configurationElement);
}
catch (WriteExternalException e) {
throw new RuntimeException(e);
}
}
}
assertSameLinesWithFile(getTestDataPath() + "/" + getTestName(true) + ".xml", JDOMUtil.writeElement(configurationsElement));
}
}
代码示例来源:origin: kiegroup/optaplanner
Element schedulingPeriodIDElement = new Element("SchedulingPeriodID");
schedulingPeriodIDElement.setText(nurseRoster.getCode());
solutionElement.addContent(schedulingPeriodIDElement);
Element competitorElement = new Element("Competitor");
competitorElement.setText("Geoffrey De Smet with OptaPlanner");
solutionElement.addContent(competitorElement);
Element softConstraintsPenaltyElement = new Element("SoftConstraintsPenalty");
softConstraintsPenaltyElement.setText(Integer.toString(nurseRoster.getScore().getSoftScore()));
solutionElement.addContent(softConstraintsPenaltyElement);
if (shift != null) {
Element assignmentElement = new Element("Assignment");
solutionElement.addContent(assignmentElement);
Element dateElement = new Element("Date");
dateElement.setText(shift.getShiftDate().getDate().format(DateTimeFormatter.ISO_DATE));
assignmentElement.addContent(dateElement);
Element employeeElement = new Element("Employee");
employeeElement.setText(shiftAssignment.getEmployee().getCode());
assignmentElement.addContent(employeeElement);
Element shiftTypeElement = new Element("ShiftType");
shiftTypeElement.setText(shift.getShiftType().getCode());
assignmentElement.addContent(shiftTypeElement);
内容来源于网络,如有侵权,请联系作者删除!